Project import generated by Copybara.

GitOrigin-RevId: ebd8895ddb097b985db1fbdc816548549e211af9
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 625bc51..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,50 +0,0 @@
-*.a
-*.o
-*.o.*
-*.d
-*.def
-*.dll
-*.dylib
-*.exe
-*.exp
-*.gcda
-*.gcno
-*.h.c
-*.ilk
-*.lib
-*.pc
-*.pdb
-*.pyc
-*.so
-*.so.*
-*.swp
-*.ver
-*.version
-*.ptx
-*.ptx.c
-*_g
-\#*
-.\#*
-/.config
-/.version
-/ffmpeg
-/ffplay
-/ffprobe
-/config.asm
-/config.h
-/coverage.info
-/avversion.h
-/lcov/
-/src
-/mapfile
-/tools/python/__pycache__/
-
-# Chromium stuff.
-/build.*
-/chromium/binaries/Chrome
-/*.props
-/*.sln
-*.target.mk
-/*.targets
-/*.vcxproj*
-/*.xml
diff --git a/.mailmap b/.mailmap
index ba072f3..3bd1a85 100644
--- a/.mailmap
+++ b/.mailmap
@@ -10,8 +10,7 @@
 <barryjzhao@tencent.com> <jun.zhao@intel.com>
 <josh@itanimul.li> <joshdk@obe.tv>
 <michael@niedermayer.cc> <michaelni@gmx.at>
-<linjie.justin.fu@gmail.com> <linjie.fu@intel.com>
-<linjie.justin.fu@gmail.com> <fulinjie@zju.edu.cn>
+<linjie.fu@intel.com> <fulinjie@zju.edu.cn>
 <ceffmpeg@gmail.com> <cehoyos@ag.or.at>
 <ceffmpeg@gmail.com> <cehoyos@rainbow.studorg.tuwien.ac.at>
 <ffmpeg@gyani.pro> <gyandoshi@gmail.com>
diff --git a/BUILD.gn b/BUILD.gn
index 40cd148..f7f34ea 100755
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -251,7 +251,7 @@
   configs -= [ "//build/config/compiler:default_optimization" ]
   configs += [ "//build/config/compiler:optimize_max" ]
 
-  if (ffmpeg_use_unsafe_atomics) {
+  if (ffmpeg_use_atomics_fallback) {
     if (is_posix || is_fuchsia) {
       include_dirs += [ "compat/atomics/gcc" ]
     } else if (is_win) {
diff --git a/Changelog b/Changelog
index b28a8c5..6ffe02c 100644
--- a/Changelog
+++ b/Changelog
@@ -53,34 +53,6 @@
 - Microsoft Paint (MSP) demuxer
 - AV1 monochrome encoding support via libaom >= 2.0.1
 - asuperpass and asuperstop filter
-- shufflepixels filter
-- tmidequalizer filter
-- estdif filter
-- epx filter
-- Dolby E parser
-- shear filter
-- kirsch filter
-- colortemperature filter
-- colorcontrast filter
-- PFM encoder
-- colorcorrect filter
-- binka demuxer
-- XBM parser
-- xbm_pipe demuxer
-- colorize filter
-- CRI parser
-- aexciter audio filter
-- exposure video filter
-- monochrome video filter
-- setts bitstream filter
-- vif video filter
-- OpenEXR image encoder
-- Simbiosis IMX decoder
-- Simbiosis IMX demuxer
-- Digital Pictures SGA demuxer and decoders
-- TTML subtitle encoder and muxer
-- identity video filter
-- msad video filter
 
 
 version 4.3:
diff --git a/DIR_METADATA b/DIR_METADATA
deleted file mode 100644
index 48be0cb..0000000
--- a/DIR_METADATA
+++ /dev/null
@@ -1,3 +0,0 @@
-monorail {
-  component: "Internals>Media>FFmpeg"
-}
diff --git a/MAINTAINERS b/MAINTAINERS
index 3b6cfad..00c9007 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -57,7 +57,7 @@
 mailing lists                           Baptiste Coudurier
 Twitter                                 Reynaldo H. Verdejo Pinochet
 Launchpad                               Timothy Gu
-ffmpeg-security                         Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, rcombs, wm4
+ffmpeg-security                         Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, Rodger Combs, wm4
 
 
 libavutil
@@ -144,7 +144,7 @@
   ass*                                  Aurelien Jacobs
   asv*                                  Michael Niedermayer
   atrac3plus*                           Maxim Poliakovski
-  audiotoolbox*                         rcombs
+  audiotoolbox*                         Rodger Combs
   avs2*                                 Huiwen Ren
   bgmc.c, bgmc.h                        Thilo Borgmann
   binkaudio.c                           Peter Ross
diff --git a/OWNERS b/OWNERS
index ad98c56..d05744d 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,3 +1,4 @@
+# COMPONENT: Internals>Media>FFmpeg
 chcunningham@chromium.org
 dalecurtis@chromium.org
 hubbe@chromium.org
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index acfaa65..cd1b8f7 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -47,7 +47,7 @@
     errors += input_api.RunTests(
         input_api.canned_checks.GetUnitTests(
             input_api, output_api,
-            ['chromium/scripts/generate_gn_unittest_wrapper.py']))
+            ['chromium/scripts/generate_gn_unittest.py']))
 
   return errors
 
diff --git a/README.chromium b/README.chromium
index 3a4336a..766b0ee 100644
--- a/README.chromium
+++ b/README.chromium
@@ -3,7 +3,7 @@
 License: LGPL 2.1
 License File: CREDITS.chromium
 Upstream Git: git://source.ffmpeg.org/ffmpeg.git
-Last Upstream Merge: f4f5da0d9167bb3ebf7519ded2a9965bac5404bf, Mar 11 2021
+Last Upstream Merge: adf72718a41943bb62b3fabd5dbe33f5b9a6e63e, Dec 11 2020
 
 This file documents the layout of the Chromium copy of FFmpeg, some common
 tasks, and how to create the build files and related configurations.
diff --git a/chromium/config/Chrome/android/arm-neon/config.h b/chromium/config/Chrome/android/arm-neon/config.h
index 53268fd..6281058 100644
--- a/chromium/config/Chrome/android/arm-neon/config.h
+++ b/chromium/config/Chrome/android/arm-neon/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi --extra-cflags='--target=arm-linux-androideabi21' --extra-ldflags='--target=arm-linux-androideabi21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-neon --extra-cflags='-mtune=generic-armv7-a' --extra-cflags='-mfloat-abi=softfp' --extra-cflags='-mfpu=neon' --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-16/arch-arm --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi --extra-cflags='--target=arm-linux-androideabi' --extra-ldflags='--target=arm-linux-androideabi' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-neon --extra-cflags='-mtune=generic-armv7-a' --extra-cflags='-mfloat-abi=softfp' --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -256,8 +254,8 @@
 #define HAVE_LDEXPF 1
 #define HAVE_LLRINT 1
 #define HAVE_LLRINTF 1
-#define HAVE_LOG2 1
-#define HAVE_LOG2F 1
+#define HAVE_LOG2 0
+#define HAVE_LOG2F 0
 #define HAVE_LOG10F 1
 #define HAVE_LRINT 1
 #define HAVE_LRINTF 1
@@ -310,7 +308,7 @@
 #define HAVE_MPROTECT 1
 #define HAVE_NANOSLEEP 1
 #define HAVE_PEEKNAMEDPIPE 0
-#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 1 -- forced to 0. See https://crbug.com/604451 */
+#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 0 -- forced to 0. See https://crbug.com/604451 */
 #define HAVE_PTHREAD_CANCEL 0
 #define HAVE_SCHED_GETAFFINITY 1
 #define HAVE_SECITEMIMPORT 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/android/arm-neon/libavutil/ffversion.h b/chromium/config/Chrome/android/arm-neon/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/android/arm-neon/libavutil/ffversion.h
+++ b/chromium/config/Chrome/android/arm-neon/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/android/arm64/config.h b/chromium/config/Chrome/android/arm64/config.h
index 2adb521..3907dd4 100644
--- a/chromium/config/Chrome/android/arm64/config.h
+++ b/chromium/config/Chrome/android/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android --extra-cflags='--target=aarch64-linux-android21' --extra-ldflags='--target=aarch64-linux-android21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-21/arch-arm64 --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android --extra-cflags='--target=aarch64-linux-android' --extra-ldflags='--target=aarch64-linux-android' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/android/arm64/libavutil/ffversion.h b/chromium/config/Chrome/android/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/android/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/android/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/android/ia32/config.h b/chromium/config/Chrome/android/ia32/config.h
index 83ae7a4..a1139f8 100644
--- a/chromium/config/Chrome/android/ia32/config.h
+++ b/chromium/config/Chrome/android/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/i686-linux-android --extra-cflags='--target=i686-linux-android21' --extra-ldflags='--target=i686-linux-android21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/i686-linux-android --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --disable-x86asm --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-16/arch-x86 --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/i686-linux-android --extra-cflags='--target=i686-linux-android' --extra-ldflags='--target=i686-linux-android' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/i686-linux-android/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --disable-x86asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -256,8 +254,8 @@
 #define HAVE_LDEXPF 1
 #define HAVE_LLRINT 1
 #define HAVE_LLRINTF 1
-#define HAVE_LOG2 1
-#define HAVE_LOG2F 1
+#define HAVE_LOG2 0
+#define HAVE_LOG2F 0
 #define HAVE_LOG10F 1
 #define HAVE_LRINT 1
 #define HAVE_LRINTF 1
@@ -310,7 +308,7 @@
 #define HAVE_MPROTECT 1
 #define HAVE_NANOSLEEP 1
 #define HAVE_PEEKNAMEDPIPE 0
-#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 1 -- forced to 0. See https://crbug.com/604451 */
+#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 0 -- forced to 0. See https://crbug.com/604451 */
 #define HAVE_PTHREAD_CANCEL 0
 #define HAVE_SCHED_GETAFFINITY 1
 #define HAVE_SECITEMIMPORT 0
@@ -341,7 +339,7 @@
 #define HAVE_AS_OBJECT_ARCH 0
 #define HAVE_ASM_MOD_Q 0
 #define HAVE_BLOCKS_EXTENSION 0
-/* #define HAVE_EBP_AVAILABLE 1 -- ebp selection is done by the chrome build */
+/* #define HAVE_EBP_AVAILABLE 0 -- ebp selection is done by the chrome build */
 #define HAVE_EBX_AVAILABLE 1
 #define HAVE_GNU_AS 0
 #define HAVE_GNU_WINDRES 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/android/ia32/libavutil/ffversion.h b/chromium/config/Chrome/android/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/android/ia32/libavutil/ffversion.h
+++ b/chromium/config/Chrome/android/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/android/x64/config.asm b/chromium/config/Chrome/android/x64/config.asm
index 7060b09..d02ea8b 100644
--- a/chromium/config/Chrome/android/x64/config.asm
+++ b/chromium/config/Chrome/android/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 0
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/android/x64/config.h b/chromium/config/Chrome/android/x64/config.h
index f20bdad..0301b77 100644
--- a/chromium/config/Chrome/android/x64/config.h
+++ b/chromium/config/Chrome/android/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android --extra-cflags='--target=x86_64-linux-android21' --extra-ldflags='--target=x86_64-linux-android21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=x86_64 --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-21/arch-x86_64 --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android --extra-cflags='--target=x86_64-linux-android' --extra-ldflags='--target=x86_64-linux-android' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=x86_64 --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-demuxer=aac --enable-parser=aac --enable-decoder=aac" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/android/x64/libavutil/ffversion.h b/chromium/config/Chrome/android/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/android/x64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/android/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux-noasm/x64/config.h b/chromium/config/Chrome/linux-noasm/x64/config.h
index 92a8e9e..07b16b9 100644
--- a/chromium/config/Chrome/linux-noasm/x64/config.h
+++ b/chromium/config/Chrome/linux-noasm/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --disable-asm --disable-inline-asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --disable-asm --disable-inline-asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux-noasm/x64/libavutil/ffversion.h b/chromium/config/Chrome/linux-noasm/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux-noasm/x64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux-noasm/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/arm-neon/config.h b/chromium/config/Chrome/linux/arm-neon/config.h
index fd93dd5..1322e1e 100644
--- a/chromium/config/Chrome/linux/arm-neon/config.h
+++ b/chromium/config/Chrome/linux/arm-neon/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --enable-neon --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --enable-neon --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/arm-neon/libavutil/ffversion.h b/chromium/config/Chrome/linux/arm-neon/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/arm-neon/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/arm-neon/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/arm/config.h b/chromium/config/Chrome/linux/arm/config.h
index d6b1ade..4a6becf 100644
--- a/chromium/config/Chrome/linux/arm/config.h
+++ b/chromium/config/Chrome/linux/arm/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --disable-neon --extra-cflags='-mfpu=vfpv3-d16' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --disable-neon --extra-cflags='-mfpu=vfpv3-d16' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/arm/libavutil/ffversion.h b/chromium/config/Chrome/linux/arm/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/arm/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/arm/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/arm64/config.h b/chromium/config/Chrome/linux/arm64/config.h
index 0815ff3..86f0d87 100644
--- a/chromium/config/Chrome/linux/arm64/config.h
+++ b/chromium/config/Chrome/linux/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-cross-compile --cross-prefix=/usr/bin/aarch64-linux-gnu- --target-os=linux --extra-cflags='--target=aarch64-linux-gnu' --extra-ldflags='--target=aarch64-linux-gnu' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm64-sysroot --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-cross-compile --cross-prefix=/usr/bin/aarch64-linux-gnu- --target-os=linux --extra-cflags='--target=aarch64-linux-gnu' --extra-ldflags='--target=aarch64-linux-gnu' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm64-sysroot --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/arm64/libavutil/ffversion.h b/chromium/config/Chrome/linux/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/ia32/config.asm b/chromium/config/Chrome/linux/ia32/config.asm
index ec62061..c3db8c9 100644
--- a/chromium/config/Chrome/linux/ia32/config.asm
+++ b/chromium/config/Chrome/linux/ia32/config.asm
@@ -172,7 +172,7 @@
 %define HAVE_ATOMIC_CAS_PTR 0
 %define HAVE_MACHINE_RW_BARRIER 0
 %define HAVE_MEMORYBARRIER 0
-%define HAVE_MM_EMPTY 1
+%define HAVE_MM_EMPTY 0
 %define HAVE_RDTSC 0
 %define HAVE_SEM_TIMEDWAIT 1
 %define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/ia32/config.h b/chromium/config/Chrome/linux/ia32/config.h
index 90cae4e..41d8317 100644
--- a/chromium/config/Chrome/linux/ia32/config.h
+++ b/chromium/config/Chrome/linux/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -188,7 +187,7 @@
 #define HAVE_ATOMIC_CAS_PTR 0
 #define HAVE_MACHINE_RW_BARRIER 0
 #define HAVE_MEMORYBARRIER 0
-#define HAVE_MM_EMPTY 1
+#define HAVE_MM_EMPTY 0
 #define HAVE_RDTSC 0
 #define HAVE_SEM_TIMEDWAIT 1
 #define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/ia32/libavutil/ffversion.h b/chromium/config/Chrome/linux/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/ia32/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/mips64el/config.h b/chromium/config/Chrome/linux/mips64el/config.h
index 4178e4c..cf44108 100644
--- a/chromium/config/Chrome/linux/mips64el/config.h
+++ b/chromium/config/Chrome/linux/mips64el/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mips64el --enable-mipsfpu --disable-mipsdsp --disable-mipsdspr2 --extra-cflags='-march=mips64el' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_mips64el-sysroot --enable-mips64r2 --disable-mips64r6 --disable-msa --extra-cflags='-mcpu=mips64r2' --extra-cflags='--target=mips64el-linux-gnuabi64' --extra-ldflags='--target=mips64el-linux-gnuabi64' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mips64el --enable-mipsfpu --disable-mipsdsp --disable-mipsdspr2 --extra-cflags='-march=mips64el' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_mips64el-sysroot --enable-mips64r2 --disable-mips64r6 --disable-msa --extra-cflags='-mcpu=mips64r2' --extra-cflags='--target=mips64el-linux-gnuabi64' --extra-ldflags='--target=mips64el-linux-gnuabi64' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/mips64el/libavutil/ffversion.h b/chromium/config/Chrome/linux/mips64el/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/mips64el/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/mips64el/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/mipsel/config.h b/chromium/config/Chrome/linux/mipsel/config.h
index 54be269..f080101 100644
--- a/chromium/config/Chrome/linux/mipsel/config.h
+++ b/chromium/config/Chrome/linux/mipsel/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mipsel --disable-mips32r6 --disable-mips32r5 --disable-mips32r2 --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-mipsfpu --extra-cflags='-march=mipsel' --extra-cflags='-mcpu=mips32' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_mips-sysroot --extra-cflags='--target=mipsel-linux-gnu' --extra-ldflags='--target=mipsel-linux-gnu' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mipsel --disable-mips32r6 --disable-mips32r5 --disable-mips32r2 --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-mipsfpu --extra-cflags='-march=mipsel' --extra-cflags='-mcpu=mips32' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_mips-sysroot --extra-cflags='--target=mipsel-linux-gnu' --extra-ldflags='--target=mipsel-linux-gnu' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/mipsel/libavutil/ffversion.h b/chromium/config/Chrome/linux/mipsel/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/mipsel/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/mipsel/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/linux/x64/config.asm b/chromium/config/Chrome/linux/x64/config.asm
index f70f2b2..29eea21 100644
--- a/chromium/config/Chrome/linux/x64/config.asm
+++ b/chromium/config/Chrome/linux/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/x64/config.h b/chromium/config/Chrome/linux/x64/config.h
index c2aad2f..19cdfaa 100644
--- a/chromium/config/Chrome/linux/x64/config.h
+++ b/chromium/config/Chrome/linux/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/linux/x64/libavutil/ffversion.h b/chromium/config/Chrome/linux/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/linux/x64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/linux/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/mac/arm64/config.h b/chromium/config/Chrome/mac/arm64/config.h
index 4f57136..0ac7c2c 100644
--- a/chromium/config/Chrome/mac/arm64/config.h
+++ b/chromium/config/Chrome/mac/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=arm64-apple-macosx' --extra-cflags=-F/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include --extra-cflags=-isystem/ssd/trunk_blink_tot/src/third_party/llvm-build/Release+Asserts/lib/clang/13.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --extra-ldflags=-L/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --extra-ldflags=-platform_version --extra-ldflags=macos --extra-ldflags=10.10 --extra-ldflags=10.10 --arch=arm64 --extra-cflags='-arch arm64' --extra-ldflags='-arch arm64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=arm64-apple-macosx' --extra-cflags=-F/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/llvm-build/Release+Asserts/lib/clang/12.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --arch=arm64 --extra-cflags='-arch arm64' --extra-ldflags='-arch arm64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME darwin
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX "_"
 #define EXTERN_ASM _
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -238,7 +236,7 @@
 #define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */
 #define HAVE_WINDOWS_H 0
 #define HAVE_WINSOCK2_H 0
-#define HAVE_INTRINSICS_NEON 1
+#define HAVE_INTRINSICS_NEON 0
 #define HAVE_ATANF 1
 #define HAVE_ATAN2F 1
 #define HAVE_CBRT 1
@@ -351,7 +349,7 @@
 #define HAVE_INLINE_ASM_NONLOCAL_LABELS 1
 #define HAVE_PRAGMA_DEPRECATED 1
 #define HAVE_RSYNC_CONTIMEOUT 1
-#define HAVE_SYMVER_ASM_LABEL 0
+#define HAVE_SYMVER_ASM_LABEL 1
 #define HAVE_SYMVER_GNU_ASM 0
 /* #define HAVE_VFP_ARGS 0 -- softfp/hardfp selection is done by the chrome build */
 #define HAVE_XFORM_ASM 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/mac/arm64/libavutil/ffversion.h b/chromium/config/Chrome/mac/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/mac/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/mac/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/mac/x64/config.asm b/chromium/config/Chrome/mac/x64/config.asm
index 7fc33be..983a8a9 100644
--- a/chromium/config/Chrome/mac/x64/config.asm
+++ b/chromium/config/Chrome/mac/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 0
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -335,7 +334,7 @@
 %define HAVE_INLINE_ASM_NONLOCAL_LABELS 1
 %define HAVE_PRAGMA_DEPRECATED 1
 %define HAVE_RSYNC_CONTIMEOUT 1
-%define HAVE_SYMVER_ASM_LABEL 0
+%define HAVE_SYMVER_ASM_LABEL 1
 %define HAVE_SYMVER_GNU_ASM 0
 %define HAVE_VFP_ARGS 0
 %define HAVE_XFORM_ASM 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/mac/x64/config.h b/chromium/config/Chrome/mac/x64/config.h
index 92a50f2..b421819 100644
--- a/chromium/config/Chrome/mac/x64/config.h
+++ b/chromium/config/Chrome/mac/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=x86_64-apple-macosx' --extra-cflags=-F/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include --extra-cflags=-isystem/ssd/trunk_blink_tot/src/third_party/llvm-build/Release+Asserts/lib/clang/13.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --extra-ldflags=-L/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --extra-ldflags=-platform_version --extra-ldflags=macos --extra-ldflags=10.10 --extra-ldflags=10.10 --arch=x86_64 --extra-cflags=-m64 --extra-ldflags='-arch x86_64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=x86_64-apple-macosx' --extra-cflags=-F/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/llvm-build/Release+Asserts/lib/clang/12.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --arch=x86_64 --extra-cflags=-m64 --extra-ldflags=-m64 --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME darwin
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX "_"
 #define EXTERN_ASM _
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -351,7 +349,7 @@
 #define HAVE_INLINE_ASM_NONLOCAL_LABELS 1
 #define HAVE_PRAGMA_DEPRECATED 1
 #define HAVE_RSYNC_CONTIMEOUT 1
-#define HAVE_SYMVER_ASM_LABEL 0
+#define HAVE_SYMVER_ASM_LABEL 1
 #define HAVE_SYMVER_GNU_ASM 0
 #define HAVE_VFP_ARGS 0
 #define HAVE_XFORM_ASM 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/mac/x64/libavutil/ffversion.h b/chromium/config/Chrome/mac/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/mac/x64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/mac/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/win/arm64/config.h b/chromium/config/Chrome/win/arm64/config.h
index 44c602d..8cdf6d3 100644
--- a/chromium/config/Chrome/win/arm64/config.h
+++ b/chromium/config/Chrome/win/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --arch=aarch64 --as=clang-cl --extra-cflags='--target=arm64-windows' --extra-cflags=/winsysroot/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/atlmfc/lib/arm64' --extra-ldflags='-libpath:/tmp/windows_build_ffmpeg0sG8TT' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegnpJGA8' --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/lib/arm64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --arch=aarch64 --as=clang-cl --extra-cflags='--target=arm64-windows' --extra-ldflags='--target=arm64-windows' --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/um --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/shared --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/winrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/ucrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/include --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/include --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/lib/arm64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/ucrt/arm64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/um/arm64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/lib/arm64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME win32
+#define CC_IDENT "clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6ee22ca6ceb71661e8dbc296b471ace0614c07e5)"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 1
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/win/arm64/libavutil/ffversion.h b/chromium/config/Chrome/win/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/win/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/win/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/win/ia32/config.asm b/chromium/config/Chrome/win/ia32/config.asm
index da4cb64..486ef4d 100644
--- a/chromium/config/Chrome/win/ia32/config.asm
+++ b/chromium/config/Chrome/win/ia32/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 1
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 0
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/win/ia32/config.h b/chromium/config/Chrome/win/ia32/config.h
index 3a96714..62074f1 100644
--- a/chromium/config/Chrome/win/ia32/config.h
+++ b/chromium/config/Chrome/win/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=-m32 --extra-cflags=/winsysroot/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x86' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegyUA9_h' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegEDND2F' --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/lib/x86' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=-m32 --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/um --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/shared --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/winrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/ucrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/include --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/include --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x86' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/ucrt/x86' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/um/x86' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/lib/x86' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME win32
+#define CC_IDENT "clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6ee22ca6ceb71661e8dbc296b471ace0614c07e5)"
 #define av_restrict restrict
 #define EXTERN_PREFIX "_"
 #define EXTERN_ASM _
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 1
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/win/ia32/libavutil/ffversion.h b/chromium/config/Chrome/win/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/win/ia32/libavutil/ffversion.h
+++ b/chromium/config/Chrome/win/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chrome/win/x64/config.asm b/chromium/config/Chrome/win/x64/config.asm
index 1e1f04f..bc2b0db 100644
--- a/chromium/config/Chrome/win/x64/config.asm
+++ b/chromium/config/Chrome/win/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 1
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 0
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/win/x64/config.h b/chromium/config/Chrome/win/x64/config.h
index dd981de..5acbedf 100644
--- a/chromium/config/Chrome/win/x64/config.h
+++ b/chromium/config/Chrome/win/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/ffmpeg/chromium/include/win --target-os=win64 --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=/winsysroot/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x64' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegyC1L2b' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegsogwo4' --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/lib/x64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/chromium/include/win --target-os=win64 --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/um --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/shared --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/winrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/ucrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/include --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/include --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/ucrt/x64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/um/x64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/lib/x64' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME win64
+#define CC_IDENT "clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6ee22ca6ceb71661e8dbc296b471ace0614c07e5)"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 1
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chrome/win/x64/libavutil/ffversion.h b/chromium/config/Chrome/win/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chrome/win/x64/libavutil/ffversion.h
+++ b/chromium/config/Chrome/win/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux-noasm/x64/config.h b/chromium/config/ChromeOS/linux-noasm/x64/config.h
index e05abf1..d7ec792 100644
--- a/chromium/config/ChromeOS/linux-noasm/x64/config.h
+++ b/chromium/config/ChromeOS/linux-noasm/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --disable-asm --disable-inline-asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --disable-asm --disable-inline-asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux-noasm/x64/libavutil/ffversion.h b/chromium/config/ChromeOS/linux-noasm/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux-noasm/x64/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux-noasm/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/arm-neon/config.h b/chromium/config/ChromeOS/linux/arm-neon/config.h
index 6ab6b10..9138a74 100644
--- a/chromium/config/ChromeOS/linux/arm-neon/config.h
+++ b/chromium/config/ChromeOS/linux/arm-neon/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --enable-neon --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --enable-neon --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/arm-neon/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/arm-neon/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/arm-neon/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/arm-neon/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/arm/config.h b/chromium/config/ChromeOS/linux/arm/config.h
index d6bcd6f..8000a0e 100644
--- a/chromium/config/ChromeOS/linux/arm/config.h
+++ b/chromium/config/ChromeOS/linux/arm/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --disable-neon --extra-cflags='-mfpu=vfpv3-d16' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --disable-neon --extra-cflags='-mfpu=vfpv3-d16' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/arm/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/arm/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/arm/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/arm/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/arm64/config.h b/chromium/config/ChromeOS/linux/arm64/config.h
index d70ced0..4f0fba3 100644
--- a/chromium/config/ChromeOS/linux/arm64/config.h
+++ b/chromium/config/ChromeOS/linux/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-cross-compile --cross-prefix=/usr/bin/aarch64-linux-gnu- --target-os=linux --extra-cflags='--target=aarch64-linux-gnu' --extra-ldflags='--target=aarch64-linux-gnu' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm64-sysroot --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-cross-compile --cross-prefix=/usr/bin/aarch64-linux-gnu- --target-os=linux --extra-cflags='--target=aarch64-linux-gnu' --extra-ldflags='--target=aarch64-linux-gnu' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm64-sysroot --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/arm64/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/arm64/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/ia32/config.asm b/chromium/config/ChromeOS/linux/ia32/config.asm
index e020992..8b4d489 100644
--- a/chromium/config/ChromeOS/linux/ia32/config.asm
+++ b/chromium/config/ChromeOS/linux/ia32/config.asm
@@ -172,7 +172,7 @@
 %define HAVE_ATOMIC_CAS_PTR 0
 %define HAVE_MACHINE_RW_BARRIER 0
 %define HAVE_MEMORYBARRIER 0
-%define HAVE_MM_EMPTY 1
+%define HAVE_MM_EMPTY 0
 %define HAVE_RDTSC 0
 %define HAVE_SEM_TIMEDWAIT 1
 %define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/ia32/config.h b/chromium/config/ChromeOS/linux/ia32/config.h
index f4152b0..ff8b5d4 100644
--- a/chromium/config/ChromeOS/linux/ia32/config.h
+++ b/chromium/config/ChromeOS/linux/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -188,7 +187,7 @@
 #define HAVE_ATOMIC_CAS_PTR 0
 #define HAVE_MACHINE_RW_BARRIER 0
 #define HAVE_MEMORYBARRIER 0
-#define HAVE_MM_EMPTY 1
+#define HAVE_MM_EMPTY 0
 #define HAVE_RDTSC 0
 #define HAVE_SEM_TIMEDWAIT 1
 #define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/ia32/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/ia32/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/mips64el/config.h b/chromium/config/ChromeOS/linux/mips64el/config.h
index 215d6fc..4aa8033 100644
--- a/chromium/config/ChromeOS/linux/mips64el/config.h
+++ b/chromium/config/ChromeOS/linux/mips64el/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mips64el --enable-mipsfpu --disable-mipsdsp --disable-mipsdspr2 --extra-cflags='-march=mips64el' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_mips64el-sysroot --enable-mips64r2 --disable-mips64r6 --disable-msa --extra-cflags='-mcpu=mips64r2' --extra-cflags='--target=mips64el-linux-gnuabi64' --extra-ldflags='--target=mips64el-linux-gnuabi64' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mips64el --enable-mipsfpu --disable-mipsdsp --disable-mipsdspr2 --extra-cflags='-march=mips64el' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_mips64el-sysroot --enable-mips64r2 --disable-mips64r6 --disable-msa --extra-cflags='-mcpu=mips64r2' --extra-cflags='--target=mips64el-linux-gnuabi64' --extra-ldflags='--target=mips64el-linux-gnuabi64' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/mips64el/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/mips64el/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/mips64el/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/mips64el/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/mipsel/config.h b/chromium/config/ChromeOS/linux/mipsel/config.h
index b1315b9..449c59a 100644
--- a/chromium/config/ChromeOS/linux/mipsel/config.h
+++ b/chromium/config/ChromeOS/linux/mipsel/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mipsel --disable-mips32r6 --disable-mips32r5 --disable-mips32r2 --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-mipsfpu --extra-cflags='-march=mipsel' --extra-cflags='-mcpu=mips32' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_mips-sysroot --extra-cflags='--target=mipsel-linux-gnu' --extra-ldflags='--target=mipsel-linux-gnu' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mipsel --disable-mips32r6 --disable-mips32r5 --disable-mips32r2 --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-mipsfpu --extra-cflags='-march=mipsel' --extra-cflags='-mcpu=mips32' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_mips-sysroot --extra-cflags='--target=mipsel-linux-gnu' --extra-ldflags='--target=mipsel-linux-gnu' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/mipsel/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/mipsel/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/mipsel/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/mipsel/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/ChromeOS/linux/x64/config.asm b/chromium/config/ChromeOS/linux/x64/config.asm
index a5a3106..76c758e 100644
--- a/chromium/config/ChromeOS/linux/x64/config.asm
+++ b/chromium/config/ChromeOS/linux/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/x64/config.h b/chromium/config/ChromeOS/linux/x64/config.h
index 60216f1..8b08475 100644
--- a/chromium/config/ChromeOS/linux/x64/config.h
+++ b/chromium/config/ChromeOS/linux/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld' --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/ChromeOS/linux/x64/libavutil/ffversion.h b/chromium/config/ChromeOS/linux/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/ChromeOS/linux/x64/libavutil/ffversion.h
+++ b/chromium/config/ChromeOS/linux/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/android/arm-neon/config.h b/chromium/config/Chromium/android/arm-neon/config.h
index e0d077b..5c58f7c 100644
--- a/chromium/config/Chromium/android/arm-neon/config.h
+++ b/chromium/config/Chromium/android/arm-neon/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi --extra-cflags='--target=arm-linux-androideabi21' --extra-ldflags='--target=arm-linux-androideabi21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-neon --extra-cflags='-mtune=generic-armv7-a' --extra-cflags='-mfloat-abi=softfp' --extra-cflags='-mfpu=neon'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-16/arch-arm --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi --extra-cflags='--target=arm-linux-androideabi' --extra-ldflags='--target=arm-linux-androideabi' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-neon --extra-cflags='-mtune=generic-armv7-a' --extra-cflags='-mfloat-abi=softfp' --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -256,8 +254,8 @@
 #define HAVE_LDEXPF 1
 #define HAVE_LLRINT 1
 #define HAVE_LLRINTF 1
-#define HAVE_LOG2 1
-#define HAVE_LOG2F 1
+#define HAVE_LOG2 0
+#define HAVE_LOG2F 0
 #define HAVE_LOG10F 1
 #define HAVE_LRINT 1
 #define HAVE_LRINTF 1
@@ -310,7 +308,7 @@
 #define HAVE_MPROTECT 1
 #define HAVE_NANOSLEEP 1
 #define HAVE_PEEKNAMEDPIPE 0
-#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 1 -- forced to 0. See https://crbug.com/604451 */
+#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 0 -- forced to 0. See https://crbug.com/604451 */
 #define HAVE_PTHREAD_CANCEL 0
 #define HAVE_SCHED_GETAFFINITY 1
 #define HAVE_SECITEMIMPORT 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/android/arm-neon/libavutil/ffversion.h b/chromium/config/Chromium/android/arm-neon/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/android/arm-neon/libavutil/ffversion.h
+++ b/chromium/config/Chromium/android/arm-neon/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/android/arm64/config.h b/chromium/config/Chromium/android/arm64/config.h
index df78bad..2e2512a 100644
--- a/chromium/config/Chromium/android/arm64/config.h
+++ b/chromium/config/Chromium/android/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android --extra-cflags='--target=aarch64-linux-android21' --extra-ldflags='--target=aarch64-linux-android21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-21/arch-arm64 --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android --extra-cflags='--target=aarch64-linux-android' --extra-ldflags='--target=aarch64-linux-android' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/android/arm64/libavutil/ffversion.h b/chromium/config/Chromium/android/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/android/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/android/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/android/ia32/config.h b/chromium/config/Chromium/android/ia32/config.h
index d2c334c..aa6592f 100644
--- a/chromium/config/Chromium/android/ia32/config.h
+++ b/chromium/config/Chromium/android/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/i686-linux-android --extra-cflags='--target=i686-linux-android21' --extra-ldflags='--target=i686-linux-android21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/i686-linux-android --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --disable-x86asm" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-16/arch-x86 --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/i686-linux-android --extra-cflags='--target=i686-linux-android' --extra-ldflags='--target=i686-linux-android' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/i686-linux-android/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --disable-x86asm --enable-pic --cc=clang --cxx=clang++ --ld=clang" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -256,8 +254,8 @@
 #define HAVE_LDEXPF 1
 #define HAVE_LLRINT 1
 #define HAVE_LLRINTF 1
-#define HAVE_LOG2 1
-#define HAVE_LOG2F 1
+#define HAVE_LOG2 0
+#define HAVE_LOG2F 0
 #define HAVE_LOG10F 1
 #define HAVE_LRINT 1
 #define HAVE_LRINTF 1
@@ -310,7 +308,7 @@
 #define HAVE_MPROTECT 1
 #define HAVE_NANOSLEEP 1
 #define HAVE_PEEKNAMEDPIPE 0
-#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 1 -- forced to 0. See https://crbug.com/604451 */
+#define HAVE_POSIX_MEMALIGN 0 /* #define HAVE_POSIX_MEMALIGN 0 -- forced to 0. See https://crbug.com/604451 */
 #define HAVE_PTHREAD_CANCEL 0
 #define HAVE_SCHED_GETAFFINITY 1
 #define HAVE_SECITEMIMPORT 0
@@ -341,7 +339,7 @@
 #define HAVE_AS_OBJECT_ARCH 0
 #define HAVE_ASM_MOD_Q 0
 #define HAVE_BLOCKS_EXTENSION 0
-/* #define HAVE_EBP_AVAILABLE 1 -- ebp selection is done by the chrome build */
+/* #define HAVE_EBP_AVAILABLE 0 -- ebp selection is done by the chrome build */
 #define HAVE_EBX_AVAILABLE 1
 #define HAVE_GNU_AS 0
 #define HAVE_GNU_WINDRES 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/android/ia32/libavutil/ffversion.h b/chromium/config/Chromium/android/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/android/ia32/libavutil/ffversion.h
+++ b/chromium/config/Chromium/android/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/android/x64/config.asm b/chromium/config/Chromium/android/x64/config.asm
index d0be566..72c9286 100644
--- a/chromium/config/Chromium/android/x64/config.asm
+++ b/chromium/config/Chromium/android/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 0
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/android/x64/config.h b/chromium/config/Chromium/android/x64/config.h
index c75297d..b5c8098 100644
--- a/chromium/config/Chromium/android/x64/config.h
+++ b/chromium/config/Chromium/android/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-pic --cc=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --ld=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --enable-cross-compile --sysroot=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android --extra-cflags='--target=x86_64-linux-android21' --extra-ldflags='--target=x86_64-linux-android21' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android --extra-ldflags='--gcc-toolchain=/ssd/trunk_blink_tot/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=x86_64" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --enable-small --enable-cross-compile --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/platforms/android-21/arch-x86_64 --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android --extra-cflags='--target=x86_64-linux-android' --extra-ldflags='--target=x86_64-linux-android' --extra-ldflags=-L/tmp/fakelinkerscripts --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android/ --extra-ldflags='--gcc-toolchain=/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/' --target-os=android --arch=x86_64 --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)"
-#define OS_NAME android
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 0
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/android/x64/libavutil/ffversion.h b/chromium/config/Chromium/android/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/android/x64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/android/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux-noasm/x64/config.h b/chromium/config/Chromium/linux-noasm/x64/config.h
index 3689bd4..624227a 100644
--- a/chromium/config/Chromium/linux-noasm/x64/config.h
+++ b/chromium/config/Chromium/linux-noasm/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --disable-asm --disable-inline-asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --disable-asm --disable-inline-asm --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux-noasm/x64/libavutil/ffversion.h b/chromium/config/Chromium/linux-noasm/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux-noasm/x64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux-noasm/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/arm-neon/config.h b/chromium/config/Chromium/linux/arm-neon/config.h
index 2ec9ad3..d920a13 100644
--- a/chromium/config/Chromium/linux/arm-neon/config.h
+++ b/chromium/config/Chromium/linux/arm-neon/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --enable-neon --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --enable-neon --extra-cflags='-mfpu=neon' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/arm-neon/libavutil/ffversion.h b/chromium/config/Chromium/linux/arm-neon/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/arm-neon/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/arm-neon/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/arm/config.h b/chromium/config/Chromium/linux/arm/config.h
index bec905b..1371de8 100644
--- a/chromium/config/Chromium/linux/arm/config.h
+++ b/chromium/config/Chromium/linux/arm/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --disable-neon --extra-cflags='-mfpu=vfpv3-d16' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=arm --enable-armv6 --enable-armv6t2 --enable-vfp --enable-thumb --extra-cflags='-march=armv7-a' --enable-cross-compile --target-os=linux --extra-cflags='--target=arm-linux-gnueabihf' --extra-ldflags='--target=arm-linux-gnueabihf' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm-sysroot --extra-cflags='-mtune=cortex-a8' --extra-cflags='-mfloat-abi=hard' --extra-cflags=-O2 --disable-neon --extra-cflags='-mfpu=vfpv3-d16' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/arm/libavutil/ffversion.h b/chromium/config/Chromium/linux/arm/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/arm/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/arm/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/arm64/config.h b/chromium/config/Chromium/linux/arm64/config.h
index 1ef89d6..2bd6782 100644
--- a/chromium/config/Chromium/linux/arm64/config.h
+++ b/chromium/config/Chromium/linux/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-cross-compile --cross-prefix=/usr/bin/aarch64-linux-gnu- --target-os=linux --extra-cflags='--target=aarch64-linux-gnu' --extra-ldflags='--target=aarch64-linux-gnu' --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_arm64-sysroot --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-cross-compile --cross-prefix=/usr/bin/aarch64-linux-gnu- --target-os=linux --extra-cflags='--target=aarch64-linux-gnu' --extra-ldflags='--target=aarch64-linux-gnu' --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_arm64-sysroot --arch=aarch64 --enable-armv8 --extra-cflags='-march=armv8-a' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/arm64/libavutil/ffversion.h b/chromium/config/Chromium/linux/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/ia32/config.asm b/chromium/config/Chromium/linux/ia32/config.asm
index 7da6b21..97ac7a7 100644
--- a/chromium/config/Chromium/linux/ia32/config.asm
+++ b/chromium/config/Chromium/linux/ia32/config.asm
@@ -172,7 +172,7 @@
 %define HAVE_ATOMIC_CAS_PTR 0
 %define HAVE_MACHINE_RW_BARRIER 0
 %define HAVE_MEMORYBARRIER 0
-%define HAVE_MM_EMPTY 1
+%define HAVE_MM_EMPTY 0
 %define HAVE_RDTSC 0
 %define HAVE_SEM_TIMEDWAIT 1
 %define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/ia32/config.h b/chromium/config/Chromium/linux/ia32/config.h
index 37bc36c..2be3ecf 100644
--- a/chromium/config/Chromium/linux/ia32/config.h
+++ b/chromium/config/Chromium/linux/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --enable-pic --cc=clang --cxx=clang++ --ld=clang" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=i686 --extra-cflags='\"-m32\"' --extra-ldflags='\"-m32\"' --enable-pic --cc=clang --cxx=clang++ --ld=clang" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -188,7 +187,7 @@
 #define HAVE_ATOMIC_CAS_PTR 0
 #define HAVE_MACHINE_RW_BARRIER 0
 #define HAVE_MEMORYBARRIER 0
-#define HAVE_MM_EMPTY 1
+#define HAVE_MM_EMPTY 0
 #define HAVE_RDTSC 0
 #define HAVE_SEM_TIMEDWAIT 1
 #define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/ia32/libavutil/ffversion.h b/chromium/config/Chromium/linux/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/ia32/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/mips64el/config.h b/chromium/config/Chromium/linux/mips64el/config.h
index 81d1d33..84bd14f 100644
--- a/chromium/config/Chromium/linux/mips64el/config.h
+++ b/chromium/config/Chromium/linux/mips64el/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mips64el --enable-mipsfpu --disable-mipsdsp --disable-mipsdspr2 --extra-cflags='-march=mips64el' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_mips64el-sysroot --enable-mips64r2 --disable-mips64r6 --disable-msa --extra-cflags='-mcpu=mips64r2' --extra-cflags='--target=mips64el-linux-gnuabi64' --extra-ldflags='--target=mips64el-linux-gnuabi64' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mips64el --enable-mipsfpu --disable-mipsdsp --disable-mipsdspr2 --extra-cflags='-march=mips64el' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_mips64el-sysroot --enable-mips64r2 --disable-mips64r6 --disable-msa --extra-cflags='-mcpu=mips64r2' --extra-cflags='--target=mips64el-linux-gnuabi64' --extra-ldflags='--target=mips64el-linux-gnuabi64' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/mips64el/libavutil/ffversion.h b/chromium/config/Chromium/linux/mips64el/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/mips64el/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/mips64el/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/mipsel/config.h b/chromium/config/Chromium/linux/mipsel/config.h
index 968241e..cabcc0e 100644
--- a/chromium/config/Chromium/linux/mipsel/config.h
+++ b/chromium/config/Chromium/linux/mipsel/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mipsel --disable-mips32r6 --disable-mips32r5 --disable-mips32r2 --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-mipsfpu --extra-cflags='-march=mipsel' --extra-cflags='-mcpu=mips32' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/ssd/trunk_blink_tot/src/build/linux/debian_sid_mips-sysroot --extra-cflags='--target=mipsel-linux-gnu' --extra-ldflags='--target=mipsel-linux-gnu' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=mipsel --disable-mips32r6 --disable-mips32r5 --disable-mips32r2 --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-mipsfpu --extra-cflags='-march=mipsel' --extra-cflags='-mcpu=mips32' --extra-ldflags='-z notext' --enable-cross-compile --target-os=linux --sysroot=/usr/local/google/home/ezemtsov/projects/chromium/src/build/linux/debian_sid_mips-sysroot --extra-cflags='--target=mipsel-linux-gnu' --extra-ldflags='--target=mipsel-linux-gnu' --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/mipsel/libavutil/ffversion.h b/chromium/config/Chromium/linux/mipsel/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/mipsel/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/mipsel/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/linux/x64/config.asm b/chromium/config/Chromium/linux/x64/config.asm
index 7403ecb..946313f 100644
--- a/chromium/config/Chromium/linux/x64/config.asm
+++ b/chromium/config/Chromium/linux/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 1
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/x64/config.h b/chromium/config/Chromium/linux/x64/config.h
index c36debb..2dab423 100644
--- a/chromium/config/Chromium/linux/x64/config.h
+++ b/chromium/config/Chromium/linux/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-lto --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags='-fuse-ld=lld'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME linux
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 1
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/linux/x64/libavutil/ffversion.h b/chromium/config/Chromium/linux/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/linux/x64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/linux/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/mac/arm64/config.h b/chromium/config/Chromium/mac/arm64/config.h
index 8dd2cb5..a46b138 100644
--- a/chromium/config/Chromium/mac/arm64/config.h
+++ b/chromium/config/Chromium/mac/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=arm64-apple-macosx' --extra-cflags=-F/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include --extra-cflags=-isystem/ssd/trunk_blink_tot/src/third_party/llvm-build/Release+Asserts/lib/clang/13.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --extra-ldflags=-L/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --extra-ldflags=-platform_version --extra-ldflags=macos --extra-ldflags=10.10 --extra-ldflags=10.10 --arch=arm64 --extra-cflags='-arch arm64' --extra-ldflags='-arch arm64'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=arm64-apple-macosx' --extra-cflags=-F/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/llvm-build/Release+Asserts/lib/clang/12.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --arch=arm64 --extra-cflags='-arch arm64' --extra-ldflags='-arch arm64'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME darwin
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX "_"
 #define EXTERN_ASM _
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -238,7 +236,7 @@
 #define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */
 #define HAVE_WINDOWS_H 0
 #define HAVE_WINSOCK2_H 0
-#define HAVE_INTRINSICS_NEON 1
+#define HAVE_INTRINSICS_NEON 0
 #define HAVE_ATANF 1
 #define HAVE_ATAN2F 1
 #define HAVE_CBRT 1
@@ -351,7 +349,7 @@
 #define HAVE_INLINE_ASM_NONLOCAL_LABELS 1
 #define HAVE_PRAGMA_DEPRECATED 1
 #define HAVE_RSYNC_CONTIMEOUT 1
-#define HAVE_SYMVER_ASM_LABEL 0
+#define HAVE_SYMVER_ASM_LABEL 1
 #define HAVE_SYMVER_GNU_ASM 0
 /* #define HAVE_VFP_ARGS 0 -- softfp/hardfp selection is done by the chrome build */
 #define HAVE_XFORM_ASM 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/mac/arm64/libavutil/ffversion.h b/chromium/config/Chromium/mac/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/mac/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/mac/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/mac/x64/config.asm b/chromium/config/Chromium/mac/x64/config.asm
index 9edb430..b43510e 100644
--- a/chromium/config/Chromium/mac/x64/config.asm
+++ b/chromium/config/Chromium/mac/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 0
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 0
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -335,7 +334,7 @@
 %define HAVE_INLINE_ASM_NONLOCAL_LABELS 1
 %define HAVE_PRAGMA_DEPRECATED 1
 %define HAVE_RSYNC_CONTIMEOUT 1
-%define HAVE_SYMVER_ASM_LABEL 0
+%define HAVE_SYMVER_ASM_LABEL 1
 %define HAVE_SYMVER_GNU_ASM 0
 %define HAVE_VFP_ARGS 0
 %define HAVE_XFORM_ASM 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/mac/x64/config.h b/chromium/config/Chromium/mac/x64/config.h
index 30cf8d0..c35c060 100644
--- a/chromium/config/Chromium/mac/x64/config.h
+++ b/chromium/config/Chromium/mac/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=x86_64-apple-macosx' --extra-cflags=-F/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include --extra-cflags=-isystem/ssd/trunk_blink_tot/src/third_party/llvm-build/Release+Asserts/lib/clang/13.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --extra-ldflags=-L/ssd/trunk_blink_tot/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --extra-ldflags=-platform_version --extra-ldflags=macos --extra-ldflags=10.10 --extra-ldflags=10.10 --arch=x86_64 --extra-cflags=-m64 --extra-ldflags='-arch x86_64'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --enable-pic --cc=clang --cxx=clang++ --ld=clang --enable-cross-compile --cc=clang --ld=ld64.lld --nm=llvm-nm --ar=llvm-ar --target-os=darwin --extra-cflags='--target=x86_64-apple-macosx' --extra-cflags=-F/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks --extra-cflags='-mmacosx-version-min=10.10' --extra-cflags=-fblocks --extra-cflags=-nostdinc --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include --extra-cflags=-isystem/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/llvm-build/Release+Asserts/lib/clang/12.0.0/include --extra-ldflags=-syslibroot --extra-ldflags=/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --extra-ldflags=-L/usr/local/google/home/ezemtsov/projects/chromium/src/build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib --extra-ldflags=-lSystem --extra-ldflags=-macosx_version_min --extra-ldflags=10.10 --extra-ldflags=-sdk_version --extra-ldflags=10.10 --arch=x86_64 --extra-cflags=-m64 --extra-ldflags=-m64" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME darwin
+#define CC_IDENT "clang version 9.0.1-14"
 #define av_restrict restrict
 #define EXTERN_PREFIX "_"
 #define EXTERN_ASM _
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 0
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -351,7 +349,7 @@
 #define HAVE_INLINE_ASM_NONLOCAL_LABELS 1
 #define HAVE_PRAGMA_DEPRECATED 1
 #define HAVE_RSYNC_CONTIMEOUT 1
-#define HAVE_SYMVER_ASM_LABEL 0
+#define HAVE_SYMVER_ASM_LABEL 1
 #define HAVE_SYMVER_GNU_ASM 0
 #define HAVE_VFP_ARGS 0
 #define HAVE_XFORM_ASM 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/mac/x64/libavutil/ffversion.h b/chromium/config/Chromium/mac/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/mac/x64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/mac/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/win/arm64/config.h b/chromium/config/Chromium/win/arm64/config.h
index 7bb921b..01832fc 100644
--- a/chromium/config/Chromium/win/arm64/config.h
+++ b/chromium/config/Chromium/win/arm64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --arch=aarch64 --as=clang-cl --extra-cflags='--target=arm64-windows' --extra-cflags=/winsysroot/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/atlmfc/lib/arm64' --extra-ldflags='-libpath:/tmp/windows_build_ffmpeg0sG8TT' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegnpJGA8' --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/lib/arm64'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --arch=aarch64 --as=clang-cl --extra-cflags='--target=arm64-windows' --extra-ldflags='--target=arm64-windows' --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/um --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/shared --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/winrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/ucrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/include --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/include --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/lib/arm64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/ucrt/arm64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/um/arm64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/lib/arm64'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME win32
+#define CC_IDENT "clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6ee22ca6ceb71661e8dbc296b471ace0614c07e5)"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 1
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/win/arm64/libavutil/ffversion.h b/chromium/config/Chromium/win/arm64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/win/arm64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/win/arm64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/win/ia32/config.asm b/chromium/config/Chromium/win/ia32/config.asm
index 0785529..ec1be8d 100644
--- a/chromium/config/Chromium/win/ia32/config.asm
+++ b/chromium/config/Chromium/win/ia32/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 1
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 0
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/win/ia32/config.h b/chromium/config/Chromium/win/ia32/config.h
index aaed39c..cda3dd8 100644
--- a/chromium/config/Chromium/win/ia32/config.h
+++ b/chromium/config/Chromium/win/ia32/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=-m32 --extra-cflags=/winsysroot/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x86' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegyUA9_h' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegEDND2F' --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/lib/x86'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/chromium/include/win --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=-m32 --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/um --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/shared --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/winrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/ucrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/include --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/include --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x86' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/ucrt/x86' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/um/x86' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/lib/x86'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME win32
+#define CC_IDENT "clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6ee22ca6ceb71661e8dbc296b471ace0614c07e5)"
 #define av_restrict restrict
 #define EXTERN_PREFIX "_"
 #define EXTERN_ASM _
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 1
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/win/ia32/libavutil/ffversion.h b/chromium/config/Chromium/win/ia32/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/win/ia32/libavutil/ffversion.h
+++ b/chromium/config/Chromium/win/ia32/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/config/Chromium/win/x64/config.asm b/chromium/config/Chromium/win/x64/config.asm
index f37d123..6aeefde 100644
--- a/chromium/config/Chromium/win/x64/config.asm
+++ b/chromium/config/Chromium/win/x64/config.asm
@@ -201,7 +201,6 @@
 %define HAVE_ES2_GL_H 0
 %define HAVE_GSM_H 0
 %define HAVE_IO_H 1
-%define HAVE_LINUX_DMA_BUF_H 0
 %define HAVE_LINUX_PERF_EVENT_H 0
 %define HAVE_MACHINE_IOCTL_BT848_H 0
 %define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -713,7 +712,6 @@
 %define CONFIG_PCM_RECHUNK_BSF 0
 %define CONFIG_PRORES_METADATA_BSF 0
 %define CONFIG_REMOVE_EXTRADATA_BSF 0
-%define CONFIG_SETTS_BSF 0
 %define CONFIG_TEXT2MOVSUB_BSF 0
 %define CONFIG_TRACE_HEADERS_BSF 0
 %define CONFIG_TRUEHD_CORE_BSF 0
@@ -919,11 +917,9 @@
 %define CONFIG_SANM_DECODER 0
 %define CONFIG_SCPR_DECODER 0
 %define CONFIG_SCREENPRESSO_DECODER 0
-%define CONFIG_SGA_DECODER 0
 %define CONFIG_SGI_DECODER 0
 %define CONFIG_SGIRLE_DECODER 0
 %define CONFIG_SHEERVIDEO_DECODER 0
-%define CONFIG_SIMBIOSIS_IMX_DECODER 0
 %define CONFIG_SMACKER_DECODER 0
 %define CONFIG_SMC_DECODER 0
 %define CONFIG_SMVJPEG_DECODER 0
@@ -1125,7 +1121,6 @@
 %define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 %define CONFIG_PCM_S64BE_DECODER 0
 %define CONFIG_PCM_S64LE_DECODER 0
-%define CONFIG_PCM_SGA_DECODER 0
 %define CONFIG_PCM_U8_DECODER 1
 %define CONFIG_PCM_U16BE_DECODER 0
 %define CONFIG_PCM_U16LE_DECODER 0
@@ -1290,7 +1285,6 @@
 %define CONFIG_DNXHD_ENCODER 0
 %define CONFIG_DPX_ENCODER 0
 %define CONFIG_DVVIDEO_ENCODER 0
-%define CONFIG_EXR_ENCODER 0
 %define CONFIG_FFV1_ENCODER 0
 %define CONFIG_FFVHUFF_ENCODER 0
 %define CONFIG_FITS_ENCODER 0
@@ -1317,7 +1311,6 @@
 %define CONFIG_PAM_ENCODER 0
 %define CONFIG_PBM_ENCODER 0
 %define CONFIG_PCX_ENCODER 0
-%define CONFIG_PFM_ENCODER 0
 %define CONFIG_PGM_ENCODER 0
 %define CONFIG_PGMYUV_ENCODER 0
 %define CONFIG_PNG_ENCODER 0
@@ -1435,7 +1428,6 @@
 %define CONFIG_SRT_ENCODER 0
 %define CONFIG_SUBRIP_ENCODER 0
 %define CONFIG_TEXT_ENCODER 0
-%define CONFIG_TTML_ENCODER 0
 %define CONFIG_WEBVTT_ENCODER 0
 %define CONFIG_XSUB_ENCODER 0
 %define CONFIG_AAC_AT_ENCODER 0
@@ -1575,11 +1567,9 @@
 %define CONFIG_BMP_PARSER 0
 %define CONFIG_CAVSVIDEO_PARSER 0
 %define CONFIG_COOK_PARSER 0
-%define CONFIG_CRI_PARSER 0
 %define CONFIG_DCA_PARSER 0
 %define CONFIG_DIRAC_PARSER 0
 %define CONFIG_DNXHD_PARSER 0
-%define CONFIG_DOLBY_E_PARSER 0
 %define CONFIG_DPX_PARSER 0
 %define CONFIG_DVAUDIO_PARSER 0
 %define CONFIG_DVBSUB_PARSER 0
@@ -1615,7 +1605,6 @@
 %define CONFIG_VP8_PARSER 1
 %define CONFIG_VP9_PARSER 1
 %define CONFIG_WEBP_PARSER 0
-%define CONFIG_XBM_PARSER 0
 %define CONFIG_XMA_PARSER 0
 %define CONFIG_ALSA_INDEV 0
 %define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1666,7 +1655,6 @@
 %define CONFIG_AECHO_FILTER 0
 %define CONFIG_AEMPHASIS_FILTER 0
 %define CONFIG_AEVAL_FILTER 0
-%define CONFIG_AEXCITER_FILTER 0
 %define CONFIG_AFADE_FILTER 0
 %define CONFIG_AFFTDN_FILTER 0
 %define CONFIG_AFFTFILT_FILTER 0
@@ -1811,16 +1799,12 @@
 %define CONFIG_CODECVIEW_FILTER 0
 %define CONFIG_COLORBALANCE_FILTER 0
 %define CONFIG_COLORCHANNELMIXER_FILTER 0
-%define CONFIG_COLORCONTRAST_FILTER 0
-%define CONFIG_COLORCORRECT_FILTER 0
-%define CONFIG_COLORIZE_FILTER 0
 %define CONFIG_COLORKEY_FILTER 0
 %define CONFIG_COLORKEY_OPENCL_FILTER 0
 %define CONFIG_COLORHOLD_FILTER 0
 %define CONFIG_COLORLEVELS_FILTER 0
 %define CONFIG_COLORMATRIX_FILTER 0
 %define CONFIG_COLORSPACE_FILTER 0
-%define CONFIG_COLORTEMPERATURE_FILTER 0
 %define CONFIG_CONVOLUTION_FILTER 0
 %define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 %define CONFIG_CONVOLVE_FILTER 0
@@ -1863,12 +1847,9 @@
 %define CONFIG_EDGEDETECT_FILTER 0
 %define CONFIG_ELBG_FILTER 0
 %define CONFIG_ENTROPY_FILTER 0
-%define CONFIG_EPX_FILTER 0
 %define CONFIG_EQ_FILTER 0
 %define CONFIG_EROSION_FILTER 0
 %define CONFIG_EROSION_OPENCL_FILTER 0
-%define CONFIG_ESTDIF_FILTER 0
-%define CONFIG_EXPOSURE_FILTER 0
 %define CONFIG_EXTRACTPLANES_FILTER 0
 %define CONFIG_FADE_FILTER 0
 %define CONFIG_FFTDNOIZ_FILTER 0
@@ -1907,14 +1888,12 @@
 %define CONFIG_HWUPLOAD_FILTER 0
 %define CONFIG_HWUPLOAD_CUDA_FILTER 0
 %define CONFIG_HYSTERESIS_FILTER 0
-%define CONFIG_IDENTITY_FILTER 0
 %define CONFIG_IDET_FILTER 0
 %define CONFIG_IL_FILTER 0
 %define CONFIG_INFLATE_FILTER 0
 %define CONFIG_INTERLACE_FILTER 0
 %define CONFIG_INTERLEAVE_FILTER 0
 %define CONFIG_KERNDEINT_FILTER 0
-%define CONFIG_KIRSCH_FILTER 0
 %define CONFIG_LAGFUN_FILTER 0
 %define CONFIG_LENSCORRECTION_FILTER 0
 %define CONFIG_LENSFUN_FILTER 0
@@ -1942,9 +1921,7 @@
 %define CONFIG_MIDEQUALIZER_FILTER 0
 %define CONFIG_MINTERPOLATE_FILTER 0
 %define CONFIG_MIX_FILTER 0
-%define CONFIG_MONOCHROME_FILTER 0
 %define CONFIG_MPDECIMATE_FILTER 0
-%define CONFIG_MSAD_FILTER 0
 %define CONFIG_NEGATE_FILTER 0
 %define CONFIG_NLMEANS_FILTER 0
 %define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2018,11 +1995,9 @@
 %define CONFIG_SETSAR_FILTER 0
 %define CONFIG_SETTB_FILTER 0
 %define CONFIG_SHARPNESS_VAAPI_FILTER 0
-%define CONFIG_SHEAR_FILTER 0
 %define CONFIG_SHOWINFO_FILTER 0
 %define CONFIG_SHOWPALETTE_FILTER 0
 %define CONFIG_SHUFFLEFRAMES_FILTER 0
-%define CONFIG_SHUFFLEPIXELS_FILTER 0
 %define CONFIG_SHUFFLEPLANES_FILTER 0
 %define CONFIG_SIDEDATA_FILTER 0
 %define CONFIG_SIGNALSTATS_FILTER 0
@@ -2050,7 +2025,6 @@
 %define CONFIG_TINTERLACE_FILTER 0
 %define CONFIG_TLUT2_FILTER 0
 %define CONFIG_TMEDIAN_FILTER 0
-%define CONFIG_TMIDEQUALIZER_FILTER 0
 %define CONFIG_TMIX_FILTER 0
 %define CONFIG_TONEMAP_FILTER 0
 %define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2074,7 +2048,6 @@
 %define CONFIG_VIBRANCE_FILTER 0
 %define CONFIG_VIDSTABDETECT_FILTER 0
 %define CONFIG_VIDSTABTRANSFORM_FILTER 0
-%define CONFIG_VIF_FILTER 0
 %define CONFIG_VIGNETTE_FILTER 0
 %define CONFIG_VMAFMOTION_FILTER 0
 %define CONFIG_VPP_QSV_FILTER 0
@@ -2181,7 +2154,6 @@
 %define CONFIG_BFI_DEMUXER 0
 %define CONFIG_BINTEXT_DEMUXER 0
 %define CONFIG_BINK_DEMUXER 0
-%define CONFIG_BINKA_DEMUXER 0
 %define CONFIG_BIT_DEMUXER 0
 %define CONFIG_BMV_DEMUXER 0
 %define CONFIG_BFSTM_DEMUXER 0
@@ -2371,10 +2343,8 @@
 %define CONFIG_SDX_DEMUXER 0
 %define CONFIG_SEGAFILM_DEMUXER 0
 %define CONFIG_SER_DEMUXER 0
-%define CONFIG_SGA_DEMUXER 0
 %define CONFIG_SHORTEN_DEMUXER 0
 %define CONFIG_SIFF_DEMUXER 0
-%define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 %define CONFIG_SLN_DEMUXER 0
 %define CONFIG_SMACKER_DEMUXER 0
 %define CONFIG_SMJPEG_DEMUXER 0
@@ -2459,7 +2429,6 @@
 %define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-%define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 %define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 %define CONFIG_LIBGME_DEMUXER 0
@@ -2620,7 +2589,6 @@
 %define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 %define CONFIG_TRUEHD_MUXER 0
 %define CONFIG_TTA_MUXER 0
-%define CONFIG_TTML_MUXER 0
 %define CONFIG_UNCODEDFRAMECRC_MUXER 0
 %define CONFIG_VC1_MUXER 0
 %define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/win/x64/config.h b/chromium/config/Chromium/win/x64/config.h
index 788a3a2..231f09e 100644
--- a/chromium/config/Chromium/win/x64/config.h
+++ b/chromium/config/Chromium/win/x64/config.h
@@ -1,13 +1,12 @@
 /* Automatically generated by configure - do not modify! */
 #ifndef FFMPEG_CONFIG_H
 #define FFMPEG_CONFIG_H
-/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/ssd/trunk_blink_tot/src/third_party/ffmpeg/chromium/include/win --target-os=win64 --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=/winsysroot/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x64' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegyC1L2b' --extra-ldflags='-libpath:/tmp/windows_build_ffmpegsogwo4' --extra-ldflags='-libpath:/ssd/trunk_blink_tot/src/third_party/depot_tools/win_toolchain/vs_files/20d5f2553f/VC/Tools/MSVC/14.26.28801/lib/x64'" -- elide long configuration string from binary */
+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --extra-cflags=-I/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/chromium/include/win --target-os=win64 --enable-cross-compile --cc=clang-cl --ld=lld-link --nm=llvm-nm --ar=llvm-ar --extra-cflags=-O2 --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/um --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/shared --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/winrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Include/10.0.19041.0/ucrt --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/include --extra-cflags=-imsvc/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/ffmpeg/../depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/include --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/atlmfc/lib/x64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/ucrt/x64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/win_sdk/Lib/10.0.19041.0/um/x64' --extra-ldflags='-libpath:/usr/local/google/home/ezemtsov/projects/chromium/src/third_party/depot_tools/win_toolchain/vs_files/a687d8e2e4114d9015eb550e1b156af21381faac/VC/Tools/MSVC/14.26.28801/lib/x64'" -- elide long configuration string from binary */
 #define FFMPEG_LICENSE "LGPL version 2.1 or later"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "/usr/local/share/ffmpeg"
 #define AVCONV_DATADIR "/usr/local/share/ffmpeg"
-#define CC_IDENT "clang version 13.0.0 (https://github.com/llvm/llvm-project/ fe5c2c3ca682b140dd5e640e75948363b6b25ef9)"
-#define OS_NAME win64
+#define CC_IDENT "clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6ee22ca6ceb71661e8dbc296b471ace0614c07e5)"
 #define av_restrict restrict
 #define EXTERN_PREFIX ""
 #define EXTERN_ASM 
@@ -217,7 +216,6 @@
 #define HAVE_ES2_GL_H 0
 #define HAVE_GSM_H 0
 #define HAVE_IO_H 1
-#define HAVE_LINUX_DMA_BUF_H 0
 #define HAVE_LINUX_PERF_EVENT_H 0
 #define HAVE_MACHINE_IOCTL_BT848_H 0
 #define HAVE_MACHINE_IOCTL_METEOR_H 0
@@ -729,7 +727,6 @@
 #define CONFIG_PCM_RECHUNK_BSF 0
 #define CONFIG_PRORES_METADATA_BSF 0
 #define CONFIG_REMOVE_EXTRADATA_BSF 0
-#define CONFIG_SETTS_BSF 0
 #define CONFIG_TEXT2MOVSUB_BSF 0
 #define CONFIG_TRACE_HEADERS_BSF 0
 #define CONFIG_TRUEHD_CORE_BSF 0
@@ -935,11 +932,9 @@
 #define CONFIG_SANM_DECODER 0
 #define CONFIG_SCPR_DECODER 0
 #define CONFIG_SCREENPRESSO_DECODER 0
-#define CONFIG_SGA_DECODER 0
 #define CONFIG_SGI_DECODER 0
 #define CONFIG_SGIRLE_DECODER 0
 #define CONFIG_SHEERVIDEO_DECODER 0
-#define CONFIG_SIMBIOSIS_IMX_DECODER 0
 #define CONFIG_SMACKER_DECODER 0
 #define CONFIG_SMC_DECODER 0
 #define CONFIG_SMVJPEG_DECODER 0
@@ -1141,7 +1136,6 @@
 #define CONFIG_PCM_S32LE_PLANAR_DECODER 0
 #define CONFIG_PCM_S64BE_DECODER 0
 #define CONFIG_PCM_S64LE_DECODER 0
-#define CONFIG_PCM_SGA_DECODER 0
 #define CONFIG_PCM_U8_DECODER 1
 #define CONFIG_PCM_U16BE_DECODER 0
 #define CONFIG_PCM_U16LE_DECODER 0
@@ -1306,7 +1300,6 @@
 #define CONFIG_DNXHD_ENCODER 0
 #define CONFIG_DPX_ENCODER 0
 #define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_EXR_ENCODER 0
 #define CONFIG_FFV1_ENCODER 0
 #define CONFIG_FFVHUFF_ENCODER 0
 #define CONFIG_FITS_ENCODER 0
@@ -1333,7 +1326,6 @@
 #define CONFIG_PAM_ENCODER 0
 #define CONFIG_PBM_ENCODER 0
 #define CONFIG_PCX_ENCODER 0
-#define CONFIG_PFM_ENCODER 0
 #define CONFIG_PGM_ENCODER 0
 #define CONFIG_PGMYUV_ENCODER 0
 #define CONFIG_PNG_ENCODER 0
@@ -1451,7 +1443,6 @@
 #define CONFIG_SRT_ENCODER 0
 #define CONFIG_SUBRIP_ENCODER 0
 #define CONFIG_TEXT_ENCODER 0
-#define CONFIG_TTML_ENCODER 0
 #define CONFIG_WEBVTT_ENCODER 0
 #define CONFIG_XSUB_ENCODER 0
 #define CONFIG_AAC_AT_ENCODER 0
@@ -1591,11 +1582,9 @@
 #define CONFIG_BMP_PARSER 0
 #define CONFIG_CAVSVIDEO_PARSER 0
 #define CONFIG_COOK_PARSER 0
-#define CONFIG_CRI_PARSER 0
 #define CONFIG_DCA_PARSER 0
 #define CONFIG_DIRAC_PARSER 0
 #define CONFIG_DNXHD_PARSER 0
-#define CONFIG_DOLBY_E_PARSER 0
 #define CONFIG_DPX_PARSER 0
 #define CONFIG_DVAUDIO_PARSER 0
 #define CONFIG_DVBSUB_PARSER 0
@@ -1631,7 +1620,6 @@
 #define CONFIG_VP8_PARSER 1
 #define CONFIG_VP9_PARSER 1
 #define CONFIG_WEBP_PARSER 0
-#define CONFIG_XBM_PARSER 0
 #define CONFIG_XMA_PARSER 0
 #define CONFIG_ALSA_INDEV 0
 #define CONFIG_ANDROID_CAMERA_INDEV 0
@@ -1682,7 +1670,6 @@
 #define CONFIG_AECHO_FILTER 0
 #define CONFIG_AEMPHASIS_FILTER 0
 #define CONFIG_AEVAL_FILTER 0
-#define CONFIG_AEXCITER_FILTER 0
 #define CONFIG_AFADE_FILTER 0
 #define CONFIG_AFFTDN_FILTER 0
 #define CONFIG_AFFTFILT_FILTER 0
@@ -1827,16 +1814,12 @@
 #define CONFIG_CODECVIEW_FILTER 0
 #define CONFIG_COLORBALANCE_FILTER 0
 #define CONFIG_COLORCHANNELMIXER_FILTER 0
-#define CONFIG_COLORCONTRAST_FILTER 0
-#define CONFIG_COLORCORRECT_FILTER 0
-#define CONFIG_COLORIZE_FILTER 0
 #define CONFIG_COLORKEY_FILTER 0
 #define CONFIG_COLORKEY_OPENCL_FILTER 0
 #define CONFIG_COLORHOLD_FILTER 0
 #define CONFIG_COLORLEVELS_FILTER 0
 #define CONFIG_COLORMATRIX_FILTER 0
 #define CONFIG_COLORSPACE_FILTER 0
-#define CONFIG_COLORTEMPERATURE_FILTER 0
 #define CONFIG_CONVOLUTION_FILTER 0
 #define CONFIG_CONVOLUTION_OPENCL_FILTER 0
 #define CONFIG_CONVOLVE_FILTER 0
@@ -1879,12 +1862,9 @@
 #define CONFIG_EDGEDETECT_FILTER 0
 #define CONFIG_ELBG_FILTER 0
 #define CONFIG_ENTROPY_FILTER 0
-#define CONFIG_EPX_FILTER 0
 #define CONFIG_EQ_FILTER 0
 #define CONFIG_EROSION_FILTER 0
 #define CONFIG_EROSION_OPENCL_FILTER 0
-#define CONFIG_ESTDIF_FILTER 0
-#define CONFIG_EXPOSURE_FILTER 0
 #define CONFIG_EXTRACTPLANES_FILTER 0
 #define CONFIG_FADE_FILTER 0
 #define CONFIG_FFTDNOIZ_FILTER 0
@@ -1923,14 +1903,12 @@
 #define CONFIG_HWUPLOAD_FILTER 0
 #define CONFIG_HWUPLOAD_CUDA_FILTER 0
 #define CONFIG_HYSTERESIS_FILTER 0
-#define CONFIG_IDENTITY_FILTER 0
 #define CONFIG_IDET_FILTER 0
 #define CONFIG_IL_FILTER 0
 #define CONFIG_INFLATE_FILTER 0
 #define CONFIG_INTERLACE_FILTER 0
 #define CONFIG_INTERLEAVE_FILTER 0
 #define CONFIG_KERNDEINT_FILTER 0
-#define CONFIG_KIRSCH_FILTER 0
 #define CONFIG_LAGFUN_FILTER 0
 #define CONFIG_LENSCORRECTION_FILTER 0
 #define CONFIG_LENSFUN_FILTER 0
@@ -1958,9 +1936,7 @@
 #define CONFIG_MIDEQUALIZER_FILTER 0
 #define CONFIG_MINTERPOLATE_FILTER 0
 #define CONFIG_MIX_FILTER 0
-#define CONFIG_MONOCHROME_FILTER 0
 #define CONFIG_MPDECIMATE_FILTER 0
-#define CONFIG_MSAD_FILTER 0
 #define CONFIG_NEGATE_FILTER 0
 #define CONFIG_NLMEANS_FILTER 0
 #define CONFIG_NLMEANS_OPENCL_FILTER 0
@@ -2034,11 +2010,9 @@
 #define CONFIG_SETSAR_FILTER 0
 #define CONFIG_SETTB_FILTER 0
 #define CONFIG_SHARPNESS_VAAPI_FILTER 0
-#define CONFIG_SHEAR_FILTER 0
 #define CONFIG_SHOWINFO_FILTER 0
 #define CONFIG_SHOWPALETTE_FILTER 0
 #define CONFIG_SHUFFLEFRAMES_FILTER 0
-#define CONFIG_SHUFFLEPIXELS_FILTER 0
 #define CONFIG_SHUFFLEPLANES_FILTER 0
 #define CONFIG_SIDEDATA_FILTER 0
 #define CONFIG_SIGNALSTATS_FILTER 0
@@ -2066,7 +2040,6 @@
 #define CONFIG_TINTERLACE_FILTER 0
 #define CONFIG_TLUT2_FILTER 0
 #define CONFIG_TMEDIAN_FILTER 0
-#define CONFIG_TMIDEQUALIZER_FILTER 0
 #define CONFIG_TMIX_FILTER 0
 #define CONFIG_TONEMAP_FILTER 0
 #define CONFIG_TONEMAP_OPENCL_FILTER 0
@@ -2090,7 +2063,6 @@
 #define CONFIG_VIBRANCE_FILTER 0
 #define CONFIG_VIDSTABDETECT_FILTER 0
 #define CONFIG_VIDSTABTRANSFORM_FILTER 0
-#define CONFIG_VIF_FILTER 0
 #define CONFIG_VIGNETTE_FILTER 0
 #define CONFIG_VMAFMOTION_FILTER 0
 #define CONFIG_VPP_QSV_FILTER 0
@@ -2197,7 +2169,6 @@
 #define CONFIG_BFI_DEMUXER 0
 #define CONFIG_BINTEXT_DEMUXER 0
 #define CONFIG_BINK_DEMUXER 0
-#define CONFIG_BINKA_DEMUXER 0
 #define CONFIG_BIT_DEMUXER 0
 #define CONFIG_BMV_DEMUXER 0
 #define CONFIG_BFSTM_DEMUXER 0
@@ -2387,10 +2358,8 @@
 #define CONFIG_SDX_DEMUXER 0
 #define CONFIG_SEGAFILM_DEMUXER 0
 #define CONFIG_SER_DEMUXER 0
-#define CONFIG_SGA_DEMUXER 0
 #define CONFIG_SHORTEN_DEMUXER 0
 #define CONFIG_SIFF_DEMUXER 0
-#define CONFIG_SIMBIOSIS_IMX_DEMUXER 0
 #define CONFIG_SLN_DEMUXER 0
 #define CONFIG_SMACKER_DEMUXER 0
 #define CONFIG_SMJPEG_DEMUXER 0
@@ -2475,7 +2444,6 @@
 #define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0
-#define CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0
 #define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0
 #define CONFIG_LIBGME_DEMUXER 0
@@ -2636,7 +2604,6 @@
 #define CONFIG_MKVTIMESTAMP_V2_MUXER 0
 #define CONFIG_TRUEHD_MUXER 0
 #define CONFIG_TTA_MUXER 0
-#define CONFIG_TTML_MUXER 0
 #define CONFIG_UNCODEDFRAMECRC_MUXER 0
 #define CONFIG_VC1_MUXER 0
 #define CONFIG_VC1T_MUXER 0
diff --git a/chromium/config/Chromium/win/x64/libavutil/ffversion.h b/chromium/config/Chromium/win/x64/libavutil/ffversion.h
index 056bc62..367a7f7 100644
--- a/chromium/config/Chromium/win/x64/libavutil/ffversion.h
+++ b/chromium/config/Chromium/win/x64/libavutil/ffversion.h
@@ -1,5 +1,5 @@
 /* Automatically generated by version.sh, do not manually edit! */
 #ifndef AVUTIL_FFVERSION_H
 #define AVUTIL_FFVERSION_H
-#define FFMPEG_VERSION "N-102522-gec861011d1"
+#define FFMPEG_VERSION "N-101445-g2e5e8668e9"
 #endif /* AVUTIL_FFVERSION_H */
diff --git a/chromium/ffmpeg.sigs b/chromium/ffmpeg.sigs
index 8ee3a26..7c06a94 100755
--- a/chromium/ffmpeg.sigs
+++ b/chromium/ffmpeg.sigs
@@ -23,8 +23,6 @@
 int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par);
 int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
 int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
-AVPacket *av_packet_alloc(void);
-void av_packet_free(AVPacket **pkt);
 
 // RDFT functions.
 RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
diff --git a/chromium/patches/README b/chromium/patches/README
index ea76002..a7bac8c 100644
--- a/chromium/patches/README
+++ b/chromium/patches/README
@@ -1,5 +1,5 @@
 ---------------------------------------------------------------------
--- Chromium Patches. Autogenerated by find_patches.py, do not edit --
+-- Chromium Patches. Autogenerated by find_patches.pyc, do not edit --
 ---------------------------------------------------------------------
 
 
@@ -795,6 +795,26 @@
     libavcodec/h264dec.c
 
 ------------------------------------------------------------------
+commit 252792a1ff65deadc4e627e59ce80b8811c5a5de
+Author: Thomas Guilbert <tguilbert@chromium.org>
+Date:   Mon Dec 9 17:09:54 2019 -0800
+
+    Fix null pointer addition error
+
+    Clusterfuzz uncovered a scenario in which 0 is added to a null pointer,
+    which is undefined behavior. This CL fixes the issue by checking the
+    pointer is null before incrementing it.
+
+    BUG= 1027047, 1028812
+
+    Change-Id: I160c7e36134687a7d2ef4099078d89a714c8cfe4
+    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/third_party/ffmpeg/+/1958714
+    Reviewed-by: Ted Meyer <tmathmeyer@chromium.org>
+
+Affects:
+    libavformat/utils.c
+
+------------------------------------------------------------------
 commit 6a44f89787a6103bf85825aac5b7bcfdba0dde5f
 Merge: c5003c8e13 acbd950ed2
 Author: John Rummell <jrummell@chromium.org>
@@ -922,47 +942,3 @@
 Affects:
     libavformat/mp3dec.c
 
-------------------------------------------------------------------
-commit afa2b4327ab4beb4cd47f6cf4e59df620b5d6e4f
-Author: Matt Wolenetz <wolenetz@chromium.org>
-Date:   Wed Mar 10 16:57:29 2021 -0800
-
-    Update mac build_ffmpeg and configure to work with ld64.lld changes
-
-    The minimal linking done with real, yet unstable, ld64.lld no longer
-    recognizes "-m64", needs "-arch x64_64" instead, and needs a
-    "-platform_version <platform> <min_version> <sdk_version>" set of
-    arguments. Beyond the initial configure step, build_ffmpeg for mac
-    cross-compilation still uses a fake linker.
-
-    Also, ld64.lld now issues error instead of warning for unrecognized
-    arguments '-Wl,-dynamic,-search_paths_first' inserted by configure,
-    causing misdetection of features due to widespread link failures in
-    configure's probing, resulting in build_ffmpeg.py failure. This change
-    updates our downstream configure script to not insert those options.
-
-    BUG=1170998
-
-    Change-Id: If6d5a73f23bf8b6d3053961e13e89b0c50ccd8a6
-    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/third_party/ffmpeg/+/2749496
-    Reviewed-by: Ted Meyer <tmathmeyer@chromium.org>
-
-Affects:
-    configure
-
-------------------------------------------------------------------
-commit 7c13bac566ff75ef1821adcc4f08935d84c0c5dd
-Author: Matt Wolenetz <wolenetz@chromium.org>
-Date:   Mon Mar 29 16:06:42 2021 -0700
-
-    Always use av_realloc_array() for nal->skipped_bytes_pos
-
-    Mixing av_malloc_array() with av_realloc_array() does not work when
-    posix_memalign() is available.
-
-    BUG=1193797,721872
-    TEST=No repro of scenario in crbug with patch applied.
-
-Affects:
-    libavcodec/h2645_parse.c
-
diff --git a/chromium/patches/config_flag_changes.txt b/chromium/patches/config_flag_changes.txt
index 57e94e5..36bc0f2 100644
--- a/chromium/patches/config_flag_changes.txt
+++ b/chromium/patches/config_flag_changes.txt
@@ -1,44 +1,37 @@
-+ CONFIG_AEXCITER_FILTER 0
-+ CONFIG_BINKA_DEMUXER 0
-+ CONFIG_COLORCONTRAST_FILTER 0
-+ CONFIG_COLORCORRECT_FILTER 0
-+ CONFIG_COLORIZE_FILTER 0
-+ CONFIG_COLORTEMPERATURE_FILTER 0
-+ CONFIG_CRI_PARSER 0
-+ CONFIG_DOLBY_E_PARSER 0
-+ CONFIG_EPX_FILTER 0
-+ CONFIG_ESTDIF_FILTER 0
-+ CONFIG_EXPOSURE_FILTER 0
-+ CONFIG_EXR_ENCODER 0
-+ CONFIG_IDENTITY_FILTER 0
-+ CONFIG_IMAGE_XBM_PIPE_DEMUXER 0
-+ CONFIG_KIRSCH_FILTER 0
-+ CONFIG_MONOCHROME_FILTER 0
-+ CONFIG_MSAD_FILTER 0
-+ CONFIG_PCM_SGA_DECODER 0
-+ CONFIG_PFM_ENCODER 0
-+ CONFIG_SETTS_BSF 0
-+ CONFIG_SGA_DECODER 0
-+ CONFIG_SGA_DEMUXER 0
-+ CONFIG_SHEAR_FILTER 0
-+ CONFIG_SHUFFLEPIXELS_FILTER 0
-+ CONFIG_SIMBIOSIS_IMX_DECODER 0
-+ CONFIG_SIMBIOSIS_IMX_DEMUXER 0
-- CONFIG_THIS_YEAR 2020
-+ CONFIG_THIS_YEAR 2021
-+ CONFIG_TMIDEQUALIZER_FILTER 0
-+ CONFIG_TTML_ENCODER 0
-+ CONFIG_TTML_MUXER 0
-+ CONFIG_VIF_FILTER 0
-+ CONFIG_XBM_PARSER 0
-- HAVE_INTRINSICS_NEON 0
-+ HAVE_INTRINSICS_NEON 1
-+ HAVE_LINUX_DMA_BUF_H 0
-- HAVE_LOG2 0
-+ HAVE_LOG2 1
-- HAVE_LOG2F 0
-+ HAVE_LOG2F 1
-- HAVE_MM_EMPTY 0
-+ HAVE_MM_EMPTY 1
-+ HAVE_SYMVER_ASM_LABEL 0
-- HAVE_SYMVER_ASM_LABEL 1
++ CONFIG_ACE_DEMUXER 0
++ CONFIG_ADENORM_FILTER 0
++ CONFIG_ADPCM_IMA_ALP_ENCODER 0
++ CONFIG_ADPCM_IMA_AMV_ENCODER 0
++ CONFIG_AFREQSHIFT_FILTER 0
++ CONFIG_ALP_MUXER 0
++ CONFIG_AMV_MUXER 0
++ CONFIG_APHASESHIFT_FILTER 0
++ CONFIG_ASUBCUT_FILTER 0
++ CONFIG_ASUPERCUT_FILTER 0
++ CONFIG_ASUPERPASS_FILTER 0
++ CONFIG_ASUPERSTOP_FILTER 0
++ CONFIG_AV1_CUVID_DECODER 0
++ CONFIG_AV1_D3D11VA2_HWACCEL 0
++ CONFIG_AV1_D3D11VA_HWACCEL 0
++ CONFIG_AV1_DXVA2_HWACCEL 0
++ CONFIG_AV1_NVDEC_HWACCEL 0
++ CONFIG_AV1_QSV_DECODER 0
++ CONFIG_AV1_VAAPI_HWACCEL 0
++ CONFIG_AVS3_DEMUXER 0
++ CONFIG_AVS3_PARSER 0
++ CONFIG_CRI_DECODER 0
++ CONFIG_IMAGE_CRI_PIPE_DEMUXER 0
++ CONFIG_LIBUAVS3D 0
++ CONFIG_LIBUAVS3D_DECODER 0
+- CONFIG_LIBWAVPACK 0
+- CONFIG_LIBWAVPACK_ENCODER 0
++ CONFIG_MSP2_DECODER 0
++ CONFIG_MSP_DEMUXER 0
++ CONFIG_SPEECHNORM_FILTER 0
++ CONFIG_SPEEDHQ_ENCODER 0
++ HAVE_INTRINSICS_NEON 0
+- HAVE_INTRINSICS_NEON 1
++ HAVE_MM_EMPTY 0
+- HAVE_MM_EMPTY 1
++ HAVE_VALGRIND_VALGRIND_H 0 ;  HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440
+- HAVE_VALGRIND_VALGRIND_H 0 ;  HAVE_VALGRIND_VALGRIND_H 1 -- forced to 0. See https://crbug.com/590440
diff --git a/chromium/scripts/build_ffmpeg.py b/chromium/scripts/build_ffmpeg.py
index fcdba5a..b51f479 100755
--- a/chromium/scripts/build_ffmpeg.py
+++ b/chromium/scripts/build_ffmpeg.py
@@ -6,7 +6,6 @@
 
 from __future__ import print_function
 
-import atexit
 import collections
 import functools
 import glob
@@ -14,12 +13,10 @@
 import os
 import platform
 import re
-import shlex
 import shutil
 import signal
 import subprocess
 import sys
-import tempfile
 
 SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__))
 FFMPEG_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', '..'))
@@ -168,99 +165,58 @@
     f.write(contents)
 
 
-# Class for determining the 32-bit and 64-bit Android API levels that Chromium
-# uses. Since @functools.cache is not available for easy memoization of the
-# determination result, we use a lazy singleton instance constructed by calling
-# Get().
-class AndroidApiLevels:
-  __instance = None
+# Extracts the Android api level from the Android config.gni.
+# Returns (api level, api 64 level).
+def GetAndroidApiLevel():
+  android_config_gni = os.path.join(CHROMIUM_ROOT_DIR, 'build', 'config',
+                                    'android', 'config.gni')
+  with open(android_config_gni, 'r') as f:
+    gni_contents = f.read()
+    api64_match = re.search('android64_ndk_api_level\s*=\s*(\d{2})',
+                            gni_contents)
+    api_match = re.search('android32_ndk_api_level\s*=\s*(\d{2})', gni_contents)
+    if not api_match or not api64_match:
+      raise Exception('Failed to find the android api level or toolchain '
+                      'version in ' + android_config_gni)
 
-  # Extracts the Android API levels from the Chromium Android GN config.
-  # Before Q1 2021, these were grep'able from build/config/android/config.gni.
-  # With conditional logic introduced in that gni file, we seek to avoid fragility
-  # going forwards, at the cost of creating a full temporary GN Chromium Android
-  # build configuration just to extract the API levels here. Caches the results
-  # in api32 and api64 instance variables.
-  def Setup(self):
-    print('Creating a temporary GN config to retrieve Android API levels:')
-
-    # Make a temporary GN build output folder
-    # No tempfile.TemporaryDirectory until python 3.2, so instead:
-    tmp_dir = tempfile.mkdtemp(prefix = 'android_build_ffmpeg_for_api_level_config')
-    print('Created temporary directory ' + tmp_dir)
-
-    # Populate that GN build output folder with generated config for Android as
-    # target OS.
-    with open(os.path.join(tmp_dir, 'args.gn'), 'w') as args_gn_file:
-      args_gn_file.write('target_os = "android"\n')
-      print('Created ' + os.path.realpath(args_gn_file.name))
-
-    # Ask GN to generate build files.
-    PrintAndCheckCall(['gn', 'gen', tmp_dir], cwd=CHROMIUM_ROOT_DIR)
-
-    # Query the API levels in the generated build config.
-    print('Retrieving config vars')
-    config_output = subprocess.check_output([
-        'gn', 'args', tmp_dir, '--short', '--list'], cwd=CHROMIUM_ROOT_DIR)
-
-    # Remove the temporary GN build output folder
-    print('removing temp dir ' + tmp_dir)
-    shutil.rmtree(tmp_dir, ignore_errors=False)
-
-    api64_match = re.search(r'android64_ndk_api_level\s*=\s*(\d{2})',
-                            config_output)
-    api32_match = re.search(r'android32_ndk_api_level\s*=\s*(\d{2})',
-                            config_output)
-    if not api32_match or not api64_match:
-      raise Exception('Failed to find the android api levels')
-
-    self.api32 = api32_match.group(1)
-    self.api64 = api64_match.group(1)
-
-  def ApiLevels(self):
-    return (self.api32, self.api64)
-
-  @classmethod
-  def Get(cls):
-    if cls.__instance is None:
-      cls.__instance = AndroidApiLevels()
-      cls.__instance.Setup()
-    return cls.__instance.ApiLevels()
+    return (api_match.group(1), api64_match.group(1))
 
 
-# Sets up cross-compilation (specific to host being linux-x64_64) for compiling
-# Android.
+# Sets up cross-compilation (regardless of host arch) for compiling Android.
 # Returns the necessary configure flags as a list.
-# See also https://developer.android.com/ndk/guides/other_build_systems
-# As of M90, //third_party/android_ndk no longer includes mipsel or mips64el
-# toolchains; they were not previously supported by default by this script, and
-# currently are unsupported due to lack of toolchain in checkout.
 def SetupAndroidToolchain(target_arch):
-  api_level, api64_level = AndroidApiLevels.Get()
-  print('Determined Android API levels: 32bit=' + api_level +
-        ', 64bit=' + api64_level)
+  api_level, api64_level = GetAndroidApiLevel()
 
   # Toolchain prefix misery, for when just one pattern is not enough :/
   toolchain_level = api_level
+  sysroot_arch = target_arch
+  toolchain_dir_prefix = target_arch
   toolchain_bin_prefix = target_arch
-
   if target_arch == 'arm-neon' or target_arch == 'arm':
-    toolchain_bin_prefix = 'arm-linux-androideabi'
+    toolchain_bin_prefix = toolchain_dir_prefix = 'arm-linux-androideabi'
+    sysroot_arch = 'arm'
   elif target_arch == 'arm64':
     toolchain_level = api64_level
-    toolchain_bin_prefix =  'aarch64-linux-android'
+    toolchain_bin_prefix = toolchain_dir_prefix = 'aarch64-linux-android'
   elif target_arch == 'ia32':
+    toolchain_dir_prefix = sysroot_arch = 'x86'
     toolchain_bin_prefix = 'i686-linux-android'
   elif target_arch == 'x64':
     toolchain_level = api64_level
+    toolchain_dir_prefix = sysroot_arch = 'x86_64'
     toolchain_bin_prefix = 'x86_64-linux-android'
-  elif target_arch == 'mipsel':  # Unsupported beginning in M90
-    toolchain_bin_prefix = 'mipsel-linux-android'
-  elif target_arch == 'mips64el': # Unsupported beginning in M90
+  elif target_arch == 'mipsel':
+    sysroot_arch = 'mips'
+    toolchain_bin_prefix = toolchain_dir_prefix = 'mipsel-linux-android'
+  elif target_arch == 'mips64el':
     toolchain_level = api64_level
-    toolchain_bin_prefix = 'mips64el-linux-android'
+    sysroot_arch = 'mips64'
+    toolchain_bin_prefix = toolchain_dir_prefix = 'mips64el-linux-android'
 
-  clang_toolchain_dir = NDK_ROOT_DIR + '/toolchains/llvm/prebuilt/linux-x86_64/'
+  sysroot = (
+      NDK_ROOT_DIR + '/platforms/android-' + toolchain_level + '/arch-' +
+      sysroot_arch)
+  gcc_toolchain = NDK_ROOT_DIR + '/toolchains/llvm/prebuilt/linux-x86_64/'
 
   # Big old nasty hack here, beware! The new android ndk has some foolery with
   # libgcc.a -- clang still uses gcc for its linker when cross compiling.
@@ -281,20 +237,19 @@
     fakedir=fakedir))
 
   return [
-      '--enable-pic',
-      '--cc=' + clang_toolchain_dir + 'bin/clang',
-      '--cxx=' + clang_toolchain_dir + 'bin/clang++',
-      '--ld=' + clang_toolchain_dir + 'bin/clang',
       '--enable-cross-compile',
-      '--sysroot=' + clang_toolchain_dir + 'sysroot',
-      '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include',
-      '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include/' +
+      '--sysroot=' + sysroot,
+
+      # Android sysroot includes are now split out; try to cobble together the
+      # correct tree.
+      '--extra-cflags=-I' + gcc_toolchain + 'sysroot/usr/include',
+      '--extra-cflags=-I' + gcc_toolchain + 'sysroot/usr/include/' +
       toolchain_bin_prefix,
-      '--extra-cflags=--target=' + toolchain_bin_prefix + toolchain_level,
-      '--extra-ldflags=--target=' + toolchain_bin_prefix + toolchain_level,
+      '--extra-cflags=--target=' + toolchain_bin_prefix,
+      '--extra-ldflags=--target=' + toolchain_bin_prefix,
       '--extra-ldflags=-L{}'.format(fakedir),
-      '--extra-ldflags=-L' + clang_toolchain_dir + toolchain_bin_prefix,
-      '--extra-ldflags=--gcc-toolchain=' + clang_toolchain_dir,
+      '--extra-ldflags=-L' + gcc_toolchain + toolchain_bin_prefix + '/',
+      '--extra-ldflags=--gcc-toolchain=' + gcc_toolchain,
       '--target-os=android',
   ]
 
@@ -329,14 +284,15 @@
         '--as=clang-cl',
         # FFMPEG is not yet enlightened for ARM64 Windows.
         # Imitate Android workaround.
-        '--extra-cflags=--target=arm64-windows'
+        '--extra-cflags=--target=arm64-windows',
+        '--extra-ldflags=--target=arm64-windows',
     ]
 
   # Turn this into a dictionary.
   win_dirs = gn_helpers.FromGNArgs(output)
 
-  # Use those paths with a second script which will tell us the proper lib paths
-  # to specify for ldflags.
+  # Use those paths with a second script which will tell us the proper include
+  # and lib paths to specify for cflags and ldflags respectively.
   output = subprocess.check_output([
       'python',
       os.path.join(CHROMIUM_ROOT_DIR, 'build', 'toolchain', 'win',
@@ -345,76 +301,42 @@
   ])
 
   flags = gn_helpers.FromGNArgs(output)
-
-  # Q1 2021 update to LLVM now lets us use a sysroot for cross-compilation
-  # targeting Windows, instead of specificying a variety of individual include
-  # folders which now include whitespace within paths within the SDK. Either
-  # injection of such paths into environment variable or using the new sysroot
-  # option is required, since using a /tmp symlink solution to avoid the spaces
-  # broke cross-compilation for win-arm64. For at least now, we'll use the
-  # sysroot approach, until and unless the environment variable injection
-  # approach is determined to be better or more consistent.
-  new_args += [
-      '--extra-cflags=/winsysroot' + win_dirs['vs_path'],
-  ]
-
-  # FFmpeg configure doesn't like arguments with spaces in them even if quoted
-  # or double-quoted or escape-quoted (whole argument and/or the internal
-  # spaces). To automate this for now, every path that has a space in it is
-  # replaced with a symbolic link created in the OS' temp folder to the real
-  # path.
-  def do_remove_temp_link(temp_name):
-    assert os.path.exists(temp_name)
-    assert os.path.islink(temp_name)
-    print('Removing temporary link ' + temp_name)
-    os.remove(temp_name)
-
-  def do_make_temp_link(real_target):
-    temp_file = tempfile.NamedTemporaryFile(prefix='windows_build_ffmpeg')
-    temp_name = temp_file.name
-    # Destroy |temp_file|, but reuse its name for the symbolic link which
-    # survives this helper method.
-    temp_file.close()
-    os.symlink(real_target, temp_name)
-    assert os.path.exists(temp_name)
-    assert os.path.islink(temp_name)
-    atexit.register(do_remove_temp_link, temp_name)
-    return temp_name
-
-  # Even with the /winsysroot option, the libpaths still require explicit
-  # configuration (for now at least); /winsysroot is not recognized as a valid
-  # extra-ldflags option by lld-link.
+  cwd = os.getcwd()
+  for cflag in flags['include_flags_imsvc'].split(' '):
+    # Apparently setup_toolchain prefers relative include paths, which
+    # may work for chrome, but it does not work for ffmpeg, so let's make
+    # them asbolute again.
+    cflag = cflag.strip('"')
+    if cflag.startswith("-imsvc"):
+      cflag = "-imsvc" + os.path.join(cwd, cflag[6:])
+    new_args += ['--extra-cflags=' + cflag]
 
   # TODO(dalecurtis): Why isn't the ucrt path printed?
   flags['vc_lib_ucrt_path'] = flags['vc_lib_um_path'].replace('/um/', '/ucrt/')
 
-  # The lib include paths are each in a separate key.
+  # Unlike the cflags, the lib include paths are each in a separate variable.
   for k in flags:
     # libpath_flags is like cflags. Since it is also redundant, skip it.
     if 'lib' in k and k != 'libpath_flags':
-      lib_path = flags[k]
-      if ' ' in lib_path:
-        # Use a temporary symbolic link instead of the real path if there is a
-        # space in the real path. Arguably, injection of these into environment
-        # variables may be better, especially if /winsysroot continues to not
-        # provide appropriate lib paths.
-        lib_path = do_make_temp_link(lib_path)
-      new_args += [ '--extra-ldflags=-libpath:' + lib_path ]
-
+      new_args += ['--extra-ldflags=-libpath:' + flags[k]]
   return new_args
 
-
 def SetupMacCrossCompileToolchain(target_arch):
   # First compute the various SDK paths.
   mac_min_ver = '10.10'
-  developer_dir =  os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files',
-          'xcode_binaries', 'Contents', 'Developer')
-  sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform',
-          'Developer', 'SDKs', 'MacOSX.sdk')
-
   if target_arch == 'x64':
+    developer_dir =  os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files',
+            'xcode_binaries', 'Contents', 'Developer')
+    sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform',
+            'Developer', 'SDKs', 'MacOSX.sdk')
     target_triple = 'x86_64-apple-macosx'
   elif target_arch == 'arm64':
+    # TODO: Once the 11.0 SDK is out of beta, it should be used for both
+    # arm64 and intel builds.
+    developer_dir =  os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files',
+            'xcode_binaries', 'Contents', 'Developer')
+    sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform',
+            'Developer', 'SDKs', 'MacOSX11.0.sdk')
     target_triple = 'arm64-apple-macosx'
   else:
     raise Exception("unknown arch " + target_arch)
@@ -459,11 +381,7 @@
       '--extra-ldflags=' + '-L' + libs_dir,
       '--extra-ldflags=-lSystem',
       '--extra-ldflags=-macosx_version_min', '--extra-ldflags=' + mac_min_ver,
-      '--extra-ldflags=-sdk_version', '--extra-ldflags=' + mac_min_ver,
-      # ld64.lld requires -platform_version <platform> <min_version>
-      # <sdk_version>
-      '--extra-ldflags=-platform_version', '--extra-ldflags=macos',
-      '--extra-ldflags=' + mac_min_ver, '--extra-ldflags=' + mac_min_ver]
+      '--extra-ldflags=-sdk_version', '--extra-ldflags=' + mac_min_ver]
 
   return new_args
 
@@ -659,7 +577,6 @@
           configure_args,
           options=options)
 
-
 def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs,
                       configure_args, options):
   if target_os == 'linux' and target_arch == 'noasm-x64':
@@ -918,7 +835,7 @@
         '--disable-inline-asm',
     ])
 
-  if 'win' not in target_os and 'android' not in target_os:
+  if 'win' not in target_os:
     configure_flags['Common'].extend([
         '--enable-pic',
         '--cc=clang',
@@ -957,7 +874,7 @@
       configure_flags['Common'].extend([
           '--arch=x86_64',
           '--extra-cflags=-m64',
-          '--extra-ldflags=-arch x86_64',
+          '--extra-ldflags=-m64',
       ])
     elif target_arch == 'arm64':
       configure_flags['Common'].extend([
diff --git a/chromium/scripts/check_merge.py b/chromium/scripts/check_merge.py
index d74c0e7..b59829d 100755
--- a/chromium/scripts/check_merge.py
+++ b/chromium/scripts/check_merge.py
@@ -61,17 +61,17 @@
   return [r for r in regexps if re.search(r, text)]
 
 def main(argv):
-  # What we're considering merging, and would like to check.  Normally, this
-  # is HEAD, but you might want to verify some previous merge.
+  # What we're considering merging, and would like to check.  Normally, this is
+  # HEAD, but you might want to verify some previous merge.
   if len(argv) > 1:
     new_commit = argv[1]
   else:
     new_commit = "HEAD"
 
-  print(f"Comparing {new_commit} to baseline {EXISTING_COMMIT}...")
+  print "Comparing %s to baseline %s..." % (new_commit, EXISTING_COMMIT)
 
   diff = subprocess.Popen(["git", "diff", "-U0", EXISTING_COMMIT, new_commit],
-          stdout=subprocess.PIPE).communicate()[0].decode(sys.stdout.encoding)
+          stdout=subprocess.PIPE).communicate()[0]
   filename=None
   skip = False
   files_encountered = 0
@@ -93,14 +93,14 @@
         if tripwire:
           failures.add("Tripwire '%s' found in %s" % (tripwire, filename))
 
-  # If we have failures, then print them and fail.
+ # If we have failures, then print them and fail.
   if failures:
     for failure in failures:
-      print(f"Failure: {failure}")
+      print "Failure: %s" % failure
     sys.exit(2)
 
-  checked = files_encountered - files_skipped
-  print(f"No problems found! Checked {checked}, skipped {files_skipped}.")
+  print ("No problems found!  Checked %d files, skipped %d." %
+      (files_encountered - files_skipped, files_skipped))
 
 if __name__ == '__main__':
   main(sys.argv)
diff --git a/chromium/scripts/credits_updater.py b/chromium/scripts/credits_updater.py
index 7082513..cf14c7f 100644
--- a/chromium/scripts/credits_updater.py
+++ b/chromium/scripts/credits_updater.py
@@ -30,6 +30,7 @@
 
 import collections
 import difflib
+from enum import enum
 import hashlib
 import os
 import re
@@ -74,8 +75,7 @@
  */"""
 
 # Known licenses
-_Licenses = ('LGPL', 'MIPS', 'JPEG', 'OGG_MA_MR_2005')
-License = collections.namedtuple('License', _Licenses)(*_Licenses)
+License = enum('LGPL', 'MIPS', 'JPEG', 'OGG_MA_MR_2005')
 
 # Tuple describing license and similarity to the FFmpeg LGPL reference for a
 # given file. See KNOWN_FILE_BUCKETS.
@@ -279,7 +279,7 @@
     # together to avoid repeating the same license text in the credits.
     if rel_file_path in self.known_file_map:
       hasher = hashlib.md5()
-      hasher.update(ConcatLines(comment_lines).encode('utf-8'))
+      hasher.update(ConcatLines(comment_lines))
 
       # Detect changes to file's licensing header.
       file_license_info = self.known_file_map[rel_file_path]
@@ -302,18 +302,18 @@
     num_known_credits = 0
     for license_bucket in self.known_credits:
       num_known_credits += len(self.known_credits[license_bucket])
-    print('CreditsUpdater stats:')
-    print(f'\t{num_known_credits} files w/ known_credits')
-    print(f'\t{len(self.generated_credits.keys())} generated_credits')
-    print(f'\t{len(self.difficult_files)} difficult_files files')
+    print 'CreditsUpdater stats:'
+    print '\t%s files w/ known_credits' % num_known_credits
+    print '\t%s generated_credits' % len(self.generated_credits.keys())
+    print '\t%s difficult_files files' % len(self.difficult_files)
 
   def WriteCredits(self):
     if self.difficult_files:
       # After taking a closer look, enhance this tool to work for these or
       # add them to the white-list if they truly have no licensing header.
-      print('Failed to find license header for these files:')
+      print 'Failed to find license header for these files:'
       for filename in self.difficult_files:
-        print(filename)
+        print filename
       exit('Update script to work for these to continue generating credits')
 
     output_path = os.path.join(self.source_dir, self.output_file)
@@ -324,7 +324,7 @@
         open_output.writelines(open_license_md.readlines())
 
       # Next write verbatim headers from the generated credits map.
-      for filename, file_license in sorted(self.generated_credits.items(),
+      for filename, file_license in sorted(self.generated_credits.iteritems(),
                                            key=lambda x: x[0]):
         open_output.writelines(LICENSE_SEPARATOR)
         open_output.writelines('%s\n\n%s' % (filename, file_license))
@@ -400,7 +400,7 @@
       comment_start_re = C_COMMENT_BLOCK_START
       comment_end_re = C_COMMENT_BLOCK_END
 
-    for _ in range(0, 100):
+    for _ in xrange(0, 100):
       line = open_file.readline()
       found_comment_start = (
           found_comment_start or comment_start_re.search(line))
@@ -421,7 +421,7 @@
 
 def StripCommentChars(comment_lines, is_asm=False):
   if is_asm:
-    for i in range(len(comment_lines)):
+    for i in xrange(len(comment_lines)):
       comment_lines[i] = re.sub(ASM_COMMENT_PRE, '', comment_lines[i])
   else:
     # Strip off the start slash-star
@@ -429,5 +429,5 @@
     # Strip off the comment end star-slash
     comment_lines[-1] = re.sub(C_COMMENT_BLOCK_END, '', comment_lines[-1])
     # Strip off the comment star for middle lines
-    for i in range(1, len(comment_lines)):
+    for i in xrange(1, len(comment_lines)):
       comment_lines[i] = re.sub(C_COMMENT_BLOCK_MID, '', comment_lines[i])
diff --git a/chromium/scripts/credits_updater_unittest.py b/chromium/scripts/credits_updater_unittest.py
index 6e99926..458a2c0 100755
--- a/chromium/scripts/credits_updater_unittest.py
+++ b/chromium/scripts/credits_updater_unittest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/python
 #
 # Copyright 2015 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
@@ -8,6 +8,7 @@
 import copy
 import credits_updater as cu
 import os
+import string
 import unittest
 
 # Assumes this script is in ffmpeg/chromium/scripts/
@@ -134,7 +135,7 @@
     credits = ''.join(ReadCreditsLines())
     current_offset = 0
     for f in sorted(files):
-      i = credits.find(f, current_offset)
+      i = string.find(credits, f, current_offset)
       if i == -1:
         self.fail("Failed to find %s starting at offset %s of content:\n%s" %
                   (f, current_offset, credits))
diff --git a/chromium/scripts/enum.py b/chromium/scripts/enum.py
new file mode 100644
index 0000000..a30d2b8
--- /dev/null
+++ b/chromium/scripts/enum.py
@@ -0,0 +1,7 @@
+import collections
+
+
+# Python has enums now, but Goobuntu machines seem to run very old python. From:
+# http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python
+def enum(*keys):
+  return collections.namedtuple('Enum', keys)(*keys)
diff --git a/chromium/scripts/find_patches.py b/chromium/scripts/find_patches.py
index c3fdf77..f579fcd 100755
--- a/chromium/scripts/find_patches.py
+++ b/chromium/scripts/find_patches.py
@@ -18,21 +18,32 @@
 find_patches.py origin/merge-m68 > patches.68
 """
 
+from __future__ import print_function
 import collections
 import os
 import re
 import sys
 import subprocess
 
-from robo_lib import shell
-
 # What directory will we look for patches in?
 # TODO(liberato): Should we find the root of the ffmpeg tree?
 PATH = "."
 
 
-def log(msg):
-  print(f"[{msg}]", file=sys.stderr)
+def log(str):
+  print("[%s]" % str, file=sys.stderr)
+
+
+def run(command):
+  """ Runs a command and returns stdout.
+
+  Args:
+    command: Array of argv[] entries. E.g., ["path_to_executable", "arg1", ...].
+
+  Returns:
+    stdout as a a string.
+  """
+  return subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
 
 
 class PatchInfo:
@@ -106,8 +117,8 @@
   """Write the patches file for |origin_branch| to |output_file|."""
   # Get the latest upstream commit that's reachable from the origin branch.
   # We'll use that to compare against.
-  upstream = shell.output_or_error(
-    ["git", "merge-base", "upstream/master", origin_branch])
+  upstream = run(["git", "merge-base", "upstream/master",
+                  origin_branch]).strip()
   if not upstream:
     raise Exception("Could not find upstream commit")
 
@@ -122,9 +133,10 @@
   # Find diffs between the versions, excluding all files that are only on
   # origin.  We explicitly exclude .gitignore, since it exists in both places.
   # Ask for no context, since we ignore it anyway.
-  diff = shell.output_or_error(
-    ["git", "diff", "--diff-filter=a", "-U0", revision_range, PATH,
-     ":!.gitignore"])
+  diff = run([
+      "git", "diff", "--diff-filter=a", "-U0", revision_range, PATH,
+      ":!.gitignore"
+  ])
 
   # Set of chromium patch sha1s we've seen.
   sha1s = set()
@@ -171,7 +183,7 @@
         # One-line change
         blame_range = "%s,+1" % added_linespec
 
-      blame = shell.output_or_error([
+      blame = run([
           "git", "blame", "-l",
           "-L %s" % blame_range, revision_range, "--", filename
       ])
@@ -201,16 +213,12 @@
       if len(deleted_line) < 4:
         continue
 
-      # git log freaks out if you search for a line starting with #, remove it.
-      while deleted_line.startswith('#'):
-        deleted_line = deleted_line[1:]
-
       log("Checking for deleted lines in %s" % filename)
       # Specify "--first-parent" so that we find commits on (presumably) origin.
-      sha1 = shell.output_or_error([
+      sha1 = run([
           "git", "log", "-1", revision_range, "--format=%H", "-S", deleted_line,
           origin_branch, "--", filename
-      ])
+      ]).strip()
 
       # Add the sha1 to the sets
       sha1s.add(sha1)
@@ -221,7 +229,7 @@
   log("Looking up sha1 dates to sort them")
   sha1_to_date = {}
   for sha1 in sha1s:
-    date = shell.output_or_error(["git", "log", "-1", "--format=%at", "%s" % sha1])
+    date = run(["git", "log", "-1", "--format=%at", "%s" % sha1]).strip()
     sha1_to_date[sha1] = date
 
   # Print the patches file.
@@ -238,12 +246,11 @@
       file=output_file)
   print("\n", file=output_file)
   wd = os.getcwd()
-  for sha1, date in sorted(sha1_to_date.items(), key=lambda kv: kv[1]):
+  for sha1, date in sorted(sha1_to_date.iteritems(), key=lambda (k, v): v):
     print(
         "------------------------------------------------------------------",
         file=output_file)
-    loglines = shell.output_or_error(["git", "log", "-1", "%s" % sha1])
-    for line in loglines.splitlines():
+    for line in run(["git", "log", "-1", "%s" % sha1]).splitlines():
       print(line.rstrip(), file=output_file)
     print("\nAffects:", file=output_file)
     # TODO(liberato): maybe add the lines that were affected.
diff --git a/chromium/scripts/generate_gn.py b/chromium/scripts/generate_gn.py
index 6814adf..d165254 100755
--- a/chromium/scripts/generate_gn.py
+++ b/chromium/scripts/generate_gn.py
@@ -25,6 +25,7 @@
 import collections
 import copy
 import datetime
+from enum import enum
 import fnmatch
 import credits_updater
 import itertools
@@ -32,6 +33,7 @@
 import os
 import re
 import shutil
+import string
 import subprocess
 import sys
 
@@ -72,8 +74,7 @@
 """
 
 # Controls conditional stanza generation.
-_Attrs = ('ARCHITECTURE', 'TARGET', 'PLATFORM')
-Attr = collections.namedtuple('Attr', _Attrs)(*_Attrs)
+Attr = enum('ARCHITECTURE', 'TARGET', 'PLATFORM')
 SUPPORT_MATRIX = {
     Attr.ARCHITECTURE:
         set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el']),
@@ -86,7 +87,7 @@
 
 def NormalizeFilename(name):
   """Removes leading path separators in an attempt to normalize paths."""
-  return name.lstrip(os.sep)
+  return string.lstrip(name, os.sep)
 
 
 def CleanObjectFiles(object_files):
@@ -735,7 +736,7 @@
 
     if not include_match:
       if EXOTIC_INCLUDE_REGEX.search(line):
-        print(f'WARNING: Investigate whacky include line: {line}')
+        print 'WARNING: Investigate whacky include line:', line
       continue
 
     include_file_path = include_match.group(1)
@@ -761,8 +762,8 @@
     # At this point we've found the file. Check if its in our ignore list which
     # means that the list should be updated to no longer mention this file.
     if include_file_path in IGNORED_INCLUDE_FILES:
-      print(f'Found {include_file_path} in IGNORED_INCLUDE_FILES. '
-             'Consider updating the list to remove this file.')
+      print('Found %s in IGNORED_INCLUDE_FILES. Consider updating the list '
+            'to remove this file.' % str(include_file_path))
 
     GetIncludedSources(resolved_include_path, source_dir, include_set)
 
@@ -783,7 +784,6 @@
       stdout=subprocess.PIPE,
       stderr=subprocess.PIPE)
   stdout, _ = check_process.communicate()
-  stdout = stdout.decode(sys.stdout.encoding)
 
   # Get the filename and license out of the stdout. stdout is expected to be
   # "/abspath/to/file: *No copyright* SOME LICENSE".
@@ -795,17 +795,17 @@
     if (licensename in ALLOWED_LICENSES or
         (licensename == 'UNKNOWN' and rel_file_path in LICENSE_EXCEPTIONS)):
       if print_licenses:
-        print(f'{filename}: {licensename}')
+        print filename, ':', licensename
       continue
 
-    print(f'UNEXPECTED LICENSE: {filename}: {licensename}')
+    print 'UNEXPECTED LICENSE: %s: %s' % (filename, licensename)
     return False
 
   return True
 
 
 def CheckLicensesForStaticLinking(sources_to_check, source_dir, print_licenses):
-  print('Checking licenses...')
+  print 'Checking licenses...'
   return CheckLicensesForSources(sources_to_check, source_dir, print_licenses)
 
 
@@ -867,8 +867,8 @@
 
     for rename in renames:
       if log_renames:
-        print(
-          f'Fixing basename collision: {rename.old_path} -> {rename.new_path}')
+        print 'Fixing basename collision: %s -> %s' % (rename.old_path,
+                                                       rename.new_path)
       _, old_filename = os.path.split(rename.old_path)
       _, file_extension = os.path.splitext(old_filename)
       include_prefix = '%' if (file_extension == '.asm') else '#'
@@ -888,12 +888,12 @@
   for source_path in all_sources:
     if RENAME_PREFIX in source_path and source_path not in all_renames:
       old_renames_to_delete.add(source_path)
-      print(f'WARNING: {source_path} no longer collides. DELETE ME!')
+      print 'WARNING: %s no longer collides. DELETE ME!' % source_path
 
   return all_renames, old_renames_to_delete
 
 def UpdateCredits(sources_to_check, source_dir):
-  print('Updating ffmpeg credits...')
+  print 'Updating ffmpeg credits...'
   updater = credits_updater.CreditsUpdater(source_dir)
   for source_name in sources_to_check:
     updater.ProcessFile(source_name)
@@ -929,7 +929,7 @@
         build_dir = os.path.join(options.build_dir, name, target)
         if not os.path.exists(build_dir):
           continue
-        print(f'Processing build directory: {name}')
+        print 'Processing build directory: %s' % name
 
         object_files = GetObjectFiles(build_dir)
 
@@ -973,11 +973,11 @@
   if not CheckLicensesForStaticLinking(sources_to_check, source_dir,
                                        options.print_licenses):
     exit('GENERATE FAILED: invalid licenses detected.')
-  print('License checks passed.')
+  print 'License checks passed.'
   UpdateCredits(sources_to_check, source_dir)
 
   gn_file_name = os.path.join(options.source_dir, 'ffmpeg_generated.gni')
-  print(f'Writing: {gn_file_name}')
+  print 'Writing:', gn_file_name
   with open(gn_file_name, 'w') as fd:
     WriteGn(fd, sets)
 
diff --git a/chromium/scripts/generate_gn_unittest.py b/chromium/scripts/generate_gn_unittest.py
index cc7d5ec..a87f516 100755
--- a/chromium/scripts/generate_gn_unittest.py
+++ b/chromium/scripts/generate_gn_unittest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/python
 #
 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
@@ -12,6 +12,7 @@
 
 import generate_gn as gg
 from generate_gn import SourceSet, SourceListCondition
+import string
 import unittest
 from os import path
 
@@ -157,28 +158,28 @@
     a = SourceSet(
         set(['a', 'b']), set([SourceListCondition('ia32', 'Chromium', 'win')]))
     a_stanza = a.GenerateGnStanza()
-    a_stanza.index('current_cpu == "x86"')
-    a_stanza.index('is_win')
+    string.index(a_stanza, 'current_cpu == "x86"')
+    string.index(a_stanza, 'is_win')
 
     # x64 should just be x64.  Linux should appear as an OS restriction.
     b = SourceSet(
         set(['a', 'b']), set([SourceListCondition('x64', 'Chromium', 'linux')]))
     b_stanza = b.GenerateGnStanza()
-    b_stanza.index('current_cpu == "x64"')
-    b_stanza.index('use_linux_config')
+    string.index(b_stanza, 'current_cpu == "x64"')
+    string.index(b_stanza, 'use_linux_config')
 
     # arm should just be arm.
     c = SourceSet(
         set(['a', 'b']), set([SourceListCondition('arm', 'Chromium', 'linux')]))
     c_stanza = c.GenerateGnStanza()
-    c_stanza.index('current_cpu == "arm"')
+    string.index(c_stanza, 'current_cpu == "arm"')
 
     # arm-neon should be arm and flip the arm_neon switch.
     d = SourceSet(
         set(['a', 'b']),
         set([SourceListCondition('arm-neon', 'Chromium', 'linux')]))
     d_stanza = d.GenerateGnStanza()
-    d_stanza.index('current_cpu == "arm" && arm_use_neon')
+    string.index(d_stanza, 'current_cpu == "arm" && arm_use_neon')
 
     # Multiple conditions
     e = SourceSet(
@@ -188,10 +189,10 @@
             SourceListCondition('x64', 'Chromium', 'linux')
         ]))
     e_stanza = e.GenerateGnStanza()
-    e_stanza.index(('is_win && current_cpu == "arm"'
-                    ' && ffmpeg_branding == "Chrome"'))
-    e_stanza.index(('use_linux_config && current_cpu == "x64"'
-                    ' && ffmpeg_branding == "Chromium"'))
+    string.index(e_stanza, ('is_win && current_cpu == "arm"'
+                            ' && ffmpeg_branding == "Chrome"'))
+    string.index(e_stanza, ('use_linux_config && current_cpu == "x64"'
+                            ' && ffmpeg_branding == "Chromium"'))
 
   def testComplexSourceListConditions(self):
     # Create 2 sets with intersecting source 'a', but setup such that 'a'
@@ -215,7 +216,7 @@
     self.assertEqual(1, len(disjoint_sets))
 
     stanza = disjoint_sets[0].GenerateGnStanza()
-    self.assertEqual(stanza.find(bad_condition), -1)
+    self.assertEqual(string.find(stanza, bad_condition), -1)
 
   def assertEqualSourceSets(self, expected, actual):
     assert all(isinstance(a, SourceSet) for a in expected)
@@ -458,10 +459,10 @@
     a = SourceSet(
         set(['foo.c']), set([SourceListCondition('x64', 'Chromium', '*')]))
     stanza = a.GenerateGnStanza()
-    stanza.index('== "x64"')
-    stanza.index('ffmpeg_branding == "Chromium"')
+    string.index(stanza, '== "x64"')
+    string.index(stanza, 'ffmpeg_branding == "Chromium"')
     # OS is wild-card, so it should not be mentioned in the stanza.
-    self.assertEqual(-1, stanza.find('OS =='))
+    self.assertEqual(-1, string.find(stanza, 'OS =='))
 
   def testFixObjectBasenameCollisions(self):
     # Use callback to capture executed renames.
diff --git a/chromium/scripts/generate_gn_unittest_wrapper.py b/chromium/scripts/generate_gn_unittest_wrapper.py
deleted file mode 100755
index 5d5ab69..0000000
--- a/chromium/scripts/generate_gn_unittest_wrapper.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env python
-'''Wrapper script to appease the PRESUBMIT.py vpython dark spirits.'''
-
-import os
-import subprocess
-import unittest
-
-class WrapperUnittest(unittest.TestCase):
-  def testCallRealTestsWithPy3(self):
-    tests = os.path.join(os.path.dirname(__file__), 'generate_gn_unittest.py')
-    try:
-      test_out = subprocess.check_output(['python3', tests])
-    except subprocess.CalledProcessError as e:
-      self.fail('Unit tests failed, see above for expectation errors')
-    self.assertEqual(test_out, '')
-
-if __name__ == '__main__':
-  unittest.main()
\ No newline at end of file
diff --git a/chromium/scripts/robo_branch.py b/chromium/scripts/robo_branch.py
index e36e3c2..c4c5a36 100644
--- a/chromium/scripts/robo_branch.py
+++ b/chromium/scripts/robo_branch.py
@@ -15,13 +15,14 @@
 import find_patches
 import os
 import re
-from robo_lib.errors import UserInstructions
-from robo_lib import shell
+from robo_lib import UserInstructions
+from robo_lib import log
+from subprocess import check_output
 
 def IsWorkingDirectoryClean():
   """Return true if and only if the working directory is clean."""
-  return not shell.output_or_error(
-    ["git", "status", "--untracked-files=no", "--porcelain"])
+  return not check_output(["git", "status", "--untracked-files=no",
+          "--porcelain"]).strip()
 
 def RequiresCleanWorkingDirectory(fn):
   def wrapper(*args, **kwargs):
@@ -35,7 +36,7 @@
   """Create a dated branch from origin/master and check it out."""
   now = datetime.now()
   branch_name=cfg.sushi_branch_prefix() + now.strftime("%Y-%m-%d-%H-%M-%S")
-  shell.log("Creating dated branch %s" % branch_name)
+  log("Creating dated branch %s" % branch_name)
   # Fetch the latest from origin
   if cfg.Call(["git", "fetch", "origin"]):
     raise Exception("Could not fetch from origin")
@@ -51,7 +52,11 @@
   #
   # We don't want to push anything to origin yet, though, just to keep from
   # making a bunch of sushi branches.  We can do it later just as easily.
-  if cfg.Call(["git", "branch", "--no-track", branch_name, cfg.origin_merge_base()]):
+  if cfg.Call(["git",
+                             "branch",
+                             "--no-track",
+                             branch_name,
+                             cfg.origin_merge_base()]):
     raise Exception("Could not create branch")
 
   # NOTE: we could push the remote branch back to origin and start tracking it
@@ -65,38 +70,35 @@
 
   cfg.SetBranchName(branch_name)
 
-
 def CreateAndCheckoutDatedSushiBranchIfNeeded(cfg):
   """Create a dated branch from origin/master if we're not already on one."""
   if cfg.sushi_branch_name():
-    shell.log(f"Already on sushi branch {cfg.sushi_branch_name()}")
+    log("Already on sushi branch %s" % cfg.sushi_branch_name())
     return
-  CreateAndCheckoutDatedSushiBranch(cfg)
 
+  CreateAndCheckoutDatedSushiBranch(cfg)
 
 @RequiresCleanWorkingDirectory
 def MergeUpstreamToSushiBranch(cfg):
-  shell.log("Merging upstream/master to local branch")
+  log("Merging upstream/master to local branch")
   if not cfg.sushi_branch_name():
     raise Exception("Refusing to do a merge on a branch I didn't create")
   if cfg.Call(["git", "fetch", "upstream"]):
     raise Exception("Could not fetch from upstream")
   if cfg.Call(["git", "merge", "upstream/master"]):
     raise UserInstructions("Merge failed -- resolve conflicts manually.")
-  shell.log("Merge has completed successfully")
-
+  log("Merge has completed successfully")
 
 def GetMergeParentsIfAny(cfg):
   """Return the set of commit sha-1s of the merge commit, if one exists, between
   HEAD and where it joins up with origin/master.  Otherwise, return []."""
   # Get all sha1s between us and origin/master
-  sha1s = shell.output_or_error(
-    ["git", "log", "--format=%H",
-     f'{cfg.origin_merge_base()}..{cfg.branch_name()}']).split()
+  sha1s = check_output(["git", "log", "--format=%H",
+          "%s..%s" % (cfg.origin_merge_base(), cfg.branch_name())]).split()
   for sha1 in sha1s:
     # Does |sha1| have more than one parent commit?
-    parents = shell.output_or_error(
-      ["git", "show", "--no-patch", "--format=%P", sha1]).split()
+    parents = check_output(["git", "show", "--no-patch", "--format=%P",
+         sha1]).split()
     if len(parents) > 1:
       return parents
   return []
@@ -111,8 +113,8 @@
   sha1s = GetMergeParentsIfAny(cfg)
   for sha1 in sha1s:
     # 'not' is correct -- it returns zero if it is an ancestor => upstream.
-    cmd = ["git", "merge-base", "--is-ancestor", sha1, "upstream/master"]
-    if not shell.stdout_fail_ok(cmd):
+    if not cfg.Call(["git", "merge-base", "--is-ancestor", sha1,
+                     "upstream/master"]):
       return sha1
   raise Exception("No upstream merge parent found.  Is the merge committed?")
 
@@ -120,7 +122,7 @@
   """Start a merge if we've not started one before, or do nothing successfully
   if the merge is complete.  If it's half done, then get mad and exit."""
   if IsMergeCommitOnThisBranch(cfg):
-    shell.log("Merge commit already marked as complete")
+    log("Merge commit already marked as complete")
     return
   # See if a merge is in progress.  "git merge HEAD" will do nothing if it
   # succeeds, but will fail if a merge is in progress.
@@ -134,13 +136,13 @@
   """Verify that the merge config looks good."""
   # If we haven't built all configs, then we might not be checking everything.
   # The check might look at config for each platform, etc.
-  shell.log("Checking merge for common failures")
+  log("Checking merge for common failures")
   cfg.chdir_to_ffmpeg_home();
   check_merge.main([])
 
 def WritePatchesReadme(cfg):
   """Write the chromium patches file."""
-  shell.log("Generating CHROMIUM.patches file")
+  log("Generating CHROMIUM.patches file")
   cfg.chdir_to_ffmpeg_home();
   with open(os.path.join("chromium", "patches", "README"), "w+") as f:
     find_patches.write_patches_file("HEAD", f)
@@ -157,10 +159,10 @@
 
 def AddAndCommit(cfg, commit_title):
   """Add everything, and commit locally with |commit_title|"""
-  shell.log("Creating local commit %s" % commit_title)
+  log("Creating local commit %s" % commit_title)
   cfg.chdir_to_ffmpeg_home();
   if IsWorkingDirectoryClean():
-    shell.log("No files to commit to %s" % commit_title)
+    log("No files to commit to %s" % commit_title)
     return
   # TODO: Ignore this file, for the "comment out autorename exception" thing.
   if cfg.Call(["git", "add", "-u"]):
@@ -172,8 +174,8 @@
   """Check if the local branch is tracking upstream."""
   # git branch -vv --list ffmpeg_roll
   # ffmpeg_roll 28e7fbe889 [origin/master: behind 8859] Merge branch 'merge-m57'
-  output = shell.output_or_error(
-    ["git", "branch", "-vv", "--list", cfg.sushi_branch_name()])
+  output = check_output(["git", "branch", "-vv", "--list",
+                         cfg.sushi_branch_name()])
   # Note that it might have ": behind" or other things.
   return "[origin/%s" % cfg.sushi_branch_name() in output
 
@@ -182,11 +184,11 @@
   cfg.chdir_to_ffmpeg_home();
   # If the tracking branch is unset, then assume that we haven't done this yet.
   if IsTrackingBranchSet(cfg):
-    shell.log("Already have local tracking branch")
+    log("Already have local tracking branch")
     return
-  shell.log("Pushing merge to origin without review")
+  log("Pushing merge to origin without review")
   cfg.Call(["git", "push", "origin", cfg.sushi_branch_name()])
-  shell.log("Setting tracking branch")
+  log("Setting tracking branch")
   cfg.Call(["git", "branch", "--set-upstream-to=origin/%s" %
          cfg.sushi_branch_name()])
   # Sanity check.  We don't want to start pushing other commits without review.
@@ -196,7 +198,7 @@
 def HandleAutorename(cfg):
   # We assume that there is a script written by generate_gn.py that adds /
   # removes files needed for autorenames.  Run it.
-  shell.log("Updating git for any autorename changes")
+  log("Updating git for any autorename changes")
   cfg.chdir_to_ffmpeg_home();
   if cfg.Call(["chmod", "+x", cfg.autorename_git_file()]):
     raise Exception("Unable to chmod %s" % cfg.autorename_git_file())
@@ -206,7 +208,7 @@
 def IsCommitOnThisBranch(robo_configuration, commit_title):
   """Detect if we've already committed the |commit_title| locally."""
   # Get all commit titles between us and origin/master
-  titles = shell.output_or_error(["git", "log", "--format=%s",
+  titles = check_output(["git", "log", "--format=%s",
           "origin/master..%s" % robo_configuration.branch_name()])
   return commit_title in titles
 
@@ -215,7 +217,7 @@
   if IsCommitOnThisBranch(
                           robo_configuration,
                           robo_configuration.patches_commit_title()):
-    shell.log("Skipping patches file since already committed")
+    log("Skipping patches file since already committed")
     return True
   return False
 
@@ -231,20 +233,20 @@
   if IsCommitOnThisBranch(
                           robo_configuration,
                           robo_configuration.readme_chromium_commit_title()):
-    shell.log("Skipping README.chromium file since already committed")
+    log("Skipping README.chromium file since already committed")
     return True
   return False
 
 @RequiresCleanWorkingDirectory
 def UpdateChromiumReadmeWithUpstream(robo_configuration):
   """Update the upstream info in README.chromium and commit the result."""
-  shell.log("Updating merge info in README.chromium")
+  log("Updating merge info in README.chromium")
   merge_sha1 = FindUpstreamMergeParent(robo_configuration)
   robo_configuration.chdir_to_ffmpeg_home();
   with open("README.chromium", "r+") as f:
     readme = f.read()
   last_upstream_merge = "Last Upstream Merge:"
-  merge_date = shell.output_or_error(["git", "log", "-1","--date=format:%b %d %Y",
+  merge_date = check_output(["git", "log", "-1","--date=format:%b %d %Y",
                             "--format=%cd", merge_sha1])
   readme = re.sub(r"(Last Upstream Merge:).*\n",
                   r"\1 %s, %s" % (merge_sha1, merge_date),
@@ -264,11 +266,11 @@
   """Check if the local branch is already uploaded."""
   robo_configuration.chdir_to_ffmpeg_home();
   if not HasGerritIssueNumber(robo_configuration):
-    shell.log("No Gerrit issue number exsts.")
+    log("No Gerrit issue number exsts.")
     return False
 
   if not IsWorkingDirectoryClean():
-    shell.log("Working directory is not clean -- commit changes and update CL");
+    log("Working directory is not clean -- commit changes and update CL");
     return False
 
   # Has been uploaded for review.  Might or might not have been landed yet.
@@ -279,13 +281,13 @@
   been landed."""
   robo_configuration.chdir_to_ffmpeg_home();
   if not IsUploadedForReview(robo_configuration):
-    shell.log("Is not uploaded for review")
+    log("Is not uploaded for review")
     return False
   # See if origin/sushi and local/sushi are the same.  This check by itself
   # isn't sufficient, since it would return true any time the two are in sync.
-  diff = shell.output_or_error(["git", "diff",
+  diff = check_output(["git", "diff",
                "origin/" + robo_configuration.sushi_branch_name(),
-               robo_configuration.sushi_branch_name()])
+               robo_configuration.sushi_branch_name()]).strip()
   return not diff
 
 @RequiresCleanWorkingDirectory
@@ -295,13 +297,13 @@
   if IsUploadedForReview(robo_configuration):
     raise Exception(
             "Sushi branch is already uploaded for review!  (try git cl web)")
-  shell.log("Uploading sushi branch for review.")
+  log("Uploading sushi branch for review.")
   os.system("git cl upload")
 
 @RequiresCleanWorkingDirectory
 def TryFakeDepsRoll(robo_configuration):
   """Start a deps roll against the sushi branch, and -1 it."""
-  shell.log("Considering starting a fake deps roll")
+  log("Considering starting a fake deps roll")
 
   # Make sure that we've landed the sushi commits.  Note that this can happen if
   # somebody re-runs robosushi after we upload the commits to Gerrit, but before
@@ -310,7 +312,7 @@
     raise Exception("Cannot start a fake deps roll until gerrit review lands!")
 
   robo_configuration.chdir_to_ffmpeg_home();
-  sha1 = shell.output_or_error("git", "show", "-1", "--format=%P")
+  sha1 = check_output("git", "show", "-1", "--format=%P").strip()
   if not sha1:
     raise Exception("Cannot get sha1 of HEAD for fakes dep roll")
 
@@ -318,5 +320,5 @@
   # TODO: make sure that there's not a deps roll in progress, else we'll keep
   # doing this every time we're run.
   # TODO: get mad otherwise.
-  shell.output_or_error(["roll-deps.py", "third_party/ffmpeg", sha1])
+  check_output(["roll-deps.py", "third_party/ffmpeg", sha1])
   # TODO: -1 it.
diff --git a/chromium/scripts/robo_build.py b/chromium/scripts/robo_build.py
index b10a210..e93f6a4 100644
--- a/chromium/scripts/robo_build.py
+++ b/chromium/scripts/robo_build.py
@@ -7,7 +7,7 @@
 # Various functions to help build / test ffmpeg.
 
 import os
-from robo_lib import shell
+from robo_lib import log
 
 def ConfigureAndBuildFFmpeg(robo_configuration, platform, architecture):
   """Run FFmpeg's configure script, and build ffmpeg.
@@ -18,15 +18,15 @@
     architecture: (optional) arch name (e.g., "ia32").  If omitted, then we
           build all of them for |platform|.
   """
-  shell.log("Generating FFmpeg config and building for %s %s" %
+  log("Generating FFmpeg config and building for %s %s" %
           (platform, architecture))
 
-  shell.log("Starting FFmpeg build for %s %s" % (platform, architecture))
+  log("Starting FFmpeg build for %s %s" % (platform, architecture))
   robo_configuration.chdir_to_ffmpeg_home();
-  command = ["python2", "./chromium/scripts/build_ffmpeg.py", platform]
+  command = ["./chromium/scripts/build_ffmpeg.py", platform]
   if architecture:
     command.append(architecture)
-  if robo_configuration.Call(command, stdout=None, stderr=None):
+  if robo_configuration.Call(command):
       raise Exception("FFmpeg build failed for %s %s" %
               (platform, architecture))
 
@@ -39,18 +39,15 @@
     with the appropriate git commands to add / rm autorenames.
   """
   robo_configuration.chdir_to_ffmpeg_home();
-  shell.log("Copying FFmpeg configs")
+  log("Copying FFmpeg configs")
   if robo_configuration.Call(["./chromium/scripts/copy_config.sh"]):
-    raise Exception("FFmpeg copy_config.sh failed")
-  
-  # TODO... seems like there are some auto-generated files that generate_gn.py
-  # throws a nasty license check on, incorrectly. maybe they should be deleted
-  shell.log("Generating GN config for all ffmpeg versions")
+      raise Exception("FFmpeg copy_config.sh failed")
+  log("Generating GN config for all ffmpeg versions")
   generate_cmd = ["./chromium/scripts/generate_gn.py"]
   if write_git_file:
     generate_cmd += ["-i", robo_configuration.autorename_git_file()]
   if robo_configuration.Call(generate_cmd):
-    raise Exception("FFmpeg generate_gn.sh failed")
+      raise Exception("FFmpeg generate_gn.sh failed")
 
 def BuildAndImportAllFFmpegConfigs(robo_configuration):
   """Build ffmpeg for all platforms that we can, and build the gn files.
@@ -100,7 +97,7 @@
     architecture: arch to build it for (e.g., "x64").
   """
   robo_configuration.chdir_to_chrome_src()
-  if robo_configuration.Call(["ninja", "-j500", "-C",
+  if robo_configuration.Call(["ninja", "-j5000", "-C",
           robo_configuration.relative_asan_directory(), target]):
       raise Exception("Failed to build %s" % target)
 
@@ -114,15 +111,15 @@
     platform: platform to build it for, which should probably be the host's.
     architecture: arch to build it for (e.g., "x64").
   """
-  shell.log("Building and running %s" % target)
+  log("Building and running %s" % target)
   BuildChromeTargetASAN(robo_configuration, target, platform, architecture)
   # TODO: we should be smarter about running things on android, for example.
-  shell.log("Running %s" % target)
+  log("Running %s" % target)
   robo_configuration.chdir_to_chrome_src()
   if robo_configuration.Call(
           [os.path.join(robo_configuration.absolute_asan_directory(), target)]):
     raise Exception("%s didn't complete successfully" % target)
-  shell.log("%s ran successfully" % target)
+  log("%s ran successfully" % target)
 
 def RunTests(robo_configuration):
   """Build all tests and run them locally.
diff --git a/chromium/scripts/robo_lib/config.py b/chromium/scripts/robo_lib.py
similarity index 77%
rename from chromium/scripts/robo_lib/config.py
rename to chromium/scripts/robo_lib.py
index 133e4ea..df71bbc 100644
--- a/chromium/scripts/robo_lib/config.py
+++ b/chromium/scripts/robo_lib.py
@@ -1,19 +1,30 @@
-""" Contains the global configuration object.
-"""
+#!/usr/bin/python
+#
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Various utility fns for robosushi.
 
 import os
-from . import shell
-from . import packages
+from subprocess import call
+import subprocess
 
+def log(msg):
+  print "[ %s ]" % msg
+
+class UserInstructions(Exception):
+  """Handy exception subclass that just prints very verbose instructions to the
+  user.  Normal exceptions tend to lose the message in the stack trace, which we
+  probably don't care about."""
+  def __init__ (self, msg):
+    self._msg = msg
+
+  def __str__(self):
+    sep = "=" * 78
+    return "\n\n%s\n%s\n%s\n\n" % (sep, self._msg, sep)
 
 class RoboConfiguration:
-  __slots__ = ('_sushi_branch_prefix', '_gn_commit_title',
-    '_patches_commit_title', '_readme_chromium_commit_title',
-    '_origin_merge_base', '_llvm_path', '_autorename_git_file',
-    '_chrome_src', '_host_operating_system', '_host_architecture',
-    '_ffmpeg_home', '_relative_asan_directory', '_branch_name',
-    '_sushi_branch_name', '_readme_chromium_commit_title', '_nasm_path',
-    '_prompt_on_call', '_os_flavor')
   def __init__(self):
     """Ensure that our config has basic fields fill in, and passes some sanity
     checks too.
@@ -42,18 +53,22 @@
             "llvm-build", "Release+Asserts", "bin")
 
     self.EnsurePathContainsLLVM()
-    shell.log("Using chrome src: %s" % self.chrome_src())
+    log("Using chrome src: %s" % self.chrome_src())
     self.EnsureFFmpegHome()
-    shell.log("Using ffmpeg home: %s" % self.ffmpeg_home())
+    log("Using ffmpeg home: %s" % self.ffmpeg_home())
     self.EnsureASANConfig()
     self.ComputeBranchName()
-    shell.log("On branch: %s" % self.branch_name())
+    log("On branch: %s" % self.branch_name())
     if self.sushi_branch_name():
-      shell.log("On sushi branch: %s" % self.sushi_branch_name())
+      log("On sushi branch: %s" % self.sushi_branch_name())
 
     # Filename that we'll ask generate_gn.py to write git commands to.
     self._autorename_git_file = os.path.join(
-      self.ffmpeg_home(), "chromium", "scripts", ".git_commands.sh")
+                                  self.ffmpeg_home(),
+                                  "chromium",
+                                  "scripts",
+                                  ".git_commands.sh")
+
 
   def chrome_src(self):
     """Return /path/to/chromium/src"""
@@ -115,24 +130,12 @@
   def override_origin_merge_base(self, new_base):
     self._origin_merge_base = new_base
 
-  def os_flavor(self):
-    return self._os_flavor
-
   def EnsureHostInfo(self):
     """Ensure that the host architecture and platform are set."""
-    kernel, host, os, *rest = shell.output_or_error(["uname", "-a"]).split()
-    assert kernel in ("Linux", "linux")
-    assert "x86_64" in rest
+    # TODO(liberato): autodetect
     self._host_operating_system = "linux"
     self._host_architecture = "x64"
 
-    if "rodete" in os:
-      self._os_flavor = packages.OsFlavor.Debian
-    elif "arch" in os:
-      self._os_flavor = packages.OsFlavor.Arch
-    else:
-      raise Exception("Couldn't determine OS flavor (needed to install packages)")
-
   def EnsureChromeSrc(self):
     """Find the /absolute/path/to/my_chrome_dir/src"""
     wd = os.getcwd()
@@ -174,9 +177,9 @@
   def ComputeBranchName(self):
     """Get the current branch name and set it."""
     self.chdir_to_ffmpeg_home()
-    branch_name = shell.output_or_error(
-      ["git", "rev-parse", "--abbrev-ref", "HEAD"])
-    self.SetBranchName(str(branch_name))
+    branch_name = subprocess.Popen(["git", "rev-parse", "--abbrev-ref", "HEAD"],
+          stdout=subprocess.PIPE).communicate()[0].strip()
+    self.SetBranchName(branch_name)
 
   def SetBranchName(self, name):
     """Set our branch name, which may be a sushi branch or not."""
@@ -197,10 +200,11 @@
   def set_prompt_on_call(self, value):
     self._prompt_on_call = value
 
-  def Call(self, args, **kwargs):
+  def Call(self, args, shell=False):
     """Run the command specified by |args| (see subprocess.call), optionally
     prompting the user."""
     if self.prompt_on_call():
-      print(f"[{os.getcwd()}] About to run: `{' '.join(args)}` ")
-      input("Press ENTER to continue, or interrupt the script: ")
-    return shell.check_run(args, **kwargs)
\ No newline at end of file
+      print("[%s] About to run: %s " % (os.getcwd(), args))
+      raw_input("Press ENTER to continue, or interrupt the script: ")
+    return call(args, shell=shell)
+
diff --git a/chromium/scripts/robo_lib/__init__.py b/chromium/scripts/robo_lib/__init__.py
deleted file mode 100644
index 33fafd6..0000000
--- a/chromium/scripts/robo_lib/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-'''placeholder'''
\ No newline at end of file
diff --git a/chromium/scripts/robo_lib/errors.py b/chromium/scripts/robo_lib/errors.py
deleted file mode 100644
index 8f1321d..0000000
--- a/chromium/scripts/robo_lib/errors.py
+++ /dev/null
@@ -1,16 +0,0 @@
-'''Custom error types.
-'''
-
-
-class UserInstructions(Exception):
-  '''Handy exception subclass that just prints very verbose instructions to the
-  user. Normal exceptions tend to lose the message in the stack trace, which we
-  probably don't care about.
-  '''
-  __slots__ = ('_msg', )
-  def __init__ (self, msg):
-    self._msg = msg
-
-  def __str__(self):
-    sep = '=' * 78
-    return f'\n\n{sep}\n{self._msg}\n{sep}\n\n'
\ No newline at end of file
diff --git a/chromium/scripts/robo_lib/packages.py b/chromium/scripts/robo_lib/packages.py
deleted file mode 100644
index d7660f7..0000000
--- a/chromium/scripts/robo_lib/packages.py
+++ /dev/null
@@ -1,28 +0,0 @@
-'''Utilities for installing os-level packages.'''
-
-import collections
-import enum
-
-
-class Library(collections.namedtuple('Library', ['name', 'pkg_map'])):
-  def Install(self, configuration):
-    flavor = configuration.os_flavor()
-    install_cmd = ['sudo', *flavor.value, self.pkg_map[flavor]]
-    return configuration.Call(install_cmd, stderr=None, stdout=None)
-
-
-class OsFlavor(enum.Enum):
-  Debian = ('apt-get', 'install')
-  Arch = ('pacman', '-S')
-
-
-Nasm = Library('nasm', {
-  OsFlavor.Debian: 'nasm',
-  OsFlavor.Arch: 'nasm',
-})
-
-
-GccAarch64LinuxGNU = Library('gcc-aarch64-linux-gnu', {
-  OsFlavor.Debian: 'gcc-aarch64-linux-gnu',
-  OsFlavor.Arch: 'aarch64-linux-gnu-binutils',
-})
\ No newline at end of file
diff --git a/chromium/scripts/robo_lib/shell.py b/chromium/scripts/robo_lib/shell.py
deleted file mode 100644
index 2b1149a..0000000
--- a/chromium/scripts/robo_lib/shell.py
+++ /dev/null
@@ -1,61 +0,0 @@
-'''Contains helper methods for writing to and reading from
-the console that can be configured by arguments, such as
-verbose logging and dryrunning potentially dangerous commands.
-'''
-
-import collections
-import os
-import subprocess
-
-
-LOG_LEVEL = collections.namedtuple('LL', ['NORM', 'VERBOSE', 'DEBUG'])(1, 2, 3)
-SET_LOG_LEVEL = LOG_LEVEL.NORM
-
-
-EXEC_MOD = collections.namedtuple('EM', ['NORM', 'DRY'])
-SET_EXEC_MOD = EXEC_MOD.NORM
-
-
-def log(message, verbosity=LOG_LEVEL.NORM, **kwargs):
-  if verbosity >= SET_LOG_LEVEL:
-    print(f'[ {message} ]', **kwargs)
-
-
-def run(command, **kwargs):
-  if SET_EXEC_MOD == EXEC_MOD.NORM:
-    return subprocess.run(command,
-                          encoding=kwargs.get('encoding', 'utf-8'),
-                          shell=kwargs.get('shell', False),
-                          stderr=kwargs.get('stderr', subprocess.PIPE),
-                          stdout=kwargs.get('stdout', subprocess.PIPE))
-  else:
-    # Print it, not 'echo' it, since there might be some funky unescape stuff
-    print(' '.join(command))
-    return subprocess.CompletedProcess(['echo'] + command, 0)
-
-
-def output_or_error(command, error_gen=None, **kwargs):
-  ''' Run a command and return the output as a string, or raise error.
-  error_gen: a function that could either return or raise an error
-             from a given subprocess.CompletedProcess object.
-  '''
-  result = run(command, **kwargs)
-  if result.returncode:
-    if error_gen is not None:
-      raise error_gen(result)
-    raise RuntimeError(f'`{" ".join(command)}` ({result.returncode})\n\t{result.stderr}\n\t{result.stdout}')
-
-  if kwargs.get('stdout', subprocess.PIPE) == subprocess.PIPE:
-    return result.stdout.strip()
-  return ''
-
-
-def check_run(command, error_gen=None, **kwargs):
-  ''' Just like output_or_error, but returns None on success.
-  '''
-  output_or_error(command, error_gen, **kwargs)
-  return None
-
-
-def stdout_fail_ok(command, **kwargs):
-  return run(command, **kwargs).stdout.strip()
\ No newline at end of file
diff --git a/chromium/scripts/robo_setup.py b/chromium/scripts/robo_setup.py
index 30d82c0..9f802d8 100755
--- a/chromium/scripts/robo_setup.py
+++ b/chromium/scripts/robo_setup.py
@@ -8,13 +8,25 @@
 
 import io
 import os
-from robo_lib.errors import UserInstructions
+from robo_lib import UserInstructions
 import subprocess
-from robo_lib import shell
-from robo_lib import packages
+from robo_lib import log
 import shutil
 
 
+def InstallUbuntuPackage(robo_configuration, package):
+  """Install |package|.
+
+    Args:
+      robo_configuration: current RoboConfiguration.
+      package: package name.
+  """
+
+  log("Installing package %s" % package)
+  if robo_configuration.Call(["sudo", "apt-get", "install", package]):
+    raise Exception("Could not install %s" % package)
+
+
 def InstallPrereqs(robo_configuration):
   """Install prereqs needed to build ffmpeg.
 
@@ -26,7 +38,7 @@
   # Check out data for ffmpeg regression tests.
   media_directory = os.path.join("media", "test", "data", "internal")
   if not os.path.exists(media_directory):
-    shell.log("Checking out media internal test data")
+    log("Checking out media internal test data")
     if robo_configuration.Call([
         "git", "clone",
         "https://chrome-internal.googlesource.com/chrome/data/media",
@@ -36,8 +48,8 @@
                       media_directory)
 
   if robo_configuration.host_operating_system() == "linux":
-    packages.Nasm.Install(robo_configuration)
-    packages.GccAarch64LinuxGNU.Install(robo_configuration)
+    InstallUbuntuPackage(robo_configuration, "nasm")
+    InstallUbuntuPackage(robo_configuration, "gcc-aarch64-linux-gnu")
   else:
     raise Exception("I don't know how to install deps for host os %s" %
                     robo_configuration.host_operating_system())
@@ -61,7 +73,7 @@
   # re-build it when we run ninja later (after importing the ffmpeg config)
   # if it's changed.
 
-  shell.log("Creating asan build dir %s" % directory_name)
+  log("Creating asan build dir %s" % directory_name)
   os.mkdir(directory_name)
 
   # TODO(liberato): ffmpeg_branding Chrome vs ChromeOS.  also add arch
@@ -70,14 +82,14 @@
           "media_use_libvpx=true", "media_use_ffmpeg=true",
           'ffmpeg_branding="Chrome"', "use_goma=true", "is_asan=true",
           "dcheck_always_on=true")
-  print(opts)
+  print opts
   with open(os.path.join(directory_name, "args.gn"), "w") as f:
     for opt in opts:
-      print(opt)
+      print opt
       f.write("%s\n" % opt)
 
   # Ask gn to generate build files.
-  shell.log("Running gn on %s" % directory_name)
+  log("Running gn on %s" % directory_name)
   if robo_configuration.Call(
       ["gn", "gen", robo_configuration.relative_asan_directory()]):
     raise Exception(
@@ -92,9 +104,9 @@
 def EnsureGClientTargets(robo_configuration):
   """Make sure that we've got the right sdks if we're on a linux host."""
   if not robo_configuration.host_operating_system() == "linux":
-    shell.log("Not changing gclient target_os list on a non-linux host")
+    log("Not changing gclient target_os list on a non-linux host")
     return
-  shell.log("Checking gclient target_os list")
+  log("Checking gclient target_os list")
   gclient_filename = os.path.join(robo_configuration.chrome_src(), "..",
                                   ".gclient")
 
@@ -102,26 +114,26 @@
   scope = {}
   try:
     exec (FileRead(gclient_filename), scope)
-  except SyntaxError as e:
+  except SyntaxError, e:
     raise Exception("Unable to read %s" % gclient_filename)
 
   if 'target_os' not in scope:
-    shell.log("Missing 'target_os', which goes at the end of .gclient,")
-    shell.log("OUTSIDE of the solutions = [] section")
-    shell.log("Example line:")
-    shell.log("target_os = [ 'android', 'win' ]")
+    log("Missing 'target_os', which goes at the end of .gclient,")
+    log("OUTSIDE of the solutions = [] section")
+    log("Example line:")
+    log("target_os = [ 'android', 'win' ]")
     raise UserInstructions("Please add target_os to %s" % gclient_filename)
 
   if ('android' not in scope['target_os']) or ('win' not in scope['target_os']):
-    shell.log("Missing 'android' and/or 'win' in target_os, which goes at the")
-    shell.log("end of .gclient, OUTSIDE of the solutions = [] section")
-    shell.log("Example line:")
-    shell.log("target_os = [ 'android', 'win' ]")
+    log("Missing 'android' and/or 'win' in target_os, which goes at the")
+    log("end of .gclient, OUTSIDE of the solutions = [] section")
+    log("Example line:")
+    log("target_os = [ 'android', 'win' ]")
     raise UserInstructions(
         "Please add 'android' and 'win' to target_os in %s" % gclient_filename)
 
   # Sync regardless of whether we changed the config.
-  shell.log("Running gclient sync")
+  log("Running gclient sync")
   robo_configuration.chdir_to_chrome_src()
   if robo_configuration.Call(["gclient", "sync"]):
     raise Exception("gclient sync failed")
@@ -131,26 +143,35 @@
   """Download some additional binaries needed by ffmpeg.  gclient sync can
   sometimes remove these.  Re-run this if you're missing llvm-nm or llvm-ar."""
   robo_configuration.chdir_to_chrome_src()
-  shell.log("Downloading some additional compiler tools")
+  log("Downloading some additional compiler tools")
   if robo_configuration.Call(["tools/clang/scripts/update.py",
                               "--package=objdump"]):
     raise Exception("update.py --package=objdump failed")
 
 
-def FetchMacSDK(robo_configuration):
-  """Download the MacOSX SDK."""
-  shell.log("Installing Mac OSX sdk")
+def FetchMacSDKs(robo_configuration):
+  """Download the MacOSX SDKs."""
+  log("Installing Mac OSX sdk")
   robo_configuration.chdir_to_chrome_src()
   if robo_configuration.Call(
       "FORCE_MAC_TOOLCHAIN=1 build/mac_toolchain.py",
       shell=True):
-    raise Exception("Cannot download and extract Mac SDK")
+    raise Exception("Cannot download and extract Mac beta SDK")
+
+  # TODO: Once the 11.0 SDK is out of beta, it should be used for both
+  # arm64 and intel builds.
+  log("Installing Mac OSX 11.0 beta sdk for arm64")
+  robo_configuration.chdir_to_chrome_src()
+  if robo_configuration.Call(
+      "FORCE_MAC_TOOLCHAIN=1 build/mac_toolchain.py",
+      shell=True):
+    raise Exception("Cannot download and extract Mac beta SDK")
 
 
 def EnsureLLVMSymlinks(robo_configuration):
   """Create some symlinks to clang and friends, since that changes their
   behavior somewhat."""
-  shell.log("Creating symlinks to compiler tools if needed")
+  log("Creating symlinks to compiler tools if needed")
   os.chdir(
       os.path.join(robo_configuration.chrome_src(), "third_party", "llvm-build",
                    "Release+Asserts", "bin"))
@@ -173,7 +194,7 @@
   robo_configuration.chdir_to_chrome_src()
   for arch in ["arm", "arm64", "mips", "mips64el"]:
     if robo_configuration.Call(
-      ["build/linux/sysroot_scripts/install-sysroot.py", f"--arch={arch}"]):
+        ["build/linux/sysroot_scripts/install-sysroot.py", "--arch=" + arch]):
       raise Exception("Failed to install sysroot for " + arch)
 
 
@@ -188,14 +209,14 @@
   # build.  That's not good.
   llvm_nasm_path = os.path.join(robo_configuration.llvm_path(), "nasm")
   if os.path.exists(llvm_nasm_path):
-    shell.log("nasm already installed in llvm bin directory")
+    log("nasm already installed in llvm bin directory")
     return
 
   # Make sure nasm is built, and copy it to the llvm bin directory.
   chromium_nasm_path = os.path.join(
       robo_configuration.absolute_asan_directory(), "nasm")
   if not os.path.exists(chromium_nasm_path):
-    shell.log("Building Chromium's nasm")
+    log("Building Chromium's nasm")
     if robo_configuration.Call([
         "ninja", "-j5000", "-C",
         robo_configuration.relative_asan_directory(), "third_party/nasm"
@@ -206,7 +227,7 @@
       raise Exception("Failed to find nasm even after building it")
 
   # Copy it
-  shell.log("Copying Chromium's nasm to llvm bin directory")
+  log("Copying Chromium's nasm to llvm bin directory")
   if shutil.copy(chromium_nasm_path, llvm_nasm_path):
     raise Exception(
         "Could not copy %s into %s" % (chromium_nasm_path, llvm_nasm_path))
@@ -216,7 +237,7 @@
   """Make sure that we have all the toolchains for cross-compilation"""
   EnsureGClientTargets(robo_configuration)
   FetchAdditionalWindowsBinaries(robo_configuration)
-  FetchMacSDK(robo_configuration)
+  FetchMacSDKs(robo_configuration)
   EnsureLLVMSymlinks(robo_configuration)
   EnsureSysroots(robo_configuration)
 
@@ -224,11 +245,12 @@
 def EnsureUpstreamRemote(robo_configuration):
   """Make sure that the upstream remote is defined."""
   robo_configuration.chdir_to_ffmpeg_home()
-  remotes = shell.output_or_error(["git", "remote", "-v"]).split()
+  remotes = subprocess.check_output(["git", "remote", "-v"]).split()
   if "upstream" in remotes:
-    shell.log("Upstream remote found")
+    log("Upstream remote found")
     return
-  shell.log("Adding upstream remote")
+  log("Adding upstream remote")
   if robo_configuration.Call([
-      "git", "remote", "add", "upstream", "git://source.ffmpeg.org/ffmpeg.git"]):
+      "git", "remote", "add", "upstream", "git://source.ffmpeg.org/ffmpeg.git"
+  ]):
     raise Exception("Failed to add git remote")
diff --git a/chromium/scripts/robosushi.py b/chromium/scripts/robosushi.py
index c86b73f..7d7e568 100755
--- a/chromium/scripts/robosushi.py
+++ b/chromium/scripts/robosushi.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/python
 #
 # Copyright 2018 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
@@ -22,9 +22,9 @@
 from subprocess import check_output
 
 import robo_branch
-from robo_lib import shell
-from robo_lib import errors
-from robo_lib import config
+from robo_lib import log
+from robo_lib import UserInstructions
+import robo_lib
 import robo_build
 import robo_setup
 
@@ -55,7 +55,6 @@
   robo_branch.AddAndCommit(robo_configuration,
                            robo_configuration.gn_commit_title())
 
-
 # Array of steps that this script knows how to perform.  Each step is a
 # dictionary that has the following keys:
 # desc:   (required) user-friendly description of this step.
@@ -124,7 +123,7 @@
   # Some things you probably don't need unless you're debugging.
   "download_mac_sdk":
       { "desc": "Try to download the mac SDK, if needed.",
-        "do_fn": robo_setup.FetchMacSDK },
+        "do_fn": robo_setup.FetchMacSDKs },
 
   # Roll-up for --auto-merge
   "auto-merge":
@@ -141,34 +140,31 @@
                                             ]) },
 }
 
-
 def RunSteps(cfg, step_names):
   for step_name in step_names:
     if not step_name in steps:
       raise Exception("Unknown step %s" % step_name)
-    shell.log("Step %s" % step_name)
+    log("Step %s" % step_name)
     step = steps[step_name]
     try:
       if "pre_fn" in step:
         raise Exception("pre_fn not supported yet")
       if "skip_fn" in step:
         if step["skip_fn"](cfg):
-          shell.log("Step %s not needed, skipping" % step_name)
+          log("Step %s not needed, skipping" % step_name)
           continue
       step["do_fn"](cfg)
-    except Exception as e:
-      shell.log("Step %s failed" % step_name)
+    except Exception, e:
+      log("Step %s failed" % step_name)
       raise e
 
-
 def ListSteps():
   for name, step in steps.iteritems():
     if "desc" in step:
-      print(f"{name}: {step['desc']}\n")
-
+      print "%s: %s\n" % (name, step["desc"])
 
 def main(argv):
-  robo_configuration = config.RoboConfiguration()
+  robo_configuration = robo_lib.RoboConfiguration()
   robo_configuration.chdir_to_ffmpeg_home();
 
   # TODO(liberato): Add a way to skip |skip_fn|.
@@ -185,13 +181,11 @@
            "dev-merge",
           ])
 
-  exec_steps = []
-
   for opt, arg in parsed:
     if opt == "--prompt":
       robo_configuration.set_prompt_on_call(True)
     elif opt == "--setup":
-      exec_steps = ["setup"]
+      RunSteps(robo_configuration, ["setup"])
     elif opt == "--test":
       robo_build.BuildAndImportFFmpegConfigForHost(robo_configuration)
       robo_build.RunTests(robo_configuration)
@@ -201,40 +195,39 @@
     elif opt == "--patches":
       # To be run after committing a local change to fix the tests.
       if not robo_branch.IsWorkingDirectoryClean():
-        raise errors.UserInstructions(
+        raise UserInstructions(
                     "Working directory must be clean to generate patches file")
       robo_branch.UpdatePatchesFileUnconditionally(robo_configuration)
     elif opt == "--auto-merge":
-      exec_steps = ["auto-merge"]
+      # TODO: make sure that any untracked autorename files are removed, or
+      # make sure that the autorename git script doesn't try to 'git rm'
+      # untracked files, else the script fails.
+      RunSteps(robo_configuration, ["auto-merge"])
+
+      # TODO: Start a fake deps roll.  To do this, we would:
+      # Create new remote branch from the current remote sushi branch.
+      # Create and check out a new local branch at the current local branch.
+      # Make the new local branch track the new remote branch.
+      # Push to origin/new remote branch.
+      # Start a fake deps roll CL that runs the *san bots.
+      # Switch back to original local branch.
+      # For extra points, include a pointer to the fake deps roll CL in the
+      # local branch, so that when it's pushed for review, it'll point the
+      # reviewer at it.
+
+      # TODO: git cl upload for review.
     elif opt == "--step":
-      exec_steps = arg.split(",")
+      RunSteps(robo_configuration, arg.split(","))
     elif opt == "--list":
       ListSteps()
     elif opt == "--dev-merge":
       # Use HEAD rather than origin/master, so that local robosushi changes
       # are part of the merge.  Only useful for testing those changes.
-      new_merge_base = shell.output_or_error(["git", "log", "--format=%H", "-1"])
-      shell.log(f"Using {new_merge_base} as new origin merge base for testing")
+      new_merge_base = check_output(["git", "log", "--format=%H", "-1"]).strip()
+      log("Using %s as new origin merge base for testing" % new_merge_base)
       robo_configuration.override_origin_merge_base(new_merge_base)
     else:
       raise Exception("Unknown option '%s'" % opt);
 
-    # TODO: make sure that any untracked autorename files are removed, or
-    # make sure that the autorename git script doesn't try to 'git rm'
-    # untracked files, else the script fails.
-    RunSteps(robo_configuration, exec_steps)
-    # TODO: Start a fake deps roll.  To do this, we would:
-    # Create new remote branch from the current remote sushi branch.
-    # Create and check out a new local branch at the current local branch.
-    # Make the new local branch track the new remote branch.
-    # Push to origin/new remote branch.
-    # Start a fake deps roll CL that runs the *san bots.
-    # Switch back to original local branch.
-    # For extra points, include a pointer to the fake deps roll CL in the
-    # local branch, so that when it's pushed for review, it'll point the
-    # reviewer at it.
-    # TODO: git cl upload for review.
-
-
 if __name__ == "__main__":
   main(sys.argv[1:])
diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h
index c5450b2..590c2d1 100644
--- a/compat/cuda/cuda_runtime.h
+++ b/compat/cuda/cuda_runtime.h
@@ -1,7 +1,7 @@
 /*
  * Minimum CUDA compatibility definitions header
  *
- * Copyright (c) 2019 rcombs
+ * Copyright (c) 2019 Rodger Combs
  *
  * This file is part of FFmpeg.
  *
@@ -73,7 +73,7 @@
 
 typedef struct __device_builtin__ __align__(8) ushort4
 {
-    unsigned short x, y, z, w;
+    unsigned char x, y, z, w;
 } ushort4;
 
 typedef struct __device_builtin__ __align__(16) int4
diff --git a/configure b/configure
index eeb2b0a..0d94922 100755
--- a/configure
+++ b/configure
@@ -2125,7 +2125,6 @@
     ES2_gl_h
     gsm_h
     io_h
-    linux_dma_buf_h
     linux_perf_event_h
     machine_ioctl_bt848_h
     machine_ioctl_meteor_h
@@ -2652,7 +2651,7 @@
 
 # decoders / encoders
 aac_decoder_select="adts_header mdct15 mdct sinewin"
-aac_fixed_decoder_select="adts_header mdct"
+aac_fixed_decoder_select="adts_header mdct sinewin"
 aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin"
 aac_latm_decoder_select="aac_decoder aac_latm_parser"
 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
@@ -2688,6 +2687,7 @@
 atrac3pal_decoder_select="mdct sinewin"
 atrac9_decoder_select="mdct"
 av1_decoder_select="cbs_av1"
+avrn_decoder_select="exif jpegtables"
 bink_decoder_select="blockdsp hpeldsp"
 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
@@ -2715,7 +2715,6 @@
 eatgq_decoder_select="aandcttables"
 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
 exr_decoder_deps="zlib"
-exr_encoder_deps="zlib"
 ffv1_decoder_select="rangecoder"
 ffv1_encoder_select="rangecoder"
 ffvhuff_decoder_select="huffyuv_decoder"
@@ -2761,7 +2760,7 @@
 jpegls_decoder_select="mjpeg_decoder"
 jv_decoder_select="blockdsp"
 lagarith_decoder_select="llviddsp"
-ljpeg_encoder_select="idctdsp jpegtables"
+ljpeg_encoder_select="idctdsp jpegtables mpegvideoenc"
 lscr_decoder_deps="zlib"
 magicyuv_decoder_select="llviddsp"
 magicyuv_encoder_select="llvidencdsp"
@@ -2847,7 +2846,6 @@
 sonic_ls_encoder_select="golomb rangecoder"
 sp5x_decoder_select="mjpeg_decoder"
 speedhq_decoder_select="mpegvideo"
-speedhq_encoder_select="mpegvideoenc"
 srgc_decoder_deps="zlib"
 svq1_decoder_select="hpeldsp"
 svq1_encoder_select="hpeldsp me_cmp mpegvideoenc"
@@ -3306,9 +3304,9 @@
 asf_muxer_select="riffenc"
 asf_stream_muxer_select="asf_muxer"
 av1_demuxer_select="av1_frame_merge_bsf av1_parser"
-avi_demuxer_select="riffdec exif"
+avi_demuxer_select="iso_media riffdec exif"
 avi_muxer_select="riffenc"
-caf_demuxer_select="iso_media"
+caf_demuxer_select="iso_media riffdec"
 caf_muxer_select="iso_media"
 dash_muxer_select="mp4_muxer"
 dash_demuxer_deps="libxml2"
@@ -3334,9 +3332,9 @@
 ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
 latm_muxer_select="aac_adtstoasc_bsf"
 matroska_audio_muxer_select="matroska_muxer"
-matroska_demuxer_select="riffdec"
+matroska_demuxer_select="iso_media riffdec"
 matroska_demuxer_suggest="bzlib lzo zlib"
-matroska_muxer_select="riffenc vp9_superframe_bsf aac_adtstoasc_bsf"
+matroska_muxer_select="iso_media riffenc vp9_superframe_bsf aac_adtstoasc_bsf"
 mlp_demuxer_select="mlp_parser"
 mmf_muxer_select="riffenc"
 mov_demuxer_select="iso_media riffdec"
@@ -3382,7 +3380,7 @@
 wav_demuxer_select="riffdec"
 wav_muxer_select="riffenc"
 webm_chunk_muxer_select="webm_muxer"
-webm_muxer_select="riffenc"
+webm_muxer_select="iso_media riffenc"
 webm_dash_manifest_demuxer_select="matroska_demuxer"
 wtv_demuxer_select="mpegts_demuxer riffdec"
 wtv_muxer_select="mpegts_muxer riffenc"
@@ -4268,7 +4266,7 @@
         ld_default="$source_path/compat/windows/mslink"
         nm_default="dumpbin.exe -symbols"
         ar_default="lib.exe"
-        case "${arch:-$arch_default}" in
+        case "$arch" in
         aarch64|arm64)
             as_default="armasm64.exe"
             ;;
@@ -5390,12 +5388,7 @@
         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(INSTALL_NAME_DIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
         strip="${strip} -x"
-
-        # TODO(wolenetz): ld64.lld no longer recognizes the following flags and
-        # produces error causing configure to misdetect things like whether
-        # stdlib defines getenv.
-        # add_ldflags -Wl,-dynamic,-search_paths_first
-
+        add_ldflags -Wl,-dynamic,-search_paths_first
         check_cflags -Werror=partial-availability
         SLIBSUF=".dylib"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
@@ -6163,9 +6156,6 @@
 check_headers dxva.h
 check_headers dxva2api.h -D_WIN32_WINNT=0x0600
 check_headers io.h
-enabled libdrm &&
-    check_headers linux/dma-buf.h
-
 check_headers linux/perf_event.h
 check_headers libcrystalhd/libcrystalhd_if.h
 check_headers malloc.h
@@ -6252,7 +6242,7 @@
 if enabled cuda_nvcc; then
     nvccflags="$nvccflags -ptx"
 else
-    nvccflags="$nvccflags -S -nocudalib -nocudainc --cuda-device-only -Wno-c++11-narrowing -include ${source_link}/compat/cuda/cuda_runtime.h"
+    nvccflags="$nvccflags -S -nocudalib -nocudainc --cuda-device-only -include ${source_link}/compat/cuda/cuda_runtime.h"
     check_nvcc cuda_llvm
 fi
 
@@ -6419,7 +6409,7 @@
 # }
 enabled libpulse          && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new
 enabled librabbitmq       && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection
-enabled librav1e          && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new
+enabled librav1e          && require_pkg_config librav1e "rav1e >= 0.1.0" rav1e.h rav1e_context_new
 enabled librsvg           && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp           && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket
 enabled librubberband     && require_pkg_config librubberband "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append librubberband_extralibs "-lstdc++"
@@ -7586,11 +7576,10 @@
 #define FFMPEG_CONFIG_H
 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
 #define FFMPEG_LICENSE "$(c_escape $license)"
-#define CONFIG_THIS_YEAR 2021
+#define CONFIG_THIS_YEAR 2020
 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
 #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
-#define OS_NAME $target_os
 #define av_restrict $restrict_keyword
 #define EXTERN_PREFIX "${extern_prefix}"
 #define EXTERN_ASM ${extern_prefix}
diff --git a/doc/APIchanges b/doc/APIchanges
index 13350c0..3fb9e12 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,51 +15,6 @@
 
 API changes, most recent first:
 
-2021-03-10 - xxxxxxxxxx - lavf 58.72.100 - avformat.h
-  Change AVBufferRef related AVStream function and struct size
-  parameter and fields type to size_t at next major bump.
-
-2021-03-10 - xxxxxxxxxx - lavc 58.130.100 - packet.h
-  Change AVBufferRef related AVPacket function and struct size
-  parameter and fields type to size_t at next major bump.
-
-2021-03-10 - xxxxxxxxxx - lavu 56.68.100 - buffer.h frame.h
-  Change AVBufferRef and relevant AVFrame function and struct size
-  parameter and fields type to size_t at next major bump.
-
-2021-03-04 - xxxxxxxxxx - lavc 58.128.101 - avcodec.h
-  Enable err_recognition to be set for encoders.
-
-2021-03-03 - xxxxxxxxxx - lavf 58.70.100 - avformat.h
-  Deprecate AVFMT_FLAG_PRIV_OPT. It will do nothing
-  as soon as av_demuxer_open() is removed.
-
-2021-02-27 - xxxxxxxxxx - lavc 58.126.100 - avcodec.h
-  Deprecated avcodec_get_frame_class().
-
-2021-02-21 - xxxxxxxxxx - lavu 56.66.100 - tx.h
-  Add enum AVTXFlags and AVTXFlags.AV_TX_INPLACE
-
-2021-02-14 - xxxxxxxxxx - lavd 58.12.100 - avdevice.h
-  Deprecated avdevice_capabilities_create() and
-  avdevice_capabilities_free().
-
-2021-02-xx - xxxxxxxxxx - lavu 56.xx.100 - common.h
-  Add FFABS64U()
-
-2021-01-26 - xxxxxxxxxx - lavu 56.64.100 - common.h
-  Add FFABSU()
-
-2021-01-25 - xxxxxxxxxx - lavc 58.119.100 - avcodec.h
-  Deprecate AVCodecContext.debug_mv, FF_DEBUG_VIS_MV_P_FOR, FF_DEBUG_VIS_MV_B_FOR,
-  FF_DEBUG_VIS_MV_B_BACK
-
-2021-01-11 - xxxxxxxxxx - lavc 58.116.100 - avcodec.h
-  Add FF_PROFILE_VVC_MAIN_10 and FF_PROFILE_VVC_MAIN_10_444.
-
-2020-xx-xx - xxxxxxxxxx - lavu 56.63.100 - video_enc_params.h
-  Add AV_VIDEO_ENC_PARAMS_MPEG2
-
 2020-12-03 - xxxxxxxxxx - lavu 56.62.100 - timecode.h
   Add av_timecode_init_from_components.
 
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 60e7294..8a2f55c 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -675,63 +675,6 @@
 @end table
 @end table
 
-@section setts
-Set PTS and DTS in packets.
-
-It accepts the following parameters:
-@table @option
-@item ts
-@item pts
-@item dts
-Set expressions for PTS, DTS or both.
-@end table
-
-The expressions are evaluated through the eval API and can contain the following
-constants:
-
-@table @option
-@item N
-The count of the input packet. Starting from 0.
-
-@item TS
-The demux timestamp in input in case of @code{ts} or @code{dts} option or presentation
-timestamp in case of @code{pts} option.
-
-@item POS
-The original position in the file of the packet, or undefined if undefined
-for the current packet
-
-@item DTS
-The demux timestamp in input.
-
-@item PTS
-The presentation timestamp in input.
-
-@item STARTDTS
-The DTS of the first packet.
-
-@item STARTPTS
-The PTS of the first packet.
-
-@item PREV_INDTS
-The previous input DTS.
-
-@item PREV_INPTS
-The previous input PTS.
-
-@item PREV_OUTDTS
-The previous output DTS.
-
-@item PREV_OUTPTS
-The previous output PTS.
-
-@item TB
-The timebase of stream packet belongs.
-
-@item SR
-The sample rate of stream packet belongs.
-@end table
-
 @anchor{text2movsub}
 @section text2movsub
 
diff --git a/doc/codecs.texi b/doc/codecs.texi
index 9add762..1da2590 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -50,6 +50,8 @@
 Use internal 2pass ratecontrol in second pass mode.
 @item gray
 Only decode/encode grayscale.
+@item emu_edge
+Do not draw edges.
 @item psnr
 Set error[?] variables during encoding.
 @item truncated
@@ -70,6 +72,10 @@
 platforms. Its primary use is for regression testing.
 @item aic
 Apply H263 advanced intra coding / mpeg4 ac prediction.
+@item cbp
+Deprecated, use mpegvideo private options instead.
+@item qprd
+Deprecated, use mpegvideo private options instead.
 @item ilme
 Apply interlaced motion estimation.
 @item cgop
@@ -78,6 +84,40 @@
 Output even potentially corrupted frames.
 @end table
 
+@item me_method @var{integer} (@emph{encoding,video})
+Set motion estimation method.
+
+Possible values:
+@table @samp
+@item zero
+zero motion estimation (fastest)
+@item full
+full motion estimation (slowest)
+@item epzs
+EPZS motion estimation (default)
+@item esa
+esa motion estimation (alias for full)
+@item tesa
+tesa motion estimation
+@item dia
+dia motion estimation (alias for epzs)
+@item log
+log motion estimation
+@item phods
+phods motion estimation
+@item x1
+X1 motion estimation
+@item hex
+hex motion estimation
+@item umh
+umh motion estimation
+@item iter
+iter motion estimation
+@end table
+
+@item extradata_size @var{integer}
+Set extradata size.
+
 @item time_base @var{rational number}
 Set codec time base.
 
@@ -144,6 +184,9 @@
 @item b_qfactor @var{float} (@emph{encoding,video})
 Set qp factor between P and B frames.
 
+@item rc_strategy @var{integer} (@emph{encoding,video})
+Set ratecontrol method.
+
 @item b_strategy @var{integer} (@emph{encoding,video})
 Set strategy to choose between I/P/B-frames.
 
@@ -167,6 +210,8 @@
 @table @samp
 @item autodetect
 
+@item old_msmpeg4
+some old lavc generated msmpeg4v3 files (no autodetection)
 @item xvid_ilace
 Xvid interlacing bug (autodetected if fourcc==XVIX)
 @item ump4
@@ -175,6 +220,8 @@
 padding bug (autodetected)
 @item amv
 
+@item ac_vlc
+illegal vlc bug (autodetected per fourcc)
 @item qpel_chroma
 
 @item std_qpel
@@ -195,6 +242,14 @@
 trancated frames
 @end table
 
+@item lelim @var{integer} (@emph{encoding,video})
+Set single coefficient elimination threshold for luminance (negative
+values also consider DC coefficient).
+
+@item celim @var{integer} (@emph{encoding,video})
+Set single coefficient elimination threshold for chrominance (negative
+values also consider dc coefficient)
+
 @item strict @var{integer} (@emph{decoding/encoding,audio,video})
 Specify how strictly to follow the standards.
 
@@ -251,8 +306,26 @@
 @item mpeg_quant @var{integer} (@emph{encoding,video})
 Use MPEG quantizers instead of H.263.
 
+@item qsquish @var{float} (@emph{encoding,video})
+How to keep quantizer between qmin and qmax (0 = clip, 1 = use
+differentiable function).
+
+@item rc_qmod_amp @var{float} (@emph{encoding,video})
+Set experimental quantizer modulation.
+
+@item rc_qmod_freq @var{integer} (@emph{encoding,video})
+Set experimental quantizer modulation.
+
 @item rc_override_count @var{integer}
 
+@item rc_eq @var{string} (@emph{encoding,video})
+Set rate control equation. When computing the expression, besides the
+standard functions defined in the section 'Expression Evaluation', the
+following functions are available: bits2qp(bits), qp2bits(qp). Also
+the following constants are available: iTex pTex tex mv fCode iCount
+mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex
+avgTex.
+
 @item maxrate @var{integer} (@emph{encoding,audio,video})
 Set max bitrate tolerance (in bits/s). Requires bufsize to be set.
 
@@ -263,12 +336,18 @@
 @item bufsize @var{integer} (@emph{encoding,audio,video})
 Set ratecontrol buffer size (in bits).
 
+@item rc_buf_aggressivity @var{float} (@emph{encoding,video})
+Currently useless.
+
 @item i_qfactor @var{float} (@emph{encoding,video})
 Set QP factor between P and I frames.
 
 @item i_qoffset @var{float} (@emph{encoding,video})
 Set QP offset between P and I frames.
 
+@item rc_init_cplx @var{float} (@emph{encoding,video})
+Set initial complexity for 1-pass encoding.
+
 @item dct @var{integer} (@emph{encoding,video})
 Set DCT algorithm.
 
@@ -333,7 +412,11 @@
 
 @item simpleneon
 
-@item xvid
+@item simplealpha
+
+@item ipp
+
+@item xvidmmx
 
 @item faani
 floating point AAN IDCT
@@ -631,9 +714,19 @@
 @item subq @var{integer} (@emph{encoding,video})
 Set sub pel motion estimation quality.
 
+@item dtg_active_format @var{integer}
+
 @item me_range @var{integer} (@emph{encoding,video})
 Set limit motion vectors range (1023 for DivX player).
 
+@item ibias @var{integer} (@emph{encoding,video})
+Set intra quant bias.
+
+@item pbias @var{integer} (@emph{encoding,video})
+Set inter quant bias.
+
+@item color_table_id @var{integer}
+
 @item global_quality @var{integer} (@emph{encoding,audio,video})
 
 @item coder @var{integer} (@emph{encoding,video})
@@ -648,6 +741,8 @@
 raw (no encoding)
 @item rle
 run-length coder
+@item deflate
+deflate-based coder
 @end table
 
 @item context @var{integer} (@emph{encoding,video})
@@ -668,9 +763,17 @@
 use best rate distortion
 @end table
 
+@item stream_codec_tag @var{integer}
+
 @item sc_threshold @var{integer} (@emph{encoding,video})
 Set scene change threshold.
 
+@item lmin @var{integer} (@emph{encoding,video})
+Set min lagrange factor (VBR).
+
+@item lmax @var{integer} (@emph{encoding,video})
+Set max lagrange factor (VBR).
+
 @item nr @var{integer} (@emph{encoding,video})
 Set noise reduction.
 
@@ -713,14 +816,13 @@
 @item prft
 Export encoder Producer Reference Time into packet side-data (see @code{AV_PKT_DATA_PRFT})
 for codecs that support it.
-@item venc_params
-Export video encoding parameters through frame side data (see @code{AV_FRAME_DATA_VIDEO_ENC_PARAMS})
-for codecs that support it. At present, those are H.264 and VP9.
-@item film_grain
-Export film grain parameters through frame side data (see @code{AV_FRAME_DATA_FILM_GRAIN_PARAMS}).
-Supported at present by AV1 decoders.
 @end table
 
+@item error @var{integer} (@emph{encoding,video})
+
+@item qns @var{integer} (@emph{encoding,video})
+Deprecated, use mpegvideo private options instead.
+
 @item threads @var{integer} (@emph{decoding/encoding,video})
 Set the number of threads to be used, in case the selected codec
 implementation supports multi-threading.
@@ -733,6 +835,12 @@
 
 Default value is @samp{auto}.
 
+@item me_threshold @var{integer} (@emph{encoding,video})
+Set motion estimation threshold.
+
+@item mb_threshold @var{integer} (@emph{encoding,video})
+Set macroblock threshold.
+
 @item dc @var{integer} (@emph{encoding,video})
 Set intra_dc_precision.
 
@@ -810,6 +918,9 @@
 
 @end table
 
+@item border_mask @var{float} (@emph{encoding,video})
+Increase the quantizer for macroblocks close to borders.
+
 @item mblmin @var{integer} (@emph{encoding,video})
 Set min macroblock lagrange factor (VBR).
 
@@ -883,6 +994,9 @@
 @item timecode_frame_start @var{integer} (@emph{encoding,video})
 Set GOP timecode frame start number, in non drop frame format.
 
+@item request_channels @var{integer} (@emph{decoding,audio})
+Set desired number of audio channels.
+
 @item bits_per_raw_sample @var{integer}
 @item channel_layout @var{integer} (@emph{decoding/encoding,audio})
 
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 27c6ba4..bfab562 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -25,19 +25,6 @@
 A description of some of the currently available video decoders
 follows.
 
-@section av1
-
-AOMedia Video 1 (AV1) decoder.
-
-@subsection Options
-
-@table @option
-
-@item operating_point
-Select an operating point of a scalable AV1 bitstream (0 - 31). Default is 0.
-
-@end table
-
 @section rawvideo
 
 Raw video decoder.
diff --git a/doc/encoders.texi b/doc/encoders.texi
index c9c8785..0b1c69e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -151,9 +151,10 @@
 The @var{ac3} encoder uses floating-point math, while the @var{ac3_fixed}
 encoder only uses fixed-point integer math. This does not mean that one is
 always faster, just that one or the other may be better suited to a
-particular system. The @var{ac3_fixed} encoder is not the default codec for
-any of the output formats, so it must be specified explicitly using the option
-@code{-acodec ac3_fixed} in order to use it.
+particular system. The floating-point encoder will generally produce better
+quality audio for a given bitrate. The @var{ac3_fixed} encoder is not the
+default codec for any of the output formats, so it must be specified explicitly
+using the option @code{-acodec ac3_fixed} in order to use it.
 
 @subsection AC-3 Metadata
 
@@ -1268,44 +1269,6 @@
 A description of some of the currently available video encoders
 follows.
 
-@section GIF
-
-GIF image/animation encoder.
-
-@subsection Options
-
-@table @option
-@item gifflags @var{integer}
-Sets the flags used for GIF encoding.
-
-@table @option
-@item offsetting
-Enables picture offsetting.
-
-Default is enabled.
-
-@item transdiff
-Enables transparency detection between frames.
-
-Default is enabled.
-
-@end table
-
-@item gifimage @var{integer}
-Enables encoding one full GIF image per frame, rather than an animated GIF.
-
-Default value is @option{0}.
-
-@item global_palette @var{integer}
-Writes a palette to the global GIF header where feasible.
-
-If disabled, every frame will always have a palette written, even if there
-is a global palette supplied.
-
-Default value is @option{1}.
-
-@end table
-
 @section Hap
 
 Vidvox Hap video encoder.
@@ -1722,17 +1685,6 @@
 @item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)
 Enable smooth interintra mode. Default is true.
 
-@item aom-params
-Set libaom options using a list of @var{key}=@var{value} pairs separated
-by ":". For a list of supported options, see @command{aomenc --help} under the
-section "AV1 Specific Options".
-
-For example to specify libaom encoding options with @option{-aom-params}:
-
-@example
-ffmpeg -i input -c:v libaom-av1 -b:v 500K -aom-params tune=psnr:enable-tpl-model=1 output.mp4
-@end example
-
 @end table
 
 @section libsvtav1
@@ -2177,38 +2129,6 @@
 The valid range is [0, 10000]. 0 (default) uses standard VBR.
 @item enable-tpl @var{boolean}
 Enable temporal dependency model.
-@item ref-frame-config
-Using per-frame metadata, set members of the structure @code{vpx_svc_ref_frame_config_t} in @code{vpx/vp8cx.h} to fine-control referencing schemes and frame buffer management.
-@*Use a :-separated list of key=value pairs.
-For example,
-@example
-av_dict_set(&av_frame->metadata, "ref-frame-config", \
-"rfc_update_buffer_slot=7:rfc_lst_fb_idx=0:rfc_gld_fb_idx=1:rfc_alt_fb_idx=2:rfc_reference_last=0:rfc_reference_golden=0:rfc_reference_alt_ref=0");
-@end example
-@table @option
-@item rfc_update_buffer_slot
-Indicates the buffer slot number to update
-@item rfc_update_last
-Indicates whether to update the LAST frame
-@item rfc_update_golden
-Indicates whether to update GOLDEN frame
-@item rfc_update_alt_ref
-Indicates whether to update ALT_REF frame
-@item rfc_lst_fb_idx
-LAST frame buffer index
-@item rfc_gld_fb_idx
-GOLDEN frame buffer index
-@item rfc_alt_fb_idx
-ALT_REF frame buffer index
-@item rfc_reference_last
-Indicates whether to reference LAST frame
-@item rfc_reference_golden
-Indicates whether to reference GOLDEN frame
-@item rfc_reference_alt_ref
-Indicates whether to reference ALT_REF frame
-@item rfc_reference_duration
-Indicates frame duration
-@end table
 @end table
 
 @end table
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index b0d1cf0..95d6463 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -675,19 +675,14 @@
 Print encoding progress/statistics. It is on by default, to explicitly
 disable it you need to specify @code{-nostats}.
 
-@item -stats_period @var{time} (@emph{global})
-Set period at which encoding progress/statistics are updated. Default is 0.5 seconds.
-
 @item -progress @var{url} (@emph{global})
 Send program-friendly progress information to @var{url}.
 
-Progress information is written periodically and at the end of
+Progress information is written approximately every second and at the end of
 the encoding process. It is made of "@var{key}=@var{value}" lines. @var{key}
 consists of only alphanumeric characters. The last key of a sequence of
 progress information is always "progress".
 
-The update period is set using @code{-stats_period}.
-
 @anchor{stdin option}
 @item -stdin
 Enable interaction on standard input. On by default unless standard input is
@@ -759,13 +754,6 @@
 As an output option, duplicate or drop input frames to achieve constant output
 frame rate @var{fps}.
 
-@item -fpsmax[:@var{stream_specifier}] @var{fps} (@emph{output,per-stream})
-Set maximum frame rate (Hz value, fraction or abbreviation).
-
-Clamps output frame rate when output framerate is auto-set and is higher than this value.
-Useful in batch processing or when input framerate is wrongly detected as very high.
-It cannot be set together with @code{-r}. It is ignored during streamcopy.
-
 @item -s[:@var{stream_specifier}] @var{size} (@emph{input/output,per-stream})
 Set frame size.
 
@@ -1512,17 +1500,6 @@
 
 This option has been deprecated. Use the @code{aresample} audio filter instead.
 
-@item -adrift_threshold @var{time}
-Set the minimum difference between timestamps and audio data (in seconds) to trigger
-adding/dropping samples to make it match the timestamps. This option effectively is
-a threshold to select between hard (add/drop) and soft (squeeze/stretch) compensation.
-@code{-async} must be set to a positive value.
-
-@item -apad @var{parameters} (@emph{output,per-stream})
-Pad the output audio stream(s). This is the same as applying @code{-af apad}.
-Argument is a string of filter parameters composed the same as with the @code{apad} filter.
-@code{-shortest} must be set for this output for the option to take effect.
-
 @item -copyts
 Do not process input timestamps, but keep their values without trying
 to sanitize them. In particular, do not remove the initial start time
@@ -1677,22 +1654,6 @@
 ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
 @end example
 
-As a special exception, you can use a bitmap subtitle stream as input: it
-will be converted into a video with the same size as the largest video in
-the file, or 720x576 if no video is present. Note that this is an
-experimental and temporary solution. It will be removed once libavfilter has
-proper support for subtitles.
-
-For example, to hardcode subtitles on top of a DVB-T recording stored in
-MPEG-TS format, delaying the subtitles by 1 second:
-@example
-ffmpeg -i input.ts -filter_complex \
-  '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
-  -sn -map '#0x2dc' output.mkv
-@end example
-(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
-audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
-
 To generate 5 seconds of pure red video using lavfi @code{color} source:
 @example
 ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
@@ -1773,11 +1734,6 @@
 No packets were passed to the muxer in some of the output streams.
 @end table
 
-@item -max_error_rate (@emph{global})
-Set fraction of decoding frame failures across all inputs which when crossed
-ffmpeg will return exit code 69. Crossing this threshold does not terminate
-processing. Range is a floating-point number between 0 to 1. Default is 2/3.
-
 @item -xerror (@emph{global})
 Stop and exit on error
 
@@ -1807,6 +1763,22 @@
 
 @end table
 
+As a special exception, you can use a bitmap subtitle stream as input: it
+will be converted into a video with the same size as the largest video in
+the file, or 720x576 if no video is present. Note that this is an
+experimental and temporary solution. It will be removed once libavfilter has
+proper support for subtitles.
+
+For example, to hardcode subtitles on top of a DVB-T recording stored in
+MPEG-TS format, delaying the subtitles by 1 second:
+@example
+ffmpeg -i input.ts -filter_complex \
+  '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
+  -sn -map '#0x2dc' output.mkv
+@end example
+(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
+audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
+
 @section Preset files
 A preset file contains a sequence of @var{option}=@var{value} pairs,
 one for each line, specifying a sequence of options which would be
diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 4427d02..71cbd23 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -61,6 +61,8 @@
       <xsd:attribute name="dts_time"      type="xsd:float" />
       <xsd:attribute name="duration"      type="xsd:long"  />
       <xsd:attribute name="duration_time" type="xsd:float" />
+      <xsd:attribute name="convergence_duration"      type="xsd:long"  />
+      <xsd:attribute name="convergence_duration_time" type="xsd:float" />
       <xsd:attribute name="size"          type="xsd:long" use="required" />
       <xsd:attribute name="pos"           type="xsd:long"  />
       <xsd:attribute name="flags"         type="xsd:string" use="required" />
@@ -213,6 +215,7 @@
       <xsd:attribute name="codec_long_name"  type="xsd:string" />
       <xsd:attribute name="profile"          type="xsd:string" />
       <xsd:attribute name="codec_type"       type="xsd:string" />
+      <xsd:attribute name="codec_time_base"  type="xsd:string" use="required"/>
       <xsd:attribute name="codec_tag"        type="xsd:string" use="required"/>
       <xsd:attribute name="codec_tag_string" type="xsd:string" use="required"/>
       <xsd:attribute name="extradata"        type="xsd:string" />
@@ -235,6 +238,7 @@
       <xsd:attribute name="color_primaries"      type="xsd:string"/>
       <xsd:attribute name="chroma_location"      type="xsd:string"/>
       <xsd:attribute name="field_order"          type="xsd:string"/>
+      <xsd:attribute name="timecode"             type="xsd:string"/>
       <xsd:attribute name="refs"                 type="xsd:int"/>
 
       <!-- audio attributes -->
@@ -354,6 +358,7 @@
       <xsd:attribute name="hwaccel"    type="xsd:int" use="required"/>
       <xsd:attribute name="planar"     type="xsd:int" use="required"/>
       <xsd:attribute name="rgb"        type="xsd:int" use="required"/>
+      <xsd:attribute name="pseudopal"  type="xsd:int" use="required"/>
       <xsd:attribute name="alpha"      type="xsd:int" use="required"/>
     </xsd:complexType>
 
diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index 5260ecb..2c94eae 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -122,9 +122,6 @@
 @item -version
 Show version.
 
-@item -buildconf
-Show the build configuration, one option per line.
-
 @item -formats
 Show available formats (including devices).
 
@@ -352,12 +349,6 @@
 @item k8
 @end table
 @end table
-
-@item -max_alloc @var{bytes}
-Set the maximum size limit for allocating a block on the heap by ffmpeg's
-family of malloc functions. Exercise @strong{extreme caution} when using
-this option. Don't use if you do not understand the full consequence of doing so.
-Default is INT_MAX.
 @end table
 
 @section AVOptions
diff --git a/doc/filters.texi b/doc/filters.texi
index eb0a0b6..89244dc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -640,10 +640,6 @@
 Set LFO rate.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section acue
 
 Delay audio filtering until a given wallclock timestamp. See the @ref{cue}
@@ -656,44 +652,44 @@
 autoregressive modelling.
 
 @table @option
-@item window, w
+@item w
 Set window size, in milliseconds. Allowed range is from @code{10} to
 @code{100}. Default value is @code{55} milliseconds.
 This sets size of window which will be processed at once.
 
-@item overlap, o
+@item o
 Set window overlap, in percentage of window size. Allowed range is from
 @code{50} to @code{95}. Default value is @code{75} percent.
 Setting this to a very high value increases impulsive noise removal but makes
 whole process much slower.
 
-@item arorder, a
+@item a
 Set autoregression order, in percentage of window size. Allowed range is from
 @code{0} to @code{25}. Default value is @code{2} percent. This option also
 controls quality of interpolated samples using neighbour good samples.
 
-@item threshold, t
+@item t
 Set threshold value. Allowed range is from @code{1} to @code{100}.
 Default value is @code{2}.
 This controls the strength of impulsive noise which is going to be removed.
 The lower value, the more samples will be detected as impulsive noise.
 
-@item burst, b
+@item b
 Set burst fusion, in percentage of window size. Allowed range is @code{0} to
 @code{10}. Default value is @code{2}.
 If any two samples detected as noise are spaced less than this value then any
 sample between those two samples will be also detected as noise.
 
-@item method, m
+@item m
 Set overlap method.
 
 It accepts the following values:
 @table @option
-@item add, a
+@item a
 Select overlap-add method. Even not interpolated samples are slightly
 changed with this method.
 
-@item save, s
+@item s
 Select overlap-save method. Not interpolated samples remain unchanged.
 @end table
 
@@ -707,38 +703,38 @@
 autoregressive modelling.
 
 @table @option
-@item window, w
+@item w
 Set window size, in milliseconds. Allowed range is from @code{10} to @code{100}.
 Default value is @code{55} milliseconds.
 This sets size of window which will be processed at once.
 
-@item overlap, o
+@item o
 Set window overlap, in percentage of window size. Allowed range is from @code{50}
 to @code{95}. Default value is @code{75} percent.
 
-@item arorder, a
+@item a
 Set autoregression order, in percentage of window size. Allowed range is from
 @code{0} to @code{25}. Default value is @code{8} percent. This option also controls
 quality of interpolated samples using neighbour good samples.
 
-@item threshold, t
+@item t
 Set threshold value. Allowed range is from @code{1} to @code{100}.
 Default value is @code{10}. Higher values make clip detection less aggressive.
 
-@item hsize, n
+@item n
 Set size of histogram used to detect clips. Allowed range is from @code{100} to @code{9999}.
 Default value is @code{1000}. Higher values make clip detection less aggressive.
 
-@item method, m
+@item m
 Set overlap method.
 
 It accepts the following values:
 @table @option
-@item add, a
+@item a
 Select overlap-add method. Even not interpolated samples are slightly changed
 with this method.
 
-@item save, s
+@item s
 Select overlap-save method. Not interpolated samples remain unchanged.
 @end table
 
@@ -1003,62 +999,6 @@
 @end example
 @end itemize
 
-@section aexciter
-
-An exciter is used to produce high sound that is not present in the
-original signal. This is done by creating harmonic distortions of the
-signal which are restricted in range and added to the original signal.
-An Exciter raises the upper end of an audio signal without simply raising
-the higher frequencies like an equalizer would do to create a more
-"crisp" or "brilliant" sound.
-
-The filter accepts the following options:
-
-@table @option
-@item level_in
-Set input level prior processing of signal.
-Allowed range is from 0 to 64.
-Default value is 1.
-
-@item level_out
-Set output level after processing of signal.
-Allowed range is from 0 to 64.
-Default value is 1.
-
-@item amount
-Set the amount of harmonics added to original signal.
-Allowed range is from 0 to 64.
-Default value is 1.
-
-@item drive
-Set the amount of newly created harmonics.
-Allowed range is from 0.1 to 10.
-Default value is 8.5.
-
-@item blend
-Set the octave of newly created harmonics.
-Allowed range is from -10 to 10.
-Default value is 0.
-
-@item freq
-Set the lower frequency limit of producing harmonics in Hz.
-Allowed range is from 2000 to 12000 Hz.
-Default is 7500 Hz.
-
-@item ceil
-Set the upper frequency limit of producing harmonics.
-Allowed range is from 9999 to 20000 Hz.
-If value is lower than 10000 Hz no limit is applied.
-
-@item listen
-Mute the original signal and output only added harmonics.
-By default is disabled.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @anchor{afade}
 @section afade
 
@@ -1935,11 +1875,6 @@
 @item weights
 Specify weight of each input audio stream as sequence.
 Each weight is separated by space. By default all inputs have same weight.
-
-@item normalize
-Always scale inputs instead of only doing summation of samples.
-Beware of heavy clipping if inputs are not normalized prior or after filtering
-by this filter if this option is disabled. By default is enabled.
 @end table
 
 @subsection Commands
@@ -1947,7 +1882,6 @@
 This filter supports the following commands:
 @table @option
 @item weights
-@item sum
 Syntax is same as option with same name.
 @end table
 
@@ -2409,10 +2343,6 @@
 noise removed from input signal.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section asetnsamples
 
 Set the number of samples per each output audio frame.
@@ -2524,12 +2454,6 @@
 @item erf
 @end table
 
-@item threshold
-Set threshold from where to start clipping. Default value is 0dB or 1.
-
-@item output
-Set gain applied to output. Default value is 0dB or 1.
-
 @item param
 Set additional parameter which controls sigmoid function.
 
@@ -3225,9 +3149,6 @@
 @item width, w
 Determine how steep is the filter's shelf transition.
 
-@item poles, p
-Set number of poles. Default is 2.
-
 @item mix, m
 How much to use filtered signal in output. Default is 1.
 Range is between 0 and 1.
@@ -3752,17 +3673,14 @@
 This filter supports the all above options as @ref{commands}.
 
 @section crystalizer
-Simple algorithm for audio noise sharpening.
-
-This filter linearly increases differences betweeen each audio sample.
+Simple algorithm to expand audio dynamic range.
 
 The filter accepts the following options:
 
 @table @option
 @item i
-Sets the intensity of effect (default: 2.0). Must be in range between -10.0 to 0
+Sets the intensity of effect (default: 2.0). Must be in range between 0.0
 (unchanged sound) to 10.0 (maximum effect).
-To inverse filtering use negative value.
 
 @item c
 Enable clipping. By default is enabled.
@@ -6132,9 +6050,6 @@
 @item width, w
 Determine how steep is the filter's shelf transition.
 
-@item poles, p
-Set number of poles. Default is 2.
-
 @item mix, m
 How much to use filtered signal in output. Default is 1.
 Range is between 0 and 1.
@@ -7166,15 +7081,6 @@
 Parallel can be faster then serial, while other way around is never true.
 Parallel will abort early on first change being greater then thresholds, while serial
 will continue processing other side of frames if they are equal or below thresholds.
-
-@item 0s
-@item 1s
-@item 2s
-Set sigma for 1st plane, 2nd plane or 3rd plane. Default is 32767.
-Valid range is from 0 to 32767.
-This options controls weight for each pixel in radius defined by size.
-Default value means every pixel have same weight.
-Setting this option to 0 effectively disables filtering.
 @end table
 
 @subsection Commands
@@ -7223,10 +7129,6 @@
 Set the minimal luminance value. Default is @code{16}.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section bilateral
 Apply bilateral filter, spatial smoothing while preserving edges.
 
@@ -7244,10 +7146,6 @@
 Set planes to filter. Default is first only.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section bitplanenoise
 
 Show and measure bit plane noise.
@@ -7515,9 +7413,6 @@
 @end example
 @end itemize
 
-@subsection Commands
-This filter supports same @ref{commands} as options.
-
 @section bm3d
 
 Denoise frames using Block-Matching 3D algorithm.
@@ -7759,9 +7654,6 @@
 planes except alpha plane.
 @end table
 
-@subsection Commands
-This filter supports same @ref{commands} as options.
-
 @section chromahold
 Remove all color information for all colors except for certain one.
 
@@ -8095,69 +7987,6 @@
 
 This filter supports the all above options as @ref{commands}.
 
-@section colorcontrast
-
-Adjust color contrast between RGB components.
-
-The filter accepts the following options:
-
-@table @option
-@item rc
-Set the red-cyan contrast. Defaults is 0.0. Allowed range is from -1.0 to 1.0.
-
-@item gm
-Set the green-magenta contrast. Defaults is 0.0. Allowed range is from -1.0 to 1.0.
-
-@item by
-Set the blue-yellow contrast. Defaults is 0.0. Allowed range is from -1.0 to 1.0.
-
-@item rcw
-@item gmw
-@item byw
-Set the weight of each @code{rc}, @code{gm}, @code{by} option value. Default value is 0.0.
-Allowed range is from 0.0 to 1.0. If all weights are 0.0 filtering is disabled.
-
-@item pl
-Set the amount of preserving lightness. Default value is 0.0. Allowed range is from 0.0 to 1.0.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
-@section colorcorrect
-
-Adjust color white balance selectively for blacks and whites.
-This filter operates in YUV colorspace.
-
-The filter accepts the following options:
-
-@table @option
-@item rl
-Set the red shadow spot. Allowed range is from -1.0 to 1.0.
-Default value is 0.
-
-@item bl
-Set the blue shadow spot. Allowed range is from -1.0 to 1.0.
-Default value is 0.
-
-@item rh
-Set the red highlight spot. Allowed range is from -1.0 to 1.0.
-Default value is 0.
-
-@item bh
-Set the red highlight spot. Allowed range is from -1.0 to 1.0.
-Default value is 0.
-
-@item saturation
-Set the amount of saturation. Allowed range is from -3.0 to 3.0.
-Default value is 1.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section colorchannelmixer
 
 Adjust video input frames by re-mixing color channels.
@@ -8201,10 +8030,6 @@
 Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
 
 Allowed ranges for options are @code{[-2.0, 2.0]}.
-
-@item pl
-Preserve lightness when changing colors. Allowed range is from @code{[0.0, 1.0]}.
-Default is @code{0.0}, thus disabled.
 @end table
 
 @subsection Examples
@@ -8226,33 +8051,6 @@
 
 This filter supports the all above options as @ref{commands}.
 
-@section colorize
-Overlay a solid color on the video stream.
-
-The filter accepts the following options:
-
-@table @option
-@item hue
-Set the color hue. Allowed range is from 0 to 360.
-Default value is 0.
-
-@item saturation
-Set the color saturation. Allowed range is from 0 to 1.
-Default value is 0.5.
-
-@item lightness
-Set the color lightness. Allowed range is from 0 to 1.
-Default value is 0.5.
-
-@item mix
-Set the mix of source lightness. By default is set to 1.0.
-Allowed range is from 0.0 to 1.0.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section colorkey
 RGB colorspace color keying.
 
@@ -8713,28 +8511,6 @@
 colorspace=smpte240m
 @end example
 
-@section colortemperature
-Adjust color temperature in video to simulate variations in ambient color temperature.
-
-The filter accepts the following options:
-
-@table @option
-@item temperature
-Set the temperature in Kelvin. Allowed range is from 1000 to 40000.
-Default value is 6500 K.
-
-@item mix
-Set mixing with filtered output. Allowed range is from 0 to 1.
-Default value is 1.
-
-@item pl
-Set the amount of preserving lightness. Allowed range is from 0 to 1.
-Default value is 0.
-@end table
-
-@subsection Commands
-This filter supports same @ref{commands} as options.
-
 @section convolution
 
 Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49 elements.
@@ -9313,10 +9089,6 @@
 To avoid some filtergraph syntax conflicts, each key points list need to be
 defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
 
-@subsection Commands
-
-This filter supports same @ref{commands} as options.
-
 @subsection Examples
 
 @itemize
@@ -9409,15 +9181,8 @@
 
 @item format
 Set display number format. Can be @code{hex}, or @code{dec}. Default is @code{hex}.
-
-@item components
-Set pixel components to display. By default all pixel components are displayed.
 @end table
 
-@subsection Commands
-
-This filter supports same @ref{commands} as options excluding @code{size} option.
-
 @section dblur
 Apply Directional blur filter.
 
@@ -9550,10 +9315,6 @@
 The default is disabled.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section deblock
 
 Remove blocking artifacts from input video.
@@ -9613,10 +9374,6 @@
 @end example
 @end itemize
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @anchor{decimate}
 @section decimate
 
@@ -10180,10 +9937,6 @@
 @item output
 Set the output name of the dnn network.
 
-@item async
-use DNN async execution if set (default: set),
-roll back to sync execution if the backend does not support async.
-
 @end table
 
 @subsection Examples
@@ -11145,18 +10898,6 @@
 between neighbour histogram values.
 @end table
 
-@section epx
-Apply the EPX magnification filter which is designed for pixel art.
-
-It accepts the following option:
-
-@table @option
-@item n
-Set the scaling dimension: @code{2} for @code{2xEPX}, @code{3} for
-@code{3xEPX}.
-Default is @code{3}.
-@end table
-
 @section eq
 Set brightness, contrast, saturation and approximate gamma adjustment.
 
@@ -11298,102 +11039,6 @@
 
 This filter supports the all above options as @ref{commands}.
 
-@section estdif
-
-Deinterlace the input video ("estdif" stands for "Edge Slope
-Tracing Deinterlacing Filter").
-
-Spatial only filter that uses edge slope tracing algorithm
-to interpolate missing lines.
-It accepts the following parameters:
-
-@table @option
-@item mode
-The interlacing mode to adopt. It accepts one of the following values:
-
-@table @option
-@item frame
-Output one frame for each frame.
-@item field
-Output one frame for each field.
-@end table
-
-The default value is @code{field}.
-
-@item parity
-The picture field parity assumed for the input interlaced video. It accepts one
-of the following values:
-
-@table @option
-@item tff
-Assume the top field is first.
-@item bff
-Assume the bottom field is first.
-@item auto
-Enable automatic detection of field parity.
-@end table
-
-The default value is @code{auto}.
-If the interlacing is unknown or the decoder does not export this information,
-top field first will be assumed.
-
-@item deint
-Specify which frames to deinterlace. Accepts one of the following
-values:
-
-@table @option
-@item all
-Deinterlace all frames.
-@item interlaced
-Only deinterlace frames marked as interlaced.
-@end table
-
-The default value is @code{all}.
-
-@item rslope
-Specify the search radius for edge slope tracing. Default value is 1.
-Allowed range is from 1 to 15.
-
-@item redge
-Specify the search radius for best edge matching. Default value is 2.
-Allowed range is from 0 to 15.
-
-@item interp
-Specify the interpolation used. Default is 4-point interpolation. It accepts one
-of the following values:
-
-@table @option
-@item 2p
-Two-point interpolation.
-@item 4p
-Four-point interpolation.
-@item 6p
-Six-point interpolation.
-@end table
-@end table
-
-@subsection Commands
-This filter supports same @ref{commands} as options.
-
-@section exposure
-Adjust exposure of the video stream.
-
-The filter accepts the following options:
-
-@table @option
-@item exposure
-Set the exposure correction in EV. Allowed range is from -3.0 to 3.0 EV
-Default value is 0 EV.
-
-@item black
-Set the black level correction. Allowed range is from -1.0 to 1.0.
-Default value is 0.
-@end table
-
-@subsection Commands
-
-This filter supports same @ref{commands} as options.
-
 @section extractplanes
 
 Extract color channel components from input video stream into
@@ -12099,25 +11744,16 @@
 fill pixels using outermost pixels
 
 @item mirror
-fill pixels using mirroring (half sample symmetric)
+fill pixels using mirroring
 
 @item fixed
 fill pixels with constant value
-
-@item reflect
-fill pixels using reflecting (whole sample symmetric)
-
-@item wrap
-fill pixels using wrapping
-
-@item fade
-fade pixels to constant value
 @end table
 
 Default is @var{smear}.
 
 @item color
-Set color for pixels in fixed or fade mode. Default is @var{black}.
+Set color for pixels in fixed mode. Default is @var{black}.
 @end table
 
 @subsection Commands
@@ -12901,10 +12537,6 @@
 More information about the Hald CLUT can be found on Eskil Steenberg's website
 (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
 
-@subsection Commands
-
-This filter supports the @code{interp} option as @ref{commands}.
-
 @subsection Workflow examples
 
 @subsubsection Hald CLUT video stream
@@ -13382,28 +13014,6 @@
 
 The @code{hysteresis} filter also supports the @ref{framesync} options.
 
-@section identity
-
-Obtain the identity score between two input videos.
-
-This filter takes two input videos.
-
-Both input videos must have the same resolution and pixel format for
-this filter to work correctly. Also it assumes that both inputs
-have the same number of frames, which are compared one by one.
-
-The obtained per component, average, min and max identity score is printed through
-the logging system.
-
-The filter stores the calculated identity scores of each frame in frame metadata.
-
-In the below example the input file @file{main.mpg} being processed is compared
-with the reference file @file{ref.mpg}.
-
-@example
-ffmpeg -i main.mpg -i ref.mpg -lavfi identity -f null -
-@end example
-
 @section idet
 
 Detect video interlacing type.
@@ -13646,27 +13256,6 @@
 @end example
 @end itemize
 
-@section kirsch
-Apply kirsch operator to input video stream.
-
-The filter accepts the following option:
-
-@table @option
-@item planes
-Set which planes will be processed, unprocessed planes will be copied.
-By default value 0xf, all planes will be processed.
-
-@item scale
-Set value which will be multiplied with filtered result.
-
-@item delta
-Set value which will be added to filtered result.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section lagfun
 
 Slowly update darker pixels.
@@ -13682,10 +13271,6 @@
 Set which planes to filter. Default is all. Allowed range is from 0 to 15.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section lenscorrection
 
 Correct radial lens distortion
@@ -13724,13 +13309,6 @@
 @item k2
 Coefficient of the double quadratic correction term. This value has a range [-1,1].
 0 means no correction. Default is 0.
-@item i
-Set interpolation type. Can be @code{nearest} or @code{bilinear}.
-Default is @code{nearest}.
-@item fc
-Specify the color of the unmapped pixels. For the syntax of this option,
-check the @ref{color syntax,,"Color" section in the ffmpeg-utils
-manual,ffmpeg-utils}. Default color is @code{black@@0}.
 @end table
 
 The formula that generates the correction is:
@@ -13740,10 +13318,6 @@
 where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
 distances from the focal point in the source and target images, respectively.
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section lensfun
 
 Apply lens correction via the lensfun library (@url{http://lensfun.sourceforge.net/}).
@@ -13977,10 +13551,6 @@
 Specify which planes will be processed. Defaults to all available.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section loop
 
 Loop video frames.
@@ -14058,10 +13628,6 @@
 @end table
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @anchor{lut3d}
 @section lut3d
 
@@ -14098,17 +13664,9 @@
 Interpolate values using the 8 points defining a cube.
 @item tetrahedral
 Interpolate values using a tetrahedron.
-@item pyramid
-Interpolate values using a pyramid.
-@item prism
-Interpolate values using a prism.
 @end table
 @end table
 
-@subsection Commands
-
-This filter supports the @code{interp} option as @ref{commands}.
-
 @section lumakey
 
 Turn certain luma values into transparency.
@@ -14219,10 +13777,6 @@
 
 All expressions default to "val".
 
-@subsection Commands
-
-This filter supports same @ref{commands} as options.
-
 @subsection Examples
 
 @itemize
@@ -14342,10 +13896,6 @@
 
 All expressions default to "x".
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands} except option @code{d}.
-
 @subsection Examples
 
 @itemize
@@ -14389,10 +13939,6 @@
 By default value 0xf, all planes will be processed.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section maskedmax
 
 Merge the second and third input stream into output stream using absolute differences
@@ -14409,10 +13955,6 @@
 By default value 0xf, all planes will be processed.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section maskedmerge
 
 Merge the first input stream with the second input stream using per pixel
@@ -14432,10 +13974,6 @@
 By default value 0xf, all planes will be processed.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section maskedmin
 
 Merge the second and third input stream into output stream using absolute differences
@@ -14452,10 +13990,6 @@
 By default value 0xf, all planes will be processed.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section maskedthreshold
 Pick pixels comparing absolute difference of two video streams with fixed
 threshold.
@@ -14477,10 +14011,6 @@
 By default value 0xf, all planes will be processed.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section maskfun
 Create mask from input video.
 
@@ -14508,10 +14038,6 @@
 Typically useful for scene changes when used in combination with @code{tblend} filter.
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section mcdeint
 
 Apply motion-compensation deinterlacing.
@@ -14829,42 +14355,6 @@
 @end table
 @end table
 
-@subsection Commands
-
-This filter supports the following commands:
-@table @option
-@item weights
-@item scale
-Syntax is same as option with same name.
-@end table
-
-@section monochrome
-Convert video to gray using custom color filter.
-
-A description of the accepted options follows.
-
-@table @option
-@item cb
-Set the chroma blue spot. Allowed range is from -1 to 1.
-Default value is 0.
-
-@item cr
-Set the chroma red spot. Allowed range is from -1 to 1.
-Default value is 0.
-
-@item size
-Set the color filter size. Allowed range is from .1 to 10.
-Default value is 1.
-
-@item high
-Set the highlights strength. Allowed range is from 0 to 1.
-Default value is 0.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section mpdecimate
 
 Drop frames that do not differ greatly from the previous frame in
@@ -14903,27 +14393,6 @@
 64*5, and default value for @option{frac} is 0.33.
 @end table
 
-@section msad
-
-Obtain the MSAD (Mean Sum of Absolute Differences) between two input videos.
-
-This filter takes two input videos.
-
-Both input videos must have the same resolution and pixel format for
-this filter to work correctly. Also it assumes that both inputs
-have the same number of frames, which are compared one by one.
-
-The obtained per component, average, min and max MSAD is printed through
-the logging system.
-
-The filter stores the calculated MSAD of each frame in frame metadata.
-
-In the below example the input file @file{main.mpg} being processed is compared
-with the reference file @file{ref.mpg}.
-
-@example
-ffmpeg -i main.mpg -i ref.mpg -lavfi msad -f null -
-@end example
 
 @section negate
 
@@ -14937,10 +14406,6 @@
 With value 1, it negates the alpha component, if present. Default value is 0.
 @end table
 
-@subsection Commands
-
-This filter supports same @ref{commands} as options.
-
 @anchor{nlmeans}
 @section nlmeans
 
@@ -15054,9 +14519,9 @@
 Can be one of the following:
 
 @table @samp
-@item a, abs
+@item a
 weights trained to minimize absolute error
-@item s, mse
+@item s
 weights trained to minimize squared error
 @end table
 
@@ -15078,15 +14543,13 @@
 @item none
 @item original
 @item new
-@item new2
-@item new3
 @end table
 
 Default is @code{new}.
-@end table
 
-@subsection Commands
-This filter supports same @ref{commands} as options, excluding @var{weights} option.
+@item fapprox
+Set various debugging flags.
+@end table
 
 @section noformat
 
@@ -16195,10 +15658,6 @@
 @end table
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section photosensitivity
 Reduce various flashes in video, so to help users with epilepsy.
 
@@ -16261,10 +15720,6 @@
 Set window Y position, relative offset on Y axis.
 @end table
 
-@subsection Commands
-
-This filter supports same @ref{commands} as options.
-
 @section pp
 
 Enable the specified chain of postprocessing subfilters using libpostproc. This
@@ -16523,33 +15978,12 @@
 @item c3
 set pixel fourth component expression, corresponds to the alpha component
 
-@item index, i
+@item i
 set component to use as base for altering colors
-
-@item preset, p
-Pick one of built-in LUTs. By default is set to none.
-
-Available LUTs:
-@table @samp
-@item magma
-@item inferno
-@item plasma
-@item viridis
-@item turbo
-@item cividis
-@item range1
-@item range2
-@item shadows
-@item highlights
 @end table
 
-@item opacity
-Set opacity of output colors. Allowed range is from 0 to 1.
-Default value is set to 1.
-@end table
-
-Each of the expression options specifies the expression to use for computing
-the lookup table for the corresponding pixel component values.
+Each of them specifies the expression to use for computing the lookup table for
+the corresponding pixel component values.
 
 The expressions can contain the following constants and functions:
 
@@ -16570,10 +16004,6 @@
 
 All expressions default to "val".
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @subsection Examples
 
 @itemize
@@ -18208,37 +17638,6 @@
 @end table
 @end table
 
-@section shear
-Apply shear transform to input video.
-
-This filter supports the following options:
-
-@table @option
-@item shx
-Shear factor in X-direction. Default value is 0.
-Allowed range is from -2 to 2.
-
-@item shy
-Shear factor in Y-direction. Default value is 0.
-Allowed range is from -2 to 2.
-
-@item fillcolor, c
-Set the color used to fill the output area not covered by the transformed
-video. For the general syntax of this option, check the
-@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
-If the special value "none" is selected then no
-background is printed (useful for example if the background is never shown).
-
-Default value is "black".
-
-@item interp
-Set interpolation type. Can be @code{bilinear} or @code{nearest}. Default is @code{bilinear}.
-@end table
-
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section showinfo
 
 Show a line containing various information for each input video frame.
@@ -18359,33 +17758,6 @@
 @end example
 @end itemize
 
-@section shufflepixels
-
-Reorder pixels in video frames.
-
-This filter accepts the following options:
-
-@table @option
-@item direction, d
-Set shuffle direction. Can be forward or inverse direction.
-Default direction is forward.
-
-@item mode, m
-Set shuffle mode. Can be horizontal, vertical or block mode.
-
-@item width, w
-@item height, h
-Set shuffle block_size. In case of horizontal shuffle mode only width
-part of size is used, and in case of vertical shuffle mode only height
-part of size is used.
-
-@item seed, s
-Set random seed used with shuffling pixels. Mainly useful to set to be able
-to reverse filtering process to get original input.
-For example, to reverse forward shuffle you need to use same parameters
-and exact same seed and to set direction to inverse.
-@end table
-
 @section shuffleplanes
 
 Reorder and/or duplicate video planes.
@@ -19330,10 +18702,6 @@
 the position in the file of the input frame, NAN if unknown
 @end table
 
-@subsection Commands
-
-This filter supports the all above options as @ref{commands}.
-
 @section swapuv
 Swap U & V plane.
 
@@ -19869,32 +19237,6 @@
 minimum values, and @code{1} maximum values.
 @end table
 
-@subsection Commands
-
-This filter supports all above options as @ref{commands}, excluding option @code{radius}.
-
-@section tmidequalizer
-
-Apply Temporal Midway Video Equalization effect.
-
-Midway Video Equalization adjusts a sequence of video frames to have the same
-histograms, while maintaining their dynamics as much as possible. It's
-useful for e.g. matching exposures from a video frames sequence.
-
-This filter accepts the following option:
-
-@table @option
-@item radius
-Set filtering radius. Default is @code{5}. Allowed range is from 1 to 127.
-
-@item sigma
-Set filtering sigma. Default is @code{0.5}. This controls strength of filtering.
-Setting this option to 0 effectively does nothing.
-
-@item planes
-Set which planes to process. Default is @code{15}, which is all available planes.
-@end table
-
 @section tmix
 
 Mix successive video frames.
@@ -19939,15 +19281,6 @@
 @end example
 @end itemize
 
-@subsection Commands
-
-This filter supports the following commands:
-@table @option
-@item weights
-@item scale
-Syntax is same as option with same name.
-@end table
-
 @anchor{tonemap}
 @section tonemap
 Tone map colors from different dynamic ranges.
@@ -21309,27 +20642,6 @@
 
 This filter supports the all above options as @ref{commands}.
 
-@section vif
-
-Obtain the average VIF (Visual Information Fidelity) between two input videos.
-
-This filter takes two input videos.
-
-Both input videos must have the same resolution and pixel format for
-this filter to work correctly. Also it assumes that both inputs
-have the same number of frames, which are compared one by one.
-
-The obtained average VIF score is printed through the logging system.
-
-The filter stores the calculated VIF score of each frame.
-
-In the below example the input file @file{main.mpg} being processed is compared
-with the reference file @file{ref.mpg}.
-
-@example
-ffmpeg -i main.mpg -i ref.mpg -lavfi vif -f null -
-@end example
-
 @anchor{vignette}
 @section vignette
 
@@ -21511,35 +20823,6 @@
 @end table
 Default value is @samp{complex}.
 
-@item mode
-The interlacing mode to adopt. It accepts one of the following values:
-
-@table @option
-@item frame
-Output one frame for each frame.
-@item field
-Output one frame for each field.
-@end table
-
-The default value is @code{field}.
-
-@item parity
-The picture field parity assumed for the input interlaced video. It accepts one
-of the following values:
-
-@table @option
-@item tff
-Assume the top field is first.
-@item bff
-Assume the bottom field is first.
-@item auto
-Enable automatic detection of field parity.
-@end table
-
-The default value is @code{auto}.
-If the interlacing is unknown or the decoder does not export this information,
-top field first will be assumed.
-
 @item deint
 Specify which frames to deinterlace. Accepts one of the following values:
 
@@ -21553,9 +20836,6 @@
 Default value is @samp{all}.
 @end table
 
-@subsection Commands
-This filter supports same @ref{commands} as options.
-
 @section waveform
 Video waveform monitor.
 
@@ -21901,10 +21181,6 @@
 minimum values, and @code{1} maximum values.
 @end table
 
-@subsection Commands
-
-This filter supports all above options as @ref{commands}, excluding option @code{inputs}.
-
 @section xstack
 Stack video inputs into custom layout.
 
@@ -22488,13 +21764,6 @@
 
 @item npl
 Set the nominal peak luminance.
-
-@item param_a
-Parameter A for scaling filters. Parameter "b" for bicubic, and the number of
-filter taps for lanczos.
-
-@item param_b
-Parameter B for scaling filters. Parameter "c" for bicubic.
 @end table
 
 The values of the @option{w} and @option{h} options are expressions
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 58c9bcf..443e8ed 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -385,7 +385,6 @@
     @tab Audio format used on the PS2.
 @item APNG                      @tab X @tab X
 @item ASF                       @tab X @tab X
-    @tab Advanced / Active Streaming Format.
 @item AST                       @tab X @tab X
     @tab Audio format used on the Nintendo Wii.
 @item AVI                       @tab X @tab X
@@ -401,20 +400,14 @@
 @item Binary text               @tab   @tab X
 @item Bink                      @tab   @tab X
     @tab Multimedia format used by many games.
-@item Bink Audio                @tab   @tab X
-    @tab Audio only multimedia format used by some games.
 @item Bitmap Brothers JV        @tab   @tab X
     @tab Used in Z and Z95 games.
-@item BRP                       @tab   @tab X
-    @tab Argonaut Games format.
 @item Brute Force & Ignorance   @tab   @tab X
     @tab Used in the game Flash Traffic: City of Angels.
 @item BFSTM                     @tab   @tab X
     @tab Audio format used on the Nintendo WiiU (based on BRSTM).
 @item BRSTM                     @tab   @tab X
     @tab Audio format used on the Nintendo Wii.
-@item BW64                      @tab   @tab X
-    @tab Broadcast Wave 64bit.
 @item BWF                       @tab X @tab X
 @item codec2 (raw)              @tab X @tab X
     @tab Must be given -mode format option to decode correctly.
@@ -637,7 +630,6 @@
 @item RedSpark                  @tab   @tab X
 @item Renderware TeXture Dictionary @tab   @tab X
 @item Resolume DXV              @tab   @tab X
-@item RF64                      @tab   @tab X
 @item RL2                       @tab   @tab X
     @tab Audio and video format used in some games by Entertainment Software Partners.
 @item RPL/ARMovie               @tab   @tab X
@@ -727,13 +719,10 @@
     @tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @item APNG         @tab X @tab X
-    @tab Animated Portable Network Graphics
 @item BMP          @tab X @tab X
     @tab Microsoft BMP image
 @item BRender PIX  @tab   @tab X
     @tab Argonaut BRender 3D engine image format.
-@item CRI          @tab   @tab X
-    @tab Cintel RAW
 @item DPX          @tab X @tab X
     @tab Digital Picture Exchange
 @item EXR          @tab   @tab X
@@ -752,12 +741,8 @@
     @tab PAM is a PNM extension with alpha support.
 @item PBM          @tab X @tab X
     @tab Portable BitMap image
-@item PCD          @tab   @tab X
-    @tab PhotoCD
 @item PCX          @tab X @tab X
     @tab PC Paintbrush
-@item PFM          @tab X @tab X
-    @tab Portable FloatMap image
 @item PGM          @tab X @tab X
     @tab Portable GrayMap image
 @item PGMYUV       @tab X @tab X
@@ -767,7 +752,6 @@
 @item PIC          @tab @tab X
     @tab Pictor/PC Paint
 @item PNG          @tab X @tab X
-    @tab Portable Network Graphics image
 @item PPM          @tab X @tab X
     @tab Portable PixelMap image
 @item PSD          @tab   @tab X
@@ -821,8 +805,6 @@
     @tab fourcc: apch,apcn,apcs,apco,ap4h,ap4x
 @item Apple QuickDraw        @tab     @tab  X
     @tab fourcc: qdrw
-@item Argonaut Video         @tab     @tab  X
-    @tab Used in some Argonaut games.
 @item Asus v1                @tab  X  @tab  X
     @tab fourcc: ASV1
 @item Asus v2                @tab  X  @tab  X
@@ -1352,7 +1334,6 @@
 @item SubViewer v1     @tab   @tab X @tab   @tab X
 @item SubViewer        @tab   @tab X @tab   @tab X
 @item TED Talks captions @tab @tab X @tab   @tab X
-@item TTML             @tab X @tab   @tab X @tab
 @item VobSub (IDX+SUB) @tab   @tab X @tab   @tab X
 @item VPlayer          @tab   @tab X @tab   @tab X
 @item WebVTT           @tab X @tab X @tab X @tab X
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 74833d7..179b923 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -242,8 +242,6 @@
 @item seg_duration @var{duration}
 Set the segment length in seconds (fractional value can be set). The value is
 treated as average segment duration when @var{use_template} is enabled and
-@var{use_timeline} is disabled and as minimum segment duration for all the other
-use cases.
 @item frag_duration @var{duration}
 Set the length in seconds of fragments within segments (fractional value can be set).
 @item frag_type @var{type}
@@ -611,21 +609,14 @@
 This muxer supports the following options:
 
 @table @option
-@item hls_init_time @var{duration}
-Set the initial target segment length. Default value is @var{0}.
-
-@var{duration} must be a time duration specification,
-see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
-
+@item hls_init_time @var{seconds}
+Set the initial target segment length in seconds. Default value is @var{0}.
 Segment will be cut on the next key frame after this time has passed on the first m3u8 list.
 After the initial playlist is filled @command{ffmpeg} will cut segments
 at duration equal to @code{hls_time}
 
-@item hls_time @var{duration}
-Set the target segment length. Default value is 2.
-
-@var{duration} must be a time duration specification,
-see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
+@item hls_time @var{seconds}
+Set the target segment length in seconds. Default value is 2.
 Segment will be cut on the next key frame after this time has passed.
 
 @item hls_list_size @var{size}
@@ -840,7 +831,7 @@
 is saved as @var{playlist name}.key.
 
 @item -hls_enc_key @var{key}
-16-octet key to encrypt the segments, by default it
+Hex-coded 16byte key to encrypt the segments, by default it
 is randomly generated.
 
 @item -hls_enc_key_url @var{keyurl}
@@ -848,7 +839,7 @@
 in the playlist.
 
 @item -hls_enc_iv @var{iv}
-16-octet initialization vector for every segment instead
+Hex-coded 16byte initialization vector for every segment instead
 of the autogenerated ones.
 
 @item hls_segment_type @var{flags}
diff --git a/doc/protocols.texi b/doc/protocols.texi
index c0b511b..b4efa14 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -63,17 +63,16 @@
 the command:
 
 @example
-ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port][/vhost]
+ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port]
 @end example
 
 Where hostname and port (default is 5672) is the address of the broker. The
 client may also set a user/password for authentication. The default for both
-fields is "guest". Name of virtual host on broker can be set with vhost. The
-default value is "/".
+fields is "guest".
 
 Muliple subscribers may stream from the broker using the command:
 @example
-ffplay amqp://[[user]:[password]@@]hostname[:port][/vhost]
+ffplay amqp://[[user]:[password]@@]hostname[:port]
 @end example
 
 In RabbitMQ all data published to the broker flows through a specific exchange,
@@ -175,16 +174,6 @@
 
 Cache the input stream to temporary file. It brings seeking capability to live streams.
 
-The accepted options are:
-@table @option
-
-@item read_ahead_limit
-Amount in bytes that may be read ahead when seeking isn't supported. Range is -1 to INT_MAX.
--1 for unlimited. Default is 65536.
-
-@end table
-
-URL Syntax is
 @example
 cache:@var{URL}
 @end example
@@ -410,13 +399,6 @@
 @item reconnect_streamed
 If set then even streamed/non seekable streams will be reconnected on errors.
 
-@item reconnect_on_network_error
-Reconnect automatically in case of TCP/TLS errors during connect.
-
-@item reconnect_on_http_error
-A comma separated list of HTTP status codes to reconnect on. The list can
-include specific status codes (e.g. '503') or the strings '4xx' / '5xx'.
-
 @item reconnect_delay_max
 Sets the maximum delay in seconds after which to give up reconnecting
 
@@ -1652,9 +1634,8 @@
 The list of supported options follows.
 
 @table @option
-@item listen=@var{2|1|0}
-Listen for an incoming connection. 0 disables listen, 1 enables listen in
-single client mode, 2 enables listen in multi-client mode. Default value is 0.
+@item listen=@var{1|0}
+Listen for an incoming connection. Default value is 0.
 
 @item timeout=@var{microseconds}
 Set raise error timeout, expressed in microseconds.
diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index e070b6b..13e1355 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -107,7 +107,7 @@
 %.c %.h %.pc %.ver %.version: TAG = GEN
 
 # Dummy rule to stop make trying to rebuild removed or renamed headers
-%.h %_template.c:
+%.h:
 	@:
 
 # Disable suffix rules.  Most of the builtin rules are suffix rules,
diff --git a/ffmpeg_generated.gni b/ffmpeg_generated.gni
index 88f513b..ddb03ff 100644
--- a/ffmpeg_generated.gni
+++ b/ffmpeg_generated.gni
@@ -1,4 +1,4 @@
-# Copyright 2021 The Chromium Authors. All rights reserved.
+# Copyright 2020 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
@@ -42,6 +42,7 @@
     "libavcodec/dirac.c",
     "libavcodec/dv_profile.c",
     "libavcodec/encode.c",
+    "libavcodec/fft_fixed.c",
     "libavcodec/fft_fixed_32.c",
     "libavcodec/fft_float.c",
     "libavcodec/fft_init_table.c",
@@ -54,9 +55,11 @@
     "libavcodec/libopus.c",
     "libavcodec/libopusdec.c",
     "libavcodec/mathtables.c",
+    "libavcodec/mdct_fixed.c",
     "libavcodec/mdct_fixed_32.c",
     "libavcodec/mdct_float.c",
     "libavcodec/mediacodec.c",
+    "libavcodec/mjpegenc_huffman.c",
     "libavcodec/mpeg12framerate.c",
     "libavcodec/mpeg4audio.c",
     "libavcodec/mpegaudio.c",
@@ -96,6 +99,7 @@
     "libavformat/autorename_libavformat_utils.c",
     "libavformat/avio.c",
     "libavformat/aviobuf.c",
+    "libavformat/cutils.c",
     "libavformat/dump.c",
     "libavformat/flac_picture.c",
     "libavformat/flacdec.c",
@@ -103,7 +107,6 @@
     "libavformat/id3v1.c",
     "libavformat/id3v2.c",
     "libavformat/isom.c",
-    "libavformat/isom_tags.c",
     "libavformat/matroska.c",
     "libavformat/matroskadec.c",
     "libavformat/metadata.c",
@@ -213,7 +216,6 @@
   ffmpeg_c_sources += [
     "libavcodec/aac_ac3_parser.c",
     "libavcodec/aac_parser.c",
-    "libavcodec/aacps_common.c",
     "libavcodec/aacps_float.c",
     "libavcodec/aacpsdsp_float.c",
     "libavcodec/aacsbr.c",
@@ -225,6 +227,7 @@
     "libavcodec/cbrt_data.c",
     "libavcodec/kbdwin.c",
     "libavcodec/sinewin.c",
+    "libavcodec/sinewin_fixed.c",
     "libavformat/aacdec.c",
     "libavformat/apetag.c",
     "libavformat/img2.c",
@@ -293,6 +296,7 @@
 
 if ((is_android && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm")) {
   ffmpeg_c_sources += [
+    "libavcodec/arm/fft_fixed_init_arm.c",
     "libavcodec/arm/fft_init_arm.c",
     "libavcodec/arm/flacdsp_init_arm.c",
     "libavcodec/arm/mpegaudiodsp_init_arm.c",
@@ -391,6 +395,7 @@
     "libavcodec/error_resilience.c",
     "libavcodec/exif.c",
     "libavcodec/fdctdsp.c",
+    "libavcodec/flvdec.c",
     "libavcodec/gsm_parser.c",
     "libavcodec/gsmdec.c",
     "libavcodec/gsmdec_data.c",
@@ -399,6 +404,7 @@
     "libavcodec/h263data.c",
     "libavcodec/h263dec.c",
     "libavcodec/h263dsp.c",
+    "libavcodec/intelh263dec.c",
     "libavcodec/ituh263dec.c",
     "libavcodec/jfdctfst.c",
     "libavcodec/jfdctint.c",
@@ -504,7 +510,9 @@
     "libavutil/arm/float_dsp_init_neon.c",
   ]
   ffmpeg_gas_sources += [
+    "libavcodec/arm/fft_fixed_neon.S",
     "libavcodec/arm/fft_neon.S",
+    "libavcodec/arm/mdct_fixed_neon.S",
     "libavcodec/arm/mdct_neon.S",
     "libavcodec/arm/rdft_neon.S",
     "libavcodec/arm/vorbisdsp_neon.S",
diff --git a/ffmpeg_options.gni b/ffmpeg_options.gni
index c9ebbca..026e955 100644
--- a/ffmpeg_options.gni
+++ b/ffmpeg_options.gni
@@ -40,8 +40,7 @@
   # https://groups.google.com/a/chromium.org/forum/#!msg/chromium-packagers/R5rcZXWxBEQ/B6k0zzmJbvcJ
   is_component_ffmpeg = is_component_build
 
-  # Set to true to force the use of ffmpeg's stdatomic fallback code. This code
-  # is unsafe and does not implement atomics properly. https://crbug.com/161723.
+  # Set to true to force the use of ffmpeg's stdatomic fallback code.
   #
   # Windows and GCC prior to 4.9 lack stdatomic.h.
   #
@@ -49,7 +48,7 @@
   # clang's -frewrite-includes flag which is broken with #include_next
   # directives as used in chromium's clang stdatomic.h.
   # Some background: https://bugs.llvm.org/show_bug.cgi?id=26828
-  ffmpeg_use_unsafe_atomics = false
+  ffmpeg_use_atomics_fallback = !is_clang
 }
 
 assert(ffmpeg_branding == "Chromium" ||
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8cfca22..4eb68d2 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -215,9 +215,11 @@
 
 static const OptionDef *find_option(const OptionDef *po, const char *name)
 {
+    const char *p = strchr(name, ':');
+    int len = p ? p - name : strlen(name);
+
     while (po->name) {
-        const char *end;
-        if (av_strstart(name, po->name, &end) && (!*end || *end == ':'))
+        if (!strncmp(name, po->name, len) && strlen(po->name) == len)
             break;
         po++;
     }
@@ -2101,7 +2103,7 @@
 }
 
 AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
-                                AVFormatContext *s, AVStream *st, const AVCodec *codec)
+                                AVFormatContext *s, AVStream *st, AVCodec *codec)
 {
     AVDictionary    *ret = NULL;
     AVDictionaryEntry *t = NULL;
@@ -2130,7 +2132,6 @@
     }
 
     while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) {
-        const AVClass *priv_class;
         char *p = strchr(t->key, ':');
 
         /* check stream specification in opt name */
@@ -2143,8 +2144,8 @@
 
         if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) ||
             !codec ||
-            ((priv_class = codec->priv_class) &&
-             av_opt_find(&priv_class, t->key, NULL, flags,
+            (codec->priv_class &&
+             av_opt_find(&codec->priv_class, t->key, NULL, flags,
                          AV_OPT_SEARCH_FAKE_OBJ)))
             av_dict_set(&ret, t->key, t->value, 0);
         else if (t->key[0] == prefix &&
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 5da9f4c..1917510 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -414,7 +414,7 @@
  * @return a pointer to the created dictionary
  */
 AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
-                                AVFormatContext *s, AVStream *st, const AVCodec *codec);
+                                AVFormatContext *s, AVStream *st, AVCodec *codec);
 
 /**
  * Setup AVCodecContext options for avformat_find_stream_info().
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2abbc0f..b446d9b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -136,7 +136,6 @@
 static unsigned dup_warning = 1000;
 static int nb_frames_drop = 0;
 static int64_t decode_error_stat[2];
-static unsigned nb_output_dumped = 0;
 
 static int want_sdp = 1;
 
@@ -394,30 +393,8 @@
 }
 #endif
 
-#ifdef __linux__
-#define SIGNAL(sig, func)               \
-    do {                                \
-        action.sa_handler = func;       \
-        sigaction(sig, &action, NULL);  \
-    } while (0)
-#else
-#define SIGNAL(sig, func) \
-    signal(sig, func)
-#endif
-
 void term_init(void)
 {
-#if defined __linux__
-    struct sigaction action = {0};
-    action.sa_handler = sigterm_handler;
-
-    /* block other interrupts while processing this one */
-    sigfillset(&action.sa_mask);
-
-    /* restart interruptible functions (i.e. don't fail with EINTR)  */
-    action.sa_flags = SA_RESTART;
-#endif
-
 #if HAVE_TERMIOS_H
     if (!run_as_daemon && stdin_interaction) {
         struct termios tty;
@@ -436,14 +413,14 @@
 
             tcsetattr (0, TCSANOW, &tty);
         }
-        SIGNAL(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
+        signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
     }
 #endif
 
-    SIGNAL(SIGINT , sigterm_handler); /* Interrupt (ANSI).    */
-    SIGNAL(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
+    signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).    */
+    signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
 #ifdef SIGXCPU
-    SIGNAL(SIGXCPU, sigterm_handler);
+    signal(SIGXCPU, sigterm_handler);
 #endif
 #ifdef SIGPIPE
     signal(SIGPIPE, SIG_IGN); /* Broken pipe (POSIX). */
@@ -688,7 +665,7 @@
     }
 }
 
-static void abort_codec_experimental(const AVCodec *c, int encoder)
+static void abort_codec_experimental(AVCodec *c, int encoder)
 {
     exit_program(1);
 }
@@ -1708,7 +1685,6 @@
     double speed;
     int64_t pts = INT64_MIN + 1;
     static int64_t last_time = -1;
-    static int first_report = 1;
     static int qp_histogram[52];
     int hours, mins, secs, us;
     const char *hours_sign;
@@ -1721,9 +1697,9 @@
     if (!is_last_report) {
         if (last_time == -1) {
             last_time = cur_time;
+            return;
         }
-        if (((cur_time - last_time) < stats_period && !first_report) ||
-            (first_report && nb_output_dumped < nb_output_files))
+        if ((cur_time - last_time) < 500000)
             return;
         last_time = cur_time;
     }
@@ -1900,8 +1876,6 @@
         }
     }
 
-    first_report = 0;
-
     if (is_last_report)
         print_final_stats(total_size);
 }
@@ -2943,7 +2917,7 @@
     InputStream *ist = input_streams[ist_index];
 
     if (ist->decoding_needed) {
-        const AVCodec *codec = ist->dec;
+        AVCodec *codec = ist->dec;
         if (!codec) {
             snprintf(error, error_len, "Decoder (codec %s) not found for input stream #%d:%d",
                     avcodec_get_name(ist->dec_ctx->codec_id), ist->file_index, ist->st->index);
@@ -2957,6 +2931,7 @@
         ist->dec_ctx->thread_safe_callbacks = 1;
 #endif
 
+        av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);
         if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
            (ist->decoding_needed & DECODING_FOR_OST)) {
             av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE);
@@ -3040,7 +3015,6 @@
     of->header_written = 1;
 
     av_dump_format(of->ctx, file_index, of->ctx->url, 1);
-    nb_output_dumped++;
 
     if (sdp_filename || want_sdp)
         print_sdp();
@@ -3375,7 +3349,7 @@
             ost->frame_rate = ist->framerate;
         if (ist && !ost->frame_rate.num)
             ost->frame_rate = ist->st->r_frame_rate;
-        if (ist && !ost->frame_rate.num && !ost->max_frame_rate.num) {
+        if (ist && !ost->frame_rate.num) {
             ost->frame_rate = (AVRational){25, 1};
             av_log(NULL, AV_LOG_WARNING,
                    "No information "
@@ -3385,11 +3359,6 @@
                    ost->file_index, ost->index);
         }
 
-        if (ost->max_frame_rate.num &&
-            (av_q2d(ost->frame_rate) > av_q2d(ost->max_frame_rate) ||
-            !ost->frame_rate.den))
-            ost->frame_rate = ost->max_frame_rate;
-
         if (ost->enc->supported_framerates && !ost->force_fps) {
             int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
             ost->frame_rate = ost->enc->supported_framerates[idx];
@@ -3522,7 +3491,7 @@
     int ret = 0;
 
     if (ost->encoding_needed) {
-        const AVCodec *codec = ost->enc;
+        AVCodec      *codec = ost->enc;
         AVCodecContext *dec = NULL;
         InputStream *ist;
 
@@ -4036,7 +4005,11 @@
         if(key == 'D') {
             debug = input_streams[0]->dec_ctx->debug << 1;
             if(!debug) debug = 1;
-            while (debug & FF_DEBUG_DCT_COEFF) //unsupported, would just crash
+            while(debug & (FF_DEBUG_DCT_COEFF
+#if FF_API_DEBUG_MV
+                                             |FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE
+#endif
+                                                                                  )) //unsupported, would just crash
                 debug += debug;
         }else{
             char buf[32];
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8813eaf..3b54dab 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -108,8 +108,6 @@
     int        nb_audio_sample_rate;
     SpecifierOpt *frame_rates;
     int        nb_frame_rates;
-    SpecifierOpt *max_frame_rates;
-    int        nb_max_frame_rates;
     SpecifierOpt *frame_sizes;
     int        nb_frame_sizes;
     SpecifierOpt *frame_pix_fmts;
@@ -307,7 +305,7 @@
 #define DECODING_FOR_FILTER 2
 
     AVCodecContext *dec_ctx;
-    const AVCodec *dec;
+    AVCodec *dec;
     AVFrame *decoded_frame;
     AVFrame *filter_frame; /* a ref of decoded_frame, to be sent to filters */
 
@@ -470,7 +468,7 @@
 
     AVCodecContext *enc_ctx;
     AVCodecParameters *ref_par; /* associated input codec parameters with encoders options applied */
-    const AVCodec *enc;
+    AVCodec *enc;
     int64_t max_frames;
     AVFrame *filtered_frame;
     AVFrame *last_frame;
@@ -481,7 +479,6 @@
 
     /* video only */
     AVRational frame_rate;
-    AVRational max_frame_rate;
     int is_cfr;
     int force_fps;
     int top_field_first;
@@ -617,7 +614,6 @@
 extern int exit_on_error;
 extern int abort_on_flags;
 extern int print_stats;
-extern int64_t stats_period;
 extern int qp_hist;
 extern int stdin_interaction;
 extern int frame_bits_per_raw_sample;
@@ -643,15 +639,24 @@
 void term_init(void);
 void term_exit(void);
 
+void reset_options(OptionsContext *o, int is_input);
 void show_usage(void);
 
+void opt_output_file(void *optctx, const char *filename);
+
 void remove_avoptions(AVDictionary **a, AVDictionary *b);
 void assert_avoptions(AVDictionary *m);
 
 int guess_input_channel_layout(InputStream *ist);
 
+enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx,
+                                    const AVCodec *codec, enum AVPixelFormat target);
+void choose_sample_fmt(AVStream *st, const AVCodec *codec);
+
 int configure_filtergraph(FilterGraph *fg);
+int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
 void check_filter_outputs(void);
+int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
 int filtergraph_is_simple(FilterGraph *fg);
 int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
 int init_complex_filtergraph(FilterGraph *fg);
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 4ab769c..e9e31e0 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -60,7 +60,7 @@
     }
 }
 
-static enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx,
+enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx,
                                     const AVCodec *codec, enum AVPixelFormat target)
 {
     if (codec && codec->pix_fmts) {
@@ -74,7 +74,7 @@
             p = get_compliance_unofficial_pix_fmts(enc_ctx->codec_id, p);
         }
         for (; *p != AV_PIX_FMT_NONE; p++) {
-            best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL);
+            best= avcodec_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL);
             if (*p == target)
                 break;
         }
@@ -91,6 +91,29 @@
     return target;
 }
 
+void choose_sample_fmt(AVStream *st, const AVCodec *codec)
+{
+    if (codec && codec->sample_fmts) {
+        const enum AVSampleFormat *p = codec->sample_fmts;
+        for (; *p != -1; p++) {
+            if (*p == st->codecpar->format)
+                break;
+        }
+        if (*p == -1) {
+            const AVCodecDescriptor *desc = avcodec_descriptor_get(codec->id);
+            if(desc && (desc->props & AV_CODEC_PROP_LOSSLESS) && av_get_sample_fmt_name(st->codecpar->format) > av_get_sample_fmt_name(codec->sample_fmts[0]))
+                av_log(NULL, AV_LOG_ERROR, "Conversion will not be lossless.\n");
+            if(av_get_sample_fmt_name(st->codecpar->format))
+            av_log(NULL, AV_LOG_WARNING,
+                   "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
+                   av_get_sample_fmt_name(st->codecpar->format),
+                   codec->name,
+                   av_get_sample_fmt_name(codec->sample_fmts[0]));
+            st->codecpar->format = codec->sample_fmts[0];
+        }
+    }
+}
+
 static char *choose_pix_fmts(OutputFilter *ofilter)
 {
     OutputStream *ost = ofilter->ost;
@@ -618,6 +641,13 @@
         pad_idx = 0;
     }
 
+    if (audio_volume != 256 && 0) {
+        char args[256];
+
+        snprintf(args, sizeof(args), "%f", audio_volume / 256.);
+        AUTO_INSERT_FILTER("-vol", "volume", args);
+    }
+
     if (ost->apad && of->shortest) {
         char args[256];
         int i;
@@ -645,8 +675,7 @@
     return 0;
 }
 
-static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter,
-                                   AVFilterInOut *out)
+int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
 {
     if (!ofilter->ost) {
         av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
@@ -1177,6 +1206,15 @@
     return 0;
 }
 
+int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
+{
+    int i;
+    for (i = 0; i < fg->nb_inputs; i++)
+        if (fg->inputs[i]->ist == ist)
+            return 1;
+    return 0;
+}
+
 int filtergraph_is_simple(FilterGraph *fg)
 {
     return !fg->graph_desc;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 85feeb8..7ee034c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -51,50 +51,49 @@
 #define SPECIFIER_OPT_FMT_f    "%f"
 #define SPECIFIER_OPT_FMT_dbl  "%lf"
 
-static const char *const opt_name_codec_names[]               = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL};
-static const char *const opt_name_audio_channels[]            = {"ac", NULL};
-static const char *const opt_name_audio_sample_rate[]         = {"ar", NULL};
-static const char *const opt_name_frame_rates[]               = {"r", NULL};
-static const char *const opt_name_max_frame_rates[]           = {"fpsmax", NULL};
-static const char *const opt_name_frame_sizes[]               = {"s", NULL};
-static const char *const opt_name_frame_pix_fmts[]            = {"pix_fmt", NULL};
-static const char *const opt_name_ts_scale[]                  = {"itsscale", NULL};
-static const char *const opt_name_hwaccels[]                  = {"hwaccel", NULL};
-static const char *const opt_name_hwaccel_devices[]           = {"hwaccel_device", NULL};
-static const char *const opt_name_hwaccel_output_formats[]    = {"hwaccel_output_format", NULL};
-static const char *const opt_name_autorotate[]                = {"autorotate", NULL};
-static const char *const opt_name_autoscale[]                 = {"autoscale", NULL};
-static const char *const opt_name_max_frames[]                = {"frames", "aframes", "vframes", "dframes", NULL};
-static const char *const opt_name_bitstream_filters[]         = {"bsf", "absf", "vbsf", NULL};
-static const char *const opt_name_codec_tags[]                = {"tag", "atag", "vtag", "stag", NULL};
-static const char *const opt_name_sample_fmts[]               = {"sample_fmt", NULL};
-static const char *const opt_name_qscale[]                    = {"q", "qscale", NULL};
-static const char *const opt_name_forced_key_frames[]         = {"forced_key_frames", NULL};
-static const char *const opt_name_force_fps[]                 = {"force_fps", NULL};
-static const char *const opt_name_frame_aspect_ratios[]       = {"aspect", NULL};
-static const char *const opt_name_rc_overrides[]              = {"rc_override", NULL};
-static const char *const opt_name_intra_matrices[]            = {"intra_matrix", NULL};
-static const char *const opt_name_inter_matrices[]            = {"inter_matrix", NULL};
-static const char *const opt_name_chroma_intra_matrices[]     = {"chroma_intra_matrix", NULL};
-static const char *const opt_name_top_field_first[]           = {"top", NULL};
-static const char *const opt_name_presets[]                   = {"pre", "apre", "vpre", "spre", NULL};
-static const char *const opt_name_copy_initial_nonkeyframes[] = {"copyinkfr", NULL};
-static const char *const opt_name_copy_prior_start[]          = {"copypriorss", NULL};
-static const char *const opt_name_filters[]                   = {"filter", "af", "vf", NULL};
-static const char *const opt_name_filter_scripts[]            = {"filter_script", NULL};
-static const char *const opt_name_reinit_filters[]            = {"reinit_filter", NULL};
-static const char *const opt_name_fix_sub_duration[]          = {"fix_sub_duration", NULL};
-static const char *const opt_name_canvas_sizes[]              = {"canvas_size", NULL};
-static const char *const opt_name_pass[]                      = {"pass", NULL};
-static const char *const opt_name_passlogfiles[]              = {"passlogfile", NULL};
-static const char *const opt_name_max_muxing_queue_size[]     = {"max_muxing_queue_size", NULL};
-static const char *const opt_name_muxing_queue_data_threshold[] = {"muxing_queue_data_threshold", NULL};
-static const char *const opt_name_guess_layout_max[]          = {"guess_layout_max", NULL};
-static const char *const opt_name_apad[]                      = {"apad", NULL};
-static const char *const opt_name_discard[]                   = {"discard", NULL};
-static const char *const opt_name_disposition[]               = {"disposition", NULL};
-static const char *const opt_name_time_bases[]                = {"time_base", NULL};
-static const char *const opt_name_enc_time_bases[]            = {"enc_time_base", NULL};
+static const char *opt_name_codec_names[]               = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL};
+static const char *opt_name_audio_channels[]            = {"ac", NULL};
+static const char *opt_name_audio_sample_rate[]         = {"ar", NULL};
+static const char *opt_name_frame_rates[]               = {"r", NULL};
+static const char *opt_name_frame_sizes[]               = {"s", NULL};
+static const char *opt_name_frame_pix_fmts[]            = {"pix_fmt", NULL};
+static const char *opt_name_ts_scale[]                  = {"itsscale", NULL};
+static const char *opt_name_hwaccels[]                  = {"hwaccel", NULL};
+static const char *opt_name_hwaccel_devices[]           = {"hwaccel_device", NULL};
+static const char *opt_name_hwaccel_output_formats[]    = {"hwaccel_output_format", NULL};
+static const char *opt_name_autorotate[]                = {"autorotate", NULL};
+static const char *opt_name_autoscale[]                 = {"autoscale", NULL};
+static const char *opt_name_max_frames[]                = {"frames", "aframes", "vframes", "dframes", NULL};
+static const char *opt_name_bitstream_filters[]         = {"bsf", "absf", "vbsf", NULL};
+static const char *opt_name_codec_tags[]                = {"tag", "atag", "vtag", "stag", NULL};
+static const char *opt_name_sample_fmts[]               = {"sample_fmt", NULL};
+static const char *opt_name_qscale[]                    = {"q", "qscale", NULL};
+static const char *opt_name_forced_key_frames[]         = {"forced_key_frames", NULL};
+static const char *opt_name_force_fps[]                 = {"force_fps", NULL};
+static const char *opt_name_frame_aspect_ratios[]       = {"aspect", NULL};
+static const char *opt_name_rc_overrides[]              = {"rc_override", NULL};
+static const char *opt_name_intra_matrices[]            = {"intra_matrix", NULL};
+static const char *opt_name_inter_matrices[]            = {"inter_matrix", NULL};
+static const char *opt_name_chroma_intra_matrices[]     = {"chroma_intra_matrix", NULL};
+static const char *opt_name_top_field_first[]           = {"top", NULL};
+static const char *opt_name_presets[]                   = {"pre", "apre", "vpre", "spre", NULL};
+static const char *opt_name_copy_initial_nonkeyframes[] = {"copyinkfr", NULL};
+static const char *opt_name_copy_prior_start[]          = {"copypriorss", NULL};
+static const char *opt_name_filters[]                   = {"filter", "af", "vf", NULL};
+static const char *opt_name_filter_scripts[]            = {"filter_script", NULL};
+static const char *opt_name_reinit_filters[]            = {"reinit_filter", NULL};
+static const char *opt_name_fix_sub_duration[]          = {"fix_sub_duration", NULL};
+static const char *opt_name_canvas_sizes[]              = {"canvas_size", NULL};
+static const char *opt_name_pass[]                      = {"pass", NULL};
+static const char *opt_name_passlogfiles[]              = {"passlogfile", NULL};
+static const char *opt_name_max_muxing_queue_size[]     = {"max_muxing_queue_size", NULL};
+static const char *opt_name_muxing_queue_data_threshold[] = {"muxing_queue_data_threshold", NULL};
+static const char *opt_name_guess_layout_max[]          = {"guess_layout_max", NULL};
+static const char *opt_name_apad[]                      = {"apad", NULL};
+static const char *opt_name_discard[]                   = {"discard", NULL};
+static const char *opt_name_disposition[]               = {"disposition", NULL};
+static const char *opt_name_time_bases[]                = {"time_base", NULL};
+static const char *opt_name_enc_time_bases[]            = {"enc_time_base", NULL};
 
 #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
 {\
@@ -175,7 +174,6 @@
 int filter_complex_nbthreads = 0;
 int vstats_version = 2;
 int auto_conversion_filters = 1;
-int64_t stats_period = 500000;
 
 
 static int intra_only         = 0;
@@ -284,21 +282,6 @@
     return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags);
 }
 
-static int opt_stats_period(void *optctx, const char *opt, const char *arg)
-{
-    int64_t user_stats_period = parse_time_or_die(opt, arg, 1);
-
-    if (user_stats_period <= 0) {
-        av_log(NULL, AV_LOG_ERROR, "stats_period %s must be positive.\n", arg);
-        return AVERROR(EINVAL);
-    }
-
-    stats_period = user_stats_period;
-    av_log(NULL, AV_LOG_INFO, "ffmpeg stats and -progress period set to %s.\n", arg);
-
-    return 0;
-}
-
 static int opt_sameq(void *optctx, const char *opt, const char *arg)
 {
     av_log(NULL, AV_LOG_ERROR, "Option '%s' was removed. "
@@ -766,13 +749,13 @@
     return codec;
 }
 
-static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st)
+static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st)
 {
     char *codec_name = NULL;
 
     MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
     if (codec_name) {
-        const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
+        AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
         st->codecpar->codec_id = codec->id;
         return codec;
     } else
@@ -868,6 +851,15 @@
         case AVMEDIA_TYPE_VIDEO:
             if(!ist->dec)
                 ist->dec = avcodec_find_decoder(par->codec_id);
+#if FF_API_LOWRES
+            if (st->codec->lowres) {
+                ist->dec_ctx->lowres = st->codec->lowres;
+                ist->dec_ctx->width  = st->codec->width;
+                ist->dec_ctx->height = st->codec->height;
+                ist->dec_ctx->coded_width  = st->codec->coded_width;
+                ist->dec_ctx->coded_height = st->codec->coded_height;
+            }
+#endif
 
             // avformat_find_stream_info() doesn't set this for us anymore.
             ist->dec_ctx->framerate = st->avg_frame_rate;
@@ -1689,7 +1681,7 @@
     AVStream *st;
     OutputStream *ost;
     AVCodecContext *video_enc;
-    char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = NULL;
+    char *frame_rate = NULL, *frame_aspect_ratio = NULL;
 
     ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
     st  = ost->st;
@@ -1700,21 +1692,8 @@
         av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
         exit_program(1);
     }
-
-    MATCH_PER_STREAM_OPT(max_frame_rates, str, max_frame_rate, oc, st);
-    if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
-        exit_program(1);
-    }
-
-    if (frame_rate && max_frame_rate) {
-        av_log(NULL, AV_LOG_ERROR, "Only one of -fpsmax and -r can be set for a stream.\n");
-        exit_program(1);
-    }
-
-    if ((frame_rate || max_frame_rate) &&
-        video_sync_method == VSYNC_PASSTHROUGH)
-        av_log(NULL, AV_LOG_ERROR, "Using -vsync 0 and -r/-fpsmax can produce invalid output files\n");
+    if (frame_rate && video_sync_method == VSYNC_PASSTHROUGH)
+        av_log(NULL, AV_LOG_ERROR, "Using -vsync 0 and -r can produce invalid output files\n");
 
     MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);
     if (frame_aspect_ratio) {
@@ -2655,9 +2634,6 @@
         if(o->recording_time != INT64_MAX)
             av_dict_set(&oc->metadata, "duration", NULL, 0);
         av_dict_set(&oc->metadata, "creation_time", NULL, 0);
-        av_dict_set(&oc->metadata, "company_name", NULL, 0);
-        av_dict_set(&oc->metadata, "product_name", NULL, 0);
-        av_dict_set(&oc->metadata, "product_version", NULL, 0);
     }
     if (!o->metadata_streams_manual)
         for (i = of->ost_index; i < nb_output_streams; i++) {
@@ -3581,8 +3557,6 @@
         "enable automatic conversion filters globally" },
     { "stats",          OPT_BOOL,                                    { &print_stats },
         "print progress report during encoding", },
-    { "stats_period",    HAS_ARG | OPT_EXPERT,                       { .func_arg = opt_stats_period },
-        "set the period at which ffmpeg updates stats and -progress output", "time" },
     { "attach",         HAS_ARG | OPT_PERFILE | OPT_EXPERT |
                         OPT_OUTPUT,                                  { .func_arg = opt_attach },
         "add an attachment to the output file", "filename" },
@@ -3594,7 +3568,7 @@
     { "debug_ts",       OPT_BOOL | OPT_EXPERT,                       { &debug_ts },
         "print timestamp debugging info" },
     { "max_error_rate",  HAS_ARG | OPT_FLOAT,                        { &max_error_rate },
-        "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
+        "ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
     { "discard",        OPT_STRING | HAS_ARG | OPT_SPEC |
                         OPT_INPUT,                                   { .off = OFFSET(discard) },
         "discard", "" },
@@ -3613,9 +3587,6 @@
     { "r",            OPT_VIDEO | HAS_ARG  | OPT_STRING | OPT_SPEC |
                       OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(frame_rates) },
         "set frame rate (Hz value, fraction or abbreviation)", "rate" },
-    { "fpsmax",       OPT_VIDEO | HAS_ARG  | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(max_frame_rates) },
-        "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
     { "s",            OPT_VIDEO | HAS_ARG | OPT_SUBTITLE | OPT_STRING | OPT_SPEC |
                       OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(frame_sizes) },
         "set frame size (WxH or abbreviation)", "size" },
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index e14c800..9ff0425 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -36,7 +36,6 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/dict.h"
-#include "libavutil/fifo.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/samplefmt.h"
 #include "libavutil/avassert.h"
@@ -112,12 +111,13 @@
 static unsigned sws_flags = SWS_BICUBIC;
 
 typedef struct MyAVPacketList {
-    AVPacket *pkt;
+    AVPacket pkt;
+    struct MyAVPacketList *next;
     int serial;
 } MyAVPacketList;
 
 typedef struct PacketQueue {
-    AVFifoBuffer *pkt_list;
+    MyAVPacketList *first_pkt, *last_pkt;
     int nb_packets;
     int size;
     int64_t duration;
@@ -187,7 +187,7 @@
 };
 
 typedef struct Decoder {
-    AVPacket *pkt;
+    AVPacket pkt;
     PacketQueue *queue;
     AVCodecContext *avctx;
     int pkt_serial;
@@ -361,6 +361,8 @@
 static int is_full_screen;
 static int64_t audio_callback_time;
 
+static AVPacket flush_pkt;
+
 #define FF_QUIT_EVENT    (SDL_USEREVENT + 2)
 
 static SDL_Window *window;
@@ -425,23 +427,28 @@
 
 static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
 {
-    MyAVPacketList pkt1;
+    MyAVPacketList *pkt1;
 
     if (q->abort_request)
        return -1;
 
-    if (av_fifo_space(q->pkt_list) < sizeof(pkt1)) {
-        if (av_fifo_grow(q->pkt_list, sizeof(pkt1)) < 0)
-            return -1;
-    }
+    pkt1 = av_malloc(sizeof(MyAVPacketList));
+    if (!pkt1)
+        return -1;
+    pkt1->pkt = *pkt;
+    pkt1->next = NULL;
+    if (pkt == &flush_pkt)
+        q->serial++;
+    pkt1->serial = q->serial;
 
-    pkt1.pkt = pkt;
-    pkt1.serial = q->serial;
-
-    av_fifo_generic_write(q->pkt_list, &pkt1, sizeof(pkt1), NULL);
+    if (!q->last_pkt)
+        q->first_pkt = pkt1;
+    else
+        q->last_pkt->next = pkt1;
+    q->last_pkt = pkt1;
     q->nb_packets++;
-    q->size += pkt1.pkt->size + sizeof(pkt1);
-    q->duration += pkt1.pkt->duration;
+    q->size += pkt1->pkt.size + sizeof(*pkt1);
+    q->duration += pkt1->pkt.duration;
     /* XXX: should duplicate packet data in DV case */
     SDL_CondSignal(q->cond);
     return 0;
@@ -449,28 +456,24 @@
 
 static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
 {
-    AVPacket *pkt1;
     int ret;
 
-    pkt1 = av_packet_alloc();
-    if (!pkt1) {
-        av_packet_unref(pkt);
-        return -1;
-    }
-    av_packet_move_ref(pkt1, pkt);
-
     SDL_LockMutex(q->mutex);
-    ret = packet_queue_put_private(q, pkt1);
+    ret = packet_queue_put_private(q, pkt);
     SDL_UnlockMutex(q->mutex);
 
-    if (ret < 0)
-        av_packet_free(&pkt1);
+    if (pkt != &flush_pkt && ret < 0)
+        av_packet_unref(pkt);
 
     return ret;
 }
 
-static int packet_queue_put_nullpacket(PacketQueue *q, AVPacket *pkt, int stream_index)
+static int packet_queue_put_nullpacket(PacketQueue *q, int stream_index)
 {
+    AVPacket pkt1, *pkt = &pkt1;
+    av_init_packet(pkt);
+    pkt->data = NULL;
+    pkt->size = 0;
     pkt->stream_index = stream_index;
     return packet_queue_put(q, pkt);
 }
@@ -479,9 +482,6 @@
 static int packet_queue_init(PacketQueue *q)
 {
     memset(q, 0, sizeof(PacketQueue));
-    q->pkt_list = av_fifo_alloc(sizeof(MyAVPacketList));
-    if (!q->pkt_list)
-        return AVERROR(ENOMEM);
     q->mutex = SDL_CreateMutex();
     if (!q->mutex) {
         av_log(NULL, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError());
@@ -498,24 +498,25 @@
 
 static void packet_queue_flush(PacketQueue *q)
 {
-    MyAVPacketList pkt1;
+    MyAVPacketList *pkt, *pkt1;
 
     SDL_LockMutex(q->mutex);
-    while (av_fifo_size(q->pkt_list) >= sizeof(pkt1)) {
-        av_fifo_generic_read(q->pkt_list, &pkt1, sizeof(pkt1), NULL);
-        av_packet_free(&pkt1.pkt);
+    for (pkt = q->first_pkt; pkt; pkt = pkt1) {
+        pkt1 = pkt->next;
+        av_packet_unref(&pkt->pkt);
+        av_freep(&pkt);
     }
+    q->last_pkt = NULL;
+    q->first_pkt = NULL;
     q->nb_packets = 0;
     q->size = 0;
     q->duration = 0;
-    q->serial++;
     SDL_UnlockMutex(q->mutex);
 }
 
 static void packet_queue_destroy(PacketQueue *q)
 {
     packet_queue_flush(q);
-    av_fifo_freep(&q->pkt_list);
     SDL_DestroyMutex(q->mutex);
     SDL_DestroyCond(q->cond);
 }
@@ -535,14 +536,14 @@
 {
     SDL_LockMutex(q->mutex);
     q->abort_request = 0;
-    q->serial++;
+    packet_queue_put_private(q, &flush_pkt);
     SDL_UnlockMutex(q->mutex);
 }
 
 /* return < 0 if aborted, 0 if no packet and > 0 if packet.  */
 static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial)
 {
-    MyAVPacketList pkt1;
+    MyAVPacketList *pkt1;
     int ret;
 
     SDL_LockMutex(q->mutex);
@@ -553,15 +554,18 @@
             break;
         }
 
-        if (av_fifo_size(q->pkt_list) >= sizeof(pkt1)) {
-            av_fifo_generic_read(q->pkt_list, &pkt1, sizeof(pkt1), NULL);
+        pkt1 = q->first_pkt;
+        if (pkt1) {
+            q->first_pkt = pkt1->next;
+            if (!q->first_pkt)
+                q->last_pkt = NULL;
             q->nb_packets--;
-            q->size -= pkt1.pkt->size + sizeof(pkt1);
-            q->duration -= pkt1.pkt->duration;
-            av_packet_move_ref(pkt, pkt1.pkt);
+            q->size -= pkt1->pkt.size + sizeof(*pkt1);
+            q->duration -= pkt1->pkt.duration;
+            *pkt = pkt1->pkt;
             if (serial)
-                *serial = pkt1.serial;
-            av_packet_free(&pkt1.pkt);
+                *serial = pkt1->serial;
+            av_free(pkt1);
             ret = 1;
             break;
         } else if (!block) {
@@ -575,23 +579,21 @@
     return ret;
 }
 
-static int decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue, SDL_cond *empty_queue_cond) {
+static void decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue, SDL_cond *empty_queue_cond) {
     memset(d, 0, sizeof(Decoder));
-    d->pkt = av_packet_alloc();
-    if (!d->pkt)
-        return AVERROR(ENOMEM);
     d->avctx = avctx;
     d->queue = queue;
     d->empty_queue_cond = empty_queue_cond;
     d->start_pts = AV_NOPTS_VALUE;
     d->pkt_serial = -1;
-    return 0;
 }
 
 static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
     int ret = AVERROR(EAGAIN);
 
     for (;;) {
+        AVPacket pkt;
+
         if (d->queue->serial == d->pkt_serial) {
             do {
                 if (d->queue->abort_request)
@@ -637,48 +639,49 @@
             if (d->queue->nb_packets == 0)
                 SDL_CondSignal(d->empty_queue_cond);
             if (d->packet_pending) {
+                av_packet_move_ref(&pkt, &d->pkt);
                 d->packet_pending = 0;
             } else {
-                int old_serial = d->pkt_serial;
-                if (packet_queue_get(d->queue, d->pkt, 1, &d->pkt_serial) < 0)
+                if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
                     return -1;
-                if (old_serial != d->pkt_serial) {
-                    avcodec_flush_buffers(d->avctx);
-                    d->finished = 0;
-                    d->next_pts = d->start_pts;
-                    d->next_pts_tb = d->start_pts_tb;
-                }
             }
             if (d->queue->serial == d->pkt_serial)
                 break;
-            av_packet_unref(d->pkt);
+            av_packet_unref(&pkt);
         } while (1);
 
-        if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
-            int got_frame = 0;
-            ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, d->pkt);
-            if (ret < 0) {
-                ret = AVERROR(EAGAIN);
-            } else {
-                if (got_frame && !d->pkt->data) {
-                    d->packet_pending = 1;
-                }
-                ret = got_frame ? 0 : (d->pkt->data ? AVERROR(EAGAIN) : AVERROR_EOF);
-            }
-            av_packet_unref(d->pkt);
+        if (pkt.data == flush_pkt.data) {
+            avcodec_flush_buffers(d->avctx);
+            d->finished = 0;
+            d->next_pts = d->start_pts;
+            d->next_pts_tb = d->start_pts_tb;
         } else {
-            if (avcodec_send_packet(d->avctx, d->pkt) == AVERROR(EAGAIN)) {
-                av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");
-                d->packet_pending = 1;
+            if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+                int got_frame = 0;
+                ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, &pkt);
+                if (ret < 0) {
+                    ret = AVERROR(EAGAIN);
+                } else {
+                    if (got_frame && !pkt.data) {
+                       d->packet_pending = 1;
+                       av_packet_move_ref(&d->pkt, &pkt);
+                    }
+                    ret = got_frame ? 0 : (pkt.data ? AVERROR(EAGAIN) : AVERROR_EOF);
+                }
             } else {
-                av_packet_unref(d->pkt);
+                if (avcodec_send_packet(d->avctx, &pkt) == AVERROR(EAGAIN)) {
+                    av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");
+                    d->packet_pending = 1;
+                    av_packet_move_ref(&d->pkt, &pkt);
+                }
             }
+            av_packet_unref(&pkt);
         }
     }
 }
 
 static void decoder_destroy(Decoder *d) {
-    av_packet_free(&d->pkt);
+    av_packet_unref(&d->pkt);
     avcodec_free_context(&d->avctx);
 }
 
@@ -1148,8 +1151,6 @@
         if (realloc_texture(&s->vis_texture, SDL_PIXELFORMAT_ARGB8888, s->width, s->height, SDL_BLENDMODE_NONE, 1) < 0)
             return;
 
-        if (s->xpos >= s->width)
-            s->xpos = 0;
         nb_display_channels= FFMIN(nb_display_channels, 2);
         if (rdft_bits != s->rdft_bits) {
             av_rdft_end(s->rdft);
@@ -1199,6 +1200,8 @@
         }
         if (!s->paused)
             s->xpos++;
+        if (s->xpos >= s->width)
+            s->xpos= s->xleft;
     }
 }
 
@@ -1644,37 +1647,37 @@
             }
 
             if (is->subtitle_st) {
-                while (frame_queue_nb_remaining(&is->subpq) > 0) {
-                    sp = frame_queue_peek(&is->subpq);
+                    while (frame_queue_nb_remaining(&is->subpq) > 0) {
+                        sp = frame_queue_peek(&is->subpq);
 
-                    if (frame_queue_nb_remaining(&is->subpq) > 1)
-                        sp2 = frame_queue_peek_next(&is->subpq);
-                    else
-                        sp2 = NULL;
+                        if (frame_queue_nb_remaining(&is->subpq) > 1)
+                            sp2 = frame_queue_peek_next(&is->subpq);
+                        else
+                            sp2 = NULL;
 
-                    if (sp->serial != is->subtitleq.serial
-                            || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
-                            || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
-                    {
-                        if (sp->uploaded) {
-                            int i;
-                            for (i = 0; i < sp->sub.num_rects; i++) {
-                                AVSubtitleRect *sub_rect = sp->sub.rects[i];
-                                uint8_t *pixels;
-                                int pitch, j;
+                        if (sp->serial != is->subtitleq.serial
+                                || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
+                                || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
+                        {
+                            if (sp->uploaded) {
+                                int i;
+                                for (i = 0; i < sp->sub.num_rects; i++) {
+                                    AVSubtitleRect *sub_rect = sp->sub.rects[i];
+                                    uint8_t *pixels;
+                                    int pitch, j;
 
-                                if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) {
-                                    for (j = 0; j < sub_rect->h; j++, pixels += pitch)
-                                        memset(pixels, 0, sub_rect->w << 2);
-                                    SDL_UnlockTexture(is->sub_texture);
+                                    if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) {
+                                        for (j = 0; j < sub_rect->h; j++, pixels += pitch)
+                                            memset(pixels, 0, sub_rect->w << 2);
+                                        SDL_UnlockTexture(is->sub_texture);
+                                    }
                                 }
                             }
+                            frame_queue_next(&is->subpq);
+                        } else {
+                            break;
                         }
-                        frame_queue_next(&is->subpq);
-                    } else {
-                        break;
                     }
-                }
             }
 
             frame_queue_next(&is->pictq);
@@ -2573,7 +2576,7 @@
 {
     AVFormatContext *ic = is->ic;
     AVCodecContext *avctx;
-    const AVCodec *codec;
+    AVCodec *codec;
     const char *forced_codec_name = NULL;
     AVDictionary *opts = NULL;
     AVDictionaryEntry *t = NULL;
@@ -2628,6 +2631,8 @@
         av_dict_set(&opts, "threads", "auto", 0);
     if (stream_lowres)
         av_dict_set_int(&opts, "lowres", stream_lowres, 0);
+    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
+        av_dict_set(&opts, "refcounted_frames", "1", 0);
     if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {
         goto fail;
     }
@@ -2680,8 +2685,7 @@
         is->audio_stream = stream_index;
         is->audio_st = ic->streams[stream_index];
 
-        if ((ret = decoder_init(&is->auddec, avctx, &is->audioq, is->continue_read_thread)) < 0)
-            goto fail;
+        decoder_init(&is->auddec, avctx, &is->audioq, is->continue_read_thread);
         if ((is->ic->iformat->flags & (AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK)) && !is->ic->iformat->read_seek) {
             is->auddec.start_pts = is->audio_st->start_time;
             is->auddec.start_pts_tb = is->audio_st->time_base;
@@ -2694,8 +2698,7 @@
         is->video_stream = stream_index;
         is->video_st = ic->streams[stream_index];
 
-        if ((ret = decoder_init(&is->viddec, avctx, &is->videoq, is->continue_read_thread)) < 0)
-            goto fail;
+        decoder_init(&is->viddec, avctx, &is->videoq, is->continue_read_thread);
         if ((ret = decoder_start(&is->viddec, video_thread, "video_decoder", is)) < 0)
             goto out;
         is->queue_attachments_req = 1;
@@ -2704,8 +2707,7 @@
         is->subtitle_stream = stream_index;
         is->subtitle_st = ic->streams[stream_index];
 
-        if ((ret = decoder_init(&is->subdec, avctx, &is->subtitleq, is->continue_read_thread)) < 0)
-            goto fail;
+        decoder_init(&is->subdec, avctx, &is->subtitleq, is->continue_read_thread);
         if ((ret = decoder_start(&is->subdec, subtitle_thread, "subtitle_decoder", is)) < 0)
             goto out;
         break;
@@ -2758,7 +2760,7 @@
     AVFormatContext *ic = NULL;
     int err, i, ret;
     int st_index[AVMEDIA_TYPE_NB];
-    AVPacket *pkt = NULL;
+    AVPacket pkt1, *pkt = &pkt1;
     int64_t stream_start_time;
     int pkt_in_play_range = 0;
     AVDictionaryEntry *t;
@@ -2775,12 +2777,6 @@
     memset(st_index, -1, sizeof(st_index));
     is->eof = 0;
 
-    pkt = av_packet_alloc();
-    if (!pkt) {
-        av_log(NULL, AV_LOG_FATAL, "Could not allocate packet.\n");
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
     ic = avformat_alloc_context();
     if (!ic) {
         av_log(NULL, AV_LOG_FATAL, "Could not allocate context.\n");
@@ -2964,12 +2960,18 @@
                 av_log(NULL, AV_LOG_ERROR,
                        "%s: error while seeking\n", is->ic->url);
             } else {
-                if (is->audio_stream >= 0)
+                if (is->audio_stream >= 0) {
                     packet_queue_flush(&is->audioq);
-                if (is->subtitle_stream >= 0)
+                    packet_queue_put(&is->audioq, &flush_pkt);
+                }
+                if (is->subtitle_stream >= 0) {
                     packet_queue_flush(&is->subtitleq);
-                if (is->video_stream >= 0)
+                    packet_queue_put(&is->subtitleq, &flush_pkt);
+                }
+                if (is->video_stream >= 0) {
                     packet_queue_flush(&is->videoq);
+                    packet_queue_put(&is->videoq, &flush_pkt);
+                }
                 if (is->seek_flags & AVSEEK_FLAG_BYTE) {
                    set_clock(&is->extclk, NAN, 0);
                 } else {
@@ -2984,10 +2986,11 @@
         }
         if (is->queue_attachments_req) {
             if (is->video_st && is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC) {
-                if ((ret = av_packet_ref(pkt, &is->video_st->attached_pic)) < 0)
+                AVPacket copy;
+                if ((ret = av_packet_ref(&copy, &is->video_st->attached_pic)) < 0)
                     goto fail;
-                packet_queue_put(&is->videoq, pkt);
-                packet_queue_put_nullpacket(&is->videoq, pkt, is->video_stream);
+                packet_queue_put(&is->videoq, &copy);
+                packet_queue_put_nullpacket(&is->videoq, is->video_stream);
             }
             is->queue_attachments_req = 0;
         }
@@ -3018,11 +3021,11 @@
         if (ret < 0) {
             if ((ret == AVERROR_EOF || avio_feof(ic->pb)) && !is->eof) {
                 if (is->video_stream >= 0)
-                    packet_queue_put_nullpacket(&is->videoq, pkt, is->video_stream);
+                    packet_queue_put_nullpacket(&is->videoq, is->video_stream);
                 if (is->audio_stream >= 0)
-                    packet_queue_put_nullpacket(&is->audioq, pkt, is->audio_stream);
+                    packet_queue_put_nullpacket(&is->audioq, is->audio_stream);
                 if (is->subtitle_stream >= 0)
-                    packet_queue_put_nullpacket(&is->subtitleq, pkt, is->subtitle_stream);
+                    packet_queue_put_nullpacket(&is->subtitleq, is->subtitle_stream);
                 is->eof = 1;
             }
             if (ic->pb && ic->pb->error) {
@@ -3063,7 +3066,6 @@
     if (ic && !is->ic)
         avformat_close_input(&ic);
 
-    av_packet_free(&pkt);
     if (ret != 0) {
         SDL_Event event;
 
@@ -3736,6 +3738,9 @@
     SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
     SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
 
+    av_init_packet(&flush_pkt);
+    flush_pkt.data = (uint8_t *)&flush_pkt;
+
     if (!display_disable) {
         int flags = SDL_WINDOW_HIDDEN;
         if (alwaysontop)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 1eb9d88..3453aa0 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -1672,6 +1672,24 @@
     return 0;
 }
 
+static const char *xml_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
+{
+    const char *p;
+
+    for (p = src; *p; p++) {
+        switch (*p) {
+        case '&' : av_bprintf(dst, "%s", "&amp;");  break;
+        case '<' : av_bprintf(dst, "%s", "&lt;");   break;
+        case '>' : av_bprintf(dst, "%s", "&gt;");   break;
+        case '"' : av_bprintf(dst, "%s", "&quot;"); break;
+        case '\'': av_bprintf(dst, "%s", "&apos;"); break;
+        default: av_bprint_chars(dst, *p, 1);
+        }
+    }
+
+    return dst->str;
+}
+
 #define XML_INDENT() printf("%*c", xml->indent_level * 4, ' ')
 
 static void xml_print_section_header(WriterContext *wctx)
@@ -1743,22 +1761,14 @@
 
     if (section->flags & SECTION_FLAG_HAS_VARIABLE_FIELDS) {
         XML_INDENT();
-        av_bprint_escape(&buf, key, NULL,
-                         AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
         printf("<%s key=\"%s\"",
-               section->element_name, buf.str);
+               section->element_name, xml_escape_str(&buf, key, wctx));
         av_bprint_clear(&buf);
-
-        av_bprint_escape(&buf, value, NULL,
-                         AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
-        printf(" value=\"%s\"/>\n", buf.str);
+        printf(" value=\"%s\"/>\n", xml_escape_str(&buf, value, wctx));
     } else {
         if (wctx->nb_item[wctx->level])
             printf(" ");
-
-        av_bprint_escape(&buf, value, NULL,
-                         AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
-        printf("%s=\"%s\"", key, buf.str);
+        printf("%s=\"%s\"", key, xml_escape_str(&buf, value, wctx));
     }
 
     av_bprint_finalize(&buf, NULL);
@@ -2158,6 +2168,8 @@
     print_time("dts_time",        pkt->dts, &st->time_base);
     print_duration_ts("duration",        pkt->duration);
     print_duration_time("duration_time", pkt->duration, &st->time_base);
+    print_duration_ts("convergence_duration", pkt->convergence_duration);
+    print_duration_time("convergence_duration_time", pkt->convergence_duration, &st->time_base);
     print_val("size",             pkt->size, unit_byte_str);
     if (pkt->pos != -1) print_fmt    ("pos", "%"PRId64, pkt->pos);
     else                print_str_opt("pos", "N/A");
@@ -2621,6 +2633,10 @@
     s = av_get_media_type_string(par->codec_type);
     if (s) print_str    ("codec_type", s);
     else   print_str_opt("codec_type", "unknown");
+#if FF_API_LAVF_AVCTX
+    if (dec_ctx)
+        print_q("codec_time_base", dec_ctx->time_base, '/');
+#endif
 
     /* print AVI/FourCC tag */
     print_str("codec_tag_string",    av_fourcc2str(par->codec_tag));
@@ -2630,11 +2646,13 @@
     case AVMEDIA_TYPE_VIDEO:
         print_int("width",        par->width);
         print_int("height",       par->height);
+#if FF_API_LAVF_AVCTX
         if (dec_ctx) {
             print_int("coded_width",  dec_ctx->coded_width);
             print_int("coded_height", dec_ctx->coded_height);
             print_int("closed_captions", !!(dec_ctx->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
         }
+#endif
         print_int("has_b_frames", par->video_delay);
         sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
         if (sar.num) {
@@ -2672,6 +2690,15 @@
         else
             print_str_opt("field_order", "unknown");
 
+#if FF_API_PRIVATE_OPT
+        if (dec_ctx && dec_ctx->timecode_frame_start >= 0) {
+            char tcbuf[AV_TIMECODE_STR_SIZE];
+            av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);
+            print_str("timecode", tcbuf);
+        } else {
+            print_str_opt("timecode", "N/A");
+        }
+#endif
         if (dec_ctx)
             print_int("refs", dec_ctx->refs);
         break;
@@ -2729,10 +2756,10 @@
     print_time("duration",    stream->duration, &stream->time_base);
     if (par->bit_rate > 0)     print_val    ("bit_rate", par->bit_rate, unit_bit_per_second_str);
     else                       print_str_opt("bit_rate", "N/A");
-    if (dec_ctx && dec_ctx->rc_max_rate > 0)
-        print_val ("max_bit_rate", dec_ctx->rc_max_rate, unit_bit_per_second_str);
-    else
-        print_str_opt("max_bit_rate", "N/A");
+#if FF_API_LAVF_AVCTX
+    if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str);
+    else                                print_str_opt("max_bit_rate", "N/A");
+#endif
     if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
     else                                             print_str_opt("bits_per_raw_sample", "N/A");
     if (stream->nb_frames) print_fmt    ("nb_frames", "%"PRId64, stream->nb_frames);
@@ -2986,7 +3013,7 @@
     for (i = 0; i < fmt_ctx->nb_streams; i++) {
         InputStream *ist = &ifile->streams[i];
         AVStream *stream = fmt_ctx->streams[i];
-        const AVCodec *codec;
+        AVCodec *codec;
 
         ist->st = stream;
 
@@ -3024,6 +3051,12 @@
             }
 
             ist->dec_ctx->pkt_timebase = stream->time_base;
+            ist->dec_ctx->framerate = stream->avg_frame_rate;
+#if FF_API_LAVF_AVCTX
+            ist->dec_ctx->properties = stream->codec->properties;
+            ist->dec_ctx->coded_width = stream->codec->coded_width;
+            ist->dec_ctx->coded_height = stream->codec->coded_height;
+#endif
 
             if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
                 av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",
@@ -3224,6 +3257,9 @@
             PRINT_PIX_FMT_FLAG(HWACCEL,   "hwaccel");
             PRINT_PIX_FMT_FLAG(PLANAR,    "planar");
             PRINT_PIX_FMT_FLAG(RGB,       "rgb");
+#if FF_API_PSEUDOPAL
+            PRINT_PIX_FMT_FLAG(PSEUDOPAL, "pseudopal");
+#endif
             PRINT_PIX_FMT_FLAG(ALPHA,     "alpha");
             writer_print_section_footer(w);
         }
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 4d58b09..336c651 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -30,7 +30,6 @@
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c
index 53e939d..aa2318f 100644
--- a/libavcodec/8bps.c
+++ b/libavcodec/8bps.c
@@ -122,7 +122,7 @@
     }
 
     if (avctx->bits_per_coded_sample <= 8) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt,
                                                      AV_PKT_DATA_PALETTE,
                                                      &size);
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 81cc164..4507818 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -48,6 +48,7 @@
        mediacodec.o                                                     \
        mpeg12framerate.o                                                \
        options.o                                                        \
+       mjpegenc_huffman.o                                               \
        parser.o                                                         \
        parsers.o                                                        \
        profiles.o                                                       \
@@ -68,10 +69,10 @@
 OBJS-$(CONFIG_BLOCKDSP)                += blockdsp.o
 OBJS-$(CONFIG_BSWAPDSP)                += bswapdsp.o
 OBJS-$(CONFIG_CABAC)                   += cabac.o
-OBJS-$(CONFIG_CBS)                     += cbs.o cbs_bsf.o
+OBJS-$(CONFIG_CBS)                     += cbs.o
 OBJS-$(CONFIG_CBS_AV1)                 += cbs_av1.o
-OBJS-$(CONFIG_CBS_H264)                += cbs_h2645.o cbs_sei.o h2645_parse.o
-OBJS-$(CONFIG_CBS_H265)                += cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H264)                += cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H265)                += cbs_h2645.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)                += cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)               += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9)                 += cbs_vp9.o
@@ -82,9 +83,10 @@
 OBJS-$(CONFIG_FAANDCT)                 += faandct.o
 OBJS-$(CONFIG_FAANIDCT)                += faanidct.o
 OBJS-$(CONFIG_FDCTDSP)                 += fdctdsp.o jfdctfst.o jfdctint.o
-FFT-OBJS-$(CONFIG_HARDCODED_TABLES)    += cos_tables.o
-OBJS-$(CONFIG_FFT)                     += avfft.o fft_float.o fft_fixed_32.o \
-                                          fft_init_table.o $(FFT-OBJS-yes)
+FFT-OBJS-$(CONFIG_HARDCODED_TABLES)    += cos_tables.o cos_fixed_tables.o
+OBJS-$(CONFIG_FFT)                     += avfft.o fft_fixed.o fft_float.o \
+                                          fft_fixed_32.o fft_init_table.o \
+                                          $(FFT-OBJS-yes)
 OBJS-$(CONFIG_FLACDSP)                 += flacdsp.o
 OBJS-$(CONFIG_FMTCONVERT)              += fmtconvert.o
 OBJS-$(CONFIG_GOLOMB)                  += golomb.o
@@ -113,7 +115,7 @@
 OBJS-$(CONFIG_LPC)                     += lpc.o
 OBJS-$(CONFIG_LSP)                     += lsp.o
 OBJS-$(CONFIG_LZF)                     += lzf.o
-OBJS-$(CONFIG_MDCT)                    += mdct_float.o mdct_fixed_32.o
+OBJS-$(CONFIG_MDCT)                    += mdct_fixed.o mdct_float.o mdct_fixed_32.o
 OBJS-$(CONFIG_ME_CMP)                  += me_cmp.o
 OBJS-$(CONFIG_MEDIACODEC)              += mediacodecdec_common.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o
 OBJS-$(CONFIG_MPEG_ER)                 += mpeg_er.o
@@ -140,7 +142,7 @@
 OBJS-$(CONFIG_RDFT)                    += rdft.o
 OBJS-$(CONFIG_RV34DSP)                 += rv34dsp.o
 OBJS-$(CONFIG_SHARED)                  += log2_tab.o reverse.o
-OBJS-$(CONFIG_SINEWIN)                 += sinewin.o
+OBJS-$(CONFIG_SINEWIN)                 += sinewin.o sinewin_fixed.o
 OBJS-$(CONFIG_SNAPPY)                  += snappy.o
 OBJS-$(CONFIG_STARTCODE)               += startcode.o
 OBJS-$(CONFIG_TEXTUREDSP)              += texturedsp.o
@@ -160,10 +162,10 @@
 OBJS-$(CONFIG_ZERO12V_DECODER)         += 012v.o
 OBJS-$(CONFIG_A64MULTI_ENCODER)        += a64multienc.o elbg.o
 OBJS-$(CONFIG_A64MULTI5_ENCODER)       += a64multienc.o elbg.o
-OBJS-$(CONFIG_AAC_DECODER)             += aacdec.o aactab.o aacsbr.o aacps_common.o aacps_float.o \
+OBJS-$(CONFIG_AAC_DECODER)             += aacdec.o aactab.o aacsbr.o aacps_float.o \
                                           mpeg4audio.o kbdwin.o \
                                           sbrdsp.o aacpsdsp_float.o cbrt_data.o
-OBJS-$(CONFIG_AAC_FIXED_DECODER)       += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_common.o aacps_fixed.o \
+OBJS-$(CONFIG_AAC_FIXED_DECODER)       += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \
                                           mpeg4audio.o kbdwin.o \
                                           sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o
 OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o aacenctab.o    \
@@ -172,14 +174,14 @@
                                           aacenc_tns.o \
                                           aacenc_ltp.o \
                                           aacenc_pred.o \
-                                          psymodel.o mpeg4audio.o kbdwin.o
+                                          psymodel.o mpeg4audio.o kbdwin.o cbrt_data.o
 OBJS-$(CONFIG_AAC_MF_ENCODER)          += mfenc.o mf_utils.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
 OBJS-$(CONFIG_AC3_DECODER)             += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o
 OBJS-$(CONFIG_AC3_FIXED_DECODER)       += ac3dec_fixed.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o
 OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3enc.o ac3tab.o \
                                           ac3.o kbdwin.o
-OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o kbdwin.o
+OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AC3_MF_ENCODER)          += mfenc.o mf_utils.o
 OBJS-$(CONFIG_ACELP_KELVIN_DECODER)    += g729dec.o lsp.o celp_math.o celp_filters.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o g729postfilter.o
 OBJS-$(CONFIG_AGM_DECODER)             += agm.o
@@ -230,7 +232,7 @@
 OBJS-$(CONFIG_AURA2_DECODER)           += aura.o
 OBJS-$(CONFIG_AV1_DECODER)             += av1dec.o
 OBJS-$(CONFIG_AV1_CUVID_DECODER)       += cuviddec.o
-OBJS-$(CONFIG_AVRN_DECODER)            += avrndec.o
+OBJS-$(CONFIG_AVRN_DECODER)            += avrndec.o mjpegdec.o
 OBJS-$(CONFIG_AVRP_DECODER)            += r210dec.o
 OBJS-$(CONFIG_AVRP_ENCODER)            += r210enc.o
 OBJS-$(CONFIG_AVS_DECODER)             += avs.o
@@ -258,7 +260,7 @@
 OBJS-$(CONFIG_CDTOONS_DECODER)         += cdtoons.o
 OBJS-$(CONFIG_CDXL_DECODER)            += cdxl.o
 OBJS-$(CONFIG_CFHD_DECODER)            += cfhd.o cfhddata.o cfhddsp.o
-OBJS-$(CONFIG_CFHD_ENCODER)            += cfhdenc.o cfhddata.o cfhdencdsp.o
+OBJS-$(CONFIG_CFHD_ENCODER)            += cfhdenc.o cfhddata.o
 OBJS-$(CONFIG_CINEPAK_DECODER)         += cinepak.o
 OBJS-$(CONFIG_CINEPAK_ENCODER)         += cinepakenc.o elbg.o
 OBJS-$(CONFIG_CLEARVIDEO_DECODER)      += clearvideo.o
@@ -275,7 +277,7 @@
 OBJS-$(CONFIG_DCA_DECODER)             += dcadec.o dca.o dcadata.o dcahuff.o \
                                           dca_core.o dca_exss.o dca_xll.o dca_lbr.o \
                                           dcadsp.o dcadct.o synth_filter.o
-OBJS-$(CONFIG_DCA_ENCODER)             += dcaenc.o dcadata.o dcahuff.o \
+OBJS-$(CONFIG_DCA_ENCODER)             += dcaenc.o dca.o dcadata.o dcahuff.o \
                                           dcaadpcm.o
 OBJS-$(CONFIG_DDS_DECODER)             += dds.o
 OBJS-$(CONFIG_DERF_DPCM_DECODER)       += dpcm.o
@@ -284,7 +286,7 @@
 OBJS-$(CONFIG_DFA_DECODER)             += dfa.o
 OBJS-$(CONFIG_DNXHD_DECODER)           += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)           += dnxhdenc.o dnxhddata.o
-OBJS-$(CONFIG_DOLBY_E_DECODER)         += dolby_e.o dolby_e_parse.o kbdwin.o
+OBJS-$(CONFIG_DOLBY_E_DECODER)         += dolby_e.o kbdwin.o
 OBJS-$(CONFIG_DPX_DECODER)             += dpx.o
 OBJS-$(CONFIG_DPX_ENCODER)             += dpxenc.o
 OBJS-$(CONFIG_DSD_LSBF_DECODER)        += dsddec.o dsd.o
@@ -320,7 +322,6 @@
 OBJS-$(CONFIG_ESCAPE130_DECODER)       += escape130.o
 OBJS-$(CONFIG_EVRC_DECODER)            += evrcdec.o acelp_vectors.o lsp.o
 OBJS-$(CONFIG_EXR_DECODER)             += exr.o exrdsp.o
-OBJS-$(CONFIG_EXR_ENCODER)             += exrenc.o
 OBJS-$(CONFIG_FASTAUDIO_DECODER)       += fastaudio.o
 OBJS-$(CONFIG_FFV1_DECODER)            += ffv1dec.o ffv1.o
 OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1enc.o ffv1.o
@@ -329,19 +330,17 @@
 OBJS-$(CONFIG_FITS_DECODER)            += fitsdec.o fits.o
 OBJS-$(CONFIG_FITS_ENCODER)            += fitsenc.o
 OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o
-OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o vorbis_data.o
 OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
 OBJS-$(CONFIG_FLASHSV2_ENCODER)        += flashsv2enc.o
 OBJS-$(CONFIG_FLASHSV2_DECODER)        += flashsv.o
 OBJS-$(CONFIG_FLIC_DECODER)            += flicvideo.o
-OBJS-$(CONFIG_FLV_DECODER)             += flvdec.o
-OBJS-$(CONFIG_FLV_ENCODER)             += flvenc.o
 OBJS-$(CONFIG_FMVC_DECODER)            += fmvc.o
 OBJS-$(CONFIG_FOURXM_DECODER)          += 4xm.o
 OBJS-$(CONFIG_FRAPS_DECODER)           += fraps.o
 OBJS-$(CONFIG_FRWU_DECODER)            += frwu.o
-OBJS-$(CONFIG_G2M_DECODER)             += g2meet.o elsdec.o mjpegdec_common.o
+OBJS-$(CONFIG_G2M_DECODER)             += g2meet.o elsdec.o
 OBJS-$(CONFIG_G723_1_DECODER)          += g723_1dec.o g723_1.o \
                                           acelp_vectors.o celp_filters.o celp_math.o
 OBJS-$(CONFIG_G723_1_ENCODER)          += g723_1enc.o g723_1.o \
@@ -356,11 +355,10 @@
 OBJS-$(CONFIG_H261_DECODER)            += h261dec.o h261data.o h261.o
 OBJS-$(CONFIG_H261_ENCODER)            += h261enc.o h261data.o h261.o
 OBJS-$(CONFIG_H263_DECODER)            += h263dec.o h263.o ituh263dec.o        \
-                                          mpeg4video.o mpeg4videodec.o \
-                                          h263data.o
-OBJS-$(CONFIG_H263I_DECODER)           += intelh263dec.o
-OBJS-$(CONFIG_H263_ENCODER)            += mpeg4video.o  \
-                                          h263.o ituh263enc.o h263data.o
+                                          mpeg4video.o mpeg4videodec.o flvdec.o\
+                                          intelh263dec.o h263data.o
+OBJS-$(CONFIG_H263_ENCODER)            += mpeg4videoenc.o mpeg4video.o  \
+                                          h263.o ituh263enc.o flvenc.o h263data.o
 OBJS-$(CONFIG_H263_V4L2M2M_DECODER)    += v4l2_m2m_dec.o
 OBJS-$(CONFIG_H263_V4L2M2M_ENCODER)    += v4l2_m2m_enc.o
 OBJS-$(CONFIG_H264_DECODER)            += h264dec.o h264_cabac.o h264_cavlc.o \
@@ -377,7 +375,7 @@
 OBJS-$(CONFIG_NVENC_ENCODER)           += nvenc_h264.o
 OBJS-$(CONFIG_NVENC_H264_ENCODER)      += nvenc_h264.o
 OBJS-$(CONFIG_H264_OMX_ENCODER)        += omx.o
-OBJS-$(CONFIG_H264_QSV_DECODER)        += qsvdec.o
+OBJS-$(CONFIG_H264_QSV_DECODER)        += qsvdec_h2645.o
 OBJS-$(CONFIG_H264_QSV_ENCODER)        += qsvenc_h264.o
 OBJS-$(CONFIG_H264_RKMPP_DECODER)      += rkmppdec.o
 OBJS-$(CONFIG_H264_VAAPI_ENCODER)      += vaapi_encode_h264.o h264_levels.o
@@ -397,7 +395,7 @@
 OBJS-$(CONFIG_HEVC_MF_ENCODER)         += mfenc.o mf_utils.o
 OBJS-$(CONFIG_HEVC_NVENC_ENCODER)      += nvenc_hevc.o
 OBJS-$(CONFIG_NVENC_HEVC_ENCODER)      += nvenc_hevc.o
-OBJS-$(CONFIG_HEVC_QSV_DECODER)        += qsvdec.o
+OBJS-$(CONFIG_HEVC_QSV_DECODER)        += qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_QSV_ENCODER)        += qsvenc_hevc.o hevc_ps_enc.o       \
                                           hevc_data.o
 OBJS-$(CONFIG_HEVC_RKMPP_DECODER)      += rkmppdec.o
@@ -439,7 +437,7 @@
 OBJS-$(CONFIG_LAGARITH_DECODER)        += lagarith.o lagarithrac.o
 OBJS-$(CONFIG_LJPEG_ENCODER)           += ljpegenc.o mjpegenc_common.o
 OBJS-$(CONFIG_LOCO_DECODER)            += loco.o
-OBJS-$(CONFIG_LSCR_DECODER)            += lscrdec.o png.o pngdec.o pngdsp.o
+OBJS-$(CONFIG_LSCR_DECODER)            += png.o pngdec.o pngdsp.o
 OBJS-$(CONFIG_M101_DECODER)            += m101.o
 OBJS-$(CONFIG_MACE3_DECODER)           += mace.o
 OBJS-$(CONFIG_MACE6_DECODER)           += mace.o
@@ -450,8 +448,8 @@
                                           twinvq.o
 OBJS-$(CONFIG_MICRODVD_DECODER)        += microdvddec.o ass.o
 OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o
-OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o mjpegdec_common.o
-OBJS-$(CONFIG_MJPEG_QSV_DECODER)       += qsvdec.o
+OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o
+OBJS-$(CONFIG_MJPEG_QSV_DECODER)       += qsvdec_other.o
 OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o mjpegenc_common.o \
                                           mjpegenc_huffman.o
 OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o
@@ -488,7 +486,7 @@
 OBJS-$(CONFIG_MPEG1_CUVID_DECODER)     += cuviddec.o
 OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER)   += v4l2_m2m_dec.o
 OBJS-$(CONFIG_MPEG2_MMAL_DECODER)      += mmaldec.o
-OBJS-$(CONFIG_MPEG2_QSV_DECODER)       += qsvdec.o
+OBJS-$(CONFIG_MPEG2_QSV_DECODER)       += qsvdec_other.o
 OBJS-$(CONFIG_MPEG2_QSV_ENCODER)       += qsvenc_mpeg2.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
@@ -497,7 +495,6 @@
 OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER)     += vaapi_encode_mpeg2.o
 OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER)   += v4l2_m2m_dec.o
 OBJS-$(CONFIG_MPEG4_DECODER)           += xvididct.o
-OBJS-$(CONFIG_MPEG4_ENCODER)           += mpeg4videoenc.o
 OBJS-$(CONFIG_MPEG4_CUVID_DECODER)     += cuviddec.o
 OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG4_OMX_ENCODER)       += omx.o
@@ -545,7 +542,6 @@
 OBJS-$(CONFIG_PCX_DECODER)             += pcx.o
 OBJS-$(CONFIG_PCX_ENCODER)             += pcxenc.o
 OBJS-$(CONFIG_PFM_DECODER)             += pnmdec.o pnm.o
-OBJS-$(CONFIG_PFM_ENCODER)             += pnmenc.o
 OBJS-$(CONFIG_PGM_DECODER)             += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGM_ENCODER)             += pnmenc.o
 OBJS-$(CONFIG_PGMYUV_DECODER)          += pnmdec.o pnm.o
@@ -609,7 +605,6 @@
 OBJS-$(CONFIG_SCPR_DECODER)            += scpr.o
 OBJS-$(CONFIG_SCREENPRESSO_DECODER)    += screenpresso.o
 OBJS-$(CONFIG_SDX2_DPCM_DECODER)       += dpcm.o
-OBJS-$(CONFIG_SGA_DECODER)             += sga.o
 OBJS-$(CONFIG_SGI_DECODER)             += sgidec.o
 OBJS-$(CONFIG_SGI_ENCODER)             += sgienc.o rle.o
 OBJS-$(CONFIG_SGIRLE_DECODER)          += sgirledec.o
@@ -620,7 +615,6 @@
                                           acelp_filters.o celp_filters.o \
                                           sipr16k.o
 OBJS-$(CONFIG_SIREN_DECODER)           += siren.o
-OBJS-$(CONFIG_SIMBIOSIS_IMX_DECODER)   += imx.o
 OBJS-$(CONFIG_SMACKAUD_DECODER)        += smacker.o
 OBJS-$(CONFIG_SMACKER_DECODER)         += smacker.o
 OBJS-$(CONFIG_SMC_DECODER)             += smc.o
@@ -659,8 +653,8 @@
 OBJS-$(CONFIG_TARGA_Y216_DECODER)      += targa_y216dec.o
 OBJS-$(CONFIG_TDSC_DECODER)            += tdsc.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
-OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o tiff_common.o
-OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o
+OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o tiff_data.o tiff_common.o mjpegdec.o
+OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER)             += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)          += mlpdec.o mlpdsp.o
 OBJS-$(CONFIG_TRUEHD_ENCODER)          += mlpenc.o mlp.o
@@ -672,8 +666,7 @@
 OBJS-$(CONFIG_TSCC2_DECODER)           += tscc2.o
 OBJS-$(CONFIG_TTA_DECODER)             += tta.o ttadata.o ttadsp.o
 OBJS-$(CONFIG_TTA_ENCODER)             += ttaenc.o ttaencdsp.o ttadata.o
-OBJS-$(CONFIG_TTML_ENCODER)            += ttmlenc.o ass_split.o
-OBJS-$(CONFIG_TWINVQ_DECODER)          += twinvqdec.o twinvq.o metasound_data.o
+OBJS-$(CONFIG_TWINVQ_DECODER)          += twinvqdec.o twinvq.o
 OBJS-$(CONFIG_TXD_DECODER)             += txd.o
 OBJS-$(CONFIG_ULTI_DECODER)            += ulti.o
 OBJS-$(CONFIG_UTVIDEO_DECODER)         += utvideodec.o utvideodsp.o
@@ -695,7 +688,7 @@
                                           wmv2dsp.o wmv2data.o
 OBJS-$(CONFIG_VC1_CUVID_DECODER)       += cuviddec.o
 OBJS-$(CONFIG_VC1_MMAL_DECODER)        += mmaldec.o
-OBJS-$(CONFIG_VC1_QSV_DECODER)         += qsvdec.o
+OBJS-$(CONFIG_VC1_QSV_DECODER)         += qsvdec_other.o
 OBJS-$(CONFIG_VC1_V4L2M2M_DECODER)     += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VC2_ENCODER)             += vc2enc.o vc2enc_dwt.o diractab.o
 OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
@@ -714,7 +707,7 @@
 OBJS-$(CONFIG_VP8_DECODER)             += vp8.o vp56rac.o
 OBJS-$(CONFIG_VP8_CUVID_DECODER)       += cuviddec.o
 OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER)  += mediacodecdec.o
-OBJS-$(CONFIG_VP8_QSV_DECODER)         += qsvdec.o
+OBJS-$(CONFIG_VP8_QSV_DECODER)         += qsvdec_other.o
 OBJS-$(CONFIG_VP8_RKMPP_DECODER)       += rkmppdec.o
 OBJS-$(CONFIG_VP8_VAAPI_ENCODER)       += vaapi_encode_vp8.o
 OBJS-$(CONFIG_VP8_V4L2M2M_DECODER)     += v4l2_m2m_dec.o
@@ -730,8 +723,8 @@
 OBJS-$(CONFIG_VPLAYER_DECODER)         += textdec.o ass.o
 OBJS-$(CONFIG_VP9_V4L2M2M_DECODER)     += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VQA_DECODER)             += vqavideo.o
-OBJS-$(CONFIG_WAVPACK_DECODER)         += wavpack.o wavpackdata.o dsd.o
-OBJS-$(CONFIG_WAVPACK_ENCODER)         += wavpackdata.o wavpackenc.o
+OBJS-$(CONFIG_WAVPACK_DECODER)         += wavpack.o dsd.o
+OBJS-$(CONFIG_WAVPACK_ENCODER)         += wavpackenc.o
 OBJS-$(CONFIG_WCMV_DECODER)            += wcmv.o
 OBJS-$(CONFIG_WEBP_DECODER)            += webp.o
 OBJS-$(CONFIG_WEBVTT_DECODER)          += webvttdec.o ass.o
@@ -832,7 +825,6 @@
 OBJS-$(CONFIG_PCM_S64BE_ENCODER)          += pcm.o
 OBJS-$(CONFIG_PCM_S64LE_DECODER)          += pcm.o
 OBJS-$(CONFIG_PCM_S64LE_ENCODER)          += pcm.o
-OBJS-$(CONFIG_PCM_SGA_DECODER)            += pcm.o
 OBJS-$(CONFIG_PCM_U8_DECODER)             += pcm.o
 OBJS-$(CONFIG_PCM_U8_ENCODER)             += pcm.o
 OBJS-$(CONFIG_PCM_U16BE_DECODER)          += pcm.o
@@ -931,14 +923,14 @@
 OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)       += dxva2_h264.o
 OBJS-$(CONFIG_H264_DXVA2_HWACCEL)         += dxva2_h264.o
 OBJS-$(CONFIG_H264_NVDEC_HWACCEL)         += nvdec_h264.o
-OBJS-$(CONFIG_H264_QSV_HWACCEL)           += qsvdec.o
+OBJS-$(CONFIG_H264_QSV_HWACCEL)           += qsvdec_h2645.o
 OBJS-$(CONFIG_H264_VAAPI_HWACCEL)         += vaapi_h264.o
 OBJS-$(CONFIG_H264_VDPAU_HWACCEL)         += vdpau_h264.o
 OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
 OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)       += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL)         += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL)         += nvdec_hevc.o
-OBJS-$(CONFIG_HEVC_QSV_HWACCEL)           += qsvdec.o
+OBJS-$(CONFIG_HEVC_QSV_HWACCEL)           += qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL)         += vaapi_hevc.o h265_profile_level.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL)         += vdpau_hevc.o h265_profile_level.o
 OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)        += nvdec_mjpeg.o
@@ -950,7 +942,7 @@
 OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL)      += dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)        += dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL)        += nvdec_mpeg12.o
-OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)          += qsvdec.o
+OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)          += qsvdec_other.o
 OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)        += vaapi_mpeg2.o
 OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL)        += vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
@@ -962,7 +954,7 @@
 OBJS-$(CONFIG_VC1_D3D11VA_HWACCEL)        += dxva2_vc1.o
 OBJS-$(CONFIG_VC1_DXVA2_HWACCEL)          += dxva2_vc1.o
 OBJS-$(CONFIG_VC1_NVDEC_HWACCEL)          += nvdec_vc1.o
-OBJS-$(CONFIG_VC1_QSV_HWACCEL)            += qsvdec.o
+OBJS-$(CONFIG_VC1_QSV_HWACCEL)            += qsvdec_other.o
 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)          += vaapi_vc1.o
 OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)          += vdpau_vc1.o
 OBJS-$(CONFIG_VP8_NVDEC_HWACCEL)          += nvdec_vp8.o
@@ -972,24 +964,26 @@
 OBJS-$(CONFIG_VP9_NVDEC_HWACCEL)          += nvdec_vp9.o
 OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)          += vaapi_vp9.o
 OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)          += vdpau_vp9.o
-OBJS-$(CONFIG_VP8_QSV_HWACCEL)            += qsvdec.o
+OBJS-$(CONFIG_VP8_QSV_HWACCEL)            += qsvdec_other.o
 
 # libavformat dependencies
 OBJS-$(CONFIG_ISO_MEDIA)               += mpeg4audio.o mpegaudiodata.o
 
 OBJS-$(CONFIG_ADTS_MUXER)              += mpeg4audio.o
+OBJS-$(CONFIG_CAF_DEMUXER)             += ac3tab.o
 OBJS-$(CONFIG_CODEC2_DEMUXER)          += codec2utils.o
 OBJS-$(CONFIG_CODEC2_MUXER)            += codec2utils.o
 OBJS-$(CONFIG_CODEC2RAW_DEMUXER)       += codec2utils.o
 OBJS-$(CONFIG_DNXHD_DEMUXER)           += dnxhddata.o
 OBJS-$(CONFIG_FITS_DEMUXER)            += fits.o
+OBJS-$(CONFIG_FLV_DEMUXER)             += mpeg4audio.o
 OBJS-$(CONFIG_LATM_MUXER)              += mpeg4audio.o
 OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += mpeg4audio.o
 OBJS-$(CONFIG_MATROSKA_MUXER)          += mpeg4audio.o
 OBJS-$(CONFIG_MOV_DEMUXER)             += ac3tab.o
-OBJS-$(CONFIG_MATROSKA_DEMUXER)        += mpeg4audio.o
 OBJS-$(CONFIG_MXF_MUXER)               += dnxhddata.o
 OBJS-$(CONFIG_NUT_MUXER)               += mpegaudiodata.o
+OBJS-$(CONFIG_NUT_DEMUXER)             += mpegaudiodata.o mpeg4audio.o
 OBJS-$(CONFIG_RTP_MUXER)               += mpeg4audio.o
 OBJS-$(CONFIG_SPDIF_MUXER)             += dca.o
 OBJS-$(CONFIG_TAK_DEMUXER)             += tak.o
@@ -1086,17 +1080,16 @@
 OBJS-$(CONFIG_BMP_PARSER)              += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER)             += cook_parser.o
-OBJS-$(CONFIG_CRI_PARSER)              += cri_parser.o
 OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o dca_exss.o dca.o
 OBJS-$(CONFIG_DIRAC_PARSER)            += dirac_parser.o
 OBJS-$(CONFIG_DNXHD_PARSER)            += dnxhd_parser.o dnxhddata.o
-OBJS-$(CONFIG_DOLBY_E_PARSER)          += dolby_e_parser.o dolby_e_parse.o
 OBJS-$(CONFIG_DPX_PARSER)              += dpx_parser.o
 OBJS-$(CONFIG_DVAUDIO_PARSER)          += dvaudio_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsub_parser.o
 OBJS-$(CONFIG_DVD_NAV_PARSER)          += dvd_nav_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsub_parser.o
-OBJS-$(CONFIG_FLAC_PARSER)             += flac_parser.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_PARSER)             += flac_parser.o flacdata.o flac.o \
+                                          vorbis_data.o
 OBJS-$(CONFIG_G723_1_PARSER)           += g723_1_parser.o
 OBJS-$(CONFIG_G729_PARSER)             += g729_parser.o
 OBJS-$(CONFIG_GIF_PARSER)              += gif_parser.o
@@ -1130,7 +1123,6 @@
 OBJS-$(CONFIG_VP8_PARSER)              += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)              += vp9_parser.o
 OBJS-$(CONFIG_WEBP_PARSER)             += webp_parser.o
-OBJS-$(CONFIG_XBM_PARSER)              += xbm_parser.o
 OBJS-$(CONFIG_XMA_PARSER)              += xma_parser.o
 
 # bitstream filters
@@ -1165,7 +1157,6 @@
 OBJS-$(CONFIG_PCM_RECHUNK_BSF)            += pcm_rechunk_bsf.o
 OBJS-$(CONFIG_PRORES_METADATA_BSF)        += prores_metadata_bsf.o
 OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)       += remove_extradata_bsf.o
-OBJS-$(CONFIG_SETTS_BSF)                  += setts_bsf.o
 OBJS-$(CONFIG_TEXT2MOVSUB_BSF)            += movsub_bsf.o
 OBJS-$(CONFIG_TRACE_HEADERS_BSF)          += trace_headers_bsf.o
 OBJS-$(CONFIG_TRUEHD_CORE_BSF)            += truehd_core_bsf.o mlp_parse.o mlp.o
@@ -1205,6 +1196,7 @@
 SKIPHEADERS-$(CONFIG_NVDEC)            += nvdec.h
 SKIPHEADERS-$(CONFIG_NVENC)            += nvenc.h
 SKIPHEADERS-$(CONFIG_QSV)              += qsv.h qsv_internal.h
+SKIPHEADERS-$(CONFIG_QSVDEC)           += qsvdec.h
 SKIPHEADERS-$(CONFIG_QSVENC)           += qsvenc.h
 SKIPHEADERS-$(CONFIG_XVMC)             += xvmc.h
 SKIPHEADERS-$(CONFIG_VAAPI)            += vaapi_decode.h vaapi_hevc.h vaapi_encode.h
@@ -1219,15 +1211,16 @@
             imgconvert                                                  \
             jpeg2000dwt                                                 \
             mathops                                                    \
+            options                                                     \
+            mjpegenc_huffman                                            \
             utils                                                       \
 
 TESTPROGS-$(CONFIG_CABAC)                 += cabac
 TESTPROGS-$(CONFIG_DCT)                   += avfft
-TESTPROGS-$(CONFIG_FFT)                   += fft fft-fixed32
+TESTPROGS-$(CONFIG_FFT)                   += fft fft-fixed fft-fixed32
 TESTPROGS-$(CONFIG_GOLOMB)                += golomb
 TESTPROGS-$(CONFIG_IDCTDSP)               += dct
 TESTPROGS-$(CONFIG_IIRFILTER)             += iirfilter
-TESTPROGS-$(CONFIG_MJPEG_ENCODER)         += mjpegenc_huffman
 TESTPROGS-$(HAVE_MMX)                     += motion
 TESTPROGS-$(CONFIG_MPEGVIDEO)             += mpeg12framerate
 TESTPROGS-$(CONFIG_H264_METADATA_BSF)     += h264_levels
@@ -1283,9 +1276,9 @@
 ifdef CONFIG_HARDCODED_TABLES
 $(SUBDIR)cbrt_data.o: $(SUBDIR)cbrt_tables.h
 $(SUBDIR)cbrt_data_fixed.o: $(SUBDIR)cbrt_fixed_tables.h
-$(SUBDIR)aacdec_fixed.o: $(SUBDIR)sinewin_fixed_tables.h
 $(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h
 $(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h
+$(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h
 $(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h
 $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
 $(SUBDIR)mpegaudiodec_common.o: $(SUBDIR)mpegaudiodec_common_tables.h
@@ -1294,4 +1287,5 @@
 $(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h
 $(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h
 $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h
+$(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h
 endif
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 1e82f56..d422ea5 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -34,7 +34,6 @@
 #include "aac_defines.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
-#include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #if !USE_FIXED
 #include "mdct15.h"
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index e84d30a..e5d4b53 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -89,7 +89,7 @@
            the frame). */
         if (avctx->codec_id != AV_CODEC_ID_AAC) {
             avctx->sample_rate = s->sample_rate;
-            if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
+            if (avctx->codec_id != AV_CODEC_ID_EAC3) {
                 avctx->channels = s->channels;
                 avctx->channel_layout = s->channel_layout;
             }
@@ -99,7 +99,7 @@
 
         /* Calculate the average bit rate */
         s->frame_number++;
-        if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
+        if (avctx->codec_id != AV_CODEC_ID_EAC3) {
             avctx->bit_rate +=
                 (s->bit_rate - avctx->bit_rate) / s->frame_number;
         }
diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h
index e94475a..74ac011 100644
--- a/libavcodec/aac_defines.h
+++ b/libavcodec/aac_defines.h
@@ -34,7 +34,7 @@
 
 #define AAC_RENAME(x)       x ## _fixed
 #define AAC_RENAME_32(x)    x ## _fixed_32
-#define AAC_RENAME2(x)      x ## _fixed
+#define AAC_KBD_RENAME(x)   aac_ ## x ## _fixed
 typedef int                 INTFLOAT;
 typedef unsigned            UINTFLOAT;  ///< Equivalent to INTFLOAT, Used as temporal cast to avoid undefined sign overflow operations.
 typedef int64_t             INT64FLOAT;
@@ -84,7 +84,7 @@
 
 #define AAC_RENAME(x)       x
 #define AAC_RENAME_32(x)    x
-#define AAC_RENAME2(x)      ff_ ## x
+#define AAC_KBD_RENAME(x)   ff_aac_ ## x
 typedef float               INTFLOAT;
 typedef float               UINTFLOAT;
 typedef float               INT64FLOAT;
diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
index c5d923a..4d82b7b 100644
--- a/libavcodec/aacdec_fixed.c
+++ b/libavcodec/aacdec_fixed.c
@@ -70,7 +70,7 @@
 #include "fft.h"
 #include "lpc.h"
 #include "kbdwin.h"
-#include "sinewin_fixed_tablegen.h"
+#include "sinewin.h"
 
 #include "aac.h"
 #include "aactab.h"
@@ -86,8 +86,8 @@
 #include <math.h>
 #include <string.h>
 
-DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_long_1024))[1024];
-DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_short_128))[128];
+DECLARE_ALIGNED(32, static int, AAC_KBD_RENAME(kbd_long_1024))[1024];
+DECLARE_ALIGNED(32, static int, AAC_KBD_RENAME(kbd_short_128))[128];
 
 static av_always_inline void reset_predict_state(PredictorState *ps)
 {
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 98f77a3..fbe3074 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -639,14 +639,11 @@
      * As actual intended 7.1(wide) streams are very rare, default to assuming a
      * 7.1 layout was intended.
      */
-    if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) {
+    if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT && (!ac || !ac->warned_71_wide++)) {
+        av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
+               " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
+               " according to the specification instead.\n", FF_COMPLIANCE_STRICT);
         layout_map[2][2] = AAC_CHANNEL_SIDE;
-
-        if (!ac || !ac->warned_71_wide++) {
-            av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
-                   " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
-                   " according to the specification instead.\n", FF_COMPLIANCE_STRICT);
-        }
     }
 
     return 0;
@@ -1238,13 +1235,14 @@
     AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
     AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
     AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);
-    AAC_RENAME(ff_init_ff_sine_windows)(9);
     ff_aac_float_common_init();
 #else
-    AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
-    AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
-    init_sine_windows_fixed();
+    AAC_RENAME(ff_kbd_window_init)(AAC_KBD_RENAME(kbd_long_1024), 4.0, 1024);
+    AAC_RENAME(ff_kbd_window_init)(AAC_KBD_RENAME(kbd_short_128), 6.0, 128);
+    AAC_RENAME(ff_init_ff_sine_windows)(10);
+    AAC_RENAME(ff_init_ff_sine_windows)( 7);
 #endif
+    AAC_RENAME(ff_init_ff_sine_windows)( 9);
 
     AAC_RENAME(ff_cbrt_tableinit)();
 }
@@ -2646,10 +2644,10 @@
 static void windowing_and_mdct_ltp(AACContext *ac, INTFLOAT *out,
                                    INTFLOAT *in, IndividualChannelStream *ics)
 {
-    const INTFLOAT *lwindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
-    const INTFLOAT *swindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
-    const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
-    const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
+    const INTFLOAT *lwindow      = ics->use_kb_window[0] ? AAC_KBD_RENAME(kbd_long_1024) : AAC_RENAME(ff_sine_1024);
+    const INTFLOAT *swindow      = ics->use_kb_window[0] ? AAC_KBD_RENAME(kbd_short_128) : AAC_RENAME(ff_sine_128);
+    const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_KBD_RENAME(kbd_long_1024) : AAC_RENAME(ff_sine_1024);
+    const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_KBD_RENAME(kbd_short_128) : AAC_RENAME(ff_sine_128);
 
     if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {
         ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024);
@@ -2706,8 +2704,8 @@
     IndividualChannelStream *ics = &sce->ics;
     INTFLOAT *saved     = sce->saved;
     INTFLOAT *saved_ltp = sce->coeffs;
-    const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
-    const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
+    const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_KBD_RENAME(kbd_long_1024) : AAC_RENAME(ff_sine_1024);
+    const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_KBD_RENAME(kbd_short_128) : AAC_RENAME(ff_sine_128);
     int i;
 
     if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
@@ -2745,9 +2743,9 @@
     INTFLOAT *in    = sce->coeffs;
     INTFLOAT *out   = sce->ret;
     INTFLOAT *saved = sce->saved;
-    const INTFLOAT *swindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
-    const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
-    const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
+    const INTFLOAT *swindow      = ics->use_kb_window[0] ? AAC_KBD_RENAME(kbd_short_128) : AAC_RENAME(ff_sine_128);
+    const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_KBD_RENAME(kbd_long_1024) : AAC_RENAME(ff_sine_1024);
+    const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_KBD_RENAME(kbd_short_128) : AAC_RENAME(ff_sine_128);
     INTFLOAT *buf  = ac->buf_mdct;
     INTFLOAT *temp = ac->temp;
     int i;
@@ -2893,10 +2891,10 @@
     if (ics->use_kb_window[1]) {
         // AAC LD uses a low overlap sine window instead of a KBD window
         memcpy(out, saved, 192 * sizeof(*out));
-        ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, AAC_RENAME2(sine_128), 64);
+        ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, AAC_RENAME(ff_sine_128), 64);
         memcpy(                     out + 320, buf + 64, 192 * sizeof(*out));
     } else {
-        ac->fdsp->vector_fmul_window(out, saved, buf, AAC_RENAME2(sine_512), 256);
+        ac->fdsp->vector_fmul_window(out, saved, buf, AAC_RENAME(ff_sine_512), 256);
     }
 
     // buffer update
@@ -2905,7 +2903,7 @@
 
 static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce)
 {
-    UINTFLOAT *in   = sce->coeffs;
+    INTFLOAT *in    = sce->coeffs;
     INTFLOAT *out   = sce->ret;
     INTFLOAT *saved = sce->saved;
     INTFLOAT *buf  = ac->buf_mdct;
@@ -3216,8 +3214,7 @@
 }
 
 static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
-                                int *got_frame_ptr, GetBitContext *gb,
-                                const AVPacket *avpkt)
+                                int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
 {
     AACContext *ac = avctx->priv_data;
     ChannelElement *che = NULL, *che_prev = NULL;
@@ -3437,11 +3434,11 @@
     int buf_consumed;
     int buf_offset;
     int err;
-    buffer_size_t new_extradata_size;
+    int new_extradata_size;
     const uint8_t *new_extradata = av_packet_get_side_data(avpkt,
                                        AV_PKT_DATA_NEW_EXTRADATA,
                                        &new_extradata_size);
-    buffer_size_t jp_dualmono_size;
+    int jp_dualmono_size;
     const uint8_t *jp_dualmono   = av_packet_get_side_data(avpkt,
                                        AV_PKT_DATA_JP_DUALMONO,
                                        &jp_dualmono_size);
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 8ffc94f..5a015ca 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -23,8 +23,6 @@
 #define AVCODEC_AACENC_H
 
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "put_bits.h"
 
diff --git a/libavcodec/aacenctab.c b/libavcodec/aacenctab.c
index 874365a..f3d70fb 100644
--- a/libavcodec/aacenctab.c
+++ b/libavcodec/aacenctab.c
@@ -88,7 +88,7 @@
     32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
 };
 
-const uint8_t *const ff_aac_swb_size_128[] = {
+const uint8_t *ff_aac_swb_size_128[] = {
     swb_size_128_96, swb_size_128_96, swb_size_128_64,
     swb_size_128_48, swb_size_128_48, swb_size_128_48,
     swb_size_128_24, swb_size_128_24, swb_size_128_16,
@@ -96,7 +96,7 @@
     swb_size_128_8
 };
 
-const uint8_t *const ff_aac_swb_size_1024[] = {
+const uint8_t *ff_aac_swb_size_1024[] = {
     swb_size_1024_96, swb_size_1024_96, swb_size_1024_64,
     swb_size_1024_48, swb_size_1024_48, swb_size_1024_32,
     swb_size_1024_24, swb_size_1024_24, swb_size_1024_16,
diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h
index dbbdf61..64932d7 100644
--- a/libavcodec/aacenctab.h
+++ b/libavcodec/aacenctab.h
@@ -38,9 +38,9 @@
 
 #define AAC_MAX_CHANNELS 16
 
-extern const uint8_t *const ff_aac_swb_size_1024[];
+extern const uint8_t *ff_aac_swb_size_1024[];
 extern const int      ff_aac_swb_size_1024_len;
-extern const uint8_t *const ff_aac_swb_size_128[];
+extern const uint8_t *ff_aac_swb_size_128[];
 extern const int      ff_aac_swb_size_128_len;
 
 /* Supported layouts without using a PCE */
diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c
index 6c7a33f..22df160 100644
--- a/libavcodec/aacps.c
+++ b/libavcodec/aacps.c
@@ -25,8 +25,8 @@
 #include <stdint.h>
 #include "libavutil/common.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 #include "avcodec.h"
+#include "get_bits.h"
 #include "aacps.h"
 #if USE_FIXED
 #include "aacps_fixed_tablegen.h"
@@ -34,12 +34,118 @@
 #include "libavutil/internal.h"
 #include "aacps_tablegen.h"
 #endif /* USE_FIXED */
+#include "aacpsdata.c"
 
-static const INTFLOAT g1_Q2[] = {
-    Q31(0.0f),  Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f),
-    Q31(0.0f),  Q31(0.30596630545168f), Q31(0.5f)
+#define PS_BASELINE 0  ///< Operate in Baseline PS mode
+                       ///< Baseline implies 10 or 20 stereo bands,
+                       ///< mixing mode A, and no ipd/opd
+
+#define numQMFSlots 32 //numTimeSlots * RATE
+
+static const int8_t num_env_tab[2][4] = {
+    { 0, 1, 2, 4, },
+    { 1, 2, 3, 4, },
 };
 
+static const int8_t nr_iidicc_par_tab[] = {
+    10, 20, 34, 10, 20, 34,
+};
+
+static const int8_t nr_iidopd_par_tab[] = {
+     5, 11, 17,  5, 11, 17,
+};
+
+enum {
+    huff_iid_df1,
+    huff_iid_dt1,
+    huff_iid_df0,
+    huff_iid_dt0,
+    huff_icc_df,
+    huff_icc_dt,
+    huff_ipd_df,
+    huff_ipd_dt,
+    huff_opd_df,
+    huff_opd_dt,
+};
+
+static const int huff_iid[] = {
+    huff_iid_df0,
+    huff_iid_df1,
+    huff_iid_dt0,
+    huff_iid_dt1,
+};
+
+static VLC vlc_ps[10];
+
+#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \
+/** \
+ * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \
+ * Inter-channel Phase Difference/Overall Phase Difference parameters from the \
+ * bitstream. \
+ * \
+ * @param avctx contains the current codec context \
+ * @param gb    pointer to the input bitstream \
+ * @param ps    pointer to the Parametric Stereo context \
+ * @param PAR   pointer to the parameter to be read \
+ * @param e     envelope to decode \
+ * @param dt    1: time delta-coded, 0: frequency delta-coded \
+ */ \
+static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \
+                        int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
+{ \
+    int b, num = ps->nr_ ## PAR ## _par; \
+    VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \
+    if (dt) { \
+        int e_prev = e ? e - 1 : ps->num_env_old - 1; \
+        e_prev = FFMAX(e_prev, 0); \
+        for (b = 0; b < num; b++) { \
+            int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \
+            if (MASK) val &= MASK; \
+            PAR[e][b] = val; \
+            if (ERR_CONDITION) \
+                goto err; \
+        } \
+    } else { \
+        int val = 0; \
+        for (b = 0; b < num; b++) { \
+            val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \
+            if (MASK) val &= MASK; \
+            PAR[e][b] = val; \
+            if (ERR_CONDITION) \
+                goto err; \
+        } \
+    } \
+    return 0; \
+err: \
+    av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \
+    return AVERROR_INVALIDDATA; \
+}
+
+READ_PAR_DATA(iid,    huff_offset[table_idx],    0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant)
+READ_PAR_DATA(icc,    huff_offset[table_idx],    0, ps->icc_par[e][b] > 7U)
+READ_PAR_DATA(ipdopd,                      0, 0x07, 0)
+
+static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
+{
+    int e;
+    int count = get_bits_count(gb);
+
+    if (ps_extension_id)
+        return 0;
+
+    ps->enable_ipdopd = get_bits1(gb);
+    if (ps->enable_ipdopd) {
+        for (e = 0; e < ps->num_env; e++) {
+            int dt = get_bits1(gb);
+            read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt);
+            dt = get_bits1(gb);
+            read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt);
+        }
+    }
+    skip_bits1(gb);      //reserved_ps
+    return get_bits_count(gb) - count;
+}
+
 static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
 {
     int i;
@@ -49,6 +155,163 @@
     }
 }
 
+int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
+{
+    int e;
+    int bit_count_start = get_bits_count(gb_host);
+    int header;
+    int bits_consumed;
+    GetBitContext gbc = *gb_host, *gb = &gbc;
+
+    header = get_bits1(gb);
+    if (header) {     //enable_ps_header
+        ps->enable_iid = get_bits1(gb);
+        if (ps->enable_iid) {
+            int iid_mode = get_bits(gb, 3);
+            if (iid_mode > 5) {
+                av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
+                       iid_mode);
+                goto err;
+            }
+            ps->nr_iid_par    = nr_iidicc_par_tab[iid_mode];
+            ps->iid_quant     = iid_mode > 2;
+            ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode];
+        }
+        ps->enable_icc = get_bits1(gb);
+        if (ps->enable_icc) {
+            ps->icc_mode = get_bits(gb, 3);
+            if (ps->icc_mode > 5) {
+                av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n",
+                       ps->icc_mode);
+                goto err;
+            }
+            ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode];
+        }
+        ps->enable_ext = get_bits1(gb);
+    }
+
+    ps->frame_class = get_bits1(gb);
+    ps->num_env_old = ps->num_env;
+    ps->num_env     = num_env_tab[ps->frame_class][get_bits(gb, 2)];
+
+    ps->border_position[0] = -1;
+    if (ps->frame_class) {
+        for (e = 1; e <= ps->num_env; e++) {
+            ps->border_position[e] = get_bits(gb, 5);
+            if (ps->border_position[e] < ps->border_position[e-1]) {
+                av_log(avctx, AV_LOG_ERROR, "border_position non monotone.\n");
+                goto err;
+            }
+        }
+    } else
+        for (e = 1; e <= ps->num_env; e++)
+            ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1;
+
+    if (ps->enable_iid) {
+        for (e = 0; e < ps->num_env; e++) {
+            int dt = get_bits1(gb);
+            if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt))
+                goto err;
+        }
+    } else
+        memset(ps->iid_par, 0, sizeof(ps->iid_par));
+
+    if (ps->enable_icc)
+        for (e = 0; e < ps->num_env; e++) {
+            int dt = get_bits1(gb);
+            if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt))
+                goto err;
+        }
+    else
+        memset(ps->icc_par, 0, sizeof(ps->icc_par));
+
+    if (ps->enable_ext) {
+        int cnt = get_bits(gb, 4);
+        if (cnt == 15) {
+            cnt += get_bits(gb, 8);
+        }
+        cnt *= 8;
+        while (cnt > 7) {
+            int ps_extension_id = get_bits(gb, 2);
+            cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id);
+        }
+        if (cnt < 0) {
+            av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d\n", cnt);
+            goto err;
+        }
+        skip_bits(gb, cnt);
+    }
+
+    ps->enable_ipdopd &= !PS_BASELINE;
+
+    //Fix up envelopes
+    if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) {
+        //Create a fake envelope
+        int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
+        int b;
+        if (source >= 0 && source != ps->num_env) {
+            if (ps->enable_iid) {
+                memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
+            }
+            if (ps->enable_icc) {
+                memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
+            }
+            if (ps->enable_ipdopd) {
+                memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
+                memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
+            }
+        }
+        if (ps->enable_iid){
+            for (b = 0; b < ps->nr_iid_par; b++) {
+                if (FFABS(ps->iid_par[ps->num_env][b]) > 7 + 8 * ps->iid_quant) {
+                    av_log(avctx, AV_LOG_ERROR, "iid_par invalid\n");
+                    goto err;
+                }
+            }
+        }
+        if (ps->enable_icc){
+            for (b = 0; b < ps->nr_iid_par; b++) {
+                if (ps->icc_par[ps->num_env][b] > 7U) {
+                    av_log(avctx, AV_LOG_ERROR, "icc_par invalid\n");
+                    goto err;
+                }
+            }
+        }
+        ps->num_env++;
+        ps->border_position[ps->num_env] = numQMFSlots - 1;
+    }
+
+
+    ps->is34bands_old = ps->is34bands;
+    if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc))
+        ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
+                        (ps->enable_icc && ps->nr_icc_par == 34);
+
+    //Baseline
+    if (!ps->enable_ipdopd) {
+        memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
+        memset(ps->opd_par, 0, sizeof(ps->opd_par));
+    }
+
+    if (header)
+        ps->start = 1;
+
+    bits_consumed = get_bits_count(gb) - bit_count_start;
+    if (bits_consumed <= bits_left) {
+        skip_bits_long(gb_host, bits_consumed);
+        return bits_consumed;
+    }
+    av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
+err:
+    ps->start = 0;
+    skip_bits_long(gb_host, bits_left);
+    memset(ps->iid_par, 0, sizeof(ps->iid_par));
+    memset(ps->icc_par, 0, sizeof(ps->icc_par));
+    memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
+    memset(ps->opd_par, 0, sizeof(ps->opd_par));
+    return bits_left;
+}
+
 /** Split one subband into 2 subsubbands with a symmetric real filter.
  * The filter must have its non-center even coefficients equal to zero. */
 static void hybrid2_re(INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT filter[8], int len, int reverse)
@@ -409,14 +672,14 @@
     const float transient_impact  = 1.5f;
     const float a_smooth          = 0.25f; ///< Smoothing coefficient
 #endif /* USE_FIXED */
-    const int8_t *const k_to_i = is34 ? ff_k_to_i_34 : ff_k_to_i_20;
+    const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
     int i, k, m, n;
     int n0 = 0, nL = 32;
     const INTFLOAT peak_decay_factor = Q31(0.76592833836465f);
 
     memset(power, 0, 34 * sizeof(*power));
 
-    if (is34 != ps->common.is34bands_old) {
+    if (is34 != ps->is34bands_old) {
         memset(ps->peak_decay_nrg,         0, sizeof(ps->peak_decay_nrg));
         memset(ps->power_smooth,           0, sizeof(ps->power_smooth));
         memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth));
@@ -558,7 +821,6 @@
 {
     int e, b, k;
 
-    PSCommonContext *const ps2 = &ps->common;
     INTFLOAT (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
     INTFLOAT (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
     INTFLOAT (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
@@ -573,29 +835,29 @@
     int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
     int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
     int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
-    const int8_t *const k_to_i = is34 ? ff_k_to_i_34 : ff_k_to_i_20;
-    TABLE_CONST INTFLOAT (*H_LUT)[8][4] = (PS_BASELINE || ps2->icc_mode < 3) ? HA : HB;
+    const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
+    TABLE_CONST INTFLOAT (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
 
     //Remapping
-    if (ps2->num_env_old) {
-        memcpy(H11[0][0], H11[0][ps2->num_env_old], sizeof(H11[0][0]));
-        memcpy(H11[1][0], H11[1][ps2->num_env_old], sizeof(H11[1][0]));
-        memcpy(H12[0][0], H12[0][ps2->num_env_old], sizeof(H12[0][0]));
-        memcpy(H12[1][0], H12[1][ps2->num_env_old], sizeof(H12[1][0]));
-        memcpy(H21[0][0], H21[0][ps2->num_env_old], sizeof(H21[0][0]));
-        memcpy(H21[1][0], H21[1][ps2->num_env_old], sizeof(H21[1][0]));
-        memcpy(H22[0][0], H22[0][ps2->num_env_old], sizeof(H22[0][0]));
-        memcpy(H22[1][0], H22[1][ps2->num_env_old], sizeof(H22[1][0]));
+    if (ps->num_env_old) {
+        memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
+        memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
+        memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
+        memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
+        memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
+        memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
+        memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
+        memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
     }
 
     if (is34) {
-        remap34(&iid_mapped, ps2->iid_par, ps2->nr_iid_par, ps2->num_env, 1);
-        remap34(&icc_mapped, ps2->icc_par, ps2->nr_icc_par, ps2->num_env, 1);
-        if (ps2->enable_ipdopd) {
-            remap34(&ipd_mapped, ps2->ipd_par, ps2->nr_ipdopd_par, ps2->num_env, 0);
-            remap34(&opd_mapped, ps2->opd_par, ps2->nr_ipdopd_par, ps2->num_env, 0);
+        remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
+        remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
+        if (ps->enable_ipdopd) {
+            remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+            remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
         }
-        if (!ps2->is34bands_old) {
+        if (!ps->is34bands_old) {
             map_val_20_to_34(H11[0][0]);
             map_val_20_to_34(H11[1][0]);
             map_val_20_to_34(H12[0][0]);
@@ -607,13 +869,13 @@
             ipdopd_reset(ipd_hist, opd_hist);
         }
     } else {
-        remap20(&iid_mapped, ps2->iid_par, ps2->nr_iid_par, ps2->num_env, 1);
-        remap20(&icc_mapped, ps2->icc_par, ps2->nr_icc_par, ps2->num_env, 1);
-        if (ps2->enable_ipdopd) {
-            remap20(&ipd_mapped, ps2->ipd_par, ps2->nr_ipdopd_par, ps2->num_env, 0);
-            remap20(&opd_mapped, ps2->opd_par, ps2->nr_ipdopd_par, ps2->num_env, 0);
+        remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
+        remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
+        if (ps->enable_ipdopd) {
+            remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+            remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
         }
-        if (ps2->is34bands_old) {
+        if (ps->is34bands_old) {
             map_val_34_to_20(H11[0][0]);
             map_val_34_to_20(H11[1][0]);
             map_val_34_to_20(H12[0][0]);
@@ -627,15 +889,15 @@
     }
 
     //Mixing
-    for (e = 0; e < ps2->num_env; e++) {
+    for (e = 0; e < ps->num_env; e++) {
         for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
             INTFLOAT h11, h12, h21, h22;
-            h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][0];
-            h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][1];
-            h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][2];
-            h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][3];
+            h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
+            h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
+            h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
+            h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
 
-            if (!PS_BASELINE && ps2->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) {
+            if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) {
                 //The spec say says to only run this smoother when enable_ipdopd
                 //is set but the reference decoder appears to run it constantly
                 INTFLOAT h11i, h12i, h21i, h22i;
@@ -672,8 +934,8 @@
         for (k = 0; k < NR_BANDS[is34]; k++) {
             LOCAL_ALIGNED_16(INTFLOAT, h, [2], [4]);
             LOCAL_ALIGNED_16(INTFLOAT, h_step, [2], [4]);
-            int start = ps2->border_position[e];
-            int stop  = ps2->border_position[e+1];
+            int start = ps->border_position[e];
+            int stop  = ps->border_position[e+1];
             INTFLOAT width = Q30(1.f) / ((stop - start) ? (stop - start) : 1);
 #if USE_FIXED
             width = FFMIN(2U*width, INT_MAX);
@@ -683,7 +945,7 @@
             h[0][1] = H12[0][e][b];
             h[0][2] = H21[0][e][b];
             h[0][3] = H22[0][e][b];
-            if (!PS_BASELINE && ps2->enable_ipdopd) {
+            if (!PS_BASELINE && ps->enable_ipdopd) {
             //Is this necessary? ps_04_new seems unchanged
             if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
                 h[1][0] = -H11[1][e][b];
@@ -702,14 +964,14 @@
             h_step[0][1] = AAC_MSUB31_V3(H12[0][e+1][b], h[0][1], width);
             h_step[0][2] = AAC_MSUB31_V3(H21[0][e+1][b], h[0][2], width);
             h_step[0][3] = AAC_MSUB31_V3(H22[0][e+1][b], h[0][3], width);
-            if (!PS_BASELINE && ps2->enable_ipdopd) {
+            if (!PS_BASELINE && ps->enable_ipdopd) {
                 h_step[1][0] = AAC_MSUB31_V3(H11[1][e+1][b], h[1][0], width);
                 h_step[1][1] = AAC_MSUB31_V3(H12[1][e+1][b], h[1][1], width);
                 h_step[1][2] = AAC_MSUB31_V3(H21[1][e+1][b], h[1][2], width);
                 h_step[1][3] = AAC_MSUB31_V3(H22[1][e+1][b], h[1][3], width);
             }
             if (stop - start)
-                ps->dsp.stereo_interpolate[!PS_BASELINE && ps2->enable_ipdopd](
+                ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd](
                     l[k] + 1 + start, r[k] + 1 + start,
                     h, h_step, stop - start);
         }
@@ -721,7 +983,7 @@
     INTFLOAT (*Lbuf)[32][2] = ps->Lbuf;
     INTFLOAT (*Rbuf)[32][2] = ps->Rbuf;
     const int len = 32;
-    int is34 = ps->common.is34bands;
+    int is34 = ps->is34bands;
 
     top += NR_BANDS[is34] - 64;
     memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
@@ -737,9 +999,45 @@
     return 0;
 }
 
+#define PS_INIT_VLC_STATIC(num, size) \
+    INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size,    \
+                    ps_tmp[num].ps_bits, 1, 1,                                          \
+                    ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \
+                    size);
+
+#define PS_VLC_ROW(name) \
+    { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
+
 av_cold void AAC_RENAME(ff_ps_init)(void) {
+    // Syntax initialization
+    static const struct {
+        const void *ps_codes, *ps_bits;
+        const unsigned int table_size, elem_size;
+    } ps_tmp[] = {
+        PS_VLC_ROW(huff_iid_df1),
+        PS_VLC_ROW(huff_iid_dt1),
+        PS_VLC_ROW(huff_iid_df0),
+        PS_VLC_ROW(huff_iid_dt0),
+        PS_VLC_ROW(huff_icc_df),
+        PS_VLC_ROW(huff_icc_dt),
+        PS_VLC_ROW(huff_ipd_df),
+        PS_VLC_ROW(huff_ipd_dt),
+        PS_VLC_ROW(huff_opd_df),
+        PS_VLC_ROW(huff_opd_dt),
+    };
+
+    PS_INIT_VLC_STATIC(0, 1544);
+    PS_INIT_VLC_STATIC(1,  832);
+    PS_INIT_VLC_STATIC(2, 1024);
+    PS_INIT_VLC_STATIC(3, 1036);
+    PS_INIT_VLC_STATIC(4,  544);
+    PS_INIT_VLC_STATIC(5,  544);
+    PS_INIT_VLC_STATIC(6,  512);
+    PS_INIT_VLC_STATIC(7,  512);
+    PS_INIT_VLC_STATIC(8,  512);
+    PS_INIT_VLC_STATIC(9,  512);
+
     ps_tableinit();
-    ff_ps_init_common();
 }
 
 av_cold void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps)
diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h
index 3efa38a..61edce3 100644
--- a/libavcodec/aacps.h
+++ b/libavcodec/aacps.h
@@ -24,8 +24,6 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem_internal.h"
-
 #include "aacpsdsp.h"
 #include "avcodec.h"
 #include "get_bits.h"
@@ -39,13 +37,8 @@
 #define PS_MAX_DELAY 14
 #define PS_AP_LINKS 3
 #define PS_MAX_AP_DELAY 5
-#define PS_BASELINE 0  ///< Operate in Baseline PS mode
-                       ///< Baseline implies 10 or 20 stereo bands,
-                       ///< mixing mode A, and no ipd/opd
 
-#define numQMFSlots 32 //numTimeSlots * RATE
-
-typedef struct PSCommonContext {
+typedef struct PSContext {
     int    start;
     int    enable_iid;
     int    iid_quant;
@@ -67,10 +60,6 @@
     int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Overall Phase Difference Parameters
     int    is34bands;
     int    is34bands_old;
-} PSCommonContext;
-
-typedef struct PSContext {
-    PSCommonContext common;
 
     DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2];
     DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
@@ -89,14 +78,9 @@
     PSDSPContext dsp;
 } PSContext;
 
-extern const int8_t ff_k_to_i_20[];
-extern const int8_t ff_k_to_i_34[];
-
-void ff_ps_init_common(void);
 void AAC_RENAME(ff_ps_init)(void);
 void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps);
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb,
-                     PSCommonContext *ps, int bits_left);
+int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left);
 int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top);
 
 #endif /* AVCODEC_AACPS_H */
diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c
deleted file mode 100644
index 8653b87..0000000
--- a/libavcodec/aacps_common.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Functions common to fixed/float MPEG-4 Parametric Stereo decoding
- * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-#include "libavutil/common.h"
-#include "libavutil/thread.h"
-#include "aacps.h"
-#include "get_bits.h"
-#include "aacpsdata.c"
-
-static const int8_t num_env_tab[2][4] = {
-    { 0, 1, 2, 4, },
-    { 1, 2, 3, 4, },
-};
-
-static const int8_t nr_iidicc_par_tab[] = {
-    10, 20, 34, 10, 20, 34,
-};
-
-static const int8_t nr_iidopd_par_tab[] = {
-     5, 11, 17,  5, 11, 17,
-};
-
-enum {
-    huff_iid_df1,
-    huff_iid_dt1,
-    huff_iid_df0,
-    huff_iid_dt0,
-    huff_icc_df,
-    huff_icc_dt,
-    huff_ipd_df,
-    huff_ipd_dt,
-    huff_opd_df,
-    huff_opd_dt,
-};
-
-static const int huff_iid[] = {
-    huff_iid_df0,
-    huff_iid_df1,
-    huff_iid_dt0,
-    huff_iid_dt1,
-};
-
-static VLC vlc_ps[10];
-
-#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION, NB_BITS, MAX_DEPTH) \
-/** \
- * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \
- * Inter-channel Phase Difference/Overall Phase Difference parameters from the \
- * bitstream. \
- * \
- * @param avctx contains the current codec context \
- * @param gb    pointer to the input bitstream \
- * @param ps    pointer to the Parametric Stereo context \
- * @param PAR   pointer to the parameter to be read \
- * @param e     envelope to decode \
- * @param dt    1: time delta-coded, 0: frequency delta-coded \
- */ \
-static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSCommonContext *ps, \
-                        int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
-{ \
-    int b, num = ps->nr_ ## PAR ## _par; \
-    VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \
-    if (dt) { \
-        int e_prev = e ? e - 1 : ps->num_env_old - 1; \
-        e_prev = FFMAX(e_prev, 0); \
-        for (b = 0; b < num; b++) { \
-            int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH) - OFFSET; \
-            if (MASK) val &= MASK; \
-            PAR[e][b] = val; \
-            if (ERR_CONDITION) \
-                goto err; \
-        } \
-    } else { \
-        int val = 0; \
-        for (b = 0; b < num; b++) { \
-            val += get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH) - OFFSET; \
-            if (MASK) val &= MASK; \
-            PAR[e][b] = val; \
-            if (ERR_CONDITION) \
-                goto err; \
-        } \
-    } \
-    return 0; \
-err: \
-    av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \
-    return AVERROR_INVALIDDATA; \
-}
-
-READ_PAR_DATA(iid,    huff_offset[table_idx],    0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant, 9, 3)
-READ_PAR_DATA(icc,    huff_offset[table_idx],    0, ps->icc_par[e][b] > 7U, 9, 2)
-READ_PAR_DATA(ipdopd,                      0, 0x07, 0, 5, 1)
-
-static int ps_read_extension_data(GetBitContext *gb, PSCommonContext *ps,
-                                  int ps_extension_id)
-{
-    int e;
-    int count = get_bits_count(gb);
-
-    if (ps_extension_id)
-        return 0;
-
-    ps->enable_ipdopd = get_bits1(gb);
-    if (ps->enable_ipdopd) {
-        for (e = 0; e < ps->num_env; e++) {
-            int dt = get_bits1(gb);
-            read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt);
-            dt = get_bits1(gb);
-            read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt);
-        }
-    }
-    skip_bits1(gb);      //reserved_ps
-    return get_bits_count(gb) - count;
-}
-
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host,
-                    PSCommonContext *ps, int bits_left)
-{
-    int e;
-    int bit_count_start = get_bits_count(gb_host);
-    int header;
-    int bits_consumed;
-    GetBitContext gbc = *gb_host, *gb = &gbc;
-
-    header = get_bits1(gb);
-    if (header) {     //enable_ps_header
-        ps->enable_iid = get_bits1(gb);
-        if (ps->enable_iid) {
-            int iid_mode = get_bits(gb, 3);
-            if (iid_mode > 5) {
-                av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
-                       iid_mode);
-                goto err;
-            }
-            ps->nr_iid_par    = nr_iidicc_par_tab[iid_mode];
-            ps->iid_quant     = iid_mode > 2;
-            ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode];
-        }
-        ps->enable_icc = get_bits1(gb);
-        if (ps->enable_icc) {
-            ps->icc_mode = get_bits(gb, 3);
-            if (ps->icc_mode > 5) {
-                av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n",
-                       ps->icc_mode);
-                goto err;
-            }
-            ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode];
-        }
-        ps->enable_ext = get_bits1(gb);
-    }
-
-    ps->frame_class = get_bits1(gb);
-    ps->num_env_old = ps->num_env;
-    ps->num_env     = num_env_tab[ps->frame_class][get_bits(gb, 2)];
-
-    ps->border_position[0] = -1;
-    if (ps->frame_class) {
-        for (e = 1; e <= ps->num_env; e++) {
-            ps->border_position[e] = get_bits(gb, 5);
-            if (ps->border_position[e] < ps->border_position[e-1]) {
-                av_log(avctx, AV_LOG_ERROR, "border_position non monotone.\n");
-                goto err;
-            }
-        }
-    } else
-        for (e = 1; e <= ps->num_env; e++)
-            ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1;
-
-    if (ps->enable_iid) {
-        for (e = 0; e < ps->num_env; e++) {
-            int dt = get_bits1(gb);
-            if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt))
-                goto err;
-        }
-    } else
-        memset(ps->iid_par, 0, sizeof(ps->iid_par));
-
-    if (ps->enable_icc)
-        for (e = 0; e < ps->num_env; e++) {
-            int dt = get_bits1(gb);
-            if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt))
-                goto err;
-        }
-    else
-        memset(ps->icc_par, 0, sizeof(ps->icc_par));
-
-    if (ps->enable_ext) {
-        int cnt = get_bits(gb, 4);
-        if (cnt == 15) {
-            cnt += get_bits(gb, 8);
-        }
-        cnt *= 8;
-        while (cnt > 7) {
-            int ps_extension_id = get_bits(gb, 2);
-            cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id);
-        }
-        if (cnt < 0) {
-            av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d\n", cnt);
-            goto err;
-        }
-        skip_bits(gb, cnt);
-    }
-
-    ps->enable_ipdopd &= !PS_BASELINE;
-
-    //Fix up envelopes
-    if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) {
-        //Create a fake envelope
-        int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
-        int b;
-        if (source >= 0 && source != ps->num_env) {
-            if (ps->enable_iid) {
-                memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
-            }
-            if (ps->enable_icc) {
-                memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
-            }
-            if (ps->enable_ipdopd) {
-                memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
-                memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
-            }
-        }
-        if (ps->enable_iid){
-            for (b = 0; b < ps->nr_iid_par; b++) {
-                if (FFABS(ps->iid_par[ps->num_env][b]) > 7 + 8 * ps->iid_quant) {
-                    av_log(avctx, AV_LOG_ERROR, "iid_par invalid\n");
-                    goto err;
-                }
-            }
-        }
-        if (ps->enable_icc){
-            for (b = 0; b < ps->nr_iid_par; b++) {
-                if (ps->icc_par[ps->num_env][b] > 7U) {
-                    av_log(avctx, AV_LOG_ERROR, "icc_par invalid\n");
-                    goto err;
-                }
-            }
-        }
-        ps->num_env++;
-        ps->border_position[ps->num_env] = numQMFSlots - 1;
-    }
-
-
-    ps->is34bands_old = ps->is34bands;
-    if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc))
-        ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
-                        (ps->enable_icc && ps->nr_icc_par == 34);
-
-    //Baseline
-    if (!ps->enable_ipdopd) {
-        memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
-        memset(ps->opd_par, 0, sizeof(ps->opd_par));
-    }
-
-    if (header)
-        ps->start = 1;
-
-    bits_consumed = get_bits_count(gb) - bit_count_start;
-    if (bits_consumed <= bits_left) {
-        skip_bits_long(gb_host, bits_consumed);
-        return bits_consumed;
-    }
-    av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
-err:
-    ps->start = 0;
-    skip_bits_long(gb_host, bits_left);
-    memset(ps->iid_par, 0, sizeof(ps->iid_par));
-    memset(ps->icc_par, 0, sizeof(ps->icc_par));
-    memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
-    memset(ps->opd_par, 0, sizeof(ps->opd_par));
-    return bits_left;
-}
-
-#define PS_INIT_VLC_STATIC(num, nb_bits, size)                          \
-    INIT_VLC_STATIC(&vlc_ps[num], nb_bits, ps_tmp[num].table_size / ps_tmp[num].elem_size,    \
-                    ps_tmp[num].ps_bits, 1, 1,                                          \
-                    ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \
-                    size);
-
-#define PS_VLC_ROW(name) \
-    { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
-
-static av_cold void ps_init_common(void)
-{
-    // Syntax initialization
-    static const struct {
-        const void *ps_codes, *ps_bits;
-        const unsigned int table_size, elem_size;
-    } ps_tmp[] = {
-        PS_VLC_ROW(huff_iid_df1),
-        PS_VLC_ROW(huff_iid_dt1),
-        PS_VLC_ROW(huff_iid_df0),
-        PS_VLC_ROW(huff_iid_dt0),
-        PS_VLC_ROW(huff_icc_df),
-        PS_VLC_ROW(huff_icc_dt),
-        PS_VLC_ROW(huff_ipd_df),
-        PS_VLC_ROW(huff_ipd_dt),
-        PS_VLC_ROW(huff_opd_df),
-        PS_VLC_ROW(huff_opd_dt),
-    };
-
-    PS_INIT_VLC_STATIC(0, 9, 1544);
-    PS_INIT_VLC_STATIC(1, 9,  832);
-    PS_INIT_VLC_STATIC(2, 9, 1024);
-    PS_INIT_VLC_STATIC(3, 9, 1036);
-    PS_INIT_VLC_STATIC(4, 9,  544);
-    PS_INIT_VLC_STATIC(5, 9,  544);
-    PS_INIT_VLC_STATIC(6, 5,   32);
-    PS_INIT_VLC_STATIC(7, 5,   32);
-    PS_INIT_VLC_STATIC(8, 5,   32);
-    PS_INIT_VLC_STATIC(9, 5,   32);
-}
-
-av_cold void ff_ps_init_common(void)
-{
-    static AVOnce init_static_once = AV_ONCE_INIT;
-    ff_thread_once(&init_static_once, ps_init_common);
-}
diff --git a/libavcodec/aacps_fixed_tablegen.h b/libavcodec/aacps_fixed_tablegen.h
index 8fb1da5..8b82deb 100644
--- a/libavcodec/aacps_fixed_tablegen.h
+++ b/libavcodec/aacps_fixed_tablegen.h
@@ -36,12 +36,7 @@
 #else
 #include "libavutil/common.h"
 #include "libavutil/mathematics.h"
-#ifdef BUILD_TABLES
-#undef DECLARE_ALIGNED
-#define DECLARE_ALIGNED(align, type, variable) type variable
-#else
-#include "libavutil/mem_internal.h"
-#endif
+#include "libavutil/mem.h"
 
 #include "aac_defines.h"
 #include "libavutil/softfloat.h"
diff --git a/libavcodec/aacps_tablegen_template.c b/libavcodec/aacps_tablegen_template.c
index e70edf8..341bd44 100644
--- a/libavcodec/aacps_tablegen_template.c
+++ b/libavcodec/aacps_tablegen_template.c
@@ -21,7 +21,6 @@
  */
 
 #include <stdlib.h>
-#define BUILD_TABLES
 #define CONFIG_HARDCODED_TABLES 0
 #include "aac_defines.h"
 
diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c
index 7a1f490..5c1a1b0 100644
--- a/libavcodec/aacpsdata.c
+++ b/libavcodec/aacpsdata.c
@@ -142,17 +142,22 @@
 };
 
 ///Table 8.48
-const int8_t ff_k_to_i_20[] = {
+static const int8_t k_to_i_20[] = {
      1,  0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 14, 15,
     15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
     18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
     19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
 };
 ///Table 8.49
-const int8_t ff_k_to_i_34[] = {
+static const int8_t k_to_i_34[] = {
      0,  1,  2,  3,  4,  5,  6,  6,  7,  2,  1,  0, 10, 10,  4,  5,  6,  7,  8,
      9, 10, 11, 12,  9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21,
     22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29,
     30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
     33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
 };
+
+static const INTFLOAT g1_Q2[] = {
+    Q31(0.0f),  Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f),
+    Q31(0.0f),  Q31(0.30596630545168f), Q31(0.5f)
+};
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
index b74cd82..1d2a8d4 100644
--- a/libavcodec/aacsbr.c
+++ b/libavcodec/aacsbr.c
@@ -31,6 +31,7 @@
 #include "sbr.h"
 #include "aacsbr.h"
 #include "aacsbrdata.h"
+#include "aacsbr_tablegen.h"
 #include "fft.h"
 #include "internal.h"
 #include "aacps.h"
@@ -38,7 +39,6 @@
 #include "libavutil/internal.h"
 #include "libavutil/libm.h"
 #include "libavutil/avassert.h"
-#include "libavutil/mem_internal.h"
 
 #include <stdint.h>
 #include <float.h>
diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c
index ffa63f2..59cbba1 100644
--- a/libavcodec/aacsbr_fixed.c
+++ b/libavcodec/aacsbr_fixed.c
@@ -60,6 +60,7 @@
 #include "sbr.h"
 #include "aacsbr.h"
 #include "aacsbrdata.h"
+#include "aacsbr_fixed_tablegen.h"
 #include "fft.h"
 #include "aacps.h"
 #include "sbrdsp.h"
diff --git a/libavcodec/ttmlenc.h b/libavcodec/aacsbr_fixed_tablegen.h
similarity index 72%
rename from libavcodec/ttmlenc.h
rename to libavcodec/aacsbr_fixed_tablegen.h
index c1dd5ec..3fcf020 100644
--- a/libavcodec/ttmlenc.h
+++ b/libavcodec/aacsbr_fixed_tablegen.h
@@ -1,6 +1,7 @@
 /*
- * TTML subtitle encoder shared functionality
- * Copyright (c) 2020 24i
+ * Header file for hardcoded AAC SBR windows
+ *
+ * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
  *
  * This file is part of FFmpeg.
  *
@@ -19,10 +20,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_TTMLENC_H
-#define AVCODEC_TTMLENC_H
+#ifndef AVCODEC_AACSBR_FIXED_TABLEGEN_H
+#define AVCODEC_AACSBR_FIXED_TABLEGEN_H
 
-#define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc"
-#define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1)
+#include "aacsbr_tablegen_common.h"
 
-#endif /* AVCODEC_TTMLENC_H */
+#endif /* AVCODEC_AACSBR_FIXED_TABLEGEN_H */
diff --git a/libavcodec/ttmlenc.h b/libavcodec/aacsbr_tablegen.h
similarity index 72%
copy from libavcodec/ttmlenc.h
copy to libavcodec/aacsbr_tablegen.h
index c1dd5ec..242a963 100644
--- a/libavcodec/ttmlenc.h
+++ b/libavcodec/aacsbr_tablegen.h
@@ -1,6 +1,7 @@
 /*
- * TTML subtitle encoder shared functionality
- * Copyright (c) 2020 24i
+ * Header file for hardcoded AAC SBR windows
+ *
+ * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
  *
  * This file is part of FFmpeg.
  *
@@ -19,10 +20,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_TTMLENC_H
-#define AVCODEC_TTMLENC_H
+#ifndef AVCODEC_AACSBR_TABLEGEN_H
+#define AVCODEC_AACSBR_TABLEGEN_H
 
-#define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc"
-#define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1)
+#include "aacsbr_tablegen_common.h"
 
-#endif /* AVCODEC_TTMLENC_H */
+#endif /* AVCODEC_AACSBR_TABLEGEN_H */
diff --git a/libavcodec/aacsbr_tablegen_common.h b/libavcodec/aacsbr_tablegen_common.h
new file mode 100644
index 0000000..8e0dd9e
--- /dev/null
+++ b/libavcodec/aacsbr_tablegen_common.h
@@ -0,0 +1,114 @@
+/*
+ * Header file for hardcoded AAC SBR windows
+ *
+ * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AACSBR_TABLEGEN_COMMON_H
+#define AVCODEC_AACSBR_TABLEGEN_COMMON_H
+#include "aac_defines.h"
+#include "libavutil/mem.h"
+
+///< window coefficients for analysis/synthesis QMF banks
+static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320];
+static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_us)[640] = {
+    Q31( 0.0000000000f), Q31(-0.0005525286f), Q31(-0.0005617692f), Q31(-0.0004947518f),
+    Q31(-0.0004875227f), Q31(-0.0004893791f), Q31(-0.0005040714f), Q31(-0.0005226564f),
+    Q31(-0.0005466565f), Q31(-0.0005677802f), Q31(-0.0005870930f), Q31(-0.0006132747f),
+    Q31(-0.0006312493f), Q31(-0.0006540333f), Q31(-0.0006777690f), Q31(-0.0006941614f),
+    Q31(-0.0007157736f), Q31(-0.0007255043f), Q31(-0.0007440941f), Q31(-0.0007490598f),
+    Q31(-0.0007681371f), Q31(-0.0007724848f), Q31(-0.0007834332f), Q31(-0.0007779869f),
+    Q31(-0.0007803664f), Q31(-0.0007801449f), Q31(-0.0007757977f), Q31(-0.0007630793f),
+    Q31(-0.0007530001f), Q31(-0.0007319357f), Q31(-0.0007215391f), Q31(-0.0006917937f),
+    Q31(-0.0006650415f), Q31(-0.0006341594f), Q31(-0.0005946118f), Q31(-0.0005564576f),
+    Q31(-0.0005145572f), Q31(-0.0004606325f), Q31(-0.0004095121f), Q31(-0.0003501175f),
+    Q31(-0.0002896981f), Q31(-0.0002098337f), Q31(-0.0001446380f), Q31(-0.0000617334f),
+    Q31( 0.0000134949f), Q31( 0.0001094383f), Q31( 0.0002043017f), Q31( 0.0002949531f),
+    Q31( 0.0004026540f), Q31( 0.0005107388f), Q31( 0.0006239376f), Q31( 0.0007458025f),
+    Q31( 0.0008608443f), Q31( 0.0009885988f), Q31( 0.0011250155f), Q31( 0.0012577884f),
+    Q31( 0.0013902494f), Q31( 0.0015443219f), Q31( 0.0016868083f), Q31( 0.0018348265f),
+    Q31( 0.0019841140f), Q31( 0.0021461583f), Q31( 0.0023017254f), Q31( 0.0024625616f),
+    Q31( 0.0026201758f), Q31( 0.0027870464f), Q31( 0.0029469447f), Q31( 0.0031125420f),
+    Q31( 0.0032739613f), Q31( 0.0034418874f), Q31( 0.0036008268f), Q31( 0.0037603922f),
+    Q31( 0.0039207432f), Q31( 0.0040819753f), Q31( 0.0042264269f), Q31( 0.0043730719f),
+    Q31( 0.0045209852f), Q31( 0.0046606460f), Q31( 0.0047932560f), Q31( 0.0049137603f),
+    Q31( 0.0050393022f), Q31( 0.0051407353f), Q31( 0.0052461166f), Q31( 0.0053471681f),
+    Q31( 0.0054196775f), Q31( 0.0054876040f), Q31( 0.0055475714f), Q31( 0.0055938023f),
+    Q31( 0.0056220643f), Q31( 0.0056455196f), Q31( 0.0056389199f), Q31( 0.0056266114f),
+    Q31( 0.0055917128f), Q31( 0.0055404363f), Q31( 0.0054753783f), Q31( 0.0053838975f),
+    Q31( 0.0052715758f), Q31( 0.0051382275f), Q31( 0.0049839687f), Q31( 0.0048109469f),
+    Q31( 0.0046039530f), Q31( 0.0043801861f), Q31( 0.0041251642f), Q31( 0.0038456408f),
+    Q31( 0.0035401246f), Q31( 0.0032091885f), Q31( 0.0028446757f), Q31( 0.0024508540f),
+    Q31( 0.0020274176f), Q31( 0.0015784682f), Q31( 0.0010902329f), Q31( 0.0005832264f),
+    Q31( 0.0000276045f), Q31(-0.0005464280f), Q31(-0.0011568135f), Q31(-0.0018039472f),
+    Q31(-0.0024826723f), Q31(-0.0031933778f), Q31(-0.0039401124f), Q31(-0.0047222596f),
+    Q31(-0.0055337211f), Q31(-0.0063792293f), Q31(-0.0072615816f), Q31(-0.0081798233f),
+    Q31(-0.0091325329f), Q31(-0.0101150215f), Q31(-0.0111315548f), Q31(-0.0121849995f),
+    Q31( 0.0132718220f), Q31( 0.0143904666f), Q31( 0.0155405553f), Q31( 0.0167324712f),
+    Q31( 0.0179433381f), Q31( 0.0191872431f), Q31( 0.0204531793f), Q31( 0.0217467550f),
+    Q31( 0.0230680169f), Q31( 0.0244160992f), Q31( 0.0257875847f), Q31( 0.0271859429f),
+    Q31( 0.0286072173f), Q31( 0.0300502657f), Q31( 0.0315017608f), Q31( 0.0329754081f),
+    Q31( 0.0344620948f), Q31( 0.0359697560f), Q31( 0.0374812850f), Q31( 0.0390053679f),
+    Q31( 0.0405349170f), Q31( 0.0420649094f), Q31( 0.0436097542f), Q31( 0.0451488405f),
+    Q31( 0.0466843027f), Q31( 0.0482165720f), Q31( 0.0497385755f), Q31( 0.0512556155f),
+    Q31( 0.0527630746f), Q31( 0.0542452768f), Q31( 0.0557173648f), Q31( 0.0571616450f),
+    Q31( 0.0585915683f), Q31( 0.0599837480f), Q31( 0.0613455171f), Q31( 0.0626857808f),
+    Q31( 0.0639715898f), Q31( 0.0652247106f), Q31( 0.0664367512f), Q31( 0.0676075985f),
+    Q31( 0.0687043828f), Q31( 0.0697630244f), Q31( 0.0707628710f), Q31( 0.0717002673f),
+    Q31( 0.0725682583f), Q31( 0.0733620255f), Q31( 0.0741003642f), Q31( 0.0747452558f),
+    Q31( 0.0753137336f), Q31( 0.0758008358f), Q31( 0.0761992479f), Q31( 0.0764992170f),
+    Q31( 0.0767093490f), Q31( 0.0768173975f), Q31( 0.0768230011f), Q31( 0.0767204924f),
+    Q31( 0.0765050718f), Q31( 0.0761748321f), Q31( 0.0757305756f), Q31( 0.0751576255f),
+    Q31( 0.0744664394f), Q31( 0.0736406005f), Q31( 0.0726774642f), Q31( 0.0715826364f),
+    Q31( 0.0703533073f), Q31( 0.0689664013f), Q31( 0.0674525021f), Q31( 0.0657690668f),
+    Q31( 0.0639444805f), Q31( 0.0619602779f), Q31( 0.0598166570f), Q31( 0.0575152691f),
+    Q31( 0.0550460034f), Q31( 0.0524093821f), Q31( 0.0495978676f), Q31( 0.0466303305f),
+    Q31( 0.0434768782f), Q31( 0.0401458278f), Q31( 0.0366418116f), Q31( 0.0329583930f),
+    Q31( 0.0290824006f), Q31( 0.0250307561f), Q31( 0.0207997072f), Q31( 0.0163701258f),
+    Q31( 0.0117623832f), Q31( 0.0069636862f), Q31( 0.0019765601f), Q31(-0.0032086896f),
+    Q31(-0.0085711749f), Q31(-0.0141288827f), Q31(-0.0198834129f), Q31(-0.0258227288f),
+    Q31(-0.0319531274f), Q31(-0.0382776572f), Q31(-0.0447806821f), Q31(-0.0514804176f),
+    Q31(-0.0583705326f), Q31(-0.0654409853f), Q31(-0.0726943300f), Q31(-0.0801372934f),
+    Q31(-0.0877547536f), Q31(-0.0955533352f), Q31(-0.1035329531f), Q31(-0.1116826931f),
+    Q31(-0.1200077984f), Q31(-0.1285002850f), Q31(-0.1371551761f), Q31(-0.1459766491f),
+    Q31(-0.1549607071f), Q31(-0.1640958855f), Q31(-0.1733808172f), Q31(-0.1828172548f),
+    Q31(-0.1923966745f), Q31(-0.2021250176f), Q31(-0.2119735853f), Q31(-0.2219652696f),
+    Q31(-0.2320690870f), Q31(-0.2423016884f), Q31(-0.2526480309f), Q31(-0.2631053299f),
+    Q31(-0.2736634040f), Q31(-0.2843214189f), Q31(-0.2950716717f), Q31(-0.3059098575f),
+    Q31(-0.3168278913f), Q31(-0.3278113727f), Q31(-0.3388722693f), Q31(-0.3499914122f),
+    Q31( 0.3611589903f), Q31( 0.3723795546f), Q31( 0.3836350013f), Q31( 0.3949211761f),
+    Q31( 0.4062317676f), Q31( 0.4175696896f), Q31( 0.4289119920f), Q31( 0.4402553754f),
+    Q31( 0.4515996535f), Q31( 0.4629308085f), Q31( 0.4742453214f), Q31( 0.4855253091f),
+    Q31( 0.4967708254f), Q31( 0.5079817500f), Q31( 0.5191234970f), Q31( 0.5302240895f),
+    Q31( 0.5412553448f), Q31( 0.5522051258f), Q31( 0.5630789140f), Q31( 0.5738524131f),
+    Q31( 0.5845403235f), Q31( 0.5951123086f), Q31( 0.6055783538f), Q31( 0.6159109932f),
+    Q31( 0.6261242695f), Q31( 0.6361980107f), Q31( 0.6461269695f), Q31( 0.6559016302f),
+    Q31( 0.6655139880f), Q31( 0.6749663190f), Q31( 0.6842353293f), Q31( 0.6933282376f),
+    Q31( 0.7022388719f), Q31( 0.7109410426f), Q31( 0.7194462634f), Q31( 0.7277448900f),
+    Q31( 0.7358211758f), Q31( 0.7436827863f), Q31( 0.7513137456f), Q31( 0.7587080760f),
+    Q31( 0.7658674865f), Q31( 0.7727780881f), Q31( 0.7794287519f), Q31( 0.7858353120f),
+    Q31( 0.7919735841f), Q31( 0.7978466413f), Q31( 0.8034485751f), Q31( 0.8087695004f),
+    Q31( 0.8138191270f), Q31( 0.8185776004f), Q31( 0.8230419890f), Q31( 0.8272275347f),
+    Q31( 0.8311038457f), Q31( 0.8346937361f), Q31( 0.8379717337f), Q31( 0.8409541392f),
+    Q31( 0.8436238281f), Q31( 0.8459818469f), Q31( 0.8480315777f), Q31( 0.8497805198f),
+    Q31( 0.8511971524f), Q31( 0.8523047035f), Q31( 0.8531020949f), Q31( 0.8535720573f),
+    Q31( 0.8537385600f),
+};
+
+#endif /* AVCODEC_AACSBR_TABLEGEN_COMMON_H */
diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c
index 774f12e..821615f 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -37,6 +37,10 @@
 static av_cold void aacsbr_tableinit(void)
 {
     int n;
+    for (n = 1; n < 320; n++)
+        sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n];
+    sbr_qmf_window_us[384] = -sbr_qmf_window_us[384];
+    sbr_qmf_window_us[512] = -sbr_qmf_window_us[512];
 
     for (n = 0; n < 320; n++)
         sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n];
@@ -953,7 +957,7 @@
             skip_bits_long(gb, *num_bits_left); // bs_fill_bits
             *num_bits_left = 0;
         } else {
-            *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps.common, *num_bits_left);
+            *num_bits_left -= AAC_RENAME(ff_ps_read_data)(ac->avctx, gb, &sbr->ps, *num_bits_left);
             ac->avctx->profile = FF_PROFILE_AAC_HE_V2;
         }
         break;
@@ -1544,7 +1548,7 @@
     }
 
     if (ac->oc[1].m4ac.ps == 1) {
-        if (sbr->ps.common.start) {
+        if (sbr->ps.start) {
             AAC_RENAME(ff_ps_apply)(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]);
         } else {
             memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0]));
diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h
index 7a11594..4ff8fae 100644
--- a/libavcodec/aacsbrdata.h
+++ b/libavcodec/aacsbrdata.h
@@ -29,7 +29,7 @@
 #define AVCODEC_AACSBRDATA_H
 
 #include <stdint.h>
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "aac_defines.h"
 
 ///< Huffman tables for SBR
@@ -532,171 +532,4 @@
 {Q31(-0.01053049862020f), Q31(-0.66959058036166f)}, {Q31(-0.91266367957293f), Q31(-0.11522938140034f)},
 };
 
-///< window coefficients for analysis/synthesis QMF banks
-static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320];
-/* This table contains redundancy: It is symmetric about the entry #320
- * with the exception of entries 384 and 512 which are negated. */
-static const DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_us)[640] = {
-     Q31( 0.0000000000f), Q31(-0.0005525286f), Q31(-0.0005617692f), Q31(-0.0004947518f),
-     Q31(-0.0004875227f), Q31(-0.0004893791f), Q31(-0.0005040714f), Q31(-0.0005226564f),
-     Q31(-0.0005466565f), Q31(-0.0005677802f), Q31(-0.0005870930f), Q31(-0.0006132747f),
-     Q31(-0.0006312493f), Q31(-0.0006540333f), Q31(-0.0006777690f), Q31(-0.0006941614f),
-     Q31(-0.0007157736f), Q31(-0.0007255043f), Q31(-0.0007440941f), Q31(-0.0007490598f),
-     Q31(-0.0007681371f), Q31(-0.0007724848f), Q31(-0.0007834332f), Q31(-0.0007779869f),
-     Q31(-0.0007803664f), Q31(-0.0007801449f), Q31(-0.0007757977f), Q31(-0.0007630793f),
-     Q31(-0.0007530001f), Q31(-0.0007319357f), Q31(-0.0007215391f), Q31(-0.0006917937f),
-     Q31(-0.0006650415f), Q31(-0.0006341594f), Q31(-0.0005946118f), Q31(-0.0005564576f),
-     Q31(-0.0005145572f), Q31(-0.0004606325f), Q31(-0.0004095121f), Q31(-0.0003501175f),
-     Q31(-0.0002896981f), Q31(-0.0002098337f), Q31(-0.0001446380f), Q31(-0.0000617334f),
-     Q31( 0.0000134949f), Q31( 0.0001094383f), Q31( 0.0002043017f), Q31( 0.0002949531f),
-     Q31( 0.0004026540f), Q31( 0.0005107388f), Q31( 0.0006239376f), Q31( 0.0007458025f),
-     Q31( 0.0008608443f), Q31( 0.0009885988f), Q31( 0.0011250155f), Q31( 0.0012577884f),
-     Q31( 0.0013902494f), Q31( 0.0015443219f), Q31( 0.0016868083f), Q31( 0.0018348265f),
-     Q31( 0.0019841140f), Q31( 0.0021461583f), Q31( 0.0023017254f), Q31( 0.0024625616f),
-     Q31( 0.0026201758f), Q31( 0.0027870464f), Q31( 0.0029469447f), Q31( 0.0031125420f),
-     Q31( 0.0032739613f), Q31( 0.0034418874f), Q31( 0.0036008268f), Q31( 0.0037603922f),
-     Q31( 0.0039207432f), Q31( 0.0040819753f), Q31( 0.0042264269f), Q31( 0.0043730719f),
-     Q31( 0.0045209852f), Q31( 0.0046606460f), Q31( 0.0047932560f), Q31( 0.0049137603f),
-     Q31( 0.0050393022f), Q31( 0.0051407353f), Q31( 0.0052461166f), Q31( 0.0053471681f),
-     Q31( 0.0054196775f), Q31( 0.0054876040f), Q31( 0.0055475714f), Q31( 0.0055938023f),
-     Q31( 0.0056220643f), Q31( 0.0056455196f), Q31( 0.0056389199f), Q31( 0.0056266114f),
-     Q31( 0.0055917128f), Q31( 0.0055404363f), Q31( 0.0054753783f), Q31( 0.0053838975f),
-     Q31( 0.0052715758f), Q31( 0.0051382275f), Q31( 0.0049839687f), Q31( 0.0048109469f),
-     Q31( 0.0046039530f), Q31( 0.0043801861f), Q31( 0.0041251642f), Q31( 0.0038456408f),
-     Q31( 0.0035401246f), Q31( 0.0032091885f), Q31( 0.0028446757f), Q31( 0.0024508540f),
-     Q31( 0.0020274176f), Q31( 0.0015784682f), Q31( 0.0010902329f), Q31( 0.0005832264f),
-     Q31( 0.0000276045f), Q31(-0.0005464280f), Q31(-0.0011568135f), Q31(-0.0018039472f),
-     Q31(-0.0024826723f), Q31(-0.0031933778f), Q31(-0.0039401124f), Q31(-0.0047222596f),
-     Q31(-0.0055337211f), Q31(-0.0063792293f), Q31(-0.0072615816f), Q31(-0.0081798233f),
-     Q31(-0.0091325329f), Q31(-0.0101150215f), Q31(-0.0111315548f), Q31(-0.0121849995f),
-     Q31( 0.0132718220f), Q31( 0.0143904666f), Q31( 0.0155405553f), Q31( 0.0167324712f),
-     Q31( 0.0179433381f), Q31( 0.0191872431f), Q31( 0.0204531793f), Q31( 0.0217467550f),
-     Q31( 0.0230680169f), Q31( 0.0244160992f), Q31( 0.0257875847f), Q31( 0.0271859429f),
-     Q31( 0.0286072173f), Q31( 0.0300502657f), Q31( 0.0315017608f), Q31( 0.0329754081f),
-     Q31( 0.0344620948f), Q31( 0.0359697560f), Q31( 0.0374812850f), Q31( 0.0390053679f),
-     Q31( 0.0405349170f), Q31( 0.0420649094f), Q31( 0.0436097542f), Q31( 0.0451488405f),
-     Q31( 0.0466843027f), Q31( 0.0482165720f), Q31( 0.0497385755f), Q31( 0.0512556155f),
-     Q31( 0.0527630746f), Q31( 0.0542452768f), Q31( 0.0557173648f), Q31( 0.0571616450f),
-     Q31( 0.0585915683f), Q31( 0.0599837480f), Q31( 0.0613455171f), Q31( 0.0626857808f),
-     Q31( 0.0639715898f), Q31( 0.0652247106f), Q31( 0.0664367512f), Q31( 0.0676075985f),
-     Q31( 0.0687043828f), Q31( 0.0697630244f), Q31( 0.0707628710f), Q31( 0.0717002673f),
-     Q31( 0.0725682583f), Q31( 0.0733620255f), Q31( 0.0741003642f), Q31( 0.0747452558f),
-     Q31( 0.0753137336f), Q31( 0.0758008358f), Q31( 0.0761992479f), Q31( 0.0764992170f),
-     Q31( 0.0767093490f), Q31( 0.0768173975f), Q31( 0.0768230011f), Q31( 0.0767204924f),
-     Q31( 0.0765050718f), Q31( 0.0761748321f), Q31( 0.0757305756f), Q31( 0.0751576255f),
-     Q31( 0.0744664394f), Q31( 0.0736406005f), Q31( 0.0726774642f), Q31( 0.0715826364f),
-     Q31( 0.0703533073f), Q31( 0.0689664013f), Q31( 0.0674525021f), Q31( 0.0657690668f),
-     Q31( 0.0639444805f), Q31( 0.0619602779f), Q31( 0.0598166570f), Q31( 0.0575152691f),
-     Q31( 0.0550460034f), Q31( 0.0524093821f), Q31( 0.0495978676f), Q31( 0.0466303305f),
-     Q31( 0.0434768782f), Q31( 0.0401458278f), Q31( 0.0366418116f), Q31( 0.0329583930f),
-     Q31( 0.0290824006f), Q31( 0.0250307561f), Q31( 0.0207997072f), Q31( 0.0163701258f),
-     Q31( 0.0117623832f), Q31( 0.0069636862f), Q31( 0.0019765601f), Q31(-0.0032086896f),
-     Q31(-0.0085711749f), Q31(-0.0141288827f), Q31(-0.0198834129f), Q31(-0.0258227288f),
-     Q31(-0.0319531274f), Q31(-0.0382776572f), Q31(-0.0447806821f), Q31(-0.0514804176f),
-     Q31(-0.0583705326f), Q31(-0.0654409853f), Q31(-0.0726943300f), Q31(-0.0801372934f),
-     Q31(-0.0877547536f), Q31(-0.0955533352f), Q31(-0.1035329531f), Q31(-0.1116826931f),
-     Q31(-0.1200077984f), Q31(-0.1285002850f), Q31(-0.1371551761f), Q31(-0.1459766491f),
-     Q31(-0.1549607071f), Q31(-0.1640958855f), Q31(-0.1733808172f), Q31(-0.1828172548f),
-     Q31(-0.1923966745f), Q31(-0.2021250176f), Q31(-0.2119735853f), Q31(-0.2219652696f),
-     Q31(-0.2320690870f), Q31(-0.2423016884f), Q31(-0.2526480309f), Q31(-0.2631053299f),
-     Q31(-0.2736634040f), Q31(-0.2843214189f), Q31(-0.2950716717f), Q31(-0.3059098575f),
-     Q31(-0.3168278913f), Q31(-0.3278113727f), Q31(-0.3388722693f), Q31(-0.3499914122f),
-     Q31( 0.3611589903f), Q31( 0.3723795546f), Q31( 0.3836350013f), Q31( 0.3949211761f),
-     Q31( 0.4062317676f), Q31( 0.4175696896f), Q31( 0.4289119920f), Q31( 0.4402553754f),
-     Q31( 0.4515996535f), Q31( 0.4629308085f), Q31( 0.4742453214f), Q31( 0.4855253091f),
-     Q31( 0.4967708254f), Q31( 0.5079817500f), Q31( 0.5191234970f), Q31( 0.5302240895f),
-     Q31( 0.5412553448f), Q31( 0.5522051258f), Q31( 0.5630789140f), Q31( 0.5738524131f),
-     Q31( 0.5845403235f), Q31( 0.5951123086f), Q31( 0.6055783538f), Q31( 0.6159109932f),
-     Q31( 0.6261242695f), Q31( 0.6361980107f), Q31( 0.6461269695f), Q31( 0.6559016302f),
-     Q31( 0.6655139880f), Q31( 0.6749663190f), Q31( 0.6842353293f), Q31( 0.6933282376f),
-     Q31( 0.7022388719f), Q31( 0.7109410426f), Q31( 0.7194462634f), Q31( 0.7277448900f),
-     Q31( 0.7358211758f), Q31( 0.7436827863f), Q31( 0.7513137456f), Q31( 0.7587080760f),
-     Q31( 0.7658674865f), Q31( 0.7727780881f), Q31( 0.7794287519f), Q31( 0.7858353120f),
-     Q31( 0.7919735841f), Q31( 0.7978466413f), Q31( 0.8034485751f), Q31( 0.8087695004f),
-     Q31( 0.8138191270f), Q31( 0.8185776004f), Q31( 0.8230419890f), Q31( 0.8272275347f),
-     Q31( 0.8311038457f), Q31( 0.8346937361f), Q31( 0.8379717337f), Q31( 0.8409541392f),
-     Q31( 0.8436238281f), Q31( 0.8459818469f), Q31( 0.8480315777f), Q31( 0.8497805198f),
-     Q31( 0.8511971524f), Q31( 0.8523047035f), Q31( 0.8531020949f), Q31( 0.8535720573f),
-     Q31( 0.8537385600f), Q31( 0.8535720573f), Q31( 0.8531020949f), Q31( 0.8523047035f),
-     Q31( 0.8511971524f), Q31( 0.8497805198f), Q31( 0.8480315777f), Q31( 0.8459818469f),
-     Q31( 0.8436238281f), Q31( 0.8409541392f), Q31( 0.8379717337f), Q31( 0.8346937361f),
-     Q31( 0.8311038457f), Q31( 0.8272275347f), Q31( 0.8230419890f), Q31( 0.8185776004f),
-     Q31( 0.8138191270f), Q31( 0.8087695004f), Q31( 0.8034485751f), Q31( 0.7978466413f),
-     Q31( 0.7919735841f), Q31( 0.7858353120f), Q31( 0.7794287519f), Q31( 0.7727780881f),
-     Q31( 0.7658674865f), Q31( 0.7587080760f), Q31( 0.7513137456f), Q31( 0.7436827863f),
-     Q31( 0.7358211758f), Q31( 0.7277448900f), Q31( 0.7194462634f), Q31( 0.7109410426f),
-     Q31( 0.7022388719f), Q31( 0.6933282376f), Q31( 0.6842353293f), Q31( 0.6749663190f),
-     Q31( 0.6655139880f), Q31( 0.6559016302f), Q31( 0.6461269695f), Q31( 0.6361980107f),
-     Q31( 0.6261242695f), Q31( 0.6159109932f), Q31( 0.6055783538f), Q31( 0.5951123086f),
-     Q31( 0.5845403235f), Q31( 0.5738524131f), Q31( 0.5630789140f), Q31( 0.5522051258f),
-     Q31( 0.5412553448f), Q31( 0.5302240895f), Q31( 0.5191234970f), Q31( 0.5079817500f),
-     Q31( 0.4967708254f), Q31( 0.4855253091f), Q31( 0.4742453214f), Q31( 0.4629308085f),
-     Q31( 0.4515996535f), Q31( 0.4402553754f), Q31( 0.4289119920f), Q31( 0.4175696896f),
-     Q31( 0.4062317676f), Q31( 0.3949211761f), Q31( 0.3836350013f), Q31( 0.3723795546f),
-    -Q31( 0.3611589903f), Q31(-0.3499914122f), Q31(-0.3388722693f), Q31(-0.3278113727f),
-     Q31(-0.3168278913f), Q31(-0.3059098575f), Q31(-0.2950716717f), Q31(-0.2843214189f),
-     Q31(-0.2736634040f), Q31(-0.2631053299f), Q31(-0.2526480309f), Q31(-0.2423016884f),
-     Q31(-0.2320690870f), Q31(-0.2219652696f), Q31(-0.2119735853f), Q31(-0.2021250176f),
-     Q31(-0.1923966745f), Q31(-0.1828172548f), Q31(-0.1733808172f), Q31(-0.1640958855f),
-     Q31(-0.1549607071f), Q31(-0.1459766491f), Q31(-0.1371551761f), Q31(-0.1285002850f),
-     Q31(-0.1200077984f), Q31(-0.1116826931f), Q31(-0.1035329531f), Q31(-0.0955533352f),
-     Q31(-0.0877547536f), Q31(-0.0801372934f), Q31(-0.0726943300f), Q31(-0.0654409853f),
-     Q31(-0.0583705326f), Q31(-0.0514804176f), Q31(-0.0447806821f), Q31(-0.0382776572f),
-     Q31(-0.0319531274f), Q31(-0.0258227288f), Q31(-0.0198834129f), Q31(-0.0141288827f),
-     Q31(-0.0085711749f), Q31(-0.0032086896f), Q31( 0.0019765601f), Q31( 0.0069636862f),
-     Q31( 0.0117623832f), Q31( 0.0163701258f), Q31( 0.0207997072f), Q31( 0.0250307561f),
-     Q31( 0.0290824006f), Q31( 0.0329583930f), Q31( 0.0366418116f), Q31( 0.0401458278f),
-     Q31( 0.0434768782f), Q31( 0.0466303305f), Q31( 0.0495978676f), Q31( 0.0524093821f),
-     Q31( 0.0550460034f), Q31( 0.0575152691f), Q31( 0.0598166570f), Q31( 0.0619602779f),
-     Q31( 0.0639444805f), Q31( 0.0657690668f), Q31( 0.0674525021f), Q31( 0.0689664013f),
-     Q31( 0.0703533073f), Q31( 0.0715826364f), Q31( 0.0726774642f), Q31( 0.0736406005f),
-     Q31( 0.0744664394f), Q31( 0.0751576255f), Q31( 0.0757305756f), Q31( 0.0761748321f),
-     Q31( 0.0765050718f), Q31( 0.0767204924f), Q31( 0.0768230011f), Q31( 0.0768173975f),
-     Q31( 0.0767093490f), Q31( 0.0764992170f), Q31( 0.0761992479f), Q31( 0.0758008358f),
-     Q31( 0.0753137336f), Q31( 0.0747452558f), Q31( 0.0741003642f), Q31( 0.0733620255f),
-     Q31( 0.0725682583f), Q31( 0.0717002673f), Q31( 0.0707628710f), Q31( 0.0697630244f),
-     Q31( 0.0687043828f), Q31( 0.0676075985f), Q31( 0.0664367512f), Q31( 0.0652247106f),
-     Q31( 0.0639715898f), Q31( 0.0626857808f), Q31( 0.0613455171f), Q31( 0.0599837480f),
-     Q31( 0.0585915683f), Q31( 0.0571616450f), Q31( 0.0557173648f), Q31( 0.0542452768f),
-     Q31( 0.0527630746f), Q31( 0.0512556155f), Q31( 0.0497385755f), Q31( 0.0482165720f),
-     Q31( 0.0466843027f), Q31( 0.0451488405f), Q31( 0.0436097542f), Q31( 0.0420649094f),
-     Q31( 0.0405349170f), Q31( 0.0390053679f), Q31( 0.0374812850f), Q31( 0.0359697560f),
-     Q31( 0.0344620948f), Q31( 0.0329754081f), Q31( 0.0315017608f), Q31( 0.0300502657f),
-     Q31( 0.0286072173f), Q31( 0.0271859429f), Q31( 0.0257875847f), Q31( 0.0244160992f),
-     Q31( 0.0230680169f), Q31( 0.0217467550f), Q31( 0.0204531793f), Q31( 0.0191872431f),
-     Q31( 0.0179433381f), Q31( 0.0167324712f), Q31( 0.0155405553f), Q31( 0.0143904666f),
-    -Q31( 0.0132718220f), Q31(-0.0121849995f), Q31(-0.0111315548f), Q31(-0.0101150215f),
-     Q31(-0.0091325329f), Q31(-0.0081798233f), Q31(-0.0072615816f), Q31(-0.0063792293f),
-     Q31(-0.0055337211f), Q31(-0.0047222596f), Q31(-0.0039401124f), Q31(-0.0031933778f),
-     Q31(-0.0024826723f), Q31(-0.0018039472f), Q31(-0.0011568135f), Q31(-0.0005464280f),
-     Q31( 0.0000276045f), Q31( 0.0005832264f), Q31( 0.0010902329f), Q31( 0.0015784682f),
-     Q31( 0.0020274176f), Q31( 0.0024508540f), Q31( 0.0028446757f), Q31( 0.0032091885f),
-     Q31( 0.0035401246f), Q31( 0.0038456408f), Q31( 0.0041251642f), Q31( 0.0043801861f),
-     Q31( 0.0046039530f), Q31( 0.0048109469f), Q31( 0.0049839687f), Q31( 0.0051382275f),
-     Q31( 0.0052715758f), Q31( 0.0053838975f), Q31( 0.0054753783f), Q31( 0.0055404363f),
-     Q31( 0.0055917128f), Q31( 0.0056266114f), Q31( 0.0056389199f), Q31( 0.0056455196f),
-     Q31( 0.0056220643f), Q31( 0.0055938023f), Q31( 0.0055475714f), Q31( 0.0054876040f),
-     Q31( 0.0054196775f), Q31( 0.0053471681f), Q31( 0.0052461166f), Q31( 0.0051407353f),
-     Q31( 0.0050393022f), Q31( 0.0049137603f), Q31( 0.0047932560f), Q31( 0.0046606460f),
-     Q31( 0.0045209852f), Q31( 0.0043730719f), Q31( 0.0042264269f), Q31( 0.0040819753f),
-     Q31( 0.0039207432f), Q31( 0.0037603922f), Q31( 0.0036008268f), Q31( 0.0034418874f),
-     Q31( 0.0032739613f), Q31( 0.0031125420f), Q31( 0.0029469447f), Q31( 0.0027870464f),
-     Q31( 0.0026201758f), Q31( 0.0024625616f), Q31( 0.0023017254f), Q31( 0.0021461583f),
-     Q31( 0.0019841140f), Q31( 0.0018348265f), Q31( 0.0016868083f), Q31( 0.0015443219f),
-     Q31( 0.0013902494f), Q31( 0.0012577884f), Q31( 0.0011250155f), Q31( 0.0009885988f),
-     Q31( 0.0008608443f), Q31( 0.0007458025f), Q31( 0.0006239376f), Q31( 0.0005107388f),
-     Q31( 0.0004026540f), Q31( 0.0002949531f), Q31( 0.0002043017f), Q31( 0.0001094383f),
-     Q31( 0.0000134949f), Q31(-0.0000617334f), Q31(-0.0001446380f), Q31(-0.0002098337f),
-     Q31(-0.0002896981f), Q31(-0.0003501175f), Q31(-0.0004095121f), Q31(-0.0004606325f),
-     Q31(-0.0005145572f), Q31(-0.0005564576f), Q31(-0.0005946118f), Q31(-0.0006341594f),
-     Q31(-0.0006650415f), Q31(-0.0006917937f), Q31(-0.0007215391f), Q31(-0.0007319357f),
-     Q31(-0.0007530001f), Q31(-0.0007630793f), Q31(-0.0007757977f), Q31(-0.0007801449f),
-     Q31(-0.0007803664f), Q31(-0.0007779869f), Q31(-0.0007834332f), Q31(-0.0007724848f),
-     Q31(-0.0007681371f), Q31(-0.0007490598f), Q31(-0.0007440941f), Q31(-0.0007255043f),
-     Q31(-0.0007157736f), Q31(-0.0006941614f), Q31(-0.0006777690f), Q31(-0.0006540333f),
-     Q31(-0.0006312493f), Q31(-0.0006132747f), Q31(-0.0005870930f), Q31(-0.0005677802f),
-     Q31(-0.0005466565f), Q31(-0.0005226564f), Q31(-0.0005040714f), Q31(-0.0004893791f),
-     Q31(-0.0004875227f), Q31(-0.0004947518f), Q31(-0.0005617692f), Q31(-0.0005525286f),
-};
-
 #endif /* AVCODEC_AACSBRDATA_H */
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index fa5420f..abe5fd7 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -29,7 +29,6 @@
 
 #include "config.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "aac.h"
 #include "aactab.h"
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 9b1450c..8a354e8 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -30,7 +30,7 @@
 #ifndef AVCODEC_AACTAB_H
 #define AVCODEC_AACTAB_H
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "aac.h"
 
 #include <stdint.h>
diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 954461f..f6434e4 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -61,6 +61,3 @@
                                            aarch64/vp9lpf_neon.o               \
                                            aarch64/vp9mc_16bpp_neon.o          \
                                            aarch64/vp9mc_neon.o
-NEON-OBJS-$(CONFIG_HEVC_DECODER)        += aarch64/hevcdsp_idct_neon.o         \
-                                           aarch64/hevcdsp_init_aarch64.o      \
-                                           aarch64/hevcdsp_sao_neon.o
diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S b/libavcodec/aarch64/hevcdsp_idct_neon.S
deleted file mode 100644
index 28c11e6..0000000
--- a/libavcodec/aarch64/hevcdsp_idct_neon.S
+++ /dev/null
@@ -1,621 +0,0 @@
-/*
- * ARM NEON optimised IDCT functions for HEVC decoding
- * Copyright (c) 2014 Seppo Tomperi <seppo.tomperi@vtt.fi>
- * Copyright (c) 2017 Alexandra Hájková
- *
- * Ported from arm/hevcdsp_idct_neon.S by
- * Copyright (c) 2020 Reimar Döffinger
- * Copyright (c) 2020 Josh Dekker
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/aarch64/asm.S"
-
-const trans, align=4
-        .short 64, 83, 64, 36
-        .short 89, 75, 50, 18
-        .short 90, 87, 80, 70
-        .short 57, 43, 25, 9
-        .short 90, 90, 88, 85
-        .short 82, 78, 73, 67
-        .short 61, 54, 46, 38
-        .short 31, 22, 13, 4
-endconst
-
-.macro clip10 in1, in2, c1, c2
-        smax        \in1, \in1, \c1
-        smax        \in2, \in2, \c1
-        smin        \in1, \in1, \c2
-        smin        \in2, \in2, \c2
-.endm
-
-function ff_hevc_add_residual_4x4_8_neon, export=1
-        ld1             {v0.8h-v1.8h}, [x1]
-        ld1             {v2.s}[0], [x0], x2
-        ld1             {v2.s}[1], [x0], x2
-        ld1             {v2.s}[2], [x0], x2
-        ld1             {v2.s}[3], [x0], x2
-        sub              x0,  x0,  x2, lsl #2
-        uxtl             v6.8h,  v2.8b
-        uxtl2            v7.8h,  v2.16b
-        sqadd            v0.8h,  v0.8h, v6.8h
-        sqadd            v1.8h,  v1.8h, v7.8h
-        sqxtun           v0.8b,  v0.8h
-        sqxtun2          v0.16b, v1.8h
-        st1             {v0.s}[0], [x0], x2
-        st1             {v0.s}[1], [x0], x2
-        st1             {v0.s}[2], [x0], x2
-        st1             {v0.s}[3], [x0], x2
-        ret
-endfunc
-
-function ff_hevc_add_residual_4x4_10_neon, export=1
-        mov             x12,  x0
-        ld1             {v0.8h-v1.8h}, [x1]
-        ld1             {v2.d}[0], [x12], x2
-        ld1             {v2.d}[1], [x12], x2
-        ld1             {v3.d}[0], [x12], x2
-        sqadd            v0.8h, v0.8h, v2.8h
-        ld1             {v3.d}[1], [x12], x2
-        movi             v4.8h, #0
-        sqadd            v1.8h, v1.8h, v3.8h
-        mvni             v5.8h, #0xFC, lsl #8 // movi #0x3FF
-        clip10           v0.8h, v1.8h, v4.8h, v5.8h
-        st1             {v0.d}[0],  [x0], x2
-        st1             {v0.d}[1],  [x0], x2
-        st1             {v1.d}[0],  [x0], x2
-        st1             {v1.d}[1],  [x0], x2
-        ret
-endfunc
-
-function ff_hevc_add_residual_8x8_8_neon, export=1
-        add             x12,  x0, x2
-        add              x2,  x2, x2
-        mov              x3,  #8
-1:      subs             x3,  x3, #2
-        ld1             {v2.d}[0],     [x0]
-        ld1             {v2.d}[1],    [x12]
-        uxtl             v3.8h,  v2.8b
-        ld1             {v0.8h-v1.8h}, [x1], #32
-        uxtl2            v2.8h,  v2.16b
-        sqadd            v0.8h,  v0.8h,   v3.8h
-        sqadd            v1.8h,  v1.8h,   v2.8h
-        sqxtun           v0.8b,  v0.8h
-        sqxtun2          v0.16b, v1.8h
-        st1             {v0.d}[0],     [x0], x2
-        st1             {v0.d}[1],    [x12], x2
-        bne              1b
-        ret
-endfunc
-
-function ff_hevc_add_residual_8x8_10_neon, export=1
-        add             x12,  x0, x2
-        add              x2,  x2, x2
-        mov              x3,  #8
-        movi             v4.8h, #0
-        mvni             v5.8h, #0xFC, lsl #8 // movi #0x3FF
-1:      subs             x3,  x3, #2
-        ld1             {v0.8h-v1.8h}, [x1], #32
-        ld1             {v2.8h},       [x0]
-        sqadd            v0.8h, v0.8h, v2.8h
-        ld1             {v3.8h},      [x12]
-        sqadd            v1.8h, v1.8h, v3.8h
-        clip10           v0.8h, v1.8h, v4.8h, v5.8h
-        st1             {v0.8h},       [x0], x2
-        st1             {v1.8h},      [x12], x2
-        bne              1b
-        ret
-endfunc
-
-function ff_hevc_add_residual_16x16_8_neon, export=1
-        mov              x3,  #16
-        add             x12, x0, x2
-        add              x2,  x2, x2
-1:      subs             x3,  x3, #2
-        ld1             {v16.16b},     [x0]
-        ld1             {v0.8h-v3.8h}, [x1], #64
-        ld1             {v19.16b},    [x12]
-        uxtl            v17.8h, v16.8b
-        uxtl2           v18.8h, v16.16b
-        uxtl            v20.8h, v19.8b
-        uxtl2           v21.8h, v19.16b
-        sqadd            v0.8h,  v0.8h, v17.8h
-        sqadd            v1.8h,  v1.8h, v18.8h
-        sqadd            v2.8h,  v2.8h, v20.8h
-        sqadd            v3.8h,  v3.8h, v21.8h
-        sqxtun           v0.8b,  v0.8h
-        sqxtun2         v0.16b,  v1.8h
-        sqxtun           v1.8b,  v2.8h
-        sqxtun2         v1.16b,  v3.8h
-        st1             {v0.16b},     [x0], x2
-        st1             {v1.16b},    [x12], x2
-        bne              1b
-        ret
-endfunc
-
-function ff_hevc_add_residual_16x16_10_neon, export=1
-        mov              x3,  #16
-        movi            v20.8h, #0
-        mvni            v21.8h, #0xFC, lsl #8 // movi #0x3FF
-        add             x12,  x0, x2
-        add              x2,  x2, x2
-1:      subs             x3,  x3, #2
-        ld1             {v16.8h-v17.8h}, [x0]
-        ld1             {v0.8h-v3.8h},  [x1], #64
-        sqadd            v0.8h, v0.8h, v16.8h
-        ld1             {v18.8h-v19.8h}, [x12]
-        sqadd            v1.8h, v1.8h, v17.8h
-        sqadd            v2.8h, v2.8h, v18.8h
-        sqadd            v3.8h, v3.8h, v19.8h
-        clip10           v0.8h, v1.8h, v20.8h, v21.8h
-        clip10           v2.8h, v3.8h, v20.8h, v21.8h
-        st1             {v0.8h-v1.8h},   [x0], x2
-        st1             {v2.8h-v3.8h},  [x12], x2
-        bne              1b
-        ret
-endfunc
-
-function ff_hevc_add_residual_32x32_8_neon, export=1
-        add             x12,  x0, x2
-        add              x2,  x2, x2
-        mov              x3,  #32
-1:      subs             x3,  x3, #2
-        ld1             {v20.16b, v21.16b}, [x0]
-        uxtl            v16.8h,  v20.8b
-        uxtl2           v17.8h,  v20.16b
-        ld1             {v22.16b, v23.16b}, [x12]
-        uxtl            v18.8h,  v21.8b
-        uxtl2           v19.8h,  v21.16b
-        uxtl            v20.8h,  v22.8b
-        ld1             {v0.8h-v3.8h}, [x1], #64
-        ld1             {v4.8h-v7.8h}, [x1], #64
-        uxtl2           v21.8h,  v22.16b
-        uxtl            v22.8h,  v23.8b
-        uxtl2           v23.8h,  v23.16b
-        sqadd            v0.8h,  v0.8h,  v16.8h
-        sqadd            v1.8h,  v1.8h,  v17.8h
-        sqadd            v2.8h,  v2.8h,  v18.8h
-        sqadd            v3.8h,  v3.8h,  v19.8h
-        sqadd            v4.8h,  v4.8h,  v20.8h
-        sqadd            v5.8h,  v5.8h,  v21.8h
-        sqadd            v6.8h,  v6.8h,  v22.8h
-        sqadd            v7.8h,  v7.8h,  v23.8h
-        sqxtun           v0.8b,  v0.8h
-        sqxtun2         v0.16b,  v1.8h
-        sqxtun           v1.8b,  v2.8h
-        sqxtun2         v1.16b,  v3.8h
-        sqxtun           v2.8b,  v4.8h
-        sqxtun2         v2.16b,  v5.8h
-        st1             {v0.16b, v1.16b},  [x0], x2
-        sqxtun           v3.8b,  v6.8h
-        sqxtun2         v3.16b,  v7.8h
-        st1             {v2.16b, v3.16b}, [x12], x2
-        bne              1b
-        ret
-endfunc
-
-function ff_hevc_add_residual_32x32_10_neon, export=1
-        mov              x3,  #32
-        movi            v20.8h, #0
-        mvni            v21.8h, #0xFC, lsl #8 // movi #0x3FF
-1:      subs             x3,  x3, #1
-        ld1             {v0.8h-v3.8h},   [x1], #64
-        ld1             {v16.8h-v19.8h}, [x0]
-        sqadd            v0.8h, v0.8h, v16.8h
-        sqadd            v1.8h, v1.8h, v17.8h
-        sqadd            v2.8h, v2.8h, v18.8h
-        sqadd            v3.8h, v3.8h, v19.8h
-        clip10           v0.8h, v1.8h, v20.8h, v21.8h
-        clip10           v2.8h, v3.8h, v20.8h, v21.8h
-        st1             {v0.8h-v3.8h},   [x0], x2
-        bne              1b
-        ret
-endfunc
-
-.macro sum_sub out, in, c, op, p
-  .ifc \op, +
-        smlal\p         \out, \in, \c
-  .else
-        smlsl\p         \out, \in, \c
-  .endif
-.endm
-
-.macro fixsqrshrn d, dt, n, m
-  .ifc \dt, .8h
-        sqrshrn2        \d\dt, \n\().4s, \m
-  .else
-        sqrshrn         \n\().4h, \n\().4s, \m
-        mov             \d\().d[0], \n\().d[0]
-  .endif
-.endm
-
-// uses and clobbers v28-v31 as temp registers
-.macro tr_4x4_8 in0, in1, in2, in3, out0, out1, out2, out3, p1, p2
-         sshll\p1       v28.4s, \in0, #6
-         mov            v29.16b, v28.16b
-         smull\p1       v30.4s, \in1, v0.h[1]
-         smull\p1       v31.4s, \in1, v0.h[3]
-         smlal\p2       v28.4s, \in2, v0.h[0] //e0
-         smlsl\p2       v29.4s, \in2, v0.h[0] //e1
-         smlal\p2       v30.4s, \in3, v0.h[3] //o0
-         smlsl\p2       v31.4s, \in3, v0.h[1] //o1
-
-         add            \out0, v28.4s, v30.4s
-         add            \out1, v29.4s, v31.4s
-         sub            \out2, v29.4s, v31.4s
-         sub            \out3, v28.4s, v30.4s
-.endm
-
-.macro transpose8_4x4 r0, r1, r2, r3
-        trn1            v2.8h, \r0\().8h, \r1\().8h
-        trn2            v3.8h, \r0\().8h, \r1\().8h
-        trn1            v4.8h, \r2\().8h, \r3\().8h
-        trn2            v5.8h, \r2\().8h, \r3\().8h
-        trn1            \r0\().4s, v2.4s, v4.4s
-        trn2            \r2\().4s, v2.4s, v4.4s
-        trn1            \r1\().4s, v3.4s, v5.4s
-        trn2            \r3\().4s, v3.4s, v5.4s
-.endm
-
-.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7
-        transpose8_4x4  \r0, \r1, \r2, \r3
-        transpose8_4x4  \r4, \r5, \r6, \r7
-.endm
-
-.macro tr_8x4 shift, in0,in0t, in1,in1t, in2,in2t, in3,in3t, in4,in4t, in5,in5t, in6,in6t, in7,in7t, p1, p2
-        tr_4x4_8        \in0\in0t, \in2\in2t, \in4\in4t, \in6\in6t, v24.4s, v25.4s, v26.4s, v27.4s, \p1, \p2
-
-        smull\p1        v30.4s, \in1\in1t, v0.h[6]
-        smull\p1        v28.4s, \in1\in1t, v0.h[4]
-        smull\p1        v29.4s, \in1\in1t, v0.h[5]
-        sum_sub         v30.4s, \in3\in3t, v0.h[4], -, \p1
-        sum_sub         v28.4s, \in3\in3t, v0.h[5], +, \p1
-        sum_sub         v29.4s, \in3\in3t, v0.h[7], -, \p1
-
-        sum_sub         v30.4s, \in5\in5t, v0.h[7], +, \p2
-        sum_sub         v28.4s, \in5\in5t, v0.h[6], +, \p2
-        sum_sub         v29.4s, \in5\in5t, v0.h[4], -, \p2
-
-        sum_sub         v30.4s, \in7\in7t, v0.h[5], +, \p2
-        sum_sub         v28.4s, \in7\in7t, v0.h[7], +, \p2
-        sum_sub         v29.4s, \in7\in7t, v0.h[6], -, \p2
-
-        add             v31.4s, v26.4s, v30.4s
-        sub             v26.4s, v26.4s, v30.4s
-        fixsqrshrn      \in2,\in2t, v31, \shift
-
-
-        smull\p1        v31.4s, \in1\in1t, v0.h[7]
-        sum_sub         v31.4s, \in3\in3t, v0.h[6], -, \p1
-        sum_sub         v31.4s, \in5\in5t, v0.h[5], +, \p2
-        sum_sub         v31.4s, \in7\in7t, v0.h[4], -, \p2
-        fixsqrshrn      \in5,\in5t, v26, \shift
-
-
-        add             v26.4s, v24.4s, v28.4s
-        sub             v24.4s, v24.4s, v28.4s
-        add             v28.4s, v25.4s, v29.4s
-        sub             v25.4s, v25.4s, v29.4s
-        add             v30.4s, v27.4s, v31.4s
-        sub             v27.4s, v27.4s, v31.4s
-
-        fixsqrshrn      \in0,\in0t, v26, \shift
-        fixsqrshrn      \in7,\in7t, v24, \shift
-        fixsqrshrn      \in1,\in1t, v28, \shift
-        fixsqrshrn      \in6,\in6t, v25, \shift
-        fixsqrshrn      \in3,\in3t, v30, \shift
-        fixsqrshrn      \in4,\in4t, v27, \shift
-.endm
-
-.macro idct_8x8 bitdepth
-function ff_hevc_idct_8x8_\bitdepth\()_neon, export=1
-//x0 - coeffs
-        mov              x1,  x0
-        ld1             {v16.8h-v19.8h}, [x1], #64
-        ld1             {v20.8h-v23.8h}, [x1]
-
-        movrel           x1, trans
-        ld1             {v0.8h}, [x1]
-
-        tr_8x4          7, v16,.4h, v17,.4h, v18,.4h, v19,.4h, v20,.4h, v21,.4h, v22,.4h, v23,.4h
-        tr_8x4          7, v16,.8h, v17,.8h, v18,.8h, v19,.8h, v20,.8h, v21,.8h, v22,.8h, v23,.8h, 2, 2
-
-        transpose_8x8   v16, v17, v18, v19, v20, v21, v22, v23
-
-        tr_8x4          20 - \bitdepth, v16,.4h, v17,.4h, v18,.4h, v19,.4h, v16,.8h, v17,.8h, v18,.8h, v19,.8h, , 2
-        tr_8x4          20 - \bitdepth, v20,.4h, v21,.4h, v22,.4h, v23,.4h, v20,.8h, v21,.8h, v22,.8h, v23,.8h, , 2
-
-        transpose_8x8   v16, v17, v18, v19, v20, v21, v22, v23
-
-        mov              x1,  x0
-        st1             {v16.8h-v19.8h}, [x1], #64
-        st1             {v20.8h-v23.8h}, [x1]
-
-        ret
-endfunc
-.endm
-
-.macro butterfly e, o, tmp_p, tmp_m
-        add        \tmp_p, \e, \o
-        sub        \tmp_m, \e, \o
-.endm
-
-.macro tr16_8x4 in0, in1, in2, in3, offset
-        tr_4x4_8        \in0\().4h, \in1\().4h, \in2\().4h, \in3\().4h, v24.4s, v25.4s, v26.4s, v27.4s
-
-        smull2          v28.4s, \in0\().8h, v0.h[4]
-        smull2          v29.4s, \in0\().8h, v0.h[5]
-        smull2          v30.4s, \in0\().8h, v0.h[6]
-        smull2          v31.4s, \in0\().8h, v0.h[7]
-        sum_sub         v28.4s, \in1\().8h, v0.h[5], +, 2
-        sum_sub         v29.4s, \in1\().8h, v0.h[7], -, 2
-        sum_sub         v30.4s, \in1\().8h, v0.h[4], -, 2
-        sum_sub         v31.4s, \in1\().8h, v0.h[6], -, 2
-
-        sum_sub         v28.4s, \in2\().8h, v0.h[6], +, 2
-        sum_sub         v29.4s, \in2\().8h, v0.h[4], -, 2
-        sum_sub         v30.4s, \in2\().8h, v0.h[7], +, 2
-        sum_sub         v31.4s, \in2\().8h, v0.h[5], +, 2
-
-        sum_sub         v28.4s, \in3\().8h, v0.h[7], +, 2
-        sum_sub         v29.4s, \in3\().8h, v0.h[6], -, 2
-        sum_sub         v30.4s, \in3\().8h, v0.h[5], +, 2
-        sum_sub         v31.4s, \in3\().8h, v0.h[4], -, 2
-
-        butterfly       v24.4s, v28.4s, v16.4s, v23.4s
-        butterfly       v25.4s, v29.4s, v17.4s, v22.4s
-        butterfly       v26.4s, v30.4s, v18.4s, v21.4s
-        butterfly       v27.4s, v31.4s, v19.4s, v20.4s
-        add              x4,  sp,  #\offset
-        st1             {v16.4s-v19.4s}, [x4], #64
-        st1             {v20.4s-v23.4s}, [x4]
-.endm
-
-.macro load16 in0, in1, in2, in3
-        ld1             {\in0}[0], [x1], x2
-        ld1             {\in0}[1], [x3], x2
-        ld1             {\in1}[0], [x1], x2
-        ld1             {\in1}[1], [x3], x2
-        ld1             {\in2}[0], [x1], x2
-        ld1             {\in2}[1], [x3], x2
-        ld1             {\in3}[0], [x1], x2
-        ld1             {\in3}[1], [x3], x2
-.endm
-
-.macro add_member in, t0, t1, t2, t3, t4, t5, t6, t7, op0, op1, op2, op3, op4, op5, op6, op7, p
-        sum_sub v21.4s, \in, \t0, \op0, \p
-        sum_sub v22.4s, \in, \t1, \op1, \p
-        sum_sub v23.4s, \in, \t2, \op2, \p
-        sum_sub v24.4s, \in, \t3, \op3, \p
-        sum_sub v25.4s, \in, \t4, \op4, \p
-        sum_sub v26.4s, \in, \t5, \op5, \p
-        sum_sub v27.4s, \in, \t6, \op6, \p
-        sum_sub v28.4s, \in, \t7, \op7, \p
-.endm
-
-.macro butterfly16 in0, in1, in2, in3, in4, in5, in6, in7
-        add             v20.4s, \in0, \in1
-        sub             \in0, \in0, \in1
-        add             \in1, \in2, \in3
-        sub             \in2, \in2, \in3
-        add             \in3, \in4, \in5
-        sub             \in4, \in4, \in5
-        add             \in5, \in6, \in7
-        sub             \in6, \in6, \in7
-.endm
-
-.macro store16 in0, in1, in2, in3, rx
-        st1             {\in0}[0], [x1], x2
-        st1             {\in0}[1], [x3], \rx
-        st1             {\in1}[0], [x1], x2
-        st1             {\in1}[1], [x3], \rx
-        st1             {\in2}[0], [x1], x2
-        st1             {\in2}[1], [x3], \rx
-        st1             {\in3}[0], [x1], x2
-        st1             {\in3}[1], [x3], \rx
-.endm
-
-.macro scale out0, out1, out2, out3, in0, in1, in2, in3, in4, in5, in6, in7, shift
-        sqrshrn         \out0\().4h, \in0, \shift
-        sqrshrn2        \out0\().8h, \in1, \shift
-        sqrshrn         \out1\().4h, \in2, \shift
-        sqrshrn2        \out1\().8h, \in3, \shift
-        sqrshrn         \out2\().4h, \in4, \shift
-        sqrshrn2        \out2\().8h, \in5, \shift
-        sqrshrn         \out3\().4h, \in6, \shift
-        sqrshrn2        \out3\().8h, \in7, \shift
-.endm
-
-.macro transpose16_4x4_2 r0, r1, r2, r3
-        // lower halves
-        trn1            v2.4h, \r0\().4h, \r1\().4h
-        trn2            v3.4h, \r0\().4h, \r1\().4h
-        trn1            v4.4h, \r2\().4h, \r3\().4h
-        trn2            v5.4h, \r2\().4h, \r3\().4h
-        trn1            v6.2s, v2.2s, v4.2s
-        trn2            v7.2s, v2.2s, v4.2s
-        trn1            v2.2s, v3.2s, v5.2s
-        trn2            v4.2s, v3.2s, v5.2s
-        mov             \r0\().d[0], v6.d[0]
-        mov             \r2\().d[0], v7.d[0]
-        mov             \r1\().d[0], v2.d[0]
-        mov             \r3\().d[0], v4.d[0]
-
-        // upper halves in reverse order
-        trn1            v2.8h, \r3\().8h, \r2\().8h
-        trn2            v3.8h, \r3\().8h, \r2\().8h
-        trn1            v4.8h, \r1\().8h, \r0\().8h
-        trn2            v5.8h, \r1\().8h, \r0\().8h
-        trn1            v6.4s, v2.4s, v4.4s
-        trn2            v7.4s, v2.4s, v4.4s
-        trn1            v2.4s, v3.4s, v5.4s
-        trn2            v4.4s, v3.4s, v5.4s
-        mov             \r3\().d[1], v6.d[1]
-        mov             \r1\().d[1], v7.d[1]
-        mov             \r2\().d[1], v2.d[1]
-        mov             \r0\().d[1], v4.d[1]
-.endm
-
-.macro tr_16x4 name, shift, offset, step
-function func_tr_16x4_\name
-        mov              x1,  x5
-        add              x3,  x5, #(\step * 64)
-        mov              x2,  #(\step * 128)
-        load16          v16.d, v17.d, v18.d, v19.d
-        movrel           x1,  trans
-        ld1             {v0.8h}, [x1]
-
-        tr16_8x4        v16, v17, v18, v19, \offset
-
-        add              x1,  x5, #(\step * 32)
-        add              x3,  x5, #(\step * 3 *32)
-        mov              x2,  #(\step * 128)
-        load16          v20.d, v17.d, v18.d, v19.d
-        movrel           x1, trans, 16
-        ld1             {v1.8h}, [x1]
-        smull           v21.4s, v20.4h, v1.h[0]
-        smull           v22.4s, v20.4h, v1.h[1]
-        smull           v23.4s, v20.4h, v1.h[2]
-        smull           v24.4s, v20.4h, v1.h[3]
-        smull           v25.4s, v20.4h, v1.h[4]
-        smull           v26.4s, v20.4h, v1.h[5]
-        smull           v27.4s, v20.4h, v1.h[6]
-        smull           v28.4s, v20.4h, v1.h[7]
-
-        add_member      v20.8h, v1.h[1], v1.h[4], v1.h[7], v1.h[5], v1.h[2], v1.h[0], v1.h[3], v1.h[6], +, +, +, -, -, -, -, -, 2
-        add_member      v17.4h, v1.h[2], v1.h[7], v1.h[3], v1.h[1], v1.h[6], v1.h[4], v1.h[0], v1.h[5], +, +, -, -, -, +, +, +
-        add_member      v17.8h, v1.h[3], v1.h[5], v1.h[1], v1.h[7], v1.h[0], v1.h[6], v1.h[2], v1.h[4], +, -, -, +, +, +, -, -, 2
-        add_member      v18.4h, v1.h[4], v1.h[2], v1.h[6], v1.h[0], v1.h[7], v1.h[1], v1.h[5], v1.h[3], +, -, -, +, -, -, +, +
-        add_member      v18.8h, v1.h[5], v1.h[0], v1.h[4], v1.h[6], v1.h[1], v1.h[3], v1.h[7], v1.h[2], +, -, +, +, -, +, +, -, 2
-        add_member      v19.4h, v1.h[6], v1.h[3], v1.h[0], v1.h[2], v1.h[5], v1.h[7], v1.h[4], v1.h[1], +, -, +, -, +, +, -, +
-        add_member      v19.8h, v1.h[7], v1.h[6], v1.h[5], v1.h[4], v1.h[3], v1.h[2], v1.h[1], v1.h[0], +, -, +, -, +, -, +, -, 2
-
-        add              x4, sp, #\offset
-        ld1             {v16.4s-v19.4s}, [x4], #64
-
-        butterfly16     v16.4s, v21.4s, v17.4s, v22.4s, v18.4s, v23.4s, v19.4s, v24.4s
-        scale           v29, v30, v31, v24, v20.4s, v16.4s, v21.4s, v17.4s, v22.4s, v18.4s, v23.4s, v19.4s, \shift
-        transpose16_4x4_2 v29, v30, v31, v24
-        mov              x1,  x6
-        add              x3,  x6, #(24 +3*32)
-        mov              x2, #32
-        mov              x4, #-32
-        store16         v29.d, v30.d, v31.d, v24.d, x4
-
-        add             x4, sp, #(\offset + 64)
-        ld1             {v16.4s-v19.4s}, [x4]
-        butterfly16     v16.4s, v25.4s, v17.4s, v26.4s, v18.4s, v27.4s, v19.4s, v28.4s
-        scale           v29, v30, v31, v20, v20.4s, v16.4s, v25.4s, v17.4s, v26.4s, v18.4s, v27.4s, v19.4s, \shift
-        transpose16_4x4_2 v29, v30, v31, v20
-
-        add              x1,  x6, #8
-        add              x3,  x6, #(16 + 3 * 32)
-        mov              x2, #32
-        mov              x4, #-32
-        store16         v29.d, v30.d, v31.d, v20.d, x4
-
-        ret
-endfunc
-.endm
-
-.macro idct_16x16 bitdepth
-function ff_hevc_idct_16x16_\bitdepth\()_neon, export=1
-//r0 - coeffs
-        mov             x15, x30
-
-        // allocate a temp buffer
-        sub              sp,  sp,  #640
-
-.irp i, 0, 1, 2, 3
-        add              x5,  x0, #(8 * \i)
-        add              x6,  sp, #(8 * \i * 16)
-        bl              func_tr_16x4_firstpass
-.endr
-
-.irp i, 0, 1, 2, 3
-        add              x5,  sp, #(8 * \i)
-        add              x6,  x0, #(8 * \i * 16)
-        bl              func_tr_16x4_secondpass_\bitdepth
-.endr
-
-        add              sp,  sp,  #640
-
-        mov             x30, x15
-        ret
-endfunc
-.endm
-
-idct_8x8 8
-idct_8x8 10
-
-tr_16x4 firstpass, 7, 512, 1
-tr_16x4 secondpass_8, 20 - 8, 512, 1
-tr_16x4 secondpass_10, 20 - 10, 512, 1
-
-idct_16x16 8
-idct_16x16 10
-
-// void ff_hevc_idct_NxN_dc_DEPTH_neon(int16_t *coeffs)
-.macro idct_dc size, bitdepth
-function ff_hevc_idct_\size\()x\size\()_dc_\bitdepth\()_neon, export=1
-        movi          v1.8h,  #((1 << (14 - \bitdepth))+1)
-        ld1r         {v4.8h}, [x0]
-        add           v4.8h,  v4.8h,  v1.8h
-        sshr          v0.8h,  v4.8h,  #(15 - \bitdepth)
-        sshr          v1.8h,  v4.8h,  #(15 - \bitdepth)
-.if \size > 4
-        sshr          v2.8h,  v4.8h,  #(15 - \bitdepth)
-        sshr          v3.8h,  v4.8h,  #(15 - \bitdepth)
-.if \size > 16 /* dc 32x32 */
-        mov              x2,  #4
-1:
-        subs             x2,  x2, #1
-.endif
-        add             x12,  x0, #64
-        mov             x13,  #128
-.if \size > 8 /* dc 16x16 */
-        st1            {v0.8h-v3.8h},  [x0], x13
-        st1            {v0.8h-v3.8h}, [x12], x13
-        st1            {v0.8h-v3.8h},  [x0], x13
-        st1            {v0.8h-v3.8h}, [x12], x13
-        st1            {v0.8h-v3.8h},  [x0], x13
-        st1            {v0.8h-v3.8h}, [x12], x13
-.endif /* dc 8x8 */
-        st1            {v0.8h-v3.8h},  [x0], x13
-        st1            {v0.8h-v3.8h}, [x12], x13
-.if \size > 16 /* dc 32x32 */
-        bne             1b
-.endif
-.else /* dc 4x4 */
-        st1            {v0.8h-v1.8h},  [x0]
-.endif
-        ret
-endfunc
-.endm
-
-idct_dc 4, 8
-idct_dc 4, 10
-
-idct_dc 8, 8
-idct_dc 8, 10
-
-idct_dc 16, 8
-idct_dc 16, 10
-
-idct_dc 32, 8
-idct_dc 32, 10
diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c b/libavcodec/aarch64/hevcdsp_init_aarch64.c
deleted file mode 100644
index c785e46..0000000
--- a/libavcodec/aarch64/hevcdsp_init_aarch64.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2020 Reimar Döffinger
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/aarch64/cpu.h"
-#include "libavcodec/hevcdsp.h"
-
-void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs,
-                                     ptrdiff_t stride);
-void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs,
-                                      ptrdiff_t stride);
-void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, int16_t *coeffs,
-                                     ptrdiff_t stride);
-void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, int16_t *coeffs,
-                                      ptrdiff_t stride);
-void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, int16_t *coeffs,
-                                       ptrdiff_t stride);
-void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, int16_t *coeffs,
-                                        ptrdiff_t stride);
-void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, int16_t *coeffs,
-                                       ptrdiff_t stride);
-void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, int16_t *coeffs,
-                                        ptrdiff_t stride);
-void ff_hevc_idct_8x8_8_neon(int16_t *coeffs, int col_limit);
-void ff_hevc_idct_8x8_10_neon(int16_t *coeffs, int col_limit);
-void ff_hevc_idct_16x16_8_neon(int16_t *coeffs, int col_limit);
-void ff_hevc_idct_16x16_10_neon(int16_t *coeffs, int col_limit);
-void ff_hevc_idct_4x4_dc_8_neon(int16_t *coeffs);
-void ff_hevc_idct_8x8_dc_8_neon(int16_t *coeffs);
-void ff_hevc_idct_16x16_dc_8_neon(int16_t *coeffs);
-void ff_hevc_idct_32x32_dc_8_neon(int16_t *coeffs);
-void ff_hevc_idct_4x4_dc_10_neon(int16_t *coeffs);
-void ff_hevc_idct_8x8_dc_10_neon(int16_t *coeffs);
-void ff_hevc_idct_16x16_dc_10_neon(int16_t *coeffs);
-void ff_hevc_idct_32x32_dc_10_neon(int16_t *coeffs);
-void ff_hevc_sao_band_filter_8x8_8_neon(uint8_t *_dst, uint8_t *_src,
-                                  ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                  int16_t *sao_offset_val, int sao_left_class,
-                                  int width, int height);
-
-
-
-av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth)
-{
-    if (!have_neon(av_get_cpu_flags())) return;
-
-    if (bit_depth == 8) {
-        c->add_residual[0]             = ff_hevc_add_residual_4x4_8_neon;
-        c->add_residual[1]             = ff_hevc_add_residual_8x8_8_neon;
-        c->add_residual[2]             = ff_hevc_add_residual_16x16_8_neon;
-        c->add_residual[3]             = ff_hevc_add_residual_32x32_8_neon;
-        c->idct[1]                     = ff_hevc_idct_8x8_8_neon;
-        c->idct[2]                     = ff_hevc_idct_16x16_8_neon;
-        c->idct_dc[0]                  = ff_hevc_idct_4x4_dc_8_neon;
-        c->idct_dc[1]                  = ff_hevc_idct_8x8_dc_8_neon;
-        c->idct_dc[2]                  = ff_hevc_idct_16x16_dc_8_neon;
-        c->idct_dc[3]                  = ff_hevc_idct_32x32_dc_8_neon;
-        c->sao_band_filter[0]          = ff_hevc_sao_band_filter_8x8_8_neon;
-    }
-    if (bit_depth == 10) {
-        c->add_residual[0]             = ff_hevc_add_residual_4x4_10_neon;
-        c->add_residual[1]             = ff_hevc_add_residual_8x8_10_neon;
-        c->add_residual[2]             = ff_hevc_add_residual_16x16_10_neon;
-        c->add_residual[3]             = ff_hevc_add_residual_32x32_10_neon;
-        c->idct[1]                     = ff_hevc_idct_8x8_10_neon;
-        c->idct[2]                     = ff_hevc_idct_16x16_10_neon;
-        c->idct_dc[0]                  = ff_hevc_idct_4x4_dc_10_neon;
-        c->idct_dc[1]                  = ff_hevc_idct_8x8_dc_10_neon;
-        c->idct_dc[2]                  = ff_hevc_idct_16x16_dc_10_neon;
-        c->idct_dc[3]                  = ff_hevc_idct_32x32_dc_10_neon;
-    }
-}
diff --git a/libavcodec/aarch64/hevcdsp_sao_neon.S b/libavcodec/aarch64/hevcdsp_sao_neon.S
deleted file mode 100644
index f9fed83..0000000
--- a/libavcodec/aarch64/hevcdsp_sao_neon.S
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*-arm64-*-
- * vim: syntax=arm64asm
- *
- * AArch64 NEON optimised SAO functions for HEVC decoding
- *
- * Copyright (c) 2020 Josh Dekker <josh@itanimul.li>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/aarch64/asm.S"
-
-// void sao_band_filter(uint8_t *_dst, uint8_t *_src,
-//                      ptrdiff_t stride_dst, ptrdiff_t stride_src,
-//                      int16_t *sao_offset_val, int sao_left_class,
-//                      int width, int height)
-function ff_hevc_sao_band_filter_8x8_8_neon, export=1
-        sub             sp,  sp, #64
-        stp            xzr, xzr, [sp]
-        stp            xzr, xzr, [sp, #16]
-        stp            xzr, xzr, [sp, #32]
-        stp            xzr, xzr, [sp, #48]
-        mov             w8,  #4
-0:
-        ldrsh           x9, [x4,  x8, lsl #1] // x9 = sao_offset_val[k+1]
-        subs            w8,  w8,  #1
-        add            w10,  w8,  w5 // x10 = k + sao_left_class
-        and            w10, w10, #0x1F
-        strh            w9, [sp, x10, lsl #1]
-        bne             0b
-        ld1            {v16.16b-v19.16b}, [sp], #64
-        movi           v20.8h,   #1
-1:      // beginning of line
-        mov             w8,  w6
-2:
-        // Simple layout for accessing 16bit values
-        // with 8bit LUT.
-        //
-        //   00  01  02  03  04  05  06  07
-        // +----------------------------------->
-        // |xDE#xAD|xCA#xFE|xBE#xEF|xFE#xED|....
-        // +----------------------------------->
-        //    i-0     i-1     i-2     i-3
-        // dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
-        ld1            {v2.8b}, [x1]
-        // load src[x]
-        uxtl            v0.8h,  v2.8b
-        // >> shift
-        ushr            v2.8h,  v0.8h, #3 // BIT_DEPTH - 3
-        // x2 (access lower short)
-        shl             v1.8h,  v2.8h, #1 // low (x2, accessing short)
-        // +1 access upper short
-        add             v3.8h,  v1.8h, v20.8h
-        // shift insert index to upper byte
-        sli             v1.8h,  v3.8h, #8
-        // table
-        tbx            v2.16b, {v16.16b-v19.16b}, v1.16b
-        // src[x] + table
-        add             v1.8h,  v0.8h, v2.8h
-        // clip + narrow
-        sqxtun          v4.8b,  v1.8h
-        // store
-        st1            {v4.8b}, [x0]
-        // done 8 pixels
-        subs            w8, w8,  #8
-        bne             2b
-        // finished line
-        subs            w7, w7,  #1
-        add             x0, x0,  x2 // dst += stride_dst
-        add             x1, x1,  x3 // src += stride_src
-        bne             1b
-        ret
-endfunc
diff --git a/libavcodec/aarch64/neontest.c b/libavcodec/aarch64/neontest.c
index a4fc5a0..a24c22d 100644
--- a/libavcodec/aarch64/neontest.c
+++ b/libavcodec/aarch64/neontest.c
@@ -29,7 +29,6 @@
     testneonclobbers(avcodec_open2, avctx, codec, options);
 }
 
-#if FF_API_OLD_ENCDEC
 wrap(avcodec_decode_audio4(AVCodecContext *avctx,
                            AVFrame *frame,
                            int *got_frame_ptr,
@@ -48,22 +47,6 @@
                      got_picture_ptr, avpkt);
 }
 
-wrap(avcodec_encode_audio2(AVCodecContext *avctx,
-                           AVPacket *avpkt,
-                           const AVFrame *frame,
-                           int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
-                     got_packet_ptr);
-}
-
-wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                           const AVFrame *frame, int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
-}
-#endif
-
 wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
                               AVSubtitle *sub,
                               int *got_sub_ptr,
@@ -73,6 +56,15 @@
                      got_sub_ptr, avpkt);
 }
 
+wrap(avcodec_encode_audio2(AVCodecContext *avctx,
+                           AVPacket *avpkt,
+                           const AVFrame *frame,
+                           int *got_packet_ptr))
+{
+    testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
+                     got_packet_ptr);
+}
+
 wrap(avcodec_encode_subtitle(AVCodecContext *avctx,
                              uint8_t *buf, int buf_size,
                              const AVSubtitle *sub))
@@ -80,6 +72,12 @@
     testneonclobbers(avcodec_encode_subtitle, avctx, buf, buf_size, sub);
 }
 
+wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
+                           const AVFrame *frame, int *got_packet_ptr))
+{
+    testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
+}
+
 wrap(avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt))
 {
     testneonclobbers(avcodec_send_packet, avctx, avpkt);
diff --git a/libavcodec/aarch64/vp9dsp_init_16bpp_aarch64_template.c b/libavcodec/aarch64/vp9dsp_init_16bpp_aarch64_template.c
index d2a4e90..8dcfdea 100644
--- a/libavcodec/aarch64/vp9dsp_init_16bpp_aarch64_template.c
+++ b/libavcodec/aarch64/vp9dsp_init_16bpp_aarch64_template.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/aarch64/cpu.h"
 #include "vp9dsp_init.h"
 
diff --git a/libavcodec/aarch64/vp9dsp_init_aarch64.c b/libavcodec/aarch64/vp9dsp_init_aarch64.c
index 4d1fee6..4c69975 100644
--- a/libavcodec/aarch64/vp9dsp_init_aarch64.c
+++ b/libavcodec/aarch64/vp9dsp_init_aarch64.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/aarch64/cpu.h"
 #include "libavcodec/vp9dsp.h"
 #include "vp9dsp_init.h"
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index c7deb56..eaa327a 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -33,7 +33,6 @@
 #include "libavutil/crc.h"
 #include "libavutil/downmix_info.h"
 #include "libavutil/opt.h"
-#include "libavutil/thread.h"
 #include "bswapdsp.h"
 #include "internal.h"
 #include "aac_ac3_parser.h"
@@ -184,26 +183,23 @@
  */
 static av_cold int ac3_decode_init(AVCodecContext *avctx)
 {
-    static AVOnce init_static_once = AV_ONCE_INIT;
     AC3DecodeContext *s = avctx->priv_data;
-    int i, ret;
+    int i;
 
     s->avctx = avctx;
 
-    if ((ret = ff_mdct_init(&s->imdct_256, 8, 1, 1.0)) < 0 ||
-        (ret = ff_mdct_init(&s->imdct_512, 9, 1, 1.0)) < 0)
-        return ret;
+    ac3_tables_init();
+    ff_mdct_init(&s->imdct_256, 8, 1, 1.0);
+    ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
     AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
     ff_bswapdsp_init(&s->bdsp);
 
 #if (USE_FIXED)
     s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
 #else
-    ff_fmt_convert_init(&s->fmt_conv, avctx);
     s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+    ff_fmt_convert_init(&s->fmt_conv, avctx);
 #endif
-    if (!s->fdsp)
-        return AVERROR(ENOMEM);
 
     ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
     av_lfg_init(&s->dith_state, 0);
@@ -227,8 +223,6 @@
         s->dlyptr[i] = s->delay[i];
     }
 
-    ff_thread_once(&init_static_once, ac3_tables_init);
-
     return 0;
 }
 
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 8565399..ce1434b 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -53,8 +53,6 @@
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
 #include "libavutil/lfg.h"
-#include "libavutil/mem_internal.h"
-
 #include "ac3.h"
 #include "ac3dsp.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c
index daab433..f36854c 100644
--- a/libavcodec/ac3dec_fixed.c
+++ b/libavcodec/ac3dec_fixed.c
@@ -182,5 +182,4 @@
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
                                                       AV_SAMPLE_FMT_NONE },
     .priv_class     = &ac3_decoder_class,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
index b18317f..57a626a 100644
--- a/libavcodec/ac3dec_float.c
+++ b/libavcodec/ac3dec_float.c
@@ -67,7 +67,6 @@
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
     .priv_class     = &ac3_decoder_class,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
 
 #if CONFIG_EAC3_DECODER
@@ -92,6 +91,5 @@
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
     .priv_class     = &eac3_decoder_class,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 85c721d..43438da 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "ac3.h"
 #include "ac3dsp.h"
@@ -46,6 +44,49 @@
     }
 }
 
+static int ac3_max_msb_abs_int16_c(const int16_t *src, int len)
+{
+    int i, v = 0;
+    for (i = 0; i < len; i++)
+        v |= abs(src[i]);
+    return v;
+}
+
+static void ac3_lshift_int16_c(int16_t *src, unsigned int len,
+                               unsigned int shift)
+{
+    uint32_t *src32 = (uint32_t *)src;
+    const uint32_t mask = ~(((1 << shift) - 1) << 16);
+    int i;
+    len >>= 1;
+    for (i = 0; i < len; i += 8) {
+        src32[i  ] = (src32[i  ] << shift) & mask;
+        src32[i+1] = (src32[i+1] << shift) & mask;
+        src32[i+2] = (src32[i+2] << shift) & mask;
+        src32[i+3] = (src32[i+3] << shift) & mask;
+        src32[i+4] = (src32[i+4] << shift) & mask;
+        src32[i+5] = (src32[i+5] << shift) & mask;
+        src32[i+6] = (src32[i+6] << shift) & mask;
+        src32[i+7] = (src32[i+7] << shift) & mask;
+    }
+}
+
+static void ac3_rshift_int32_c(int32_t *src, unsigned int len,
+                               unsigned int shift)
+{
+    do {
+        *src++ >>= shift;
+        *src++ >>= shift;
+        *src++ >>= shift;
+        *src++ >>= shift;
+        *src++ >>= shift;
+        *src++ >>= shift;
+        *src++ >>= shift;
+        *src++ >>= shift;
+        len -= 8;
+    } while (len > 0);
+}
+
 static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
 {
     const float scale = 1 << 24;
@@ -333,6 +374,19 @@
         ac3_downmix_c_fixed(samples, matrix, out_ch, in_ch, len);
 }
 
+static void apply_window_int16_c(int16_t *output, const int16_t *input,
+                                 const int16_t *window, unsigned int len)
+{
+    int i;
+    int len2 = len >> 1;
+
+    for (i = 0; i < len2; i++) {
+        int16_t w       = window[i];
+        output[i]       = (MUL16(input[i],       w) + (1 << 14)) >> 15;
+        output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
+    }
+}
+
 void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix,
                        int out_ch, int in_ch, int len)
 {
@@ -368,6 +422,9 @@
 av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
 {
     c->ac3_exponent_min = ac3_exponent_min_c;
+    c->ac3_max_msb_abs_int16 = ac3_max_msb_abs_int16_c;
+    c->ac3_lshift_int16 = ac3_lshift_int16_c;
+    c->ac3_rshift_int32 = ac3_rshift_int32_c;
     c->float_to_fixed24 = float_to_fixed24_c;
     c->bit_alloc_calc_bap = ac3_bit_alloc_calc_bap_c;
     c->update_bap_counts = ac3_update_bap_counts_c;
@@ -379,6 +436,7 @@
     c->out_channels          = 0;
     c->downmix               = NULL;
     c->downmix_fixed         = NULL;
+    c->apply_window_int16 = apply_window_int16_c;
 
     if (ARCH_ARM)
         ff_ac3dsp_init_arm(c, bit_exact);
diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
index a23b115..161de4c 100644
--- a/libavcodec/ac3dsp.h
+++ b/libavcodec/ac3dsp.h
@@ -43,6 +43,39 @@
     void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
 
     /**
+     * Calculate the maximum MSB of the absolute value of each element in an
+     * array of int16_t.
+     * @param src input array
+     *            constraints: align 16. values must be in range [-32767,32767]
+     * @param len number of values in the array
+     *            constraints: multiple of 16 greater than 0
+     * @return    a value with the same MSB as max(abs(src[]))
+     */
+    int (*ac3_max_msb_abs_int16)(const int16_t *src, int len);
+
+    /**
+     * Left-shift each value in an array of int16_t by a specified amount.
+     * @param src    input array
+     *               constraints: align 16
+     * @param len    number of values in the array
+     *               constraints: multiple of 32 greater than 0
+     * @param shift  left shift amount
+     *               constraints: range [0,15]
+     */
+    void (*ac3_lshift_int16)(int16_t *src, unsigned int len, unsigned int shift);
+
+    /**
+     * Right-shift each value in an array of int32_t by a specified amount.
+     * @param src    input array
+     *               constraints: align 16
+     * @param len    number of values in the array
+     *               constraints: multiple of 16 greater than 0
+     * @param shift  right shift amount
+     *               constraints: range [0,31]
+     */
+    void (*ac3_rshift_int32)(int32_t *src, unsigned int len, unsigned int shift);
+
+    /**
      * Convert an array of float in range [-1.0,1.0] to int32_t with range
      * [-(1<<24),(1<<24)]
      *
@@ -103,6 +136,20 @@
     int in_channels;
     void (*downmix)(float **samples, float **matrix, int len);
     void (*downmix_fixed)(int32_t **samples, int16_t **matrix, int len);
+
+    /**
+     * Apply symmetric window in 16-bit fixed-point.
+     * @param output destination array
+     *               constraints: 16-byte aligned
+     * @param input  source array
+     *               constraints: 16-byte aligned
+     * @param window window array
+     *               constraints: 16-byte aligned, at least len/2 elements
+     * @param len    full window length
+     *               constraints: multiple of ? greater than zero
+     */
+    void (*apply_window_int16)(int16_t *output, const int16_t *input,
+                               const int16_t *window, unsigned int len);
 } AC3DSPContext;
 
 void ff_ac3dsp_init    (AC3DSPContext *c, int bit_exact);
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 8044e6d..37dc0fb 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -34,9 +34,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
-#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "me_cmp.h"
@@ -69,65 +67,6 @@
     LEVEL_MINUS_3DB, LEVEL_MINUS_4POINT5DB, LEVEL_MINUS_6DB, LEVEL_ZERO
 };
 
-/* The first two options apply only to the AC-3 encoders;
- * the rest is also valid for EAC-3. When modifying it,
- * it might be necessary to adapt said offset in eac3enc.c. */
-#define OFFSET(param) offsetof(AC3EncodeContext, options.param)
-#define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
-const AVOption ff_ac3_enc_options[] = {
-/* AC-3 downmix levels */
-{"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM},
-{"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM},
-/* audio production information */
-{"mixing_level", "Mixing Level", OFFSET(mixing_level), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 111, AC3ENC_PARAM},
-{"room_type", "Room Type", OFFSET(room_type), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_SMALL_ROOM, AC3ENC_PARAM, "room_type"},
-    {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
-    {"large",        "Large Room",              0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_LARGE_ROOM    }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
-    {"small",        "Small Room",              0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_SMALL_ROOM    }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
-/* Metadata Options */
-{"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, AC3ENC_PARAM},
-{"copyright", "Copyright Bit", OFFSET(copyright), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM},
-{"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), AV_OPT_TYPE_INT, {.i64 = -31 }, -31, -1, AC3ENC_PARAM},
-{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dsur_mode"},
-    {"notindicated", "Not Indicated (default)",    0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
-    {"on",           "Dolby Surround Encoded",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_ON       }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
-    {"off",          "Not Dolby Surround Encoded", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_OFF      }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
-{"original", "Original Bit Stream", OFFSET(original), AV_OPT_TYPE_INT,   {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM},
-/* extended bitstream information */
-{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DOWNMIX_DPLII, AC3ENC_PARAM, "dmix_mode"},
-    {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
-    {"ltrt", "Lt/Rt Downmix Preferred",         0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DOWNMIX_LTRT  }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
-    {"loro", "Lo/Ro Downmix Preferred",         0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DOWNMIX_LORO  }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
-    {"dplii", "Dolby Pro Logic II Downmix Preferred", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DOWNMIX_DPLII }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
-{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
-{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
-{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
-{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
-{"dsurex_mode", "Dolby Surround EX Mode", OFFSET(dolby_surround_ex_mode), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DSUREX_DPLIIZ, AC3ENC_PARAM, "dsurex_mode"},
-    {"notindicated", "Not Indicated (default)",       0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
-    {"on",           "Dolby Surround EX Encoded",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_ON       }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
-    {"off",          "Not Dolby Surround EX Encoded", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_OFF      }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
-    {"dpliiz",       "Dolby Pro Logic IIz-encoded",   0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DSUREX_DPLIIZ }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
-{"dheadphone_mode", "Dolby Headphone Mode", OFFSET(dolby_headphone_mode), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dheadphone_mode"},
-    {"notindicated", "Not Indicated (default)",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
-    {"on",           "Dolby Headphone Encoded",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_ON       }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
-    {"off",          "Not Dolby Headphone Encoded", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_OFF      }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
-{"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_ADCONV_HDCD, AC3ENC_PARAM, "ad_conv_type"},
-    {"standard", "Standard (default)", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_ADCONV_STANDARD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
-    {"hdcd",     "HDCD",               0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_ADCONV_HDCD     }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
-/* Other Encoding Options */
-{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), AV_OPT_TYPE_BOOL, {.i64 = 1 }, 0, 1, AC3ENC_PARAM},
-{"channel_coupling",   "Channel Coupling",   OFFSET(channel_coupling),   AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"},
-    {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"},
-{"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"},
-    {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
-{NULL}
-};
-
-const AVCodecDefault ff_ac3_enc_defaults[] = {
-    { "b",  "0" },
-    { NULL }
-};
 
 /**
  * LUT for number of exponent groups.
@@ -161,15 +100,6 @@
      0
 };
 
-/**
- * Table to remap channels from SMPTE order to AC-3 order.
- * [channel_mode][lfe][ch]
- */
-static const uint8_t ac3_enc_channel_map[8][2][6] = {
-    COMMON_CHANNEL_MAP
-    { { 0, 1, 2, 3,    }, { 0, 1, 3, 4, 2,   } },
-    { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
-};
 
 /**
  * LUT to select the bandwidth code based on the bit rate, sample rate, and
@@ -339,7 +269,7 @@
  *
  * @param s  AC-3 encoder private context
  */
-static void ac3_apply_rematrixing(AC3EncodeContext *s)
+void ff_ac3_apply_rematrixing(AC3EncodeContext *s)
 {
     int nb_coefs;
     int blk, bnd, i;
@@ -373,7 +303,7 @@
 /*
  * Initialize exponent tables.
  */
-static av_cold void exponent_init(void)
+static av_cold void exponent_init(AC3EncodeContext *s)
 {
     int expstr, i, grpsize;
 
@@ -386,6 +316,9 @@
     }
     /* LFE */
     exponent_group_tab[0][0][7] = 2;
+
+    if (CONFIG_EAC3_ENCODER && s->eac3)
+        ff_eac3_exponent_init();
 }
 
 
@@ -643,7 +576,7 @@
  *
  * @param s  AC-3 encoder private context
  */
-static void ac3_group_exponents(AC3EncodeContext *s)
+void ff_ac3_group_exponents(AC3EncodeContext *s)
 {
     int blk, ch, i, cpl;
     int group_size, nb_groups;
@@ -701,7 +634,7 @@
  *
  * @param s  AC-3 encoder private context
  */
-static void ac3_process_exponents(AC3EncodeContext *s)
+void ff_ac3_process_exponents(AC3EncodeContext *s)
 {
     extract_exponents(s);
 
@@ -1210,7 +1143,7 @@
  * frame size.  Output is the SNR offset and a set of bit allocation pointers
  * used to quantize the mantissas.
  */
-static int ac3_compute_bit_allocation(AC3EncodeContext *s)
+int ff_ac3_compute_bit_allocation(AC3EncodeContext *s)
 {
     count_frame_bits(s);
 
@@ -1364,7 +1297,7 @@
  *
  * @param s  AC-3 encoder private context
  */
-static void ac3_quantize_mantissas(AC3EncodeContext *s)
+void ff_ac3_quantize_mantissas(AC3EncodeContext *s)
 {
     int blk, ch, ch0=0, got_cpl;
 
@@ -1725,7 +1658,7 @@
  * @param s      AC-3 encoder private context
  * @param frame  output data buffer
  */
-static void ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
+void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
 {
     int blk;
 
@@ -1739,36 +1672,6 @@
     output_frame_end(s);
 }
 
-int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt,
-                                   const AVFrame *frame, int *got_packet_ptr)
-{
-    AC3EncodeContext *const s = avctx->priv_data;
-    int ret;
-
-    ac3_apply_rematrixing(s);
-
-    ac3_process_exponents(s);
-
-    ret = ac3_compute_bit_allocation(s);
-    if (ret) {
-        av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
-        return ret;
-    }
-
-    ac3_group_exponents(s);
-
-    ac3_quantize_mantissas(s);
-
-    if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, 0)) < 0)
-        return ret;
-    ac3_output_frame(s, avpkt->data);
-
-    if (frame->pts != AV_NOPTS_VALUE)
-        avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
-
-    *got_packet_ptr = 1;
-    return 0;
-}
 
 static void dprint_options(AC3EncodeContext *s)
 {
@@ -2115,7 +2018,6 @@
     int blk, ch;
     AC3EncodeContext *s = avctx->priv_data;
 
-    av_freep(&s->mdct_window);
     av_freep(&s->windowed_samples);
     if (s->planar_samples)
     for (ch = 0; ch < s->channels; ch++)
@@ -2148,7 +2050,8 @@
         av_freep(&block->cpl_coord_mant);
     }
 
-    s->mdct_end(s);
+    if (s->mdct_end)
+        s->mdct_end(s);
 
     return 0;
 }
@@ -2193,7 +2096,7 @@
     s->has_center   = (s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO;
     s->has_surround =  s->channel_mode & 0x04;
 
-    s->channel_map  = ac3_enc_channel_map[s->channel_mode][s->lfe_on];
+    s->channel_map  = ff_ac3_enc_channel_map[s->channel_mode][s->lfe_on];
     *channel_layout = ch_layout;
     if (s->lfe_on)
         *channel_layout |= AV_CH_LOW_FREQUENCY;
@@ -2505,7 +2408,6 @@
 
 av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
 {
-    static AVOnce init_static_once = AV_ONCE_INIT;
     AC3EncodeContext *s = avctx->priv_data;
     int ret, frame_size_58;
 
@@ -2535,15 +2437,25 @@
         s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);
     }
 
-    if (CONFIG_EAC3_ENCODER && s->eac3) {
-        static AVOnce init_static_once_eac3 = AV_ONCE_INIT;
-        ff_thread_once(&init_static_once_eac3, ff_eac3_exponent_init);
+    /* set function pointers */
+    if (CONFIG_AC3_FIXED_ENCODER && s->fixed_point) {
+        s->mdct_end                     = ff_ac3_fixed_mdct_end;
+        s->mdct_init                    = ff_ac3_fixed_mdct_init;
+        s->allocate_sample_buffers      = ff_ac3_fixed_allocate_sample_buffers;
+    } else if (CONFIG_AC3_ENCODER || CONFIG_EAC3_ENCODER) {
+        s->mdct_end                     = ff_ac3_float_mdct_end;
+        s->mdct_init                    = ff_ac3_float_mdct_init;
+        s->allocate_sample_buffers      = ff_ac3_float_allocate_sample_buffers;
+    }
+    if (CONFIG_EAC3_ENCODER && s->eac3)
         s->output_frame_header = ff_eac3_output_frame_header;
-    } else
+    else
         s->output_frame_header = ac3_output_frame_header;
 
     set_bandwidth(s);
 
+    exponent_init(s);
+
     bit_alloc_init(s);
 
     ret = s->mdct_init(s);
@@ -2560,7 +2472,5 @@
 
     dprint_options(s);
 
-    ff_thread_once(&init_static_once, exponent_init);
-
     return 0;
 }
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index c064ba4..1e4a740 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -30,6 +30,8 @@
 
 #include <stdint.h>
 
+#include "libavutil/float_dsp.h"
+
 #include "ac3.h"
 #include "ac3dsp.h"
 #include "avcodec.h"
@@ -39,12 +41,18 @@
 #include "put_bits.h"
 #include "audiodsp.h"
 
-#ifndef AC3ENC_FLOAT
-#define AC3ENC_FLOAT 0
+#ifndef CONFIG_AC3ENC_FLOAT
+#define CONFIG_AC3ENC_FLOAT 0
 #endif
 
-#if AC3ENC_FLOAT
-#include "libavutil/float_dsp.h"
+#define OFFSET(param) offsetof(AC3EncodeContext, options.param)
+#define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
+
+#define AC3ENC_TYPE_AC3_FIXED   0
+#define AC3ENC_TYPE_AC3         1
+#define AC3ENC_TYPE_EAC3        2
+
+#if CONFIG_AC3ENC_FLOAT
 #define AC3_NAME(x) ff_ac3_float_ ## x
 #define MAC_COEF(d,a,b) ((d)+=(a)*(b))
 #define COEF_MIN (-16777215.0/16777216.0)
@@ -54,13 +62,12 @@
 typedef float CoefType;
 typedef float CoefSumType;
 #else
-#include "libavutil/fixed_dsp.h"
 #define AC3_NAME(x) ff_ac3_fixed_ ## x
 #define MAC_COEF(d,a,b) MAC64(d,a,b)
 #define COEF_MIN -16777215
 #define COEF_MAX  16777215
 #define NEW_CPL_COORD_THRESHOLD 503317
-typedef int32_t SampleType;
+typedef int16_t SampleType;
 typedef int32_t CoefType;
 typedef int64_t CoefSumType;
 #endif
@@ -134,6 +141,7 @@
     uint16_t **qmant;                           ///< quantized mantissas
     uint8_t  **cpl_coord_exp;                   ///< coupling coord exponents           (cplcoexp)
     uint8_t  **cpl_coord_mant;                  ///< coupling coord mantissas           (cplcomant)
+    uint8_t  coeff_shift[AC3_MAX_CHANNELS];     ///< fixed-point coefficient shift values
     uint8_t  new_rematrixing_strategy;          ///< send new rematrixing flags in this block
     int      num_rematrixing_bands;             ///< number of rematrixing bands
     uint8_t  rematrixing_flags[4];              ///< rematrixing flags
@@ -157,11 +165,7 @@
     AVCodecContext *avctx;                  ///< parent AVCodecContext
     PutBitContext pb;                       ///< bitstream writer context
     AudioDSPContext adsp;
-#if AC3ENC_FLOAT
     AVFloatDSPContext *fdsp;
-#else
-    AVFixedDSPContext *fdsp;
-#endif
     MECmpContext mecc;
     AC3DSPContext ac3dsp;                   ///< AC-3 optimized functions
     FFTContext mdct;                        ///< FFT context for MDCT calculation
@@ -266,8 +270,6 @@
 
 
 extern const uint64_t ff_ac3_channel_layouts[19];
-extern const AVOption ff_ac3_enc_options[];
-extern const AVCodecDefault ff_ac3_enc_defaults[];
 
 int ff_ac3_encode_init(AVCodecContext *avctx);
 int ff_ac3_float_encode_init(AVCodecContext *avctx);
@@ -280,11 +282,33 @@
 
 void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
 
-int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt,
-                                   const AVFrame *frame, int *got_packet_ptr);
+void ff_ac3_apply_rematrixing(AC3EncodeContext *s);
+
+void ff_ac3_process_exponents(AC3EncodeContext *s);
+
+int ff_ac3_compute_bit_allocation(AC3EncodeContext *s);
+
+void ff_ac3_group_exponents(AC3EncodeContext *s);
+
+void ff_ac3_quantize_mantissas(AC3EncodeContext *s);
+
+void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame);
+
+
+/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
+
+void ff_ac3_fixed_mdct_end(AC3EncodeContext *s);
+void ff_ac3_float_mdct_end(AC3EncodeContext *s);
+
+int ff_ac3_fixed_mdct_init(AC3EncodeContext *s);
+int ff_ac3_float_mdct_init(AC3EncodeContext *s);
+
 
 /* prototypes for functions in ac3enc_template.c */
 
+int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s);
+int ff_ac3_float_allocate_sample_buffers(AC3EncodeContext *s);
+
 int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                               const AVFrame *frame, int *got_packet_ptr);
 int ff_ac3_float_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 8b1a062..428bbfb 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -26,22 +26,54 @@
  * fixed-point AC-3 encoder.
  */
 
-#define AC3ENC_FLOAT 0
 #define FFT_FLOAT 0
-#define FFT_FIXED_32 1
+#undef CONFIG_AC3ENC_FLOAT
 #include "internal.h"
 #include "audiodsp.h"
 #include "ac3enc.h"
 #include "eac3enc.h"
-#include "kbdwin.h"
+
+#define AC3ENC_TYPE AC3ENC_TYPE_AC3_FIXED
+#include "ac3enc_opts_template.c"
 
 static const AVClass ac3enc_class = {
     .class_name = "Fixed-Point AC-3 Encoder",
     .item_name  = av_default_item_name,
-    .option     = ff_ac3_enc_options,
+    .option     = ac3_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
+/*
+ * Normalize the input samples to use the maximum available precision.
+ * This assumes signed 16-bit input samples.
+ */
+static int normalize_samples(AC3EncodeContext *s)
+{
+    int v = s->ac3dsp.ac3_max_msb_abs_int16(s->windowed_samples, AC3_WINDOW_SIZE);
+    v = 14 - av_log2(v);
+    if (v > 0)
+        s->ac3dsp.ac3_lshift_int16(s->windowed_samples, AC3_WINDOW_SIZE, v);
+    /* +6 to right-shift from 31-bit to 25-bit */
+    return v + 6;
+}
+
+
+/*
+ * Scale MDCT coefficients to 25-bit signed fixed-point.
+ */
+static void scale_coefficients(AC3EncodeContext *s)
+{
+    int blk, ch;
+
+    for (blk = 0; blk < s->num_blocks; blk++) {
+        AC3Block *block = &s->blocks[blk];
+        for (ch = 1; ch <= s->channels; ch++) {
+            s->ac3dsp.ac3_rshift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
+                                       block->coeff_shift[ch]);
+        }
+    }
+}
+
 static void sum_square_butterfly(AC3EncodeContext *s, int64_t sum[4],
                                  const int32_t *coef0, const int32_t *coef1,
                                  int len)
@@ -83,36 +115,23 @@
  *
  * @param s  AC-3 encoder private context
  */
-static av_cold void ac3_fixed_mdct_end(AC3EncodeContext *s)
+av_cold void ff_ac3_fixed_mdct_end(AC3EncodeContext *s)
 {
     ff_mdct_end(&s->mdct);
 }
 
+
 /**
  * Initialize MDCT tables.
  *
  * @param s  AC-3 encoder private context
  * @return   0 on success, negative error code on failure
  */
-static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s)
+av_cold int ff_ac3_fixed_mdct_init(AC3EncodeContext *s)
 {
-    float fwin[AC3_BLOCK_SIZE];
-
-    int32_t *iwin = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*iwin));
-    if (!iwin)
-        return AVERROR(ENOMEM);
-
-    ff_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE);
-    for (int i = 0; i < AC3_BLOCK_SIZE; i++)
-        iwin[i] = lrintf(fwin[i] * (1 << 22));
-
-    s->mdct_window = iwin;
-
-    s->fdsp = avpriv_alloc_fixed_dsp(s->avctx->flags & AV_CODEC_FLAG_BITEXACT);
-    if (!s->fdsp)
-        return AVERROR(ENOMEM);
-
-    return ff_mdct_init(&s->mdct, 9, 0, -1.0);
+    int ret = ff_mdct_init(&s->mdct, 9, 0, -1.0);
+    s->mdct_window = ff_ac3_window;
+    return ret;
 }
 
 
@@ -120,9 +139,6 @@
 {
     AC3EncodeContext *s = avctx->priv_data;
     s->fixed_point = 1;
-    s->mdct_end                = ac3_fixed_mdct_end;
-    s->mdct_init               = ac3_fixed_mdct_init;
-    s->allocate_sample_buffers = allocate_sample_buffers;
     return ff_ac3_encode_init(avctx);
 }
 
@@ -136,11 +152,11 @@
     .init            = ac3_fixed_encode_init,
     .encode2         = ff_ac3_fixed_encode_frame,
     .close           = ff_ac3_encode_close,
-    .sample_fmts     = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P,
+    .sample_fmts     = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P,
                                                       AV_SAMPLE_FMT_NONE },
     .priv_class      = &ac3enc_class,
-    .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
-    .defaults        = ff_ac3_enc_defaults,
+    .defaults        = ac3_defaults,
 };
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index 2238749..99863a9 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -26,7 +26,7 @@
  * floating-point AC-3 encoder.
  */
 
-#define AC3ENC_FLOAT 1
+#define CONFIG_AC3ENC_FLOAT 1
 #include "internal.h"
 #include "audiodsp.h"
 #include "ac3enc.h"
@@ -34,10 +34,12 @@
 #include "kbdwin.h"
 
 
+#define AC3ENC_TYPE AC3ENC_TYPE_AC3
+#include "ac3enc_opts_template.c"
 static const AVClass ac3enc_class = {
     .class_name = "AC-3 Encoder",
     .item_name  = av_default_item_name,
-    .option     = ff_ac3_enc_options,
+    .option     = ac3_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
@@ -92,9 +94,10 @@
  *
  * @param s  AC-3 encoder private context
  */
-static av_cold void ac3_float_mdct_end(AC3EncodeContext *s)
+av_cold void ff_ac3_float_mdct_end(AC3EncodeContext *s)
 {
     ff_mdct_end(&s->mdct);
+    av_freep(&s->mdct_window);
 }
 
 
@@ -104,27 +107,31 @@
  * @param s  AC-3 encoder private context
  * @return   0 on success, negative error code on failure
  */
-static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
+av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s)
 {
-    float *window = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*window));
+    float *window;
+    int i, n, n2;
+
+    n  = 1 << 9;
+    n2 = n >> 1;
+
+    window = av_malloc_array(n, sizeof(*window));
     if (!window) {
         av_log(s->avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
         return AVERROR(ENOMEM);
     }
-
-    ff_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE);
+    ff_kbd_window_init(window, 5.0, n2);
+    for (i = 0; i < n2; i++)
+        window[n-1-i] = window[i];
     s->mdct_window = window;
 
-    return ff_mdct_init(&s->mdct, 9, 0, -2.0 / AC3_WINDOW_SIZE);
+    return ff_mdct_init(&s->mdct, 9, 0, -2.0 / n);
 }
 
 
 av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx)
 {
     AC3EncodeContext *s = avctx->priv_data;
-    s->mdct_end                = ac3_float_mdct_end;
-    s->mdct_init               = ac3_float_mdct_init;
-    s->allocate_sample_buffers = allocate_sample_buffers;
     s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!s->fdsp)
         return AVERROR(ENOMEM);
@@ -145,6 +152,6 @@
     .priv_class      = &ac3enc_class,
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
-    .defaults        = ff_ac3_enc_defaults,
-    .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .defaults        = ac3_defaults,
+    .caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/ac3enc_opts_template.c b/libavcodec/ac3enc_opts_template.c
new file mode 100644
index 0000000..57b65a7
--- /dev/null
+++ b/libavcodec/ac3enc_opts_template.c
@@ -0,0 +1,82 @@
+/*
+ * AC-3 encoder options
+ * Copyright (c) 2011 Justin Ruggles <justin.ruggles@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "ac3.h"
+
+static const AVOption ac3_options[] = {
+/* Metadata Options */
+{"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, AC3ENC_PARAM},
+#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3
+/* AC-3 downmix levels */
+{"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM},
+{"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM},
+#endif
+/* audio production information */
+{"mixing_level", "Mixing Level", OFFSET(mixing_level), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 111, AC3ENC_PARAM},
+{"room_type", "Room Type", OFFSET(room_type), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_SMALL_ROOM, AC3ENC_PARAM, "room_type"},
+    {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
+    {"large",        "Large Room",              0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_LARGE_ROOM    }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
+    {"small",        "Small Room",              0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_SMALL_ROOM    }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
+/* other metadata options */
+{"copyright", "Copyright Bit", OFFSET(copyright), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM},
+{"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), AV_OPT_TYPE_INT, {.i64 = -31 }, -31, -1, AC3ENC_PARAM},
+{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dsur_mode"},
+    {"notindicated", "Not Indicated (default)",    0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
+    {"on",           "Dolby Surround Encoded",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_ON       }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
+    {"off",          "Not Dolby Surround Encoded", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_OFF      }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
+{"original", "Original Bit Stream", OFFSET(original), AV_OPT_TYPE_INT,   {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM},
+/* extended bitstream information */
+{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DOWNMIX_DPLII, AC3ENC_PARAM, "dmix_mode"},
+    {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
+    {"ltrt", "Lt/Rt Downmix Preferred",         0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DOWNMIX_LTRT  }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
+    {"loro", "Lo/Ro Downmix Preferred",         0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DOWNMIX_LORO  }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
+    {"dplii", "Dolby Pro Logic II Downmix Preferred", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DOWNMIX_DPLII }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
+{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
+{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
+{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
+{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
+{"dsurex_mode", "Dolby Surround EX Mode", OFFSET(dolby_surround_ex_mode), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DSUREX_DPLIIZ, AC3ENC_PARAM, "dsurex_mode"},
+    {"notindicated", "Not Indicated (default)",       0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
+    {"on",           "Dolby Surround EX Encoded",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_ON       }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
+    {"off",          "Not Dolby Surround EX Encoded", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_OFF      }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
+    {"dpliiz",       "Dolby Pro Logic IIz-encoded",   0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_DSUREX_DPLIIZ }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
+{"dheadphone_mode", "Dolby Headphone Mode", OFFSET(dolby_headphone_mode), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dheadphone_mode"},
+    {"notindicated", "Not Indicated (default)",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
+    {"on",           "Dolby Headphone Encoded",     0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_ON       }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
+    {"off",          "Not Dolby Headphone Encoded", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_MODE_OFF      }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
+{"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_ADCONV_HDCD, AC3ENC_PARAM, "ad_conv_type"},
+    {"standard", "Standard (default)", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_ADCONV_STANDARD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
+    {"hdcd",     "HDCD",               0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_ADCONV_HDCD     }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
+/* Other Encoding Options */
+{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), AV_OPT_TYPE_BOOL, {.i64 = 1 }, 0, 1, AC3ENC_PARAM},
+{"channel_coupling",   "Channel Coupling",   OFFSET(channel_coupling),   AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"},
+    {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"},
+{"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), AV_OPT_TYPE_INT, {.i64 = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"},
+    {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
+{NULL}
+};
+
+static const AVCodecDefault ac3_defaults[] = {
+    { "b",  "0" },
+    { NULL }
+};
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 5ecef3b..b85fe51 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -30,7 +30,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 
 #include "audiodsp.h"
 #include "internal.h"
@@ -38,7 +37,7 @@
 #include "eac3enc.h"
 
 
-static int allocate_sample_buffers(AC3EncodeContext *s)
+int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
 {
     int ch;
 
@@ -91,14 +90,19 @@
             AC3Block *block = &s->blocks[blk];
             const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
 
+#if CONFIG_AC3ENC_FLOAT
             s->fdsp->vector_fmul(s->windowed_samples, input_samples,
-                                 s->mdct_window, AC3_BLOCK_SIZE);
-            s->fdsp->vector_fmul_reverse(s->windowed_samples + AC3_BLOCK_SIZE,
-                                         &input_samples[AC3_BLOCK_SIZE],
-                                         s->mdct_window, AC3_BLOCK_SIZE);
+                                s->mdct_window, AC3_WINDOW_SIZE);
+#else
+            s->ac3dsp.apply_window_int16(s->windowed_samples, input_samples,
+                                         s->mdct_window, AC3_WINDOW_SIZE);
 
-            s->mdct.mdct_calc(&s->mdct, block->mdct_coef[ch+1],
-                              s->windowed_samples);
+            if (s->fixed_point)
+                block->coeff_shift[ch+1] = normalize_samples(s);
+#endif
+
+            s->mdct.mdct_calcw(&s->mdct, block->mdct_coef[ch+1],
+                               s->windowed_samples);
         }
     }
 }
@@ -110,7 +114,7 @@
 static void apply_channel_coupling(AC3EncodeContext *s)
 {
     LOCAL_ALIGNED_16(CoefType, cpl_coords,      [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
-#if AC3ENC_FLOAT
+#if CONFIG_AC3ENC_FLOAT
     LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
 #else
     int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;
@@ -120,7 +124,7 @@
     int cpl_start, num_cpl_coefs;
 
     memset(cpl_coords,       0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
-#if AC3ENC_FLOAT
+#if CONFIG_AC3ENC_FLOAT
     memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
 #endif
 
@@ -261,7 +265,7 @@
         if (!block->cpl_in_use)
             continue;
 
-#if AC3ENC_FLOAT
+#if CONFIG_AC3ENC_FLOAT
         s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1],
                                    cpl_coords[blk][1],
                                    s->fbw_channels * 16);
@@ -307,7 +311,7 @@
         }
     }
 
-    if (AC3ENC_FLOAT && CONFIG_EAC3_ENCODER && s->eac3)
+    if (CONFIG_EAC3_ENCODER && s->eac3)
         ff_eac3_set_cpl_states(s);
 }
 
@@ -379,13 +383,19 @@
             return ret;
     }
 
-    if (s->bit_alloc.sr_code == 1 || (AC3ENC_FLOAT && s->eac3))
+    if (s->bit_alloc.sr_code == 1 || s->eac3)
         ff_ac3_adjust_frame_size(s);
 
     copy_input_samples(s, (SampleType **)frame->extended_data);
 
     apply_mdct(s);
 
+    if (s->fixed_point)
+        scale_coefficients(s);
+
+    clip_coefficients(&s->adsp, s->blocks[0].mdct_coef[1],
+                      AC3_MAX_COEFS * s->num_blocks * s->channels);
+
     s->cpl_on = s->cpl_enabled;
     ff_ac3_compute_coupling_strategy(s);
 
@@ -394,9 +404,30 @@
 
     compute_rematrixing_strategy(s);
 
-#if AC3ENC_FLOAT
-    scale_coefficients(s);
-#endif
+    if (!s->fixed_point)
+        scale_coefficients(s);
 
-    return ff_ac3_encode_frame_common_end(avctx, avpkt, frame, got_packet_ptr);
+    ff_ac3_apply_rematrixing(s);
+
+    ff_ac3_process_exponents(s);
+
+    ret = ff_ac3_compute_bit_allocation(s);
+    if (ret) {
+        av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
+        return ret;
+    }
+
+    ff_ac3_group_exponents(s);
+
+    ff_ac3_quantize_mantissas(s);
+
+    if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, 0)) < 0)
+        return ret;
+    ff_ac3_output_frame(s, avpkt->data);
+
+    if (frame->pts != AV_NOPTS_VALUE)
+        avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
+
+    *got_packet_ptr = 1;
+    return 0;
 }
diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
index e53086a..ef2a41b 100644
--- a/libavcodec/ac3tab.c
+++ b/libavcodec/ac3tab.c
@@ -25,7 +25,7 @@
  */
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "ac3tab.h"
@@ -97,6 +97,24 @@
     AV_CH_LAYOUT_5POINT0
 };
 
+#define COMMON_CHANNEL_MAP \
+    { { 0, 1,          }, { 0, 1, 2,         } },\
+    { { 0,             }, { 0, 1,            } },\
+    { { 0, 1,          }, { 0, 1, 2,         } },\
+    { { 0, 2, 1,       }, { 0, 2, 1, 3,      } },\
+    { { 0, 1, 2,       }, { 0, 1, 3, 2,      } },\
+    { { 0, 2, 1, 3,    }, { 0, 2, 1, 4, 3,   } },
+
+/**
+ * Table to remap channels from SMPTE order to AC-3 order.
+ * [channel_mode][lfe][ch]
+ */
+const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
+    COMMON_CHANNEL_MAP
+    { { 0, 1, 2, 3,    }, { 0, 1, 3, 4, 2,   } },
+    { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
+};
+
 /**
  * Table to remap channels from AC-3 order to SMPTE order.
  * [channel_mode][lfe][ch]
@@ -129,6 +147,44 @@
     0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1
 };
 
+/* AC-3 MDCT window */
+
+/* MDCT window */
+DECLARE_ALIGNED(16, const int16_t, ff_ac3_window)[AC3_WINDOW_SIZE/2] = {
+    4,    7,   12,   16,   21,   28,   34,   42,
+   51,   61,   72,   84,   97,  111,  127,  145,
+  164,  184,  207,  231,  257,  285,  315,  347,
+  382,  419,  458,  500,  544,  591,  641,  694,
+  750,  810,  872,  937, 1007, 1079, 1155, 1235,
+ 1318, 1406, 1497, 1593, 1692, 1796, 1903, 2016,
+ 2132, 2253, 2379, 2509, 2644, 2783, 2927, 3076,
+ 3230, 3389, 3552, 3721, 3894, 4072, 4255, 4444,
+ 4637, 4835, 5038, 5246, 5459, 5677, 5899, 6127,
+ 6359, 6596, 6837, 7083, 7334, 7589, 7848, 8112,
+ 8380, 8652, 8927, 9207, 9491, 9778,10069,10363,
+10660,10960,11264,11570,11879,12190,12504,12820,
+13138,13458,13780,14103,14427,14753,15079,15407,
+15735,16063,16392,16720,17049,17377,17705,18032,
+18358,18683,19007,19330,19651,19970,20287,20602,
+20914,21225,21532,21837,22139,22438,22733,23025,
+23314,23599,23880,24157,24430,24699,24964,25225,
+25481,25732,25979,26221,26459,26691,26919,27142,
+27359,27572,27780,27983,28180,28373,28560,28742,
+28919,29091,29258,29420,29577,29729,29876,30018,
+30155,30288,30415,30538,30657,30771,30880,30985,
+31086,31182,31274,31363,31447,31528,31605,31678,
+31747,31814,31877,31936,31993,32046,32097,32145,
+32190,32232,32272,32310,32345,32378,32409,32438,
+32465,32490,32513,32535,32556,32574,32592,32608,
+32623,32636,32649,32661,32671,32681,32690,32698,
+32705,32712,32718,32724,32729,32733,32737,32741,
+32744,32747,32750,32752,32754,32756,32757,32759,
+32760,32761,32762,32763,32764,32764,32765,32765,
+32766,32766,32766,32766,32767,32767,32767,32767,
+32767,32767,32767,32767,32767,32767,32767,32767,
+32767,32767,32767,32767,32767,32767,32767,32767,
+};
+
 const uint8_t ff_ac3_log_add_tab[260]= {
 0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,
 0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f,
@@ -245,6 +301,19 @@
     0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
 };
 
+/**
+ * Default channel map for a dependent substream defined by acmod
+ */
+const uint16_t ff_eac3_default_chmap[8] = {
+    AC3_CHMAP_L |               AC3_CHMAP_R, // FIXME Ch1+Ch2
+                  AC3_CHMAP_C,
+    AC3_CHMAP_L |               AC3_CHMAP_R,
+    AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
+    AC3_CHMAP_L |               AC3_CHMAP_R |                   AC3_CHMAP_C_SUR,
+    AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R |                   AC3_CHMAP_C_SUR,
+    AC3_CHMAP_L |               AC3_CHMAP_R | AC3_CHMAP_L_SUR |                  AC3_CHMAP_R_SUR,
+    AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR |                  AC3_CHMAP_R_SUR
+};
 const uint64_t ff_eac3_custom_channel_map_locations[16][2] = {
     { 1, AV_CH_FRONT_LEFT },
     { 1, AV_CH_FRONT_CENTER },
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index ea8e334..1d1264e 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -31,11 +31,13 @@
 extern const uint16_t ff_ac3_frame_size_tab[38][3];
 extern const uint8_t  ff_ac3_channels_tab[8];
 extern av_export_avcodec const uint16_t avpriv_ac3_channel_layout_tab[8];
+extern const uint8_t  ff_ac3_enc_channel_map[8][2][6];
 extern const uint8_t  ff_ac3_dec_channel_map[8][2][6];
 extern const int      ff_ac3_sample_rate_tab[];
 extern const uint16_t ff_ac3_bitrate_tab[19];
 extern const uint8_t  ff_ac3_rematrix_band_tab[5];
 extern const uint8_t  ff_eac3_default_cpl_band_struct[18];
+extern const int16_t  ff_ac3_window[AC3_WINDOW_SIZE/2];
 extern const uint8_t  ff_ac3_log_add_tab[260];
 extern const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3];
 extern const uint8_t  ff_ac3_bap_tab[64];
@@ -45,6 +47,7 @@
 extern const uint16_t ff_ac3_db_per_bit_tab[4];
 extern const int16_t  ff_ac3_floor_tab[8];
 extern const uint16_t ff_ac3_fast_gain_tab[8];
+extern const uint16_t ff_eac3_default_chmap[8];
 extern const uint8_t  ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
 extern const uint8_t  ff_ac3_bin_to_band_tab[253];
 extern const uint64_t ff_eac3_custom_channel_map_locations[16][2];
@@ -65,12 +68,4 @@
     AC3_CHMAP_LFE =     1<<(15-15)
 };
 
-#define COMMON_CHANNEL_MAP \
-    { { 0, 1,          }, { 0, 1, 2,         } },\
-    { { 0,             }, { 0, 1,            } },\
-    { { 0, 1,          }, { 0, 1, 2,         } },\
-    { { 0, 2, 1,       }, { 0, 2, 1, 3,      } },\
-    { { 0, 1, 2,       }, { 0, 1, 3, 2,      } },\
-    { { 0, 2, 1, 3,    }, { 0, 2, 1, 4, 3,   } },
-
 #endif /* AVCODEC_AC3TAB_H */
diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
index 1eca97e..a070d1b 100644
--- a/libavcodec/acelp_pitch_delay.c
+++ b/libavcodec/acelp_pitch_delay.c
@@ -29,6 +29,47 @@
 #include "celp_math.h"
 #include "audiodsp.h"
 
+int ff_acelp_decode_8bit_to_1st_delay3(int ac_index)
+{
+    ac_index += 58;
+    if(ac_index > 254)
+        ac_index = 3 * ac_index - 510;
+    return ac_index;
+}
+
+int ff_acelp_decode_4bit_to_2nd_delay3(
+        int ac_index,
+        int pitch_delay_min)
+{
+    if(ac_index < 4)
+        return 3 * (ac_index + pitch_delay_min);
+    else if(ac_index < 12)
+        return 3 * pitch_delay_min + ac_index + 6;
+    else
+        return 3 * (ac_index + pitch_delay_min) - 18;
+}
+
+int ff_acelp_decode_5_6_bit_to_2nd_delay3(
+        int ac_index,
+        int pitch_delay_min)
+{
+        return 3 * pitch_delay_min + ac_index - 2;
+}
+
+int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
+{
+    if(ac_index < 463)
+        return ac_index + 105;
+    else
+        return 6 * (ac_index - 368);
+}
+int ff_acelp_decode_6bit_to_2nd_delay6(
+        int ac_index,
+        int pitch_delay_min)
+{
+    return 6 * pitch_delay_min + ac_index - 3;
+}
+
 void ff_acelp_update_past_gain(
     int16_t* quant_energy,
     int gain_corr_factor,
diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h
index 73fa3c3..2aade2f 100644
--- a/libavcodec/acelp_pitch_delay.h
+++ b/libavcodec/acelp_pitch_delay.h
@@ -41,13 +41,7 @@
  *    with 1/3 resolution, 19  < pitch_delay <  85
  *    integers only,       85 <= pitch_delay <= 143
  */
-static inline int ff_acelp_decode_8bit_to_1st_delay3(int ac_index)
-{
-    ac_index += 58;
-    if (ac_index > 254)
-        ac_index = 3 * ac_index - 510;
-    return ac_index;
-}
+int ff_acelp_decode_8bit_to_1st_delay3(int ac_index);
 
 /**
  * @brief Decode pitch delay of the second subframe encoded by 5 or 6 bits
@@ -64,11 +58,9 @@
  * @remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k,
  *         AMR @@7.4k for the second subframe.
  */
-static inline int ff_acelp_decode_5_6_bit_to_2nd_delay3(int ac_index,
-                                                        int pitch_delay_min)
-{
-        return 3 * pitch_delay_min + ac_index - 2;
-}
+int ff_acelp_decode_5_6_bit_to_2nd_delay3(
+        int ac_index,
+        int pitch_delay_min);
 
 /**
  * @brief Decode pitch delay with 1/3 precision.
@@ -86,16 +78,9 @@
  * @remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k,
  *         AMR @@5.15k, AMR @@4.75k for the second subframe.
  */
-static inline int ff_acelp_decode_4bit_to_2nd_delay3(int ac_index,
-                                                     int pitch_delay_min)
-{
-    if (ac_index < 4)
-        return 3 * (ac_index + pitch_delay_min);
-    else if (ac_index < 12)
-        return 3 * pitch_delay_min + ac_index + 6;
-    else
-        return 3 * (ac_index + pitch_delay_min) - 18;
-}
+int ff_acelp_decode_4bit_to_2nd_delay3(
+        int ac_index,
+        int pitch_delay_min);
 
 /**
  * @brief Decode pitch delay of the first subframe encoded by 9 bits
@@ -110,13 +95,7 @@
  *
  * @remark The routine is used in AMR @@12.2k for the first and third subframes.
  */
-static inline int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
-{
-    if (ac_index < 463)
-        return ac_index + 105;
-    else
-        return 6 * (ac_index - 368);
-}
+int ff_acelp_decode_9bit_to_1st_delay6(int ac_index);
 
 /**
  * @brief Decode pitch delay of the second subframe encoded by 6 bits
@@ -132,11 +111,9 @@
  *
  * @remark The routine is used in AMR @@12.2k for the second and fourth subframes.
  */
-static inline int ff_acelp_decode_6bit_to_2nd_delay6(int ac_index,
-                                                     int pitch_delay_min)
-{
-    return 6 * pitch_delay_min + ac_index - 3;
-}
+int ff_acelp_decode_6bit_to_2nd_delay6(
+        int ac_index,
+        int pitch_delay_min);
 
 /**
  * @brief Update past quantized energies
diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
index 0d4de0e..798217d 100644
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -28,6 +28,17 @@
 #include "avcodec.h"
 #include "acelp_vectors.h"
 
+const uint8_t ff_fc_2pulses_9bits_track1[16] =
+{
+    1,  3,
+    6,  8,
+    11, 13,
+    16, 18,
+    21, 23,
+    26, 28,
+    31, 33,
+    36, 38
+};
 const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
 {
   1,  3,
diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h
index c2587c5..fae834d 100644
--- a/libavcodec/acelp_vectors.h
+++ b/libavcodec/acelp_vectors.h
@@ -102,6 +102,7 @@
  *
  * Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding)
  */
+extern const uint8_t ff_fc_2pulses_9bits_track1[16];
 extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16];
 
 /**
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index 94de3ee..35b20c5 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -103,7 +103,7 @@
     const uint8_t *buf  = avpkt->data;
     const uint8_t *buf_end = buf + avpkt->size;
     int num_blocks, ch, ret;
-    buffer_size_t new_extradata_size;
+    int new_extradata_size;
     uint8_t *new_extradata;
 
     new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index f393831..f60cbf1 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -26,8 +26,6 @@
 
 #define BITSTREAM_READER_LE
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "bytestream.h"
 #include "copy_block.h"
diff --git a/libavcodec/aic.c b/libavcodec/aic.c
index cf5b078..f027fa9 100644
--- a/libavcodec/aic.c
+++ b/libavcodec/aic.c
@@ -22,8 +22,6 @@
 
 #include <inttypes.h>
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "bytestream.h"
 #include "internal.h"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 2e9a358..f00d524 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -109,7 +109,6 @@
 extern AVCodec ff_eightsvx_fib_decoder;
 extern AVCodec ff_escape124_decoder;
 extern AVCodec ff_escape130_decoder;
-extern AVCodec ff_exr_encoder;
 extern AVCodec ff_exr_decoder;
 extern AVCodec ff_ffv1_encoder;
 extern AVCodec ff_ffv1_decoder;
@@ -240,7 +239,6 @@
 extern AVCodec ff_pbm_decoder;
 extern AVCodec ff_pcx_encoder;
 extern AVCodec ff_pcx_decoder;
-extern AVCodec ff_pfm_encoder;
 extern AVCodec ff_pfm_decoder;
 extern AVCodec ff_pgm_encoder;
 extern AVCodec ff_pgm_decoder;
@@ -289,12 +287,10 @@
 extern AVCodec ff_sanm_decoder;
 extern AVCodec ff_scpr_decoder;
 extern AVCodec ff_screenpresso_decoder;
-extern AVCodec ff_sga_decoder;
 extern AVCodec ff_sgi_encoder;
 extern AVCodec ff_sgi_decoder;
 extern AVCodec ff_sgirle_decoder;
 extern AVCodec ff_sheervideo_decoder;
-extern AVCodec ff_simbiosis_imx_decoder;
 extern AVCodec ff_smacker_decoder;
 extern AVCodec ff_smc_decoder;
 extern AVCodec ff_smvjpeg_decoder;
@@ -569,7 +565,6 @@
 extern AVCodec ff_pcm_s64be_decoder;
 extern AVCodec ff_pcm_s64le_encoder;
 extern AVCodec ff_pcm_s64le_decoder;
-extern AVCodec ff_pcm_sga_decoder;
 extern AVCodec ff_pcm_u8_encoder;
 extern AVCodec ff_pcm_u8_decoder;
 extern AVCodec ff_pcm_u16be_encoder;
@@ -691,7 +686,6 @@
 extern AVCodec ff_subviewer1_decoder;
 extern AVCodec ff_text_encoder;
 extern AVCodec ff_text_decoder;
-extern AVCodec ff_ttml_encoder;
 extern AVCodec ff_vplayer_decoder;
 extern AVCodec ff_webvtt_encoder;
 extern AVCodec ff_webvtt_decoder;
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index a8c3433..c318ad0 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -762,7 +762,7 @@
             }
 
             for (k = 2; k < opt_order; k++)
-                quant_cof[k] = (quant_cof[k] * (1U << 14)) + (add_base << 13);
+                quant_cof[k] = (quant_cof[k] * (1 << 14)) + (add_base << 13);
         }
     }
 
@@ -1016,10 +1016,6 @@
     ALSSpecificConfig *sconf = &ctx->sconf;
 
     *bd->shift_lsbs = 0;
-
-    if (get_bits_left(gb) < 1)
-        return AVERROR_INVALIDDATA;
-
     // read block type flag and read the samples accordingly
     if (get_bits1(gb)) {
         ret = read_var_block_data(ctx, bd);
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index a1225c0..bb224c5 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -298,8 +298,6 @@
     { "b",          "2M"  },
     { "g",          "250" },
     { "slices",     "1"   },
-    { "qmin",       "-1"  },
-    { "qmax",       "-1"  },
     { NULL                },
 };
 static const AVClass hevc_amf_class = {
diff --git a/libavcodec/amrnbdata.h b/libavcodec/amrnbdata.h
index 20b7a64..435fd99 100644
--- a/libavcodec/amrnbdata.h
+++ b/libavcodec/amrnbdata.h
@@ -1424,6 +1424,11 @@
 
 // fixed tables
 
+/**
+ * number of pulses per mode
+ */
+static const uint8_t pulses_nb_per_mode[] = {2, 2, 2, 3, 4, 4, 8, 10};
+
 /** track start positions for algebraic code book routines */
 static const uint8_t track_position[16] = {
     0, 2, 0, 3, 0, 2, 0, 3, 1, 3, 2, 4, 1, 4, 1, 4
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index e0c6b6b..8fe7b5e 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -243,7 +243,6 @@
         av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n");
         return AVERROR(EINVAL);
     }
-    avctx->bits_per_raw_sample =
     s->bps = avctx->bits_per_coded_sample;
     switch (s->bps) {
     case 8:
@@ -1334,7 +1333,7 @@
             /* Version 3.98 and later files */
 
             /* Update the adaption coefficients */
-            absres = FFABSU(res);
+            absres = FFABS(res);
             if (absres)
                 *f->adaptcoeffs = APESIGN(res) *
                                   (8 << ((absres > f->avg * 3) + (absres > f->avg * 4 / 3)));
diff --git a/libavcodec/argo.c b/libavcodec/argo.c
index 7358d10..6b4d449 100644
--- a/libavcodec/argo.c
+++ b/libavcodec/argo.c
@@ -565,7 +565,7 @@
     GetByteContext *gb = &s->gb;
     const int w = frame->width;
     const int h = frame->height;
-    const int l = frame->linesize[0];
+    const int l = frame->linesize[0] / 4;
     uint8_t *dst = frame->data[0];
     int pos = 0, y = 0;
 
diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile
index c4ab93a..c6be814 100644
--- a/libavcodec/arm/Makefile
+++ b/libavcodec/arm/Makefile
@@ -5,7 +5,8 @@
                                           arm/ac3dsp_arm.o
 OBJS-$(CONFIG_AUDIODSP)                += arm/audiodsp_init_arm.o
 OBJS-$(CONFIG_BLOCKDSP)                += arm/blockdsp_init_arm.o
-OBJS-$(CONFIG_FFT)                     += arm/fft_init_arm.o
+OBJS-$(CONFIG_FFT)                     += arm/fft_init_arm.o            \
+                                          arm/fft_fixed_init_arm.o
 OBJS-$(CONFIG_FLACDSP)                 += arm/flacdsp_init_arm.o        \
                                           arm/flacdsp_arm.o
 OBJS-$(CONFIG_FMTCONVERT)              += arm/fmtconvert_init_arm.o
@@ -107,7 +108,8 @@
                                           arm/int_neon.o
 NEON-OBJS-$(CONFIG_BLOCKDSP)           += arm/blockdsp_init_neon.o      \
                                           arm/blockdsp_neon.o
-NEON-OBJS-$(CONFIG_FFT)                += arm/fft_neon.o
+NEON-OBJS-$(CONFIG_FFT)                += arm/fft_neon.o                \
+                                          arm/fft_fixed_neon.o
 NEON-OBJS-$(CONFIG_FMTCONVERT)         += arm/fmtconvert_neon.o
 NEON-OBJS-$(CONFIG_G722DSP)            += arm/g722dsp_neon.o
 NEON-OBJS-$(CONFIG_H264CHROMA)         += arm/h264cmc_neon.o
@@ -121,7 +123,8 @@
 NEON-OBJS-$(CONFIG_IDCTDSP)            += arm/idctdsp_init_neon.o       \
                                           arm/idctdsp_neon.o            \
                                           arm/simple_idct_neon.o
-NEON-OBJS-$(CONFIG_MDCT)               += arm/mdct_neon.o
+NEON-OBJS-$(CONFIG_MDCT)               += arm/mdct_neon.o               \
+                                          arm/mdct_fixed_neon.o
 NEON-OBJS-$(CONFIG_MPEGVIDEO)          += arm/mpegvideo_neon.o
 NEON-OBJS-$(CONFIG_PIXBLOCKDSP)        += arm/pixblockdsp_neon.o
 NEON-OBJS-$(CONFIG_RDFT)               += arm/rdft_neon.o
diff --git a/libavcodec/arm/ac3dsp_init_arm.c b/libavcodec/arm/ac3dsp_init_arm.c
index 9217a7d..a3c32ff 100644
--- a/libavcodec/arm/ac3dsp_init_arm.c
+++ b/libavcodec/arm/ac3dsp_init_arm.c
@@ -26,8 +26,13 @@
 #include "config.h"
 
 void ff_ac3_exponent_min_neon(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
+int ff_ac3_max_msb_abs_int16_neon(const int16_t *src, int len);
+void ff_ac3_lshift_int16_neon(int16_t *src, unsigned len, unsigned shift);
+void ff_ac3_rshift_int32_neon(int32_t *src, unsigned len, unsigned shift);
 void ff_float_to_fixed24_neon(int32_t *dst, const float *src, unsigned int len);
 void ff_ac3_extract_exponents_neon(uint8_t *exp, int32_t *coef, int nb_coefs);
+void ff_apply_window_int16_neon(int16_t *dst, const int16_t *src,
+                                const int16_t *window, unsigned n);
 void ff_ac3_sum_square_butterfly_int32_neon(int64_t sum[4],
                                             const int32_t *coef0,
                                             const int32_t *coef1,
@@ -56,8 +61,12 @@
 
     if (have_neon(cpu_flags)) {
         c->ac3_exponent_min      = ff_ac3_exponent_min_neon;
+        c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_neon;
+        c->ac3_lshift_int16      = ff_ac3_lshift_int16_neon;
+        c->ac3_rshift_int32      = ff_ac3_rshift_int32_neon;
         c->float_to_fixed24      = ff_float_to_fixed24_neon;
         c->extract_exponents     = ff_ac3_extract_exponents_neon;
+        c->apply_window_int16    = ff_apply_window_int16_neon;
         c->sum_square_butterfly_int32 = ff_ac3_sum_square_butterfly_int32_neon;
         c->sum_square_butterfly_float = ff_ac3_sum_square_butterfly_float_neon;
     }
diff --git a/libavcodec/arm/fft_fixed_init_arm.c b/libavcodec/arm/fft_fixed_init_arm.c
new file mode 100644
index 0000000..11226d6
--- /dev/null
+++ b/libavcodec/arm/fft_fixed_init_arm.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/arm/cpu.h"
+
+#define FFT_FLOAT 0
+#include "libavcodec/fft.h"
+
+void ff_fft_fixed_calc_neon(FFTContext *s, FFTComplex *z);
+void ff_mdct_fixed_calc_neon(FFTContext *s, FFTSample *o, const FFTSample *i);
+void ff_mdct_fixed_calcw_neon(FFTContext *s, FFTDouble *o, const FFTSample *i);
+
+av_cold void ff_fft_fixed_init_arm(FFTContext *s)
+{
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_neon(cpu_flags)) {
+        s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
+#if CONFIG_FFT
+        s->fft_calc        = ff_fft_fixed_calc_neon;
+#endif
+
+#if CONFIG_MDCT
+        if (!s->inverse && s->nbits >= 3) {
+            s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
+            s->mdct_calc        = ff_mdct_fixed_calc_neon;
+            s->mdct_calcw       = ff_mdct_fixed_calcw_neon;
+        }
+#endif
+    }
+}
diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S
new file mode 100644
index 0000000..2651607
--- /dev/null
+++ b/libavcodec/arm/fft_fixed_neon.S
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+.macro  bflies          d0,  d1,  r0,  r1
+        vrev64.32       \r0, \d1                @ t5, t6, t1, t2
+        vhsub.s16       \r1, \d1, \r0           @ t1-t5, t2-t6, t5-t1, t6-t2
+        vhadd.s16       \r0, \d1, \r0           @ t1+t5, t2+t6, t5+t1, t6+t2
+        vext.16         \r1, \r1, \r1, #1       @ t2-t6, t5-t1, t6-t2, t1-t5
+        vtrn.32         \r0, \r1                @ t1+t5, t2+t6, t2-t6, t5-t1
+                                                @ t5,    t6,    t4,    t3
+        vhsub.s16       \d1, \d0, \r0
+        vhadd.s16       \d0, \d0, \r0
+.endm
+
+.macro  transform01     q0,  q1,  d3,  c0,  c1,  r0,  w0,  w1
+        vrev32.16       \r0, \d3
+        vmull.s16       \w0, \d3, \c0
+        vmlal.s16       \w0, \r0, \c1
+        vshrn.s32       \d3, \w0, #15
+        bflies          \q0, \q1, \w0, \w1
+.endm
+
+.macro  transform2      d0,  d1,  d2,  d3,  q0,  q1,  c0,  c1,  c2,  c3, \
+                        r0,  r1,  w0,  w1
+        vrev32.16       \r0, \d1
+        vrev32.16       \r1, \d3
+        vmull.s16       \w0, \d1, \c0
+        vmlal.s16       \w0, \r0, \c1
+        vmull.s16       \w1, \d3, \c2
+        vmlal.s16       \w1, \r1, \c3
+        vshrn.s32       \d1, \w0, #15
+        vshrn.s32       \d3, \w1, #15
+        bflies          \q0, \q1, \w0, \w1
+.endm
+
+.macro  fft4            d0,  d1,  r0,  r1
+        vhsub.s16       \r0, \d0, \d1           @ t3, t4, t8, t7
+        vhsub.s16       \r1, \d1, \d0
+        vhadd.s16       \d0, \d0, \d1           @ t1, t2, t6, t5
+        vmov.i64        \d1, #0xffff00000000
+        vbit            \r0, \r1, \d1
+        vrev64.16       \r1, \r0                @ t7, t8, t4, t3
+        vtrn.32         \r0, \r1                @ t3, t4, t7, t8
+        vtrn.32         \d0, \r0                @ t1, t2, t3, t4, t6, t5, t8, t7
+        vhsub.s16       \d1, \d0, \r0           @ r2, i2, r3, i1
+        vhadd.s16       \d0, \d0, \r0           @ r0, i0, r1, i3
+.endm
+
+.macro  fft8            d0,  d1,  d2,  d3,  q0,  q1,  c0,  c1,  r0,  r1, w0, w1
+        fft4            \d0, \d1, \r0, \r1
+        vtrn.32         \d0, \d1                @ z0, z2, z1, z3
+        vhadd.s16       \r0, \d2, \d3           @ t1, t2, t3, t4
+        vhsub.s16       \d3, \d2, \d3           @ z5, z7
+        vmov            \d2, \r0
+        transform01     \q0, \q1, \d3, \c0, \c1, \r0, \w0, \w1
+.endm
+
+function fft4_neon
+        vld1.16         {d0-d1},  [r0]
+        fft4            d0,  d1,  d2,  d3
+        vst1.16         {d0-d1},  [r0]
+        bx              lr
+endfunc
+
+function fft8_neon
+        vld1.16         {d0-d3},  [r0,:128]
+        movrel          r1,  coefs
+        vld1.16         {d30},    [r1,:64]
+        vdup.16         d31, d30[0]
+        fft8            d0,  d1,  d2,  d3,  q0,  q1,  d31, d30, d20, d21, q8, q9
+        vtrn.32         d0,  d1
+        vtrn.32         d2,  d3
+        vst1.16         {d0-d3},  [r0,:128]
+        bx              lr
+endfunc
+
+function fft16_neon
+        vld1.16         {d0-d3},  [r0,:128]!
+        vld1.16         {d4-d7},  [r0,:128]
+        movrel          r1,  coefs
+        sub             r0,  r0,  #32
+        vld1.16         {d28-d31},[r1,:128]
+        vdup.16         d31, d28[0]
+        fft8            d0,  d1,  d2,  d3,  q0,  q1,  d31, d28, d20, d21, q8, q9
+        vswp            d5,  d6
+        fft4            q2,  q3,  q8,  q9
+        vswp            d5,  d6
+        vtrn.32         q0,  q1             @ z0, z4, z2, z6, z1, z5, z3, z7
+        vtrn.32         q2,  q3             @ z8, z12,z10,z14,z9, z13,z11,z15
+        vswp            d1,  d2
+        vdup.16         d31, d28[0]
+        transform01     q0,  q2,  d5,  d31, d28, d20, q8, q9
+        vdup.16         d26, d29[0]
+        vdup.16         d27, d30[0]
+        transform2      d2,  d6,  d3,  d7,  q1,  q3,  d26, d30, d27, d29, \
+                        d20, d21, q8,  q9
+        vtrn.32         q0,  q1
+        vtrn.32         q2,  q3
+        vst1.16         {d0-d3},  [r0,:128]!
+        vst1.16         {d4-d7},  [r0,:128]
+        bx              lr
+endfunc
+
+function fft_pass_neon
+        push            {r4,lr}
+        movrel          lr,  coefs + 24
+        vld1.16         {d30},    [lr,:64]
+        lsl             r12, r2,  #3
+        vmov            d31, d30
+        add             r3,  r1,  r2,  lsl #2
+        mov             lr,  #-8
+        sub             r3,  r3,  #2
+        mov             r4,  r0
+        vld1.16         {d27[]},  [r3,:16]
+        sub             r3,  r3,  #6
+        vld1.16         {q0},     [r4,:128], r12
+        vld1.16         {q1},     [r4,:128], r12
+        vld1.16         {q2},     [r4,:128], r12
+        vld1.16         {q3},     [r4,:128], r12
+        vld1.16         {d28},    [r1,:64]!
+        vld1.16         {d29},    [r3,:64], lr
+        vswp            d1,  d2
+        vswp            d5,  d6
+        vtrn.32         d0,  d1
+        vtrn.32         d4,  d5
+        vdup.16         d25, d28[1]
+        vmul.s16        d27, d27, d31
+        transform01     q0,  q2,  d5,  d25, d27, d20, q8,  q9
+        b               2f
+1:
+        mov             r4,  r0
+        vdup.16         d26, d29[0]
+        vld1.16         {q0},     [r4,:128], r12
+        vld1.16         {q1},     [r4,:128], r12
+        vld1.16         {q2},     [r4,:128], r12
+        vld1.16         {q3},     [r4,:128], r12
+        vld1.16         {d28},    [r1,:64]!
+        vld1.16         {d29},    [r3,:64], lr
+        vswp            d1,  d2
+        vswp            d5,  d6
+        vtrn.32         d0,  d1
+        vtrn.32         d4,  d5
+        vdup.16         d24, d28[0]
+        vdup.16         d25, d28[1]
+        vdup.16         d27, d29[3]
+        vmul.s16        q13, q13, q15
+        transform2      d0,  d4,  d1,  d5,  q0,  q2,  d24, d26, d25, d27, \
+                        d16, d17, q9,  q10
+2:
+        vtrn.32         d2,  d3
+        vtrn.32         d6,  d7
+        vdup.16         d24, d28[2]
+        vdup.16         d26, d29[2]
+        vdup.16         d25, d28[3]
+        vdup.16         d27, d29[1]
+        vmul.s16        q13, q13, q15
+        transform2      d2,  d6,  d3,  d7,  q1,  q3,  d24, d26, d25, d27, \
+                        d16, d17, q9,  q10
+        vtrn.32         d0,  d1
+        vtrn.32         d2,  d3
+        vtrn.32         d4,  d5
+        vtrn.32         d6,  d7
+        vswp            d1,  d2
+        vswp            d5,  d6
+        mov             r4,  r0
+        vst1.16         {q0},     [r4,:128], r12
+        vst1.16         {q1},     [r4,:128], r12
+        vst1.16         {q2},     [r4,:128], r12
+        vst1.16         {q3},     [r4,:128], r12
+        add             r0,  r0,  #16
+        subs            r2,  r2,  #2
+        bgt             1b
+        pop             {r4,pc}
+endfunc
+
+#define F_SQRT1_2   23170
+#define F_COS_16_1  30274
+#define F_COS_16_3  12540
+
+const   coefs, align=4
+        .short          F_SQRT1_2, -F_SQRT1_2, -F_SQRT1_2,  F_SQRT1_2
+        .short          F_COS_16_1,-F_COS_16_1,-F_COS_16_1, F_COS_16_1
+        .short          F_COS_16_3,-F_COS_16_3,-F_COS_16_3, F_COS_16_3
+        .short          1,         -1,         -1,          1
+endconst
+
+.macro  def_fft n, n2, n4
+function fft\n\()_neon
+        push            {r4, lr}
+        mov             r4,  r0
+        bl              fft\n2\()_neon
+        add             r0,  r4,  #\n4*2*4
+        bl              fft\n4\()_neon
+        add             r0,  r4,  #\n4*3*4
+        bl              fft\n4\()_neon
+        mov             r0,  r4
+        pop             {r4, lr}
+        movrelx         r1,  X(ff_cos_\n\()_fixed)
+        mov             r2,  #\n4/2
+        b               fft_pass_neon
+endfunc
+.endm
+
+        def_fft    32,    16,     8
+        def_fft    64,    32,    16
+        def_fft   128,    64,    32
+        def_fft   256,   128,    64
+        def_fft   512,   256,   128
+        def_fft  1024,   512,   256
+        def_fft  2048,  1024,   512
+        def_fft  4096,  2048,  1024
+        def_fft  8192,  4096,  2048
+        def_fft 16384,  8192,  4096
+        def_fft 32768, 16384,  8192
+        def_fft 65536, 32768, 16384
+
+function ff_fft_fixed_calc_neon, export=1
+        ldr             r2,  [r0]
+        sub             r2,  r2,  #2
+        movrel          r3,  fft_fixed_tab_neon
+        ldr             r3,  [r3, r2, lsl #2]
+        mov             r0,  r1
+        bx              r3
+endfunc
+
+const   fft_fixed_tab_neon, relocate=1
+        .word fft4_neon
+        .word fft8_neon
+        .word fft16_neon
+        .word fft32_neon
+        .word fft64_neon
+        .word fft128_neon
+        .word fft256_neon
+        .word fft512_neon
+        .word fft1024_neon
+        .word fft2048_neon
+        .word fft4096_neon
+        .word fft8192_neon
+        .word fft16384_neon
+        .word fft32768_neon
+        .word fft65536_neon
+endconst
diff --git a/libavcodec/arm/mdct_fixed_neon.S b/libavcodec/arm/mdct_fixed_neon.S
new file mode 100644
index 0000000..365c5e7
--- /dev/null
+++ b/libavcodec/arm/mdct_fixed_neon.S
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+.macro  prerot          dst, rt
+        lsr             r3,  r6,  #2            @ n4
+        add             \rt, r4,  r6,  lsr #1   @ revtab + n4
+        add             r9,  r3,  r3,  lsl #1   @ n3
+        add             r8,  r7,  r6            @ tcos + n4
+        add             r3,  r2,  r6,  lsr #1   @ in + n4
+        add             r9,  r2,  r9,  lsl #1   @ in + n3
+        sub             r8,  r8,  #16
+        sub             r10, r3,  #16
+        sub             r11, r9,  #16
+        mov             r12, #-16
+1:
+        vld2.16         {d0,d1},  [r9, :128]!
+        vld2.16         {d2,d3},  [r11,:128], r12
+        vld2.16         {d4,d5},  [r3, :128]!
+        vld2.16         {d6,d7},  [r10,:128], r12
+        vld2.16         {d16,d17},[r7, :128]!   @ cos, sin
+        vld2.16         {d18,d19},[r8, :128], r12
+        vrev64.16       q1,  q1
+        vrev64.16       q3,  q3
+        vrev64.16       q9,  q9
+        vneg.s16        d0,  d0
+        vneg.s16        d2,  d2
+        vneg.s16        d16, d16
+        vneg.s16        d18, d18
+        vhsub.s16       d0,  d0,  d3            @ re
+        vhsub.s16       d4,  d7,  d4            @ im
+        vhsub.s16       d6,  d6,  d5
+        vhsub.s16       d2,  d2,  d1
+        vmull.s16       q10, d0,  d16
+        vmlsl.s16       q10, d4,  d17
+        vmull.s16       q11, d0,  d17
+        vmlal.s16       q11, d4,  d16
+        vmull.s16       q12, d6,  d18
+        vmlsl.s16       q12, d2,  d19
+        vmull.s16       q13, d6,  d19
+        vmlal.s16       q13, d2,  d18
+        vshrn.s32       d0,  q10, #15
+        vshrn.s32       d1,  q11, #15
+        vshrn.s32       d2,  q12, #15
+        vshrn.s32       d3,  q13, #15
+        vzip.16         d0,  d1
+        vzip.16         d2,  d3
+        ldrh            lr,  [r4], #2
+        ldrh            r2,  [\rt, #-2]!
+        add             lr,  \dst, lr,  lsl #2
+        add             r2,  \dst, r2,  lsl #2
+        vst1.32         {d0[0]},  [lr,:32]
+        vst1.32         {d2[0]},  [r2,:32]
+        ldrh            lr,  [r4], #2
+        ldrh            r2,  [\rt, #-2]!
+        add             lr,  \dst, lr,  lsl #2
+        add             r2,  \dst, r2,  lsl #2
+        vst1.32         {d0[1]},  [lr,:32]
+        vst1.32         {d2[1]},  [r2,:32]
+        ldrh            lr,  [r4], #2
+        ldrh            r2,  [\rt, #-2]!
+        add             lr,  \dst, lr,  lsl #2
+        add             r2,  \dst, r2,  lsl #2
+        vst1.32         {d1[0]},  [lr,:32]
+        vst1.32         {d3[0]},  [r2,:32]
+        ldrh            lr,  [r4], #2
+        ldrh            r2,  [\rt, #-2]!
+        add             lr,  \dst, lr,  lsl #2
+        add             r2,  \dst, r2,  lsl #2
+        vst1.32         {d1[1]},  [lr,:32]
+        vst1.32         {d3[1]},  [r2,:32]
+        subs            r6,  r6,  #32
+        bgt             1b
+.endm
+
+function ff_mdct_fixed_calc_neon, export=1
+        push            {r1,r4-r11,lr}
+
+        ldr             r4,  [r0, #8]           @ revtab
+        ldr             r6,  [r0, #16]          @ mdct_size; n
+        ldr             r7,  [r0, #24]          @ tcos
+
+        prerot          r1,  r5
+
+        mov             r4,  r0
+        bl              X(ff_fft_fixed_calc_neon)
+
+        pop             {r5}
+        mov             r12, #-16
+        ldr             r6,  [r4, #16]          @ mdct_size; n
+        ldr             r7,  [r4, #24]          @ tcos
+        add             r5,  r5,  r6,  lsr #1
+        add             r7,  r7,  r6,  lsr #1
+        sub             r1,  r5,  #16
+        sub             r2,  r7,  #16
+1:
+        vld2.16         {d4,d5},  [r7,:128]!
+        vld2.16         {d6,d7},  [r2,:128], r12
+        vld2.16         {d0,d1},  [r5,:128]
+        vld2.16         {d2,d3},  [r1,:128]
+        vrev64.16       q3,  q3
+        vrev64.16       q1,  q1
+        vneg.s16        q3,  q3
+        vneg.s16        q2,  q2
+        vmull.s16       q11, d2,  d6
+        vmlal.s16       q11, d3,  d7
+        vmull.s16       q8,  d0,  d5
+        vmlsl.s16       q8,  d1,  d4
+        vmull.s16       q9,  d0,  d4
+        vmlal.s16       q9,  d1,  d5
+        vmull.s16       q10, d2,  d7
+        vmlsl.s16       q10, d3,  d6
+        vshrn.s32       d0,  q11, #15
+        vshrn.s32       d1,  q8,  #15
+        vshrn.s32       d2,  q9,  #15
+        vshrn.s32       d3,  q10, #15
+        vrev64.16       q0,  q0
+        vst2.16         {d2,d3},  [r5,:128]!
+        vst2.16         {d0,d1},  [r1,:128], r12
+        subs            r6,  r6,  #32
+        bgt             1b
+
+        pop             {r4-r11,pc}
+endfunc
+
+function ff_mdct_fixed_calcw_neon, export=1
+        push            {r1,r4-r11,lr}
+
+        ldrd            r4,  r5,  [r0, #8]      @ revtab, tmp_buf
+        ldr             r6,  [r0, #16]          @ mdct_size; n
+        ldr             r7,  [r0, #24]          @ tcos
+
+        prerot          r5,  r1
+
+        mov             r4,  r0
+        mov             r1,  r5
+        bl              X(ff_fft_fixed_calc_neon)
+
+        pop             {r7}
+        mov             r12, #-16
+        ldr             r6,  [r4, #16]          @ mdct_size; n
+        ldr             r9,  [r4, #24]          @ tcos
+        add             r5,  r5,  r6,  lsr #1
+        add             r7,  r7,  r6
+        add             r9,  r9,  r6,  lsr #1
+        sub             r3,  r5,  #16
+        sub             r1,  r7,  #16
+        sub             r2,  r9,  #16
+1:
+        vld2.16         {d4,d5},  [r9,:128]!
+        vld2.16         {d6,d7},  [r2,:128], r12
+        vld2.16         {d0,d1},  [r5,:128]!
+        vld2.16         {d2,d3},  [r3,:128], r12
+        vrev64.16       q3,  q3
+        vrev64.16       q1,  q1
+        vneg.s16        q3,  q3
+        vneg.s16        q2,  q2
+        vmull.s16       q8,  d2,  d6
+        vmlal.s16       q8,  d3,  d7
+        vmull.s16       q9,  d0,  d5
+        vmlsl.s16       q9,  d1,  d4
+        vmull.s16       q10, d0,  d4
+        vmlal.s16       q10, d1,  d5
+        vmull.s16       q11, d2,  d7
+        vmlsl.s16       q11, d3,  d6
+        vrev64.32       q8,  q8
+        vrev64.32       q9,  q9
+        vst2.32         {q10,q11},[r7,:128]!
+        vst2.32         {d16,d18},[r1,:128], r12
+        vst2.32         {d17,d19},[r1,:128], r12
+        subs            r6,  r6,  #32
+        bgt             1b
+
+        pop             {r4-r11,pc}
+endfunc
diff --git a/libavcodec/arm/neontest.c b/libavcodec/arm/neontest.c
index d1ede49..f9c0dbf 100644
--- a/libavcodec/arm/neontest.c
+++ b/libavcodec/arm/neontest.c
@@ -29,7 +29,6 @@
     testneonclobbers(avcodec_open2, avctx, codec, options);
 }
 
-#if FF_API_OLD_ENCDEC
 wrap(avcodec_decode_audio4(AVCodecContext *avctx,
                            AVFrame *frame,
                            int *got_frame_ptr,
@@ -48,22 +47,6 @@
                      got_picture_ptr, avpkt);
 }
 
-wrap(avcodec_encode_audio2(AVCodecContext *avctx,
-                           AVPacket *avpkt,
-                           const AVFrame *frame,
-                           int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
-                     got_packet_ptr);
-}
-
-wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                           const AVFrame *frame, int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
-}
-#endif
-
 wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
                               AVSubtitle *sub,
                               int *got_sub_ptr,
@@ -73,6 +56,15 @@
                      got_sub_ptr, avpkt);
 }
 
+wrap(avcodec_encode_audio2(AVCodecContext *avctx,
+                           AVPacket *avpkt,
+                           const AVFrame *frame,
+                           int *got_packet_ptr))
+{
+    testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
+                     got_packet_ptr);
+}
+
 wrap(avcodec_encode_subtitle(AVCodecContext *avctx,
                              uint8_t *buf, int buf_size,
                              const AVSubtitle *sub))
@@ -80,6 +72,12 @@
     testneonclobbers(avcodec_encode_subtitle, avctx, buf, buf_size, sub);
 }
 
+wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
+                           const AVFrame *frame, int *got_packet_ptr))
+{
+    testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
+}
+
 wrap(avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt))
 {
     testneonclobbers(avcodec_send_packet, avctx, avpkt);
diff --git a/libavcodec/arm/sbcdsp_init_arm.c b/libavcodec/arm/sbcdsp_init_arm.c
index b8fa5a3..6bf7e72 100644
--- a/libavcodec/arm/sbcdsp_init_arm.c
+++ b/libavcodec/arm/sbcdsp_init_arm.c
@@ -30,7 +30,6 @@
  */
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/arm/cpu.h"
 #include "libavcodec/sbcdsp.h"
 
diff --git a/libavcodec/arm/vp9dsp_init_16bpp_arm_template.c b/libavcodec/arm/vp9dsp_init_16bpp_arm_template.c
index b090709..1b00078 100644
--- a/libavcodec/arm/vp9dsp_init_16bpp_arm_template.c
+++ b/libavcodec/arm/vp9dsp_init_16bpp_arm_template.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/arm/cpu.h"
 #include "vp9dsp_init.h"
 
diff --git a/libavcodec/arm/vp9dsp_init_arm.c b/libavcodec/arm/vp9dsp_init_arm.c
index b3911f7..cb7f48d 100644
--- a/libavcodec/arm/vp9dsp_init_arm.c
+++ b/libavcodec/arm/vp9dsp_init_arm.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/arm/cpu.h"
 #include "libavcodec/vp9dsp.h"
 #include "vp9dsp_init.h"
diff --git a/libavcodec/asv.h b/libavcodec/asv.h
index 269bbe7..e778c72 100644
--- a/libavcodec/asv.h
+++ b/libavcodec/asv.h
@@ -28,7 +28,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "blockdsp.h"
diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index 54f9b1c..0dd8b87 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -33,8 +33,6 @@
 #include <stdio.h>
 
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "get_bits.h"
 #include "fft.h"
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 37ccbcc..6330327 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -39,7 +39,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/atrac3plus.h b/libavcodec/atrac3plus.h
index a588436..82fe0fe 100644
--- a/libavcodec/atrac3plus.h
+++ b/libavcodec/atrac3plus.h
@@ -31,8 +31,6 @@
 #include <stdint.h>
 
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
-
 #include "atrac.h"
 #include "avcodec.h"
 #include "fft.h"
diff --git a/libavcodec/atrac3plus_data.h b/libavcodec/atrac3plus_data.h
index 05ae2b7..7039936 100644
--- a/libavcodec/atrac3plus_data.h
+++ b/libavcodec/atrac3plus_data.h
@@ -104,6 +104,25 @@
      0,  1,  2, 14, 15,  3, 13,  4, 12,  5, 11,  6,  7,  9, 10,
 };
 
+static const uint8_t atrac3p_ct_huff1[4][2] = {
+    { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 3 },
+};
+
+static const uint8_t atrac3p_ct_huff2[8][2] = {
+    { 0, 2 }, { 1, 3 }, { 2, 3 }, { 3, 3 }, { 4, 3 }, { 5, 3 }, { 6, 4 },
+    { 7, 4 },
+};
+
+static const uint8_t atrac3p_ct_huff3[8][2] = {
+    { 0, 2 }, { 1, 3 }, { 2, 3 }, { 3, 3 }, { 6, 3 }, { 7, 3 }, { 4, 4 },
+    { 5, 4 },
+};
+
+static const uint8_t atrac3p_ct_huff4[8][2] = {
+    { 0, 1 }, { 1, 3 }, { 2, 4 }, { 3, 4 }, { 4, 4 }, { 5, 4 }, { 6, 4 },
+    { 7, 4 },
+};
+
 /* weights for quantized word lengths */
 static const int8_t atrac3p_wl_weights[6][32] = {
     { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
@@ -374,7 +393,7 @@
 
 /* If the first entry of a subtable is negative, it means
  * that another VLC is to be reused. */
-static const int8_t atrac3p_spectra_cbs[][12] = {
+static int8_t atrac3p_spectra_cbs[][12] = {
     {  1,  0,  0,  1,  7,  0, 19,  5, 13, 21,  6,  8 },
     {  0,  1,  0,  4, 11,  0,  1, 29,  6, 20,  7,  2 },
     {  0,  0,  1,  8,  0, 13, 18,  7,  2,  0,  0,  0 },
diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index c024ab6..2ae03d8 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -39,7 +39,6 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/atrac3plusdsp.c b/libavcodec/atrac3plusdsp.c
index e32c5c8..7af1fa2 100644
--- a/libavcodec/atrac3plusdsp.c
+++ b/libavcodec/atrac3plusdsp.c
@@ -29,8 +29,6 @@
 
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "sinewin.h"
 #include "fft.h"
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index f88b25d..f2413ef 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -27,7 +27,6 @@
 #include "atrac9tab.h"
 #include "libavutil/lfg.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
 
 #define ATRAC9_SF_VLC_BITS 8
 #define ATRAC9_COEFF_VLC_BITS 9
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index bf3e009..19003f9 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -1,7 +1,7 @@
 /*
  * Audio Toolbox system codecs
  *
- * copyright (c) 2016 rcombs
+ * copyright (c) 2016 Rodger Combs
  *
  * This file is part of FFmpeg.
  *
@@ -296,8 +296,7 @@
     return 0;
 }
 
-static av_cold int ffat_create_decoder(AVCodecContext *avctx,
-                                       const AVPacket *pkt)
+static av_cold int ffat_create_decoder(AVCodecContext *avctx, AVPacket *pkt)
 {
     ATDecodeContext *at = avctx->priv_data;
     OSStatus status;
@@ -484,7 +483,7 @@
     if (avctx->codec_id == AV_CODEC_ID_AAC) {
         if (!at->extradata_size) {
             uint8_t *side_data;
-            buffer_size_t side_data_size;
+            int side_data_size;
 
             side_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
                                                 &side_data_size);
diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index b0a4340..e8748b3 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -1,7 +1,7 @@
 /*
  * Audio Toolbox system codecs
  *
- * copyright (c) 2016 rcombs
+ * copyright (c) 2016 Rodger Combs
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/av1_frame_split_bsf.c b/libavcodec/av1_frame_split_bsf.c
index fa8b887..13bebe1 100644
--- a/libavcodec/av1_frame_split_bsf.c
+++ b/libavcodec/av1_frame_split_bsf.c
@@ -214,7 +214,7 @@
     if (ret < 0)
         return ret;
 
-    s->cbc->decompose_unit_types    = decompose_unit_types;
+    s->cbc->decompose_unit_types    = (CodedBitstreamUnitType*)decompose_unit_types;
     s->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types);
 
     if (!ctx->par_in->extradata_size)
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index 8cafe46..3158ba9 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -20,12 +20,22 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
-#include "cbs_bsf.h"
 #include "cbs_av1.h"
 
+enum {
+    PASS,
+    INSERT,
+    REMOVE,
+};
+
 typedef struct AV1MetadataContext {
-    CBSBSFContext common;
+    const AVClass *class;
+
+    CodedBitstreamContext *input;
+    CodedBitstreamContext *output;
+    CodedBitstreamFragment access_unit;
 
     int td;
 
@@ -103,27 +113,91 @@
     return 0;
 }
 
-static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
-                                        CodedBitstreamFragment *frag)
+static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
 {
     AV1MetadataContext *ctx = bsf->priv_data;
-    AV1RawOBU td, *obu;
+    CodedBitstreamFragment *frag = &ctx->access_unit;
+    uint8_t *side_data;
+    int side_data_size;
     int err, i;
 
+    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+                                        &side_data_size);
+    if (!side_data_size)
+        return 0;
+
+    err = ff_cbs_read(ctx->input, frag, side_data, side_data_size);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n");
+        return err;
+    }
+
     for (i = 0; i < frag->nb_units; i++) {
         if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
-            obu = frag->units[i].content;
+            AV1RawOBU *obu = frag->units[i].content;
             err = av1_metadata_update_sequence_header(bsf, &obu->obu.sequence_header);
             if (err < 0)
                 return err;
         }
     }
 
+    err = ff_cbs_write_fragment_data(ctx->output, frag);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n");
+        return err;
+    }
+
+    side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, frag->data_size);
+    if (!side_data)
+        return AVERROR(ENOMEM);
+    memcpy(side_data, frag->data, frag->data_size);
+
+    ff_cbs_fragment_reset(frag);
+
+    return 0;
+}
+
+static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+{
+    AV1MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *frag = &ctx->access_unit;
+    AV1RawOBU td, *obu;
+    int err, i;
+
+    err = ff_bsf_get_packet_ref(bsf, pkt);
+    if (err < 0)
+        return err;
+
+    err = av1_metadata_update_side_data(bsf, pkt);
+    if (err < 0)
+        goto fail;
+
+    err = ff_cbs_read_packet(ctx->input, frag, pkt);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+        goto fail;
+    }
+
+    if (frag->nb_units == 0) {
+        av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
+        err = AVERROR_INVALIDDATA;
+        goto fail;
+    }
+
+    for (i = 0; i < frag->nb_units; i++) {
+        if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
+            obu = frag->units[i].content;
+            err = av1_metadata_update_sequence_header(bsf, &obu->obu.sequence_header);
+            if (err < 0)
+                goto fail;
+        }
+    }
+
     // If a Temporal Delimiter is present, it must be the first OBU.
     if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
-        if (ctx->td == BSF_ELEMENT_REMOVE)
+        if (ctx->td == REMOVE)
             ff_cbs_delete_unit(frag, 0);
-    } else if (pkt && ctx->td == BSF_ELEMENT_INSERT) {
+    } else if (ctx->td == INSERT) {
         td = (AV1RawOBU) {
             .header.obu_type = AV1_OBU_TEMPORAL_DELIMITER,
         };
@@ -132,7 +206,7 @@
                                          &td, NULL);
         if (err < 0) {
             av_log(bsf, AV_LOG_ERROR, "Failed to insert Temporal Delimiter.\n");
-            return err;
+            goto fail;
         }
     }
 
@@ -143,26 +217,86 @@
         }
     }
 
-    return 0;
-}
+    err = ff_cbs_write_packet(ctx->output, pkt, frag);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+        goto fail;
+    }
 
-static const CBSBSFType av1_metadata_type = {
-    .codec_id        = AV_CODEC_ID_AV1,
-    .fragment_name   = "temporal unit",
-    .unit_name       = "OBU",
-    .update_fragment = &av1_metadata_update_fragment,
-};
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(frag);
+
+    if (err < 0)
+        av_packet_unref(pkt);
+
+    return err;
+}
 
 static int av1_metadata_init(AVBSFContext *bsf)
 {
-    return ff_cbs_bsf_generic_init(bsf, &av1_metadata_type);
+    AV1MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *frag = &ctx->access_unit;
+    AV1RawOBU *obu;
+    int err, i;
+
+    err = ff_cbs_init(&ctx->input, AV_CODEC_ID_AV1, bsf);
+    if (err < 0)
+        return err;
+    err = ff_cbs_init(&ctx->output, AV_CODEC_ID_AV1, bsf);
+    if (err < 0)
+        return err;
+
+    if (bsf->par_in->extradata) {
+        err = ff_cbs_read_extradata(ctx->input, frag, bsf->par_in);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
+            goto fail;
+        }
+
+        for (i = 0; i < frag->nb_units; i++) {
+            if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
+                obu = frag->units[i].content;
+                err = av1_metadata_update_sequence_header(bsf, &obu->obu.sequence_header);
+                if (err < 0)
+                    goto fail;
+            }
+        }
+
+        err = ff_cbs_write_extradata(ctx->output, bsf->par_out, frag);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
+            goto fail;
+        }
+    }
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(frag);
+    return err;
+}
+
+static void av1_metadata_close(AVBSFContext *bsf)
+{
+    AV1MetadataContext *ctx = bsf->priv_data;
+
+    ff_cbs_fragment_free(&ctx->access_unit);
+    ff_cbs_close(&ctx->input);
+    ff_cbs_close(&ctx->output);
 }
 
 #define OFFSET(x) offsetof(AV1MetadataContext, x)
 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption av1_metadata_options[] = {
-    BSF_ELEMENT_OPTIONS_PIR("td", "Temporal Delimiter OBU",
-                            td, FLAGS),
+    { "td", "Temporal Delimiter OBU",
+        OFFSET(td), AV_OPT_TYPE_INT,
+        { .i64 = PASS }, PASS, REMOVE, FLAGS, "td" },
+    { "pass",   NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = PASS   }, .flags = FLAGS, .unit = "td" },
+    { "insert", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = INSERT }, .flags = FLAGS, .unit = "td" },
+    { "remove", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = REMOVE }, .flags = FLAGS, .unit = "td" },
 
     { "color_primaries", "Set color primaries (section 6.4.2)",
         OFFSET(color_primaries), AV_OPT_TYPE_INT,
@@ -222,7 +356,7 @@
     .priv_data_size = sizeof(AV1MetadataContext),
     .priv_class     = &av1_metadata_class,
     .init           = &av1_metadata_init,
-    .close          = &ff_cbs_bsf_generic_close,
-    .filter         = &ff_cbs_bsf_generic_filter,
+    .close          = &av1_metadata_close,
+    .filter         = &av1_metadata_filter,
     .codec_ids      = av1_metadata_codec_ids,
 };
diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
index 6a76ffb..181ff3a 100644
--- a/libavcodec/av1_parser.c
+++ b/libavcodec/av1_parser.c
@@ -191,7 +191,7 @@
     if (ret < 0)
         return ret;
 
-    s->cbc->decompose_unit_types    = decompose_unit_types;
+    s->cbc->decompose_unit_types    = (CodedBitstreamUnitType *)decompose_unit_types;
     s->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types);
 
     return 0;
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index a75d674..bc897af 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -18,9 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/film_grain_params.h"
 #include "libavutil/pixdesc.h"
-#include "libavutil/opt.h"
 #include "avcodec.h"
 #include "av1dec.h"
 #include "bytestream.h"
@@ -654,8 +652,6 @@
     if (ret < 0)
         return ret;
 
-    av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 0);
-
     if (avctx->extradata && avctx->extradata_size) {
         ret = ff_cbs_read_extradata_from_codec(s->cbc,
                                                &s->current_obu,
@@ -741,66 +737,6 @@
     return ret;
 }
 
-static int export_film_grain(AVCodecContext *avctx, AVFrame *frame)
-{
-    AV1DecContext *s = avctx->priv_data;
-    const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain;
-    AVFilmGrainParams *fgp;
-    AVFilmGrainAOMParams *aom;
-
-    if (!film_grain->apply_grain)
-        return 0;
-
-    fgp = av_film_grain_params_create_side_data(frame);
-    if (!fgp)
-        return AVERROR(ENOMEM);
-
-    fgp->type = AV_FILM_GRAIN_PARAMS_AV1;
-    fgp->seed = film_grain->grain_seed;
-
-    aom = &fgp->codec.aom;
-    aom->chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma;
-    aom->scaling_shift = film_grain->grain_scaling_minus_8 + 8;
-    aom->ar_coeff_lag = film_grain->ar_coeff_lag;
-    aom->ar_coeff_shift = film_grain->ar_coeff_shift_minus_6 + 6;
-    aom->grain_scale_shift = film_grain->grain_scale_shift;
-    aom->overlap_flag = film_grain->overlap_flag;
-    aom->limit_output_range = film_grain->clip_to_restricted_range;
-
-    aom->num_y_points = film_grain->num_y_points;
-    for (int i = 0; i < film_grain->num_y_points; i++) {
-        aom->y_points[i][0] = film_grain->point_y_value[i];
-        aom->y_points[i][1] = film_grain->point_y_scaling[i];
-    }
-    aom->num_uv_points[0] = film_grain->num_cb_points;
-    for (int i = 0; i < film_grain->num_cb_points; i++) {
-        aom->uv_points[0][i][0] = film_grain->point_cb_value[i];
-        aom->uv_points[0][i][1] = film_grain->point_cb_scaling[i];
-    }
-    aom->num_uv_points[1] = film_grain->num_cr_points;
-    for (int i = 0; i < film_grain->num_cr_points; i++) {
-        aom->uv_points[1][i][0] = film_grain->point_cr_value[i];
-        aom->uv_points[1][i][1] = film_grain->point_cr_scaling[i];
-    }
-
-    for (int i = 0; i < 24; i++) {
-        aom->ar_coeffs_y[i] = film_grain->ar_coeffs_y_plus_128[i] - 128;
-    }
-    for (int i = 0; i < 25; i++) {
-        aom->ar_coeffs_uv[0][i] = film_grain->ar_coeffs_cb_plus_128[i] - 128;
-        aom->ar_coeffs_uv[1][i] = film_grain->ar_coeffs_cr_plus_128[i] - 128;
-    }
-
-    aom->uv_mult[0] = film_grain->cb_mult;
-    aom->uv_mult[1] = film_grain->cr_mult;
-    aom->uv_mult_luma[0] = film_grain->cb_luma_mult;
-    aom->uv_mult_luma[1] = film_grain->cr_luma_mult;
-    aom->uv_offset[0] = film_grain->cb_offset;
-    aom->uv_offset[1] = film_grain->cr_offset;
-
-    return 0;
-}
-
 static int set_output_frame(AVCodecContext *avctx, AVFrame *frame,
                             const AVPacket *pkt, int *got_frame)
 {
@@ -808,23 +744,10 @@
     const AVFrame *srcframe = s->cur_frame.tf.f;
     int ret;
 
-    // TODO: all layers
-    if (s->operating_point_idc &&
-        av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
-        return 0;
-
     ret = av_frame_ref(frame, srcframe);
     if (ret < 0)
         return ret;
 
-    if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) {
-        ret = export_film_grain(avctx, frame);
-        if (ret < 0) {
-            av_frame_unref(frame);
-            return ret;
-        }
-    }
-
     frame->pts = pkt->pts;
     frame->pkt_dts = pkt->dts;
     frame->pkt_size = pkt->size;
@@ -927,8 +850,6 @@
                 goto end;
             }
 
-            s->operating_point_idc = s->raw_seq->operating_point_idc[s->operating_point];
-
             if (s->pix_fmt == AV_PIX_FMT_NONE) {
                 ret = get_pixel_format(avctx);
                 if (ret < 0) {
@@ -1099,28 +1020,12 @@
         av1_frame_unref(avctx, &s->ref[i]);
 
     av1_frame_unref(avctx, &s->cur_frame);
-    s->operating_point_idc = 0;
     s->raw_frame_header = NULL;
     s->raw_seq = NULL;
 
     ff_cbs_flush(s->cbc);
 }
 
-#define OFFSET(x) offsetof(AV1DecContext, x)
-#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
-static const AVOption av1_options[] = {
-    { "operating_point",  "Select an operating point of the scalable bitstream",
-                          OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, AV1_MAX_OPERATING_POINTS - 1, VD },
-    { NULL }
-};
-
-static const AVClass av1_class = {
-    .class_name = "AV1 decoder",
-    .item_name  = av_default_item_name,
-    .option     = av1_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 AVCodec ff_av1_decoder = {
     .name                  = "av1",
     .long_name             = NULL_IF_CONFIG_SMALL("Alliance for Open Media AV1"),
@@ -1136,8 +1041,7 @@
                              FF_CODEC_CAP_SETS_PKT_DTS,
     .flush                 = av1_decode_flush,
     .profiles              = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
-    .priv_class            = &av1_class,
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal * []) {
 #if CONFIG_AV1_DXVA2_HWACCEL
         HWACCEL_DXVA2(av1),
 #endif
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 248a687..7e3b0c7 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -76,13 +76,9 @@
     uint16_t tg_start;
     uint16_t tg_end;
 
-    int operating_point_idc;
-
     AV1Frame ref[AV1_NUM_REF_FRAMES];
     AV1Frame cur_frame;
 
-    // AVOptions
-    int operating_point;
 } AV1DecContext;
 
 #endif /* AVCODEC_AV1DEC_H */
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3ecb3a4..1d3099d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1345,7 +1345,6 @@
      */
     int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
 
-#if FF_API_OLD_ENCDEC
     /**
      * If non-zero, the decoded audio and video frames returned from
      * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
@@ -1361,7 +1360,6 @@
      */
     attribute_deprecated
     int refcounted_frames;
-#endif
 
     /* - encoding parameters */
     float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
@@ -1621,20 +1619,42 @@
 #define FF_DEBUG_BITSTREAM   4
 #define FF_DEBUG_MB_TYPE     8
 #define FF_DEBUG_QP          16
+#if FF_API_DEBUG_MV
+/**
+ * @deprecated this option does nothing
+ */
+#define FF_DEBUG_MV          32
+#endif
 #define FF_DEBUG_DCT_COEFF   0x00000040
 #define FF_DEBUG_SKIP        0x00000080
 #define FF_DEBUG_STARTCODE   0x00000100
 #define FF_DEBUG_ER          0x00000400
 #define FF_DEBUG_MMCO        0x00000800
 #define FF_DEBUG_BUGS        0x00001000
+#if FF_API_DEBUG_MV
+#define FF_DEBUG_VIS_QP      0x00002000
+#define FF_DEBUG_VIS_MB_TYPE 0x00004000
+#endif
 #define FF_DEBUG_BUFFERS     0x00008000
 #define FF_DEBUG_THREADS     0x00010000
 #define FF_DEBUG_GREEN_MD    0x00800000
 #define FF_DEBUG_NOMC        0x01000000
 
+#if FF_API_DEBUG_MV
+    /**
+     * debug
+     * - encoding: Set by user.
+     * - decoding: Set by user.
+     */
+    int debug_mv;
+#define FF_DEBUG_VIS_MV_P_FOR  0x00000001 // visualize forward predicted MVs of P-frames
+#define FF_DEBUG_VIS_MV_B_FOR  0x00000002 // visualize forward predicted MVs of B-frames
+#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames
+#endif
+
     /**
      * Error recognition; may misdetect some more or less valid parts as errors.
-     * - encoding: Set by user.
+     * - encoding: unused
      * - decoding: Set by user.
      */
     int err_recognition;
@@ -1741,12 +1761,14 @@
      */
     int bits_per_raw_sample;
 
+#if FF_API_LOWRES
     /**
      * low resolution decoding, 1-> 1/2 size, 2->1/4 size
      * - encoding: unused
      * - decoding: Set by user.
      */
      int lowres;
+#endif
 
 #if FF_API_CODED_FRAME
     /**
@@ -1797,11 +1819,7 @@
      *
      * @deprecated the custom get_buffer2() callback should always be
      *   thread-safe. Thread-unsafe get_buffer2() implementations will be
-     *   invalid starting with LIBAVCODEC_VERSION_MAJOR=60; in other words,
-     *   libavcodec will behave as if this field was always set to 1.
-     *   Callers that want to be forward compatible with future libavcodec
-     *   versions should wrap access to this field in
-     *     #if LIBAVCODEC_VERSION_MAJOR < 60
+     *   invalid once this field is removed.
      */
     attribute_deprecated
     int thread_safe_callbacks;
@@ -1943,9 +1961,6 @@
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE          3
 #define FF_PROFILE_HEVC_REXT                        4
 
-#define FF_PROFILE_VVC_MAIN_10                      1
-#define FF_PROFILE_VVC_MAIN_10_444                 33
-
 #define FF_PROFILE_AV1_MAIN                         0
 #define FF_PROFILE_AV1_HIGH                         1
 #define FF_PROFILE_AV1_PROFESSIONAL                 2
@@ -2086,6 +2101,15 @@
      */
     const AVCodecDescriptor *codec_descriptor;
 
+#if !FF_API_LOWRES
+    /**
+     * low resolution decoding, 1-> 1/2 size, 2->1/4 size
+     * - encoding: unused
+     * - decoding: Set by user.
+     */
+     int lowres;
+#endif
+
     /**
      * Current statistics for PTS correction.
      * - decoding: maintained and used by libavcodec, not intended to be used by user apps
@@ -2136,11 +2160,12 @@
      */
     int seek_preroll;
 
-#if FF_API_DEBUG_MV
+#if !FF_API_DEBUG_MV
     /**
-     * @deprecated unused
+     * debug motion vectors
+     * - encoding: Set by user.
+     * - decoding: Set by user.
      */
-    attribute_deprecated
     int debug_mv;
 #define FF_DEBUG_VIS_MV_P_FOR  0x00000001 //visualize forward predicted MVs of P frames
 #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 //visualize forward predicted MVs of B frames
@@ -2359,10 +2384,12 @@
 attribute_deprecated
 unsigned av_codec_get_codec_properties(const AVCodecContext *avctx);
 
+#if FF_API_LOWRES
 attribute_deprecated
 int  av_codec_get_lowres(const AVCodecContext *avctx);
 attribute_deprecated
 void av_codec_set_lowres(AVCodecContext *avctx, int val);
+#endif
 
 attribute_deprecated
 int  av_codec_get_seek_preroll(const AVCodecContext *avctx);
@@ -2712,13 +2739,25 @@
 
 #if FF_API_NEXT
 /**
- * @deprecated Calling this function is unnecessary.
+ * Register the codec codec and initialize libavcodec.
+ *
+ * @warning either this function or avcodec_register_all() must be called
+ * before any other libavcodec functions.
+ *
+ * @see avcodec_register_all()
  */
 attribute_deprecated
 void avcodec_register(AVCodec *codec);
 
 /**
- * @deprecated Calling this function is unnecessary.
+ * Register all the codecs, parsers and bitstream filters which were enabled at
+ * configuration time. If you do not call this function you can select exactly
+ * which formats you want to support, by using the individual registration
+ * functions.
+ *
+ * @see avcodec_register
+ * @see av_register_codec_parser
+ * @see av_register_bitstream_filter
  */
 attribute_deprecated
 void avcodec_register_all(void);
@@ -2762,13 +2801,14 @@
  */
 const AVClass *avcodec_get_class(void);
 
-#if FF_API_GET_FRAME_CLASS
+#if FF_API_COPY_CONTEXT
 /**
- * @deprecated This function should not be used.
+ * Get the AVClass for AVFrame. It can be used in combination with
+ * AV_OPT_SEARCH_FAKE_OBJ for examining options.
+ *
+ * @see av_opt_find().
  */
-attribute_deprecated
 const AVClass *avcodec_get_frame_class(void);
-#endif
 
 /**
  * Get the AVClass for AVSubtitleRect. It can be used in combination with
@@ -2778,7 +2818,6 @@
  */
 const AVClass *avcodec_get_subtitle_rect_class(void);
 
-#if FF_API_COPY_CONTEXT
 /**
  * Copy the settings of the source AVCodecContext into the destination
  * AVCodecContext. The resulting destination codec context will be
@@ -2835,6 +2874,7 @@
  * @ref avcodec_receive_frame()).
  *
  * @code
+ * avcodec_register_all();
  * av_dict_set(&opts, "b", "2.5M", 0);
  * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
  * if (!codec)
@@ -2939,7 +2979,6 @@
  */
 enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
 
-#if FF_API_OLD_ENCDEC
 /**
  * Decode the audio frame of size avpkt->size from avpkt->data into frame.
  *
@@ -3046,7 +3085,6 @@
 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
                          int *got_picture_ptr,
                          const AVPacket *avpkt);
-#endif
 
 /**
  * Decode a subtitle message.
@@ -3503,10 +3541,7 @@
                         const uint8_t *buf, int buf_size);
     void (*parser_close)(AVCodecParserContext *s);
     int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
-#if FF_API_NEXT
-    attribute_deprecated
     struct AVCodecParser *next;
-#endif
 } AVCodecParser;
 
 /**
@@ -3567,18 +3602,14 @@
                      int64_t pts, int64_t dts,
                      int64_t pos);
 
-#if FF_API_PARSER_CHANGE
 /**
  * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
- * @deprecated Use dump_extradata, remove_extra or extract_extradata
- *             bitstream filters instead.
+ * @deprecated use AVBitStreamFilter
  */
-attribute_deprecated
 int av_parser_change(AVCodecParserContext *s,
                      AVCodecContext *avctx,
                      uint8_t **poutbuf, int *poutbuf_size,
                      const uint8_t *buf, int buf_size, int keyframe);
-#endif
 void av_parser_close(AVCodecParserContext *s);
 
 /**
@@ -3591,7 +3622,6 @@
  * @{
  */
 
-#if FF_API_OLD_ENCDEC
 /**
  * Encode a frame of audio.
  *
@@ -3674,7 +3704,6 @@
 attribute_deprecated
 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
                           const AVFrame *frame, int *got_packet_ptr);
-#endif
 
 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
                             const AVSubtitle *sub);
@@ -3782,6 +3811,12 @@
 unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
 
 /**
+ * @deprecated see av_get_pix_fmt_loss()
+ */
+int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
+                             int has_alpha);
+
+/**
  * Find the best pixel format to convert to given a certain source pixel
  * format.  When converting from one pixel format to another, information loss
  * may occur.  For example, when converting from RGB24 to GRAY, the color
@@ -3802,24 +3837,15 @@
                                             enum AVPixelFormat src_pix_fmt,
                                             int has_alpha, int *loss_ptr);
 
-#if FF_API_AVCODEC_PIX_FMT
-/**
- * @deprecated see av_get_pix_fmt_loss()
- */
-attribute_deprecated
-int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
-                             int has_alpha);
 /**
  * @deprecated see av_find_best_pix_fmt_of_2()
  */
-attribute_deprecated
 enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
 
 attribute_deprecated
 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
-#endif
 
 enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
 
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 32cb71f..e4ba403 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -330,16 +330,12 @@
 
 
 uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                                 buffer_size_t size)
+                                 int size)
 {
     int ret;
     uint8_t *data;
 
-#if FF_API_BUFFER_SIZE_T
     if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
-#else
-    if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
-#endif
         return NULL;
     data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
     if (!data)
@@ -355,7 +351,7 @@
 }
 
 uint8_t *av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
-                                 buffer_size_t *size)
+                                 int *size)
 {
     int i;
 
@@ -558,7 +554,7 @@
 }
 
 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                               buffer_size_t size)
+                               int size)
 {
     int i;
 
@@ -593,7 +589,7 @@
     dst->side_data_elems      = 0;
     for (i = 0; i < src->side_data_elems; i++) {
         enum AVPacketSideDataType type = src->side_data[i].type;
-        buffer_size_t size = src->side_data[i].size;
+        int size          = src->side_data[i].size;
         uint8_t *src_data = src->side_data[i].data;
         uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
 
@@ -800,7 +796,7 @@
 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
 {
     uint8_t *side_data;
-    buffer_size_t side_data_size;
+    int side_data_size;
     int i;
 
     side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
@@ -826,7 +822,7 @@
 {
     AVProducerReferenceTime *prft;
     uint8_t *side_data;
-    buffer_size_t side_data_size;
+    int side_data_size;
 
     side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
     if (!side_data) {
diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index 477afd8..d85e3c2 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -21,9 +21,13 @@
 
 #include "avcodec.h"
 #include "internal.h"
+#include "mjpeg.h"
+#include "mjpegdec.h"
 #include "libavutil/imgutils.h"
 
 typedef struct {
+    AVCodecContext *mjpeg_avctx;
+    int is_mjpeg;
     int interlace;
     int tff;
 } AVRnContext;
@@ -33,6 +37,42 @@
     AVRnContext *a = avctx->priv_data;
     int ret;
 
+    // Support "Resolution 1:1" for Avid AVI Codec
+    a->is_mjpeg = avctx->extradata_size < 31 || memcmp(&avctx->extradata[28], "1:1", 3);
+
+    if(!a->is_mjpeg && avctx->lowres) {
+        av_log(avctx, AV_LOG_ERROR, "lowres is not possible with rawvideo\n");
+        return AVERROR(EINVAL);
+    }
+
+    if(a->is_mjpeg) {
+        const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
+        AVDictionary *thread_opt = NULL;
+        if (!codec) {
+            av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
+            return AVERROR_DECODER_NOT_FOUND;
+        }
+
+        a->mjpeg_avctx = avcodec_alloc_context3(codec);
+        if (!a->mjpeg_avctx)
+            return AVERROR(ENOMEM);
+
+        av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ?
+        a->mjpeg_avctx->refcounted_frames = 1;
+        a->mjpeg_avctx->flags = avctx->flags;
+        a->mjpeg_avctx->idct_algo = avctx->idct_algo;
+        a->mjpeg_avctx->lowres = avctx->lowres;
+        a->mjpeg_avctx->width = avctx->width;
+        a->mjpeg_avctx->height = avctx->height;
+
+        if ((ret = avcodec_open2(a->mjpeg_avctx, codec, &thread_opt)) < 0) {
+            av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
+        }
+        av_dict_free(&thread_opt);
+
+        return ret;
+    }
+
     if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
         return ret;
 
@@ -49,6 +89,15 @@
     return 0;
 }
 
+static av_cold int end(AVCodecContext *avctx)
+{
+    AVRnContext *a = avctx->priv_data;
+
+    avcodec_free_context(&a->mjpeg_avctx);
+
+    return 0;
+}
+
 static int decode_frame(AVCodecContext *avctx, void *data,
                         int *got_frame, AVPacket *avpkt)
 {
@@ -58,6 +107,28 @@
     int buf_size       = avpkt->size;
     int y, ret, true_height;
 
+    if(a->is_mjpeg) {
+        ret = avcodec_decode_video2(a->mjpeg_avctx, data, got_frame, avpkt);
+
+        if (ret >= 0 && *got_frame && avctx->width <= p->width && avctx->height <= p->height) {
+            int shift = p->height - avctx->height;
+            int subsample_h, subsample_v;
+
+            av_pix_fmt_get_chroma_sub_sample(p->format, &subsample_h, &subsample_v);
+
+            p->data[0] += p->linesize[0] * shift;
+            if (p->data[2]) {
+                p->data[1] += p->linesize[1] * (shift>>subsample_v);
+                p->data[2] += p->linesize[2] * (shift>>subsample_v);
+            }
+
+            p->width  = avctx->width;
+            p->height = avctx->height;
+        }
+        avctx->pix_fmt = a->mjpeg_avctx->pix_fmt;
+        return ret;
+    }
+
     true_height    = buf_size / (2*avctx->width);
 
     if(buf_size < 2*avctx->width * avctx->height) {
@@ -96,7 +167,8 @@
     .id             = AV_CODEC_ID_AVRN,
     .priv_data_size = sizeof(AVRnContext),
     .init           = init,
+    .close          = end,
     .decode         = decode_frame,
-    .capabilities   = AV_CODEC_CAP_DR1,
+    .max_lowres     = 3,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 5efd24e..ec164d0 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -23,7 +23,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 381fc4c..7b5965e 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -30,7 +30,6 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/intfloat.h"
-#include "libavutil/mem_internal.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
diff --git a/libavcodec/bitpacked.c b/libavcodec/bitpacked.c
index 23e82c6..952ba73 100644
--- a/libavcodec/bitpacked.c
+++ b/libavcodec/bitpacked.c
@@ -33,12 +33,12 @@
 
 struct BitpackedContext {
     int (*decode)(AVCodecContext *avctx, AVFrame *frame,
-                  const AVPacket *pkt);
+                  AVPacket *pkt);
 };
 
 /* For this format, it's a simple passthrough */
 static int bitpacked_decode_uyvy422(AVCodecContext *avctx, AVFrame *frame,
-                                    const AVPacket *avpkt)
+                                    AVPacket *avpkt)
 {
     int ret;
 
@@ -56,7 +56,7 @@
 }
 
 static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame,
-                                      const AVPacket *avpkt)
+                                      AVPacket *avpkt)
 {
     uint64_t frame_size = (uint64_t)avctx->width * (uint64_t)avctx->height * 20;
     uint64_t packet_size = (uint64_t)avpkt->size * 8;
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index e425ffd..7570fb2 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -104,10 +104,10 @@
         v = *(const uint16_t *)ptr;                         \
         break;                                              \
     case 4:                                                 \
-    default:                                                \
-        av_assert1(size == 4);                              \
         v = *(const uint32_t *)ptr;                         \
         break;                                              \
+    default:                                                \
+        av_assert1(0);                                      \
     }                                                       \
 }
 
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 02d33ab..b26d6a9 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -53,7 +53,6 @@
 extern const AVBitStreamFilter ff_pcm_rechunk_bsf;
 extern const AVBitStreamFilter ff_prores_metadata_bsf;
 extern const AVBitStreamFilter ff_remove_extradata_bsf;
-extern const AVBitStreamFilter ff_setts_bsf;
 extern const AVBitStreamFilter ff_text2movsub_bsf;
 extern const AVBitStreamFilter ff_trace_headers_bsf;
 extern const AVBitStreamFilter ff_truehd_core_bsf;
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index 6649fee..54e9bb4 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -27,7 +27,6 @@
 #include <string.h>
 
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
 
 #include "cabac.h"
 #include "cabac_functions.h"
@@ -159,6 +158,18 @@
 };
 
 /**
+ * @param buf_size size of buf in bits
+ */
+void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){
+    init_put_bits(&c->pb, buf, buf_size);
+
+    c->low= 0;
+    c->range= 0x1FE;
+    c->outstanding_count= 0;
+    c->pb.bit_left++; //avoids firstBitFlag
+}
+
+/**
  *
  * @param buf_size size of buf in bits
  */
diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
index 38d06b2..1bf1c62 100644
--- a/libavcodec/cabac.h
+++ b/libavcodec/cabac.h
@@ -29,6 +29,8 @@
 
 #include <stdint.h>
 
+#include "put_bits.h"
+
 extern const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
 #define H264_NORM_SHIFT_OFFSET 0
 #define H264_LPS_RANGE_OFFSET 512
@@ -41,11 +43,14 @@
 typedef struct CABACContext{
     int low;
     int range;
+    int outstanding_count;
     const uint8_t *bytestream_start;
     const uint8_t *bytestream;
     const uint8_t *bytestream_end;
+    PutBitContext pb;
 }CABACContext;
 
+void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size);
 int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
 
 #endif /* AVCODEC_CABAC_H */
diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
index 46af921..bb2b421 100644
--- a/libavcodec/cabac_functions.h
+++ b/libavcodec/cabac_functions.h
@@ -27,7 +27,6 @@
 #ifndef AVCODEC_CABAC_FUNCTIONS_H
 #define AVCODEC_CABAC_FUNCTIONS_H
 
-#include <stddef.h>
 #include <stdint.h>
 
 #include "cabac.h"
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 74b8371..ba2b6ef 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -25,8 +25,6 @@
  * @author Stefan Gehrer <stefan.gehrer@gmx.de>
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "get_bits.h"
 #include "golomb.h"
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index cbc163f..6bfb22c 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -22,8 +22,6 @@
 #ifndef AVCODEC_CAVS_H
 #define AVCODEC_CAVS_H
 
-#include "libavutil/mem_internal.h"
-
 #include "cavsdsp.h"
 #include "blockdsp.h"
 #include "h264chroma.h"
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index ecf22b3..f98531e 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -23,13 +23,12 @@
 #include "libavutil/avassert.h"
 #include "libavutil/buffer.h"
 #include "libavutil/common.h"
-#include "libavutil/opt.h"
 
 #include "cbs.h"
 #include "cbs_internal.h"
 
 
-static const CodedBitstreamType *const cbs_type_table[] = {
+static const CodedBitstreamType *cbs_type_table[] = {
 #if CONFIG_CBS_AV1
     &ff_cbs_type_av1,
 #endif
@@ -102,10 +101,6 @@
             av_freep(&ctx);
             return AVERROR(ENOMEM);
         }
-        if (type->priv_class) {
-            *(const AVClass **)ctx->priv_data = type->priv_class;
-            av_opt_set_defaults(ctx->priv_data);
-        }
     }
 
     ctx->decompose_unit_types = NULL;
@@ -134,10 +129,6 @@
         ctx->codec->close(ctx);
 
     av_freep(&ctx->write_buffer);
-
-    if (ctx->codec->priv_class && ctx->priv_data)
-        av_opt_free(ctx->priv_data);
-
     av_freep(&ctx->priv_data);
     av_freep(ctx_ptr);
 }
@@ -202,12 +193,6 @@
             av_log(ctx->log_ctx, AV_LOG_VERBOSE,
                    "Decomposition unimplemented for unit %d "
                    "(type %"PRIu32").\n", i, unit->type);
-        } else if (err == AVERROR(EAGAIN)) {
-            av_log(ctx->log_ctx, AV_LOG_VERBOSE,
-                   "Skipping decomposition of unit %d "
-                   "(type %"PRIu32").\n", i, unit->type);
-            av_buffer_unref(&unit->content_ref);
-            unit->content = NULL;
         } else if (err < 0) {
             av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
                    "(type %"PRIu32").\n", i, unit->type);
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index f022282..3fd0a0e 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -196,7 +196,7 @@
      * Types not in this list will be available in bitstream form only.
      * If NULL, all supported types will be decomposed.
      */
-    const CodedBitstreamUnitType *decompose_unit_types;
+    CodedBitstreamUnitType *decompose_unit_types;
     /**
      * Length of the decompose_unit_types array.
      */
diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 302e1f3..a40c91a 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -17,7 +17,6 @@
  */
 
 #include "libavutil/avassert.h"
-#include "libavutil/opt.h"
 #include "libavutil/pixfmt.h"
 
 #include "cbs.h"
@@ -918,7 +917,7 @@
             int in_spatial_layer  =
                 (priv->operating_point_idc >> (priv->spatial_id + 8)) & 1;
             if (!in_temporal_layer || !in_spatial_layer) {
-                return AVERROR(EAGAIN); // drop_obu()
+                // Decoding will drop this OBU at this operating point.
             }
         }
     }
@@ -931,18 +930,6 @@
             if (err < 0)
                 return err;
 
-            if (priv->operating_point >= 0) {
-                AV1RawSequenceHeader *sequence_header = &obu->obu.sequence_header;
-
-                if (priv->operating_point > sequence_header->operating_points_cnt_minus_1) {
-                    av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid Operating Point %d requested. "
-                                                       "Must not be higher than %u.\n",
-                           priv->operating_point, sequence_header->operating_points_cnt_minus_1);
-                    return AVERROR(EINVAL);
-                }
-                priv->operating_point_idc = sequence_header->operating_point_idc[priv->operating_point];
-            }
-
             av_buffer_unref(&priv->sequence_header_ref);
             priv->sequence_header = NULL;
 
@@ -1304,24 +1291,9 @@
     CBS_UNIT_TYPE_END_OF_LIST
 };
 
-#define OFFSET(x) offsetof(CodedBitstreamAV1Context, x)
-static const AVOption cbs_av1_options[] = {
-    { "operating_point",  "Set operating point to select layers to parse from a scalable bitstream",
-                          OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AV1_MAX_OPERATING_POINTS - 1, 0 },
-    { NULL }
-};
-
-static const AVClass cbs_av1_class = {
-    .class_name = "cbs_av1",
-    .item_name  = av_default_item_name,
-    .option     = cbs_av1_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const CodedBitstreamType ff_cbs_type_av1 = {
     .codec_id          = AV_CODEC_ID_AV1,
 
-    .priv_class        = &cbs_av1_class,
     .priv_data_size    = sizeof(CodedBitstreamAV1Context),
 
     .unit_types        = cbs_av1_unit_types,
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 1fc80dc..7994700 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -425,8 +425,6 @@
 } AV1ReferenceFrameState;
 
 typedef struct CodedBitstreamAV1Context {
-    const AVClass *class;
-
     AV1RawSequenceHeader *sequence_header;
     AVBufferRef          *sequence_header_ref;
 
@@ -455,9 +453,6 @@
     int tile_num;
 
     AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
-
-    // AVOptions
-    int operating_point;
 } CodedBitstreamAV1Context;
 
 
diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c
deleted file mode 100644
index f0f7dd7..0000000
--- a/libavcodec/cbs_bsf.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "bsf_internal.h"
-#include "cbs_bsf.h"
-
-static int cbs_bsf_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
-{
-    CBSBSFContext           *ctx = bsf->priv_data;
-    CodedBitstreamFragment *frag = &ctx->fragment;
-    uint8_t *side_data;
-    buffer_size_t side_data_size;
-    int err;
-
-    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-                                        &side_data_size);
-    if (!side_data_size)
-        return 0;
-
-    err = ff_cbs_read(ctx->input, frag, side_data, side_data_size);
-    if (err < 0) {
-        av_log(bsf, AV_LOG_ERROR,
-               "Failed to read extradata from packet side data.\n");
-        return err;
-    }
-
-    err = ctx->type->update_fragment(bsf, NULL, frag);
-    if (err < 0)
-        return err;
-
-    err = ff_cbs_write_fragment_data(ctx->output, frag);
-    if (err < 0) {
-        av_log(bsf, AV_LOG_ERROR,
-               "Failed to write extradata into packet side data.\n");
-        return err;
-    }
-
-    side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-                                        frag->data_size);
-    if (!side_data)
-        return AVERROR(ENOMEM);
-    memcpy(side_data, frag->data, frag->data_size);
-
-    ff_cbs_fragment_reset(frag);
-    return 0;
-}
-
-int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt)
-{
-    CBSBSFContext           *ctx = bsf->priv_data;
-    CodedBitstreamFragment *frag = &ctx->fragment;
-    int err;
-
-    err = ff_bsf_get_packet_ref(bsf, pkt);
-    if (err < 0)
-        return err;
-
-    err = cbs_bsf_update_side_data(bsf, pkt);
-    if (err < 0)
-        goto fail;
-
-    err = ff_cbs_read_packet(ctx->input, frag, pkt);
-    if (err < 0) {
-        av_log(bsf, AV_LOG_ERROR, "Failed to read %s from packet.\n",
-               ctx->type->fragment_name);
-        goto fail;
-    }
-
-    if (frag->nb_units == 0) {
-        av_log(bsf, AV_LOG_ERROR, "No %s found in packet.\n",
-               ctx->type->unit_name);
-        err = AVERROR_INVALIDDATA;
-        goto fail;
-    }
-
-    err = ctx->type->update_fragment(bsf, pkt, frag);
-    if (err < 0)
-        goto fail;
-
-    err = ff_cbs_write_packet(ctx->output, pkt, frag);
-    if (err < 0) {
-        av_log(bsf, AV_LOG_ERROR, "Failed to write %s into packet.\n",
-               ctx->type->fragment_name);
-        goto fail;
-    }
-
-    err = 0;
-fail:
-    ff_cbs_fragment_reset(frag);
-
-    if (err < 0)
-        av_packet_unref(pkt);
-
-    return err;
-}
-
-int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type)
-{
-    CBSBSFContext           *ctx = bsf->priv_data;
-    CodedBitstreamFragment *frag = &ctx->fragment;
-    int err;
-
-    ctx->type = type;
-
-    err = ff_cbs_init(&ctx->input, type->codec_id, bsf);
-    if (err < 0)
-        return err;
-
-    err = ff_cbs_init(&ctx->output, type->codec_id, bsf);
-    if (err < 0)
-        return err;
-
-    if (bsf->par_in->extradata) {
-        err = ff_cbs_read_extradata(ctx->input, frag, bsf->par_in);
-        if (err < 0) {
-            av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
-            goto fail;
-        }
-
-        err = type->update_fragment(bsf, NULL, frag);
-        if (err < 0)
-            goto fail;
-
-        err = ff_cbs_write_extradata(ctx->output, bsf->par_out, frag);
-        if (err < 0) {
-            av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
-            goto fail;
-        }
-    }
-
-    err = 0;
-fail:
-    ff_cbs_fragment_reset(frag);
-    return err;
-}
-
-void ff_cbs_bsf_generic_close(AVBSFContext *bsf)
-{
-    CBSBSFContext *ctx = bsf->priv_data;
-
-    ff_cbs_fragment_free(&ctx->fragment);
-    ff_cbs_close(&ctx->input);
-    ff_cbs_close(&ctx->output);
-}
diff --git a/libavcodec/cbs_bsf.h b/libavcodec/cbs_bsf.h
deleted file mode 100644
index 6be95ab..0000000
--- a/libavcodec/cbs_bsf.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_CBS_BSF_H
-#define AVCODEC_CBS_BSF_H
-
-#include "cbs.h"
-
-
-typedef struct CBSBSFType {
-    enum AVCodecID codec_id;
-
-    // Name of a frame fragment in this codec (e.g. "access unit",
-    // "temporal unit").
-    const char *fragment_name;
-
-    // Name of a unit for this BSF, for use in error messages (e.g.
-    // "NAL unit", "OBU").
-    const char *unit_name;
-
-    // Update the content of a fragment with whatever metadata changes
-    // are desired.  The associated AVPacket is provided so that any side
-    // data associated with the fragment can be inspected or edited.  If
-    // pkt is NULL, then an extradata header fragment is being updated.
-    int (*update_fragment)(AVBSFContext *bsf, AVPacket *pkt,
-                           CodedBitstreamFragment *frag);
-} CBSBSFType;
-
-// Common structure for all generic CBS BSF users.  An instance of this
-// structure must be the first member of the BSF private context (to be
-// pointed to by AVBSFContext.priv_data).
-typedef struct CBSBSFContext {
-    const AVClass         *class;
-    const CBSBSFType      *type;
-
-    CodedBitstreamContext *input;
-    CodedBitstreamContext *output;
-    CodedBitstreamFragment fragment;
-} CBSBSFContext;
-
-/**
- * Initialise generic CBS BSF setup.
- *
- * Creates the input and output CBS instances, and applies the filter to
- * the extradata on the input codecpar if any is present.
- *
- * Since it calls the update_fragment() function immediately to deal with
- * extradata, this should be called after any codec-specific setup is done
- * (probably at the end of the AVBitStreamFilter.init function).
- */
-int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type);
-
-/**
- * Close a generic CBS BSF instance.
- *
- * If no other deinitialisation is required then this function can be used
- * directly as AVBitStreamFilter.close.
- */
-void ff_cbs_bsf_generic_close(AVBSFContext *bsf);
-
-/**
- * Filter operation for CBS BSF.
- *
- * Reads the input packet into a CBS fragment, calls update_fragment() on
- * it, then writes the result to an output packet.  If the input packet
- * has AV_PKT_DATA_NEW_EXTRADATA side-data associated with it then it does
- * the same thing to that new extradata to form the output side-data first.
- *
- * If the BSF does not do anything else then this function can be used
- * directly as AVBitStreamFilter.filter.
- */
-int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt);
-
-
-// Options for element manipulation.
-enum {
-    // Pass this element through unchanged.
-    BSF_ELEMENT_PASS,
-    // Insert this element, replacing any existing instances of it.
-    // Associated values may be provided explicitly (as addtional options)
-    // or implicitly (either as side data or deduced from other parts of
-    // the stream).
-    BSF_ELEMENT_INSERT,
-    // Remove this element if it appears in the stream.
-    BSF_ELEMENT_REMOVE,
-    // Extract this element to side data, so that further manipulation
-    // can happen elsewhere.
-    BSF_ELEMENT_EXTRACT,
-};
-
-#define BSF_ELEMENT_OPTIONS_PIR(name, help, field, opt_flags) \
-    { name, help, OFFSET(field), AV_OPT_TYPE_INT, \
-        { .i64 = BSF_ELEMENT_PASS }, \
-        BSF_ELEMENT_PASS, BSF_ELEMENT_REMOVE, opt_flags, name }, \
-    { "pass",   NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_PASS   }, .flags = opt_flags, .unit = name }, \
-    { "insert", NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_INSERT }, .flags = opt_flags, .unit = name }, \
-    { "remove", NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_REMOVE }, .flags = opt_flags, .unit = name }
-
-#define BSF_ELEMENT_OPTIONS_PIRE(name, help, field, opt_flags) \
-    { name, help, OFFSET(field), AV_OPT_TYPE_INT, \
-        { .i64 = BSF_ELEMENT_PASS }, \
-        BSF_ELEMENT_PASS, BSF_ELEMENT_EXTRACT, opt_flags, name }, \
-    { "pass",   NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_PASS    }, .flags = opt_flags, .unit = name }, \
-    { "insert", NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_INSERT  }, .flags = opt_flags, .unit = name }, \
-    { "remove", NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_REMOVE  }, .flags = opt_flags, .unit = name }, \
-    { "extract", NULL, 0, AV_OPT_TYPE_CONST, \
-        { .i64 = BSF_ELEMENT_EXTRACT }, .flags = opt_flags, .unit = name } \
-
-
-#endif /* AVCODEC_CBS_BSF_H */
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 9eb97ea..a6fe0a6 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -24,7 +24,6 @@
 
 #include "cbs.h"
 #include "cbs_h2645.h"
-#include "cbs_sei.h"
 #include "h264.h"
 
 
@@ -275,6 +274,21 @@
     uint16_t pan_scan_rect_repetition_period;
 } H264RawSEIPanScanRect;
 
+typedef struct H264RawSEIUserDataRegistered {
+    uint8_t itu_t_t35_country_code;
+    uint8_t itu_t_t35_country_code_extension_byte;
+    uint8_t     *data;
+    AVBufferRef *data_ref;
+    size_t       data_length;
+} H264RawSEIUserDataRegistered;
+
+typedef struct H264RawSEIUserDataUnregistered {
+    uint8_t uuid_iso_iec_11578[16];
+    uint8_t     *data;
+    AVBufferRef *data_ref;
+    size_t       data_length;
+} H264RawSEIUserDataUnregistered;
+
 typedef struct H264RawSEIRecoveryPoint {
     uint16_t recovery_frame_cnt;
     uint8_t exact_match_flag;
@@ -291,9 +305,47 @@
     uint8_t display_orientation_extension_flag;
 } H264RawSEIDisplayOrientation;
 
+typedef struct H264RawSEIMasteringDisplayColourVolume {
+    uint16_t display_primaries_x[3];
+    uint16_t display_primaries_y[3];
+    uint16_t white_point_x;
+    uint16_t white_point_y;
+    uint32_t max_display_mastering_luminance;
+    uint32_t min_display_mastering_luminance;
+} H264RawSEIMasteringDisplayColourVolume;
+
+typedef struct H264RawSEIAlternativeTransferCharacteristics {
+    uint8_t preferred_transfer_characteristics;
+} H264RawSEIAlternativeTransferCharacteristics;
+
+typedef struct H264RawSEIPayload {
+    uint32_t payload_type;
+    uint32_t payload_size;
+    union {
+        H264RawSEIBufferingPeriod buffering_period;
+        H264RawSEIPicTiming pic_timing;
+        H264RawSEIPanScanRect pan_scan_rect;
+        // H264RawSEIFiller filler -> no fields.
+        H264RawSEIUserDataRegistered user_data_registered;
+        H264RawSEIUserDataUnregistered user_data_unregistered;
+        H264RawSEIRecoveryPoint recovery_point;
+        H264RawSEIDisplayOrientation display_orientation;
+        H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume;
+        H264RawSEIAlternativeTransferCharacteristics
+            alternative_transfer_characteristics;
+        struct {
+            uint8_t     *data;
+            AVBufferRef *data_ref;
+            size_t       data_length;
+        } other;
+    } payload;
+} H264RawSEIPayload;
+
 typedef struct H264RawSEI {
     H264RawNALUnitHeader nal_unit_header;
-    SEIRawMessageList    message_list;
+
+    H264RawSEIPayload payload[H264_MAX_SEI_PAYLOADS];
+    uint8_t payload_count;
 } H264RawSEI;
 
 typedef struct H264RawSliceHeader {
@@ -413,4 +465,27 @@
     uint8_t last_slice_nal_unit_type;
 } CodedBitstreamH264Context;
 
+
+/**
+ * Add an SEI message to an access unit.
+ *
+ * On success, the payload will be owned by a unit in access_unit;
+ * on failure, the content of the payload will be freed.
+ */
+int ff_cbs_h264_add_sei_message(CodedBitstreamFragment *access_unit,
+                                H264RawSEIPayload *payload);
+
+/**
+ * Delete an SEI message from an access unit.
+ *
+ * Deletes from nal_unit, which must be an SEI NAL unit.  If this is the
+ * last message in nal_unit, also deletes it from access_unit.
+ *
+ * Requires nal_unit to be a unit in access_unit and position to be >= 0
+ * and < the payload count of the SEI nal_unit.
+ */
+void ff_cbs_h264_delete_sei_message(CodedBitstreamFragment *access_unit,
+                                    CodedBitstreamUnit *nal_unit,
+                                    int position);
+
 #endif /* AVCODEC_CBS_H264_H */
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 6005d46..4343224 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -253,11 +253,9 @@
             return err; \
     } while (0)
 
-#define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
-#define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name)
-#define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name)
-#define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name)
-#define FUNC_SEI(name)  FUNC_NAME1(READWRITE, sei,  name)
+#define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
+#define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
+#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
 
 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
 
@@ -348,7 +346,6 @@
 
 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw))
 
-#define bit_position(rw)   (get_bits_count(rw))
 #define byte_alignment(rw) (get_bits_count(rw) % 8)
 
 #define allocate(name, size) do { \
@@ -359,15 +356,11 @@
         name = name ## _ref->data; \
     } while (0)
 
-#define FUNC(name) FUNC_SEI(name)
-#include "cbs_sei_syntax_template.c"
-#undef FUNC
-
-#define FUNC(name) FUNC_H264(name)
+#define FUNC(name) FUNC_H264(READWRITE, name)
 #include "cbs_h264_syntax_template.c"
 #undef FUNC
 
-#define FUNC(name) FUNC_H265(name)
+#define FUNC(name) FUNC_H265(READWRITE, name)
 #include "cbs_h265_syntax_template.c"
 #undef FUNC
 
@@ -380,7 +373,6 @@
 #undef xse
 #undef infer
 #undef more_rbsp_data
-#undef bit_position
 #undef byte_alignment
 #undef allocate
 
@@ -426,7 +418,6 @@
 
 #define more_rbsp_data(var) (var)
 
-#define bit_position(rw)   (put_bits_count(rw))
 #define byte_alignment(rw) (put_bits_count(rw) % 8)
 
 #define allocate(name, size) do { \
@@ -437,15 +428,11 @@
         } \
     } while (0)
 
-#define FUNC(name) FUNC_SEI(name)
-#include "cbs_sei_syntax_template.c"
-#undef FUNC
-
-#define FUNC(name) FUNC_H264(name)
+#define FUNC(name) FUNC_H264(READWRITE, name)
 #include "cbs_h264_syntax_template.c"
 #undef FUNC
 
-#define FUNC(name) FUNC_H265(name)
+#define FUNC(name) FUNC_H265(READWRITE, name)
 #include "cbs_h265_syntax_template.c"
 #undef FUNC
 
@@ -463,7 +450,6 @@
 #undef se
 #undef infer
 #undef more_rbsp_data
-#undef bit_position
 #undef byte_alignment
 #undef allocate
 
@@ -1221,22 +1207,6 @@
     return 0;
 }
 
-static int cbs_h2645_unit_requires_zero_byte(enum AVCodecID codec_id,
-                                             CodedBitstreamUnitType type,
-                                             int nal_unit_index)
-{
-    // Section B.1.2 in H.264, section B.2.2 in H.265.
-    if (nal_unit_index == 0) {
-        // Assume that this is the first NAL unit in an access unit.
-        return 1;
-    }
-    if (codec_id == AV_CODEC_ID_H264)
-        return type == H264_NAL_SPS || type == H264_NAL_PPS;
-    if (codec_id == AV_CODEC_ID_HEVC)
-        return type == HEVC_NAL_VPS || type == HEVC_NAL_SPS || type == HEVC_NAL_PPS;
-    return 0;
-}
-
 static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,
                                        CodedBitstreamFragment *frag)
 {
@@ -1271,7 +1241,14 @@
                 frag->data_bit_padding = unit->data_bit_padding;
         }
 
-        if (cbs_h2645_unit_requires_zero_byte(ctx->codec->codec_id, unit->type, i)) {
+        if ((ctx->codec->codec_id == AV_CODEC_ID_H264 &&
+             (unit->type == H264_NAL_SPS ||
+              unit->type == H264_NAL_PPS)) ||
+            (ctx->codec->codec_id == AV_CODEC_ID_HEVC &&
+             (unit->type == HEVC_NAL_VPS ||
+              unit->type == HEVC_NAL_SPS ||
+              unit->type == HEVC_NAL_PPS)) ||
+            i == 0 /* (Assume this is the start of an access unit.) */) {
             // zero_byte
             data[dp++] = 0;
         }
@@ -1385,11 +1362,36 @@
         av_buffer_unref(&h265->pps_ref[i]);
 }
 
+static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
+{
+    switch (payload->payload_type) {
+    case H264_SEI_TYPE_BUFFERING_PERIOD:
+    case H264_SEI_TYPE_PIC_TIMING:
+    case H264_SEI_TYPE_PAN_SCAN_RECT:
+    case H264_SEI_TYPE_RECOVERY_POINT:
+    case H264_SEI_TYPE_DISPLAY_ORIENTATION:
+    case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
+    case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
+        break;
+    case H264_SEI_TYPE_USER_DATA_REGISTERED:
+        av_buffer_unref(&payload->payload.user_data_registered.data_ref);
+        break;
+    case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
+        av_buffer_unref(&payload->payload.user_data_unregistered.data_ref);
+        break;
+    default:
+        av_buffer_unref(&payload->payload.other.data_ref);
+        break;
+    }
+}
+
 static void cbs_h264_free_sei(void *opaque, uint8_t *content)
 {
     H264RawSEI *sei = (H264RawSEI*)content;
-    ff_cbs_sei_free_message_list(&sei->message_list);
-    av_free(content);
+    int i;
+    for (i = 0; i < sei->payload_count; i++)
+        cbs_h264_free_sei_payload(&sei->payload[i]);
+    av_freep(&content);
 }
 
 static const CodedBitstreamUnitTypeDescriptor cbs_h264_unit_types[] = {
@@ -1421,11 +1423,42 @@
     CBS_UNIT_TYPE_END_OF_LIST
 };
 
+static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload)
+{
+    switch (payload->payload_type) {
+    case HEVC_SEI_TYPE_BUFFERING_PERIOD:
+    case HEVC_SEI_TYPE_PICTURE_TIMING:
+    case HEVC_SEI_TYPE_PAN_SCAN_RECT:
+    case HEVC_SEI_TYPE_RECOVERY_POINT:
+    case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
+    case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
+    case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
+    case HEVC_SEI_TYPE_TIME_CODE:
+    case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
+    case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+    case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
+    case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO:
+        break;
+    case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+        av_buffer_unref(&payload->payload.user_data_registered.data_ref);
+        break;
+    case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
+        av_buffer_unref(&payload->payload.user_data_unregistered.data_ref);
+        break;
+    default:
+        av_buffer_unref(&payload->payload.other.data_ref);
+        break;
+    }
+    av_buffer_unref(&payload->extension_data.data_ref);
+}
+
 static void cbs_h265_free_sei(void *opaque, uint8_t *content)
 {
     H265RawSEI *sei = (H265RawSEI*)content;
-    ff_cbs_sei_free_message_list(&sei->message_list);
-    av_free(content);
+    int i;
+    for (i = 0; i < sei->payload_count; i++)
+        cbs_h265_free_sei_payload(&sei->payload[i]);
+    av_freep(&content);
 }
 
 static const CodedBitstreamUnitTypeDescriptor cbs_h265_unit_types[] = {
@@ -1505,164 +1538,92 @@
     .close             = &cbs_h265_close,
 };
 
-static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
-    {
-        SEI_TYPE_FILLER_PAYLOAD,
-        1, 1,
-        sizeof(SEIRawFillerPayload),
-        SEI_MESSAGE_RW(sei, filler_payload),
-    },
-    {
-        SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35,
-        1, 1,
-        sizeof(SEIRawUserDataRegistered),
-        SEI_MESSAGE_RW(sei, user_data_registered),
-    },
-    {
-        SEI_TYPE_USER_DATA_UNREGISTERED,
-        1, 1,
-        sizeof(SEIRawUserDataUnregistered),
-        SEI_MESSAGE_RW(sei, user_data_unregistered),
-    },
-    {
-        SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME,
-        1, 0,
-        sizeof(SEIRawMasteringDisplayColourVolume),
-        SEI_MESSAGE_RW(sei, mastering_display_colour_volume),
-    },
-    {
-        SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO,
-        1, 0,
-        sizeof(SEIRawContentLightLevelInfo),
-        SEI_MESSAGE_RW(sei, content_light_level_info),
-    },
-    {
-        SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS,
-        1, 0,
-        sizeof(SEIRawAlternativeTransferCharacteristics),
-        SEI_MESSAGE_RW(sei, alternative_transfer_characteristics),
-    },
-    SEI_MESSAGE_TYPE_END,
-};
-
-static const SEIMessageTypeDescriptor cbs_sei_h264_types[] = {
-    {
-        SEI_TYPE_BUFFERING_PERIOD,
-        1, 0,
-        sizeof(H264RawSEIBufferingPeriod),
-        SEI_MESSAGE_RW(h264, sei_buffering_period),
-    },
-    {
-        SEI_TYPE_PIC_TIMING,
-        1, 0,
-        sizeof(H264RawSEIPicTiming),
-        SEI_MESSAGE_RW(h264, sei_pic_timing),
-    },
-    {
-        SEI_TYPE_PAN_SCAN_RECT,
-        1, 0,
-        sizeof(H264RawSEIPanScanRect),
-        SEI_MESSAGE_RW(h264, sei_pan_scan_rect),
-    },
-    {
-        SEI_TYPE_RECOVERY_POINT,
-        1, 0,
-        sizeof(H264RawSEIRecoveryPoint),
-        SEI_MESSAGE_RW(h264, sei_recovery_point),
-    },
-    {
-        SEI_TYPE_DISPLAY_ORIENTATION,
-        1, 0,
-        sizeof(H264RawSEIDisplayOrientation),
-        SEI_MESSAGE_RW(h264, sei_display_orientation),
-    },
-    SEI_MESSAGE_TYPE_END
-};
-
-static const SEIMessageTypeDescriptor cbs_sei_h265_types[] = {
-    {
-        SEI_TYPE_BUFFERING_PERIOD,
-        1, 0,
-        sizeof(H265RawSEIBufferingPeriod),
-        SEI_MESSAGE_RW(h265, sei_buffering_period),
-    },
-    {
-        SEI_TYPE_PIC_TIMING,
-        1, 0,
-        sizeof(H265RawSEIPicTiming),
-        SEI_MESSAGE_RW(h265, sei_pic_timing),
-    },
-    {
-        SEI_TYPE_PAN_SCAN_RECT,
-        1, 0,
-        sizeof(H265RawSEIPanScanRect),
-        SEI_MESSAGE_RW(h265, sei_pan_scan_rect),
-    },
-    {
-        SEI_TYPE_RECOVERY_POINT,
-        1, 0,
-        sizeof(H265RawSEIRecoveryPoint),
-        SEI_MESSAGE_RW(h265, sei_recovery_point),
-    },
-    {
-        SEI_TYPE_DISPLAY_ORIENTATION,
-        1, 0,
-        sizeof(H265RawSEIDisplayOrientation),
-        SEI_MESSAGE_RW(h265, sei_display_orientation),
-    },
-    {
-        SEI_TYPE_ACTIVE_PARAMETER_SETS,
-        1, 0,
-        sizeof(H265RawSEIActiveParameterSets),
-        SEI_MESSAGE_RW(h265, sei_active_parameter_sets),
-    },
-    {
-        SEI_TYPE_DECODED_PICTURE_HASH,
-        0, 1,
-        sizeof(H265RawSEIDecodedPictureHash),
-        SEI_MESSAGE_RW(h265, sei_decoded_picture_hash),
-    },
-    {
-        SEI_TYPE_TIME_CODE,
-        1, 0,
-        sizeof(H265RawSEITimeCode),
-        SEI_MESSAGE_RW(h265, sei_time_code),
-    },
-    {
-        SEI_TYPE_ALPHA_CHANNEL_INFO,
-        1, 0,
-        sizeof(H265RawSEIAlphaChannelInfo),
-        SEI_MESSAGE_RW(h265, sei_alpha_channel_info),
-    },
-    SEI_MESSAGE_TYPE_END
-};
-
-const SEIMessageTypeDescriptor *ff_cbs_sei_find_type(CodedBitstreamContext *ctx,
-                                                     int payload_type)
+int ff_cbs_h264_add_sei_message(CodedBitstreamFragment *au,
+                                H264RawSEIPayload *payload)
 {
-    const SEIMessageTypeDescriptor *codec_list;
-    int i;
+    H264RawSEI *sei = NULL;
+    int err, i;
 
-    for (i = 0; cbs_sei_common_types[i].type >= 0; i++) {
-        if (cbs_sei_common_types[i].type == payload_type)
-            return &cbs_sei_common_types[i];
+    // Find an existing SEI NAL unit to add to.
+    for (i = 0; i < au->nb_units; i++) {
+        if (au->units[i].type == H264_NAL_SEI) {
+            sei = au->units[i].content;
+            if (sei->payload_count < H264_MAX_SEI_PAYLOADS)
+                break;
+
+            sei = NULL;
+        }
     }
 
-    switch (ctx->codec->codec_id) {
-    case AV_CODEC_ID_H264:
-        codec_list = cbs_sei_h264_types;
-        break;
-    case AV_CODEC_ID_H265:
-        codec_list = cbs_sei_h265_types;
-        break;
-    default:
-        return NULL;
+    if (!sei) {
+        // Need to make a new SEI NAL unit.  Insert it before the first
+        // slice data NAL unit; if no slice data, add at the end.
+        AVBufferRef *sei_ref;
+
+        sei = av_mallocz(sizeof(*sei));
+        if (!sei) {
+            err = AVERROR(ENOMEM);
+            goto fail;
+        }
+
+        sei->nal_unit_header.nal_unit_type = H264_NAL_SEI;
+        sei->nal_unit_header.nal_ref_idc   = 0;
+
+        sei_ref = av_buffer_create((uint8_t*)sei, sizeof(*sei),
+                                   &cbs_h264_free_sei, NULL, 0);
+        if (!sei_ref) {
+            av_freep(&sei);
+            err = AVERROR(ENOMEM);
+            goto fail;
+        }
+
+        for (i = 0; i < au->nb_units; i++) {
+            if (au->units[i].type == H264_NAL_SLICE ||
+                au->units[i].type == H264_NAL_IDR_SLICE)
+                break;
+        }
+
+        err = ff_cbs_insert_unit_content(au, i, H264_NAL_SEI,
+                                         sei, sei_ref);
+        av_buffer_unref(&sei_ref);
+        if (err < 0)
+            goto fail;
     }
 
-    for (i = 0; codec_list[i].type >= 0; i++) {
-        if (codec_list[i].type == payload_type)
-            return &codec_list[i];
-    }
+    memcpy(&sei->payload[sei->payload_count], payload, sizeof(*payload));
+    ++sei->payload_count;
 
-    return NULL;
+    return 0;
+fail:
+    cbs_h264_free_sei_payload(payload);
+    return err;
+}
+
+void ff_cbs_h264_delete_sei_message(CodedBitstreamFragment *au,
+                                    CodedBitstreamUnit *nal,
+                                    int position)
+{
+    H264RawSEI *sei = nal->content;
+
+    av_assert0(nal->type == H264_NAL_SEI);
+    av_assert0(position >= 0 && position < sei->payload_count);
+
+    if (position == 0 && sei->payload_count == 1) {
+        // Deleting NAL unit entirely.
+        int i;
+
+        for (i = 0; i < au->nb_units; i++) {
+            if (&au->units[i] == nal)
+                break;
+        }
+
+        ff_cbs_delete_unit(au, i);
+    } else {
+        cbs_h264_free_sei_payload(&sei->payload[position]);
+
+        --sei->payload_count;
+        memmove(sei->payload + position,
+                sei->payload + position + 1,
+                (sei->payload_count - position) * sizeof(*sei->payload));
+    }
 }
diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
index 9587f33..b654609 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -511,8 +511,7 @@
 }
 
 static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw,
-                                      H264RawSEIBufferingPeriod *current,
-                                      SEIMessageState *sei)
+                                      H264RawSEIBufferingPeriod *current)
 {
     CodedBitstreamH264Context *h264 = ctx->priv_data;
     const H264RawSPS *sps;
@@ -605,8 +604,7 @@
 }
 
 static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw,
-                                H264RawSEIPicTiming *current,
-                                SEIMessageState *sei)
+                                H264RawSEIPicTiming *current)
 {
     CodedBitstreamH264Context *h264 = ctx->priv_data;
     const H264RawSPS *sps;
@@ -677,8 +675,7 @@
 }
 
 static int FUNC(sei_pan_scan_rect)(CodedBitstreamContext *ctx, RWContext *rw,
-                                   H264RawSEIPanScanRect *current,
-                                   SEIMessageState *sei)
+                                   H264RawSEIPanScanRect *current)
 {
     int err, i;
 
@@ -703,9 +700,72 @@
     return 0;
 }
 
+static int FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext *rw,
+                                          H264RawSEIUserDataRegistered *current,
+                                          uint32_t *payload_size)
+{
+    int err, i, j;
+
+    HEADER("User Data Registered ITU-T T.35");
+
+    u(8, itu_t_t35_country_code, 0x00, 0xff);
+    if (current->itu_t_t35_country_code != 0xff)
+        i = 1;
+    else {
+        u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
+        i = 2;
+    }
+
+#ifdef READ
+    if (*payload_size < i) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR,
+               "Invalid SEI user data registered payload.\n");
+        return AVERROR_INVALIDDATA;
+    }
+    current->data_length = *payload_size - i;
+#else
+    *payload_size = i + current->data_length;
+#endif
+
+    allocate(current->data, current->data_length);
+    for (j = 0; j < current->data_length; j++)
+        xu(8, itu_t_t35_payload_byte[i], current->data[j], 0x00, 0xff, 1, i + j);
+
+    return 0;
+}
+
+static int FUNC(sei_user_data_unregistered)(CodedBitstreamContext *ctx, RWContext *rw,
+                                            H264RawSEIUserDataUnregistered *current,
+                                            uint32_t *payload_size)
+{
+    int err, i;
+
+    HEADER("User Data Unregistered");
+
+#ifdef READ
+    if (*payload_size < 16) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR,
+               "Invalid SEI user data unregistered payload.\n");
+        return AVERROR_INVALIDDATA;
+    }
+    current->data_length = *payload_size - 16;
+#else
+    *payload_size = 16 + current->data_length;
+#endif
+
+    for (i = 0; i < 16; i++)
+        us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
+
+    allocate(current->data, current->data_length);
+
+    for (i = 0; i < current->data_length; i++)
+        xu(8, user_data_payload_byte[i], current->data[i], 0x00, 0xff, 1, i);
+
+    return 0;
+}
+
 static int FUNC(sei_recovery_point)(CodedBitstreamContext *ctx, RWContext *rw,
-                                    H264RawSEIRecoveryPoint *current,
-                                    SEIMessageState *sei)
+                                    H264RawSEIRecoveryPoint *current)
 {
     int err;
 
@@ -720,8 +780,7 @@
 }
 
 static int FUNC(sei_display_orientation)(CodedBitstreamContext *ctx, RWContext *rw,
-                                         H264RawSEIDisplayOrientation *current,
-                                         SEIMessageState *sei)
+                                         H264RawSEIDisplayOrientation *current)
 {
     int err;
 
@@ -739,17 +798,205 @@
     return 0;
 }
 
+static int FUNC(sei_mastering_display_colour_volume)(CodedBitstreamContext *ctx, RWContext *rw,
+                                                     H264RawSEIMasteringDisplayColourVolume *current)
+{
+    int err, c;
+
+    HEADER("Mastering Display Colour Volume");
+
+    for (c = 0; c < 3; c++) {
+        us(16, display_primaries_x[c], 0, 50000, 1, c);
+        us(16, display_primaries_y[c], 0, 50000, 1, c);
+    }
+
+    u(16, white_point_x, 0, 50000);
+    u(16, white_point_y, 0, 50000);
+
+    u(32, max_display_mastering_luminance, 1, MAX_UINT_BITS(32));
+    u(32, min_display_mastering_luminance, 0, current->max_display_mastering_luminance - 1);
+
+    return 0;
+}
+
+static int FUNC(sei_alternative_transfer_characteristics)(CodedBitstreamContext *ctx,
+                                                          RWContext *rw,
+                                                          H264RawSEIAlternativeTransferCharacteristics *current)
+{
+    int err;
+
+    HEADER("Alternative Transfer Characteristics");
+
+    ub(8, preferred_transfer_characteristics);
+
+    return 0;
+}
+
+static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
+                             H264RawSEIPayload *current)
+{
+    int err, i;
+    int start_position, end_position;
+
+#ifdef READ
+    start_position = get_bits_count(rw);
+#else
+    start_position = put_bits_count(rw);
+#endif
+
+    switch (current->payload_type) {
+    case H264_SEI_TYPE_BUFFERING_PERIOD:
+        CHECK(FUNC(sei_buffering_period)
+              (ctx, rw, &current->payload.buffering_period));
+        break;
+    case H264_SEI_TYPE_PIC_TIMING:
+        CHECK(FUNC(sei_pic_timing)
+              (ctx, rw, &current->payload.pic_timing));
+        break;
+    case H264_SEI_TYPE_PAN_SCAN_RECT:
+        CHECK(FUNC(sei_pan_scan_rect)
+              (ctx, rw, &current->payload.pan_scan_rect));
+        break;
+    case H264_SEI_TYPE_FILLER_PAYLOAD:
+        {
+            for (i = 0; i  < current->payload_size; i++)
+                fixed(8, ff_byte, 0xff);
+        }
+        break;
+    case H264_SEI_TYPE_USER_DATA_REGISTERED:
+        CHECK(FUNC(sei_user_data_registered)
+              (ctx, rw, &current->payload.user_data_registered, &current->payload_size));
+        break;
+    case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
+        CHECK(FUNC(sei_user_data_unregistered)
+              (ctx, rw, &current->payload.user_data_unregistered, &current->payload_size));
+        break;
+    case H264_SEI_TYPE_RECOVERY_POINT:
+        CHECK(FUNC(sei_recovery_point)
+              (ctx, rw, &current->payload.recovery_point));
+        break;
+    case H264_SEI_TYPE_DISPLAY_ORIENTATION:
+        CHECK(FUNC(sei_display_orientation)
+              (ctx, rw, &current->payload.display_orientation));
+        break;
+    case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
+        CHECK(FUNC(sei_mastering_display_colour_volume)
+              (ctx, rw, &current->payload.mastering_display_colour_volume));
+        break;
+    case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
+        CHECK(FUNC(sei_alternative_transfer_characteristics)
+              (ctx, rw, &current->payload.alternative_transfer_characteristics));
+        break;
+    default:
+        {
+#ifdef READ
+            current->payload.other.data_length = current->payload_size;
+#endif
+            allocate(current->payload.other.data, current->payload.other.data_length);
+            for (i = 0; i < current->payload.other.data_length; i++)
+                xu(8, payload_byte[i], current->payload.other.data[i], 0, 255, 1, i);
+        }
+    }
+
+    if (byte_alignment(rw)) {
+        fixed(1, bit_equal_to_one, 1);
+        while (byte_alignment(rw))
+            fixed(1, bit_equal_to_zero, 0);
+    }
+
+#ifdef READ
+    end_position = get_bits_count(rw);
+    if (end_position < start_position + 8 * current->payload_size) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR, "Incorrect SEI payload length: "
+               "header %"PRIu32" bits, actually %d bits.\n",
+               8 * current->payload_size,
+               end_position - start_position);
+        return AVERROR_INVALIDDATA;
+    }
+#else
+    end_position = put_bits_count(rw);
+    current->payload_size = (end_position - start_position) / 8;
+#endif
+
+    return 0;
+}
+
 static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
                      H264RawSEI *current)
 {
-    int err;
+    int err, k;
 
     HEADER("Supplemental Enhancement Information");
 
     CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
                                 1 << H264_NAL_SEI));
 
-    CHECK(FUNC_SEI(message_list)(ctx, rw, &current->message_list, 1));
+#ifdef READ
+    for (k = 0; k < H264_MAX_SEI_PAYLOADS; k++) {
+        uint32_t payload_type = 0;
+        uint32_t payload_size = 0;
+        uint32_t tmp;
+
+        while (show_bits(rw, 8) == 0xff) {
+            fixed(8, ff_byte, 0xff);
+            payload_type += 255;
+        }
+        xu(8, last_payload_type_byte, tmp, 0, 254, 0);
+        payload_type += tmp;
+
+        while (show_bits(rw, 8) == 0xff) {
+            fixed(8, ff_byte, 0xff);
+            payload_size += 255;
+        }
+        xu(8, last_payload_size_byte, tmp, 0, 254, 0);
+        payload_size += tmp;
+
+        current->payload[k].payload_type = payload_type;
+        current->payload[k].payload_size = payload_size;
+
+        current->payload_count++;
+        CHECK(FUNC(sei_payload)(ctx, rw, &current->payload[k]));
+
+        if (!cbs_h2645_read_more_rbsp_data(rw))
+            break;
+    }
+    if (k >= H264_MAX_SEI_PAYLOADS) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many payloads in "
+               "SEI message: found %d.\n", k);
+        return AVERROR_INVALIDDATA;
+    }
+#else
+    for (k = 0; k < current->payload_count; k++) {
+        PutBitContext start_state;
+        uint32_t tmp;
+        int need_size, i;
+
+        // Somewhat clumsy: we write the payload twice when
+        // we don't know the size in advance.  This will mess
+        // with trace output, but is otherwise harmless.
+        start_state = *rw;
+        need_size = !current->payload[k].payload_size;
+        for (i = 0; i < 1 + need_size; i++) {
+            *rw = start_state;
+
+            tmp = current->payload[k].payload_type;
+            while (tmp >= 255) {
+                fixed(8, ff_byte, 0xff);
+                tmp -= 255;
+            }
+            xu(8, last_payload_type_byte, tmp, 0, 254, 0);
+
+            tmp = current->payload[k].payload_size;
+            while (tmp >= 255) {
+                fixed(8, ff_byte, 0xff);
+                tmp -= 255;
+            }
+            xu(8, last_payload_size_byte, tmp, 0, 254, 0);
+
+            CHECK(FUNC(sei_payload)(ctx, rw, &current->payload[k]));
+        }
+    }
+#endif
 
     CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
 
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 738cbee..15b22bb 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -23,7 +23,6 @@
 #include <stdint.h>
 
 #include "cbs_h2645.h"
-#include "cbs_sei.h"
 #include "hevc.h"
 
 enum {
@@ -597,6 +596,21 @@
     uint16_t pan_scan_rect_persistence_flag;
 } H265RawSEIPanScanRect;
 
+typedef struct H265RawSEIUserDataRegistered {
+    uint8_t itu_t_t35_country_code;
+    uint8_t itu_t_t35_country_code_extension_byte;
+    uint8_t     *data;
+    AVBufferRef *data_ref;
+    size_t       data_length;
+} H265RawSEIUserDataRegistered;
+
+typedef struct H265RawSEIUserDataUnregistered {
+    uint8_t uuid_iso_iec_11578[16];
+    uint8_t     *data;
+    AVBufferRef *data_ref;
+    size_t       data_length;
+} H265RawSEIUserDataUnregistered;
+
 typedef struct H265RawSEIRecoveryPoint {
     int16_t recovery_poc_cnt;
     uint8_t exact_match_flag;
@@ -647,6 +661,24 @@
     int32_t  time_offset_value[3];
 } H265RawSEITimeCode;
 
+typedef struct H265RawSEIMasteringDisplayColourVolume {
+    uint16_t display_primaries_x[3];
+    uint16_t display_primaries_y[3];
+    uint16_t white_point_x;
+    uint16_t white_point_y;
+    uint32_t max_display_mastering_luminance;
+    uint32_t min_display_mastering_luminance;
+} H265RawSEIMasteringDisplayColourVolume;
+
+typedef struct H265RawSEIContentLightLevelInfo {
+    uint16_t max_content_light_level;
+    uint16_t max_pic_average_light_level;
+} H265RawSEIContentLightLevelInfo;
+
+typedef struct H265RawSEIAlternativeTransferCharacteristics {
+    uint8_t preferred_transfer_characteristics;
+} H265RawSEIAlternativeTransferCharacteristics;
+
 typedef struct H265RawSEIAlphaChannelInfo {
     uint8_t  alpha_channel_cancel_flag;
     uint8_t  alpha_channel_use_idc;
@@ -658,9 +690,39 @@
     uint8_t  alpha_channel_clip_type_flag;
 } H265RawSEIAlphaChannelInfo;
 
+typedef struct H265RawSEIPayload {
+    uint32_t payload_type;
+    uint32_t payload_size;
+    union {
+        H265RawSEIBufferingPeriod buffering_period;
+        H265RawSEIPicTiming pic_timing;
+        H265RawSEIPanScanRect pan_scan_rect;
+        H265RawSEIUserDataRegistered user_data_registered;
+        H265RawSEIUserDataUnregistered user_data_unregistered;
+        H265RawSEIRecoveryPoint recovery_point;
+        H265RawSEIDisplayOrientation display_orientation;
+        H265RawSEIActiveParameterSets active_parameter_sets;
+        H265RawSEIDecodedPictureHash decoded_picture_hash;
+        H265RawSEITimeCode time_code;
+        H265RawSEIMasteringDisplayColourVolume mastering_display;
+        H265RawSEIContentLightLevelInfo content_light_level;
+        H265RawSEIAlternativeTransferCharacteristics
+            alternative_transfer_characteristics;
+        H265RawSEIAlphaChannelInfo alpha_channel_info;
+        struct {
+            uint8_t     *data;
+            AVBufferRef *data_ref;
+            size_t       data_length;
+        } other;
+    } payload;
+    H265RawExtensionData extension_data;
+} H265RawSEIPayload;
+
 typedef struct H265RawSEI {
     H265RawNALUnitHeader nal_unit_header;
-    SEIRawMessageList    message_list;
+
+    H265RawSEIPayload payload[H265_MAX_SEI_PAYLOADS];
+    uint8_t payload_count;
 } H265RawSEI;
 
 typedef struct CodedBitstreamH265Context {
diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c
index d09934c..48fae82 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1596,9 +1596,10 @@
     return 0;
 }
 
-static int FUNC(sei_buffering_period)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIBufferingPeriod *current, SEIMessageState *sei)
+static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw,
+                                      H265RawSEIBufferingPeriod *current,
+                                      uint32_t *payload_size,
+                                      int *more_data)
 {
     CodedBitstreamH265Context *h265 = ctx->priv_data;
     const H265RawSPS *sps;
@@ -1686,7 +1687,7 @@
 
 #ifdef READ
     end_pos = get_bits_count(rw);
-    if (cbs_h265_payload_extension_present(rw, sei->payload_size,
+    if (cbs_h265_payload_extension_present(rw, *payload_size,
                                            end_pos - start_pos))
         flag(use_alt_cpb_params_flag);
     else
@@ -1694,21 +1695,20 @@
 #else
     // If unknown extension data exists, then use_alt_cpb_params_flag is
     // coded in the bitstream and must be written even if it's 0.
-    if (current->use_alt_cpb_params_flag || sei->extension_present) {
+    if (current->use_alt_cpb_params_flag || *more_data) {
         flag(use_alt_cpb_params_flag);
         // Ensure this bit is not the last in the payload by making the
         // more_data_in_payload() check evaluate to true, so it may not
         // be mistaken as something else by decoders.
-        sei->extension_present = 1;
+        *more_data = 1;
     }
 #endif
 
     return 0;
 }
 
-static int FUNC(sei_pic_timing)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIPicTiming *current, SEIMessageState *sei)
+static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw,
+                                H265RawSEIPicTiming *current)
 {
     CodedBitstreamH265Context *h265 = ctx->priv_data;
     const H265RawSPS *sps;
@@ -1782,9 +1782,8 @@
     return 0;
 }
 
-static int FUNC(sei_pan_scan_rect)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIPanScanRect *current, SEIMessageState *sei)
+static int FUNC(sei_pan_scan_rect)(CodedBitstreamContext *ctx, RWContext *rw,
+                                   H265RawSEIPanScanRect *current)
 {
     int err, i;
 
@@ -1809,9 +1808,72 @@
     return 0;
 }
 
-static int FUNC(sei_recovery_point)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIRecoveryPoint *current, SEIMessageState *sei)
+static int FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext *rw,
+                                          H265RawSEIUserDataRegistered *current,
+                                          uint32_t *payload_size)
+{
+    int err, i, j;
+
+    HEADER("User Data Registered ITU-T T.35");
+
+    u(8, itu_t_t35_country_code, 0x00, 0xff);
+    if (current->itu_t_t35_country_code != 0xff)
+        i = 1;
+    else {
+        u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
+        i = 2;
+    }
+
+#ifdef READ
+    if (*payload_size < i) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR,
+               "Invalid SEI user data registered payload.\n");
+        return AVERROR_INVALIDDATA;
+    }
+    current->data_length = *payload_size - i;
+#else
+    *payload_size = i + current->data_length;
+#endif
+
+    allocate(current->data, current->data_length);
+    for (j = 0; j < current->data_length; j++)
+        xu(8, itu_t_t35_payload_byte[i], current->data[j], 0x00, 0xff, 1, i + j);
+
+    return 0;
+}
+
+static int FUNC(sei_user_data_unregistered)(CodedBitstreamContext *ctx, RWContext *rw,
+                                            H265RawSEIUserDataUnregistered *current,
+                                            uint32_t *payload_size)
+{
+    int err, i;
+
+    HEADER("User Data Unregistered");
+
+#ifdef READ
+    if (*payload_size < 16) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR,
+               "Invalid SEI user data unregistered payload.\n");
+        return AVERROR_INVALIDDATA;
+    }
+    current->data_length = *payload_size - 16;
+#else
+    *payload_size = 16 + current->data_length;
+#endif
+
+    for (i = 0; i < 16; i++)
+        us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
+
+    allocate(current->data, current->data_length);
+
+    for (i = 0; i < current->data_length; i++)
+        xu(8, user_data_payload_byte[i], current->data[i], 0x00, 0xff, 1, i);
+
+    return 0;
+}
+
+static int FUNC(sei_recovery_point)(CodedBitstreamContext *ctx, RWContext *rw,
+                                    H265RawSEIRecoveryPoint *current)
 {
     int err;
 
@@ -1825,9 +1887,8 @@
     return 0;
 }
 
-static int FUNC(sei_display_orientation)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIDisplayOrientation *current, SEIMessageState *sei)
+static int FUNC(sei_display_orientation)(CodedBitstreamContext *ctx, RWContext *rw,
+                                         H265RawSEIDisplayOrientation *current)
 {
     int err;
 
@@ -1844,9 +1905,8 @@
     return 0;
 }
 
-static int FUNC(sei_active_parameter_sets)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIActiveParameterSets *current, SEIMessageState *sei)
+static int FUNC(sei_active_parameter_sets)(CodedBitstreamContext *ctx, RWContext *rw,
+                                           H265RawSEIActiveParameterSets *current)
 {
     CodedBitstreamH265Context *h265 = ctx->priv_data;
     const H265RawVPS *vps;
@@ -1881,9 +1941,8 @@
     return 0;
 }
 
-static int FUNC(sei_decoded_picture_hash)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIDecodedPictureHash *current, SEIMessageState *sei)
+static int FUNC(sei_decoded_picture_hash)(CodedBitstreamContext *ctx, RWContext *rw,
+                                          H265RawSEIDecodedPictureHash *current)
 {
     CodedBitstreamH265Context *h265 = ctx->priv_data;
     const H265RawSPS *sps = h265->active_sps;
@@ -1913,9 +1972,8 @@
     return 0;
 }
 
-static int FUNC(sei_time_code)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEITimeCode *current, SEIMessageState *sei)
+static int FUNC(sei_time_code)(CodedBitstreamContext *ctx, RWContext *rw,
+                               H265RawSEITimeCode *current)
 {
     int err, i;
 
@@ -1964,9 +2022,58 @@
     return 0;
 }
 
-static int FUNC(sei_alpha_channel_info)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     H265RawSEIAlphaChannelInfo *current, SEIMessageState *sei)
+static int FUNC(sei_mastering_display)(CodedBitstreamContext *ctx, RWContext *rw,
+                                       H265RawSEIMasteringDisplayColourVolume *current)
+{
+    int err, c;
+
+    HEADER("Mastering Display Colour Volume");
+
+    for (c = 0; c < 3; c++) {
+        us(16, display_primaries_x[c], 0, 50000, 1, c);
+        us(16, display_primaries_y[c], 0, 50000, 1, c);
+    }
+
+    u(16, white_point_x, 0, 50000);
+    u(16, white_point_y, 0, 50000);
+
+    u(32, max_display_mastering_luminance,
+      1, MAX_UINT_BITS(32));
+    u(32, min_display_mastering_luminance,
+      0, current->max_display_mastering_luminance - 1);
+
+    return 0;
+}
+
+static int FUNC(sei_content_light_level)(CodedBitstreamContext *ctx, RWContext *rw,
+                                         H265RawSEIContentLightLevelInfo *current)
+{
+    int err;
+
+    HEADER("Content Light Level");
+
+    ub(16, max_content_light_level);
+    ub(16, max_pic_average_light_level);
+
+    return 0;
+}
+
+static int FUNC(sei_alternative_transfer_characteristics)(CodedBitstreamContext *ctx,
+                                                          RWContext *rw,
+                                                          H265RawSEIAlternativeTransferCharacteristics *current)
+{
+    int err;
+
+    HEADER("Alternative Transfer Characteristics");
+
+    ub(8, preferred_transfer_characteristics);
+
+    return 0;
+}
+
+static int FUNC(sei_alpha_channel_info)(CodedBitstreamContext *ctx,
+                                        RWContext *rw,
+                                        H265RawSEIAlphaChannelInfo *current)
 {
     int err, length;
 
@@ -1992,10 +2099,144 @@
     return 0;
 }
 
+static int FUNC(payload_extension)(CodedBitstreamContext *ctx, RWContext *rw,
+                                   H265RawExtensionData *current, uint32_t payload_size,
+                                   int cur_pos)
+{
+    int err;
+    size_t byte_length, k;
+
+#ifdef READ
+    GetBitContext tmp;
+    int bits_left, payload_zero_bits;
+
+    if (!cbs_h265_payload_extension_present(rw, payload_size, cur_pos))
+        return 0;
+
+    bits_left = 8 * payload_size - cur_pos;
+    tmp = *rw;
+    if (bits_left > 8)
+        skip_bits_long(&tmp, bits_left - 8);
+    payload_zero_bits = get_bits(&tmp, FFMIN(bits_left, 8));
+    if (!payload_zero_bits)
+        return AVERROR_INVALIDDATA;
+    payload_zero_bits = ff_ctz(payload_zero_bits);
+    current->bit_length = bits_left - payload_zero_bits - 1;
+    allocate(current->data, (current->bit_length + 7) / 8);
+#endif
+
+    byte_length = (current->bit_length + 7) / 8;
+    for (k = 0; k < byte_length; k++) {
+        int length = FFMIN(current->bit_length - k * 8, 8);
+        xu(length, reserved_payload_extension_data, current->data[k],
+           0, MAX_UINT_BITS(length), 0);
+    }
+
+    return 0;
+}
+
+static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
+                             H265RawSEIPayload *current, int prefix)
+{
+    int err, i;
+    int start_position, current_position;
+    int more_data = !!current->extension_data.bit_length;
+
+#ifdef READ
+    start_position = get_bits_count(rw);
+#else
+    start_position = put_bits_count(rw);
+#endif
+
+    switch (current->payload_type) {
+#define SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid) do { \
+            if (prefix && !prefix_valid) { \
+                av_log(ctx->log_ctx, AV_LOG_ERROR, "SEI type %s invalid " \
+                       "as prefix SEI!\n", #name); \
+                return AVERROR_INVALIDDATA; \
+            } \
+            if (!prefix && !suffix_valid) { \
+                av_log(ctx->log_ctx, AV_LOG_ERROR, "SEI type %s invalid " \
+                       "as suffix SEI!\n", #name); \
+                return AVERROR_INVALIDDATA; \
+            } \
+        } while (0)
+#define SEI_TYPE_N(type, prefix_valid, suffix_valid, name) \
+    case HEVC_SEI_TYPE_ ## type: \
+        SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \
+        CHECK(FUNC(sei_ ## name)(ctx, rw, &current->payload.name)); \
+        break
+#define SEI_TYPE_S(type, prefix_valid, suffix_valid, name) \
+    case HEVC_SEI_TYPE_ ## type: \
+        SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \
+        CHECK(FUNC(sei_ ## name)(ctx, rw, &current->payload.name, \
+                                 &current->payload_size)); \
+        break
+#define SEI_TYPE_E(type, prefix_valid, suffix_valid, name) \
+    case HEVC_SEI_TYPE_ ## type: \
+        SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \
+        CHECK(FUNC(sei_ ## name)(ctx, rw, &current->payload.name, \
+                                 &current->payload_size, \
+                                 &more_data)); \
+        break
+
+        SEI_TYPE_E(BUFFERING_PERIOD,         1, 0, buffering_period);
+        SEI_TYPE_N(PICTURE_TIMING,           1, 0, pic_timing);
+        SEI_TYPE_N(PAN_SCAN_RECT,            1, 0, pan_scan_rect);
+        SEI_TYPE_S(USER_DATA_REGISTERED_ITU_T_T35,
+                                             1, 1, user_data_registered);
+        SEI_TYPE_S(USER_DATA_UNREGISTERED,   1, 1, user_data_unregistered);
+        SEI_TYPE_N(RECOVERY_POINT,           1, 0, recovery_point);
+        SEI_TYPE_N(DISPLAY_ORIENTATION,      1, 0, display_orientation);
+        SEI_TYPE_N(ACTIVE_PARAMETER_SETS,    1, 0, active_parameter_sets);
+        SEI_TYPE_N(DECODED_PICTURE_HASH,     0, 1, decoded_picture_hash);
+        SEI_TYPE_N(TIME_CODE,                1, 0, time_code);
+        SEI_TYPE_N(MASTERING_DISPLAY_INFO,   1, 0, mastering_display);
+        SEI_TYPE_N(CONTENT_LIGHT_LEVEL_INFO, 1, 0, content_light_level);
+        SEI_TYPE_N(ALTERNATIVE_TRANSFER_CHARACTERISTICS,
+                                             1, 0, alternative_transfer_characteristics);
+        SEI_TYPE_N(ALPHA_CHANNEL_INFO,       1, 0, alpha_channel_info);
+
+#undef SEI_TYPE
+    default:
+        {
+#ifdef READ
+            current->payload.other.data_length = current->payload_size;
+#endif
+            allocate(current->payload.other.data, current->payload.other.data_length);
+
+            for (i = 0; i < current->payload_size; i++)
+                xu(8, payload_byte[i], current->payload.other.data[i], 0, 255,
+                   1, i);
+        }
+    }
+
+    // more_data_in_payload()
+#ifdef READ
+    current_position = get_bits_count(rw) - start_position;
+    if (current_position < 8 * current->payload_size) {
+#else
+    current_position = put_bits_count(rw) - start_position;
+    if (byte_alignment(rw) || more_data) {
+#endif
+        CHECK(FUNC(payload_extension)(ctx, rw, &current->extension_data,
+                                      current->payload_size, current_position));
+        fixed(1, bit_equal_to_one, 1);
+        while (byte_alignment(rw))
+            fixed(1, bit_equal_to_zero, 0);
+    }
+
+#ifdef WRITE
+    current->payload_size = (put_bits_count(rw) - start_position) >> 3;
+#endif
+
+    return 0;
+}
+
 static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
                      H265RawSEI *current, int prefix)
 {
-    int err;
+    int err, k;
 
     if (prefix)
         HEADER("Prefix Supplemental Enhancement Information");
@@ -2006,7 +2247,72 @@
                                 prefix ? HEVC_NAL_SEI_PREFIX
                                        : HEVC_NAL_SEI_SUFFIX));
 
-    CHECK(FUNC_SEI(message_list)(ctx, rw, &current->message_list, prefix));
+#ifdef READ
+    for (k = 0; k < H265_MAX_SEI_PAYLOADS; k++) {
+        uint32_t payload_type = 0;
+        uint32_t payload_size = 0;
+        uint32_t tmp;
+
+        while (show_bits(rw, 8) == 0xff) {
+            fixed(8, ff_byte, 0xff);
+            payload_type += 255;
+        }
+        xu(8, last_payload_type_byte, tmp, 0, 254, 0);
+        payload_type += tmp;
+
+        while (show_bits(rw, 8) == 0xff) {
+            fixed(8, ff_byte, 0xff);
+            payload_size += 255;
+        }
+        xu(8, last_payload_size_byte, tmp, 0, 254, 0);
+        payload_size += tmp;
+
+        current->payload[k].payload_type = payload_type;
+        current->payload[k].payload_size = payload_size;
+
+        current->payload_count++;
+        CHECK(FUNC(sei_payload)(ctx, rw, &current->payload[k], prefix));
+
+        if (!cbs_h2645_read_more_rbsp_data(rw))
+            break;
+    }
+    if (k >= H265_MAX_SEI_PAYLOADS) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many payloads in "
+               "SEI message: found %d.\n", k);
+        return AVERROR_INVALIDDATA;
+    }
+#else
+    for (k = 0; k < current->payload_count; k++) {
+        PutBitContext start_state;
+        uint32_t tmp;
+        int need_size, i;
+
+        // Somewhat clumsy: we write the payload twice when
+        // we don't know the size in advance.  This will mess
+        // with trace output, but is otherwise harmless.
+        start_state = *rw;
+        need_size = !current->payload[k].payload_size;
+        for (i = 0; i < 1 + need_size; i++) {
+            *rw = start_state;
+
+            tmp = current->payload[k].payload_type;
+            while (tmp >= 255) {
+                fixed(8, ff_byte, 0xff);
+                tmp -= 255;
+            }
+            xu(8, last_payload_type_byte, tmp, 0, 254, 0);
+
+            tmp = current->payload[k].payload_size;
+            while (tmp >= 255) {
+                fixed(8, ff_byte, 0xff);
+                tmp -= 255;
+            }
+            xu(8, last_payload_size_byte, tmp, 0, 254, 0);
+
+            CHECK(FUNC(sei_payload)(ctx, rw, &current->payload[k], prefix));
+        }
+    }
+#endif
 
     CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
 
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index a392880..faa847a 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -86,12 +86,6 @@
 typedef struct CodedBitstreamType {
     enum AVCodecID codec_id;
 
-    // A class for the private data, used to declare private AVOptions.
-    // This field is NULL for types that do not declare any options.
-    // If this field is non-NULL, the first member of the filter private data
-    // must be a pointer to AVClass.
-    const AVClass *priv_class;
-
     size_t priv_data_size;
 
     // List of unit type descriptors for this codec.
diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
deleted file mode 100644
index c49830a..0000000
--- a/libavcodec/cbs_sei.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "cbs.h"
-#include "cbs_internal.h"
-#include "cbs_h264.h"
-#include "cbs_h265.h"
-#include "cbs_sei.h"
-
-static void cbs_free_user_data_registered(void *opaque, uint8_t *data)
-{
-    SEIRawUserDataRegistered *udr = (SEIRawUserDataRegistered*)data;
-    av_buffer_unref(&udr->data_ref);
-    av_free(udr);
-}
-
-static void cbs_free_user_data_unregistered(void *opaque, uint8_t *data)
-{
-    SEIRawUserDataUnregistered *udu = (SEIRawUserDataUnregistered*)data;
-    av_buffer_unref(&udu->data_ref);
-    av_free(udu);
-}
-
-int ff_cbs_sei_alloc_message_payload(SEIRawMessage *message,
-                                     const SEIMessageTypeDescriptor *desc)
-{
-    void (*free_func)(void*, uint8_t*);
-
-    av_assert0(message->payload     == NULL &&
-               message->payload_ref == NULL);
-    message->payload_type = desc->type;
-
-    if (desc->type == SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35)
-        free_func = &cbs_free_user_data_registered;
-    else if (desc->type == SEI_TYPE_USER_DATA_UNREGISTERED)
-        free_func = &cbs_free_user_data_unregistered;
-    else
-        free_func = NULL;
-
-    if (free_func) {
-        message->payload = av_mallocz(desc->size);
-        if (!message->payload)
-            return AVERROR(ENOMEM);
-        message->payload_ref =
-            av_buffer_create(message->payload, desc->size,
-                             free_func, NULL, 0);
-    } else {
-        message->payload_ref = av_buffer_alloc(desc->size);
-    }
-    if (!message->payload_ref) {
-        av_freep(&message->payload);
-        return AVERROR(ENOMEM);
-    }
-    message->payload = message->payload_ref->data;
-
-    return 0;
-}
-
-int ff_cbs_sei_list_add(SEIRawMessageList *list)
-{
-    void *ptr;
-    int old_count = list->nb_messages_allocated;
-
-    av_assert0(list->nb_messages <= old_count);
-    if (list->nb_messages + 1 > old_count) {
-        int new_count = 2 * old_count + 1;
-
-        ptr = av_realloc_array(list->messages,
-                               new_count, sizeof(*list->messages));
-        if (!ptr)
-            return AVERROR(ENOMEM);
-
-        list->messages = ptr;
-        list->nb_messages_allocated = new_count;
-
-        // Zero the newly-added entries.
-        memset(list->messages + old_count, 0,
-               (new_count - old_count) * sizeof(*list->messages));
-    }
-    ++list->nb_messages;
-    return 0;
-}
-
-void ff_cbs_sei_free_message_list(SEIRawMessageList *list)
-{
-    for (int i = 0; i < list->nb_messages; i++) {
-        SEIRawMessage *message = &list->messages[i];
-        av_buffer_unref(&message->payload_ref);
-        av_buffer_unref(&message->extension_data_ref);
-    }
-    av_free(list->messages);
-}
-
-static int cbs_sei_get_unit(CodedBitstreamContext *ctx,
-                            CodedBitstreamFragment *au,
-                            int prefix,
-                            CodedBitstreamUnit **sei_unit)
-{
-    CodedBitstreamUnit *unit;
-    int sei_type, highest_vcl_type, err, i, position;
-
-    switch (ctx->codec->codec_id) {
-    case AV_CODEC_ID_H264:
-        // (We can ignore auxiliary slices because we only have prefix
-        // SEI in H.264 and an auxiliary picture must always follow a
-        // primary picture.)
-        highest_vcl_type = H264_NAL_IDR_SLICE;
-        if (prefix)
-            sei_type = H264_NAL_SEI;
-        else
-            return AVERROR(EINVAL);
-        break;
-    case AV_CODEC_ID_H265:
-        highest_vcl_type = HEVC_NAL_RSV_VCL31;
-        if (prefix)
-            sei_type = HEVC_NAL_SEI_PREFIX;
-        else
-            sei_type = HEVC_NAL_SEI_SUFFIX;
-        break;
-    default:
-        return AVERROR(EINVAL);
-    }
-
-    // Find an existing SEI NAL unit of the right type.
-    unit = NULL;
-    for (i = 0; i < au->nb_units; i++) {
-        if (au->units[i].type == sei_type) {
-            unit = &au->units[i];
-            break;
-        }
-    }
-
-    if (unit) {
-        *sei_unit = unit;
-        return 0;
-    }
-
-    // Need to add a new SEI NAL unit ...
-    if (prefix) {
-        // ... before the first VCL NAL unit.
-        for (i = 0; i < au->nb_units; i++) {
-            if (au->units[i].type < highest_vcl_type)
-                break;
-        }
-        position = i;
-    } else {
-        // ... after the last VCL NAL unit.
-        for (i = au->nb_units - 1; i >= 0; i--) {
-            if (au->units[i].type < highest_vcl_type)
-                break;
-        }
-        if (i < 0) {
-            // No VCL units; just put it at the end.
-            position = -1;
-        } else {
-            position = i + 1;
-        }
-    }
-
-    err = ff_cbs_insert_unit_content(au, position, sei_type,
-                                     NULL, NULL);
-    if (err < 0)
-        return err;
-    unit = &au->units[position];
-    unit->type = sei_type;
-
-    err = ff_cbs_alloc_unit_content2(ctx, unit);
-    if (err < 0)
-        return err;
-
-    switch (ctx->codec->codec_id) {
-    case AV_CODEC_ID_H264:
-        {
-            H264RawSEI sei = {
-                .nal_unit_header = {
-                    .nal_ref_idc   = 0,
-                    .nal_unit_type = sei_type,
-                },
-            };
-            memcpy(unit->content, &sei, sizeof(sei));
-        }
-        break;
-    case AV_CODEC_ID_H265:
-        {
-            H265RawSEI sei = {
-                .nal_unit_header = {
-                    .nal_unit_type         = sei_type,
-                    .nuh_layer_id          = 0,
-                    .nuh_temporal_id_plus1 = 1,
-                },
-            };
-            memcpy(unit->content, &sei, sizeof(sei));
-        }
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    *sei_unit = unit;
-    return 0;
-}
-
-static int cbs_sei_get_message_list(CodedBitstreamContext *ctx,
-                                    CodedBitstreamUnit *unit,
-                                    SEIRawMessageList **list)
-{
-    switch (ctx->codec->codec_id) {
-    case AV_CODEC_ID_H264:
-        {
-            H264RawSEI *sei = unit->content;
-            if (unit->type != H264_NAL_SEI)
-                return AVERROR(EINVAL);
-            *list = &sei->message_list;
-        }
-        break;
-    case AV_CODEC_ID_H265:
-        {
-            H265RawSEI *sei = unit->content;
-            if (unit->type != HEVC_NAL_SEI_PREFIX &&
-                unit->type != HEVC_NAL_SEI_SUFFIX)
-                return AVERROR(EINVAL);
-            *list = &sei->message_list;
-        }
-        break;
-    default:
-        return AVERROR(EINVAL);
-    }
-
-    return 0;
-}
-
-int ff_cbs_sei_add_message(CodedBitstreamContext *ctx,
-                           CodedBitstreamFragment *au,
-                           int prefix,
-                           uint32_t     payload_type,
-                           void        *payload_data,
-                           AVBufferRef *payload_buf)
-{
-    const SEIMessageTypeDescriptor *desc;
-    CodedBitstreamUnit *unit;
-    SEIRawMessageList *list;
-    SEIRawMessage *message;
-    AVBufferRef *payload_ref;
-    int err;
-
-    desc = ff_cbs_sei_find_type(ctx, payload_type);
-    if (!desc)
-        return AVERROR(EINVAL);
-
-    if (payload_buf) {
-        payload_ref = av_buffer_ref(payload_buf);
-        if (!payload_ref)
-            return AVERROR(ENOMEM);
-    } else {
-        payload_ref = NULL;
-    }
-
-    // Find an existing SEI unit or make a new one to add to.
-    err = cbs_sei_get_unit(ctx, au, prefix, &unit);
-    if (err < 0)
-        return err;
-
-    // Find the message list inside the codec-dependent unit.
-    err = cbs_sei_get_message_list(ctx, unit, &list);
-    if (err < 0)
-        return err;
-
-    // Add a new message to the message list.
-    err = ff_cbs_sei_list_add(list);
-    if (err < 0)
-        return err;
-
-    message = &list->messages[list->nb_messages - 1];
-
-    message->payload_type = payload_type;
-    message->payload      = payload_data;
-    message->payload_ref  = payload_ref;
-
-    return 0;
-}
-
-int ff_cbs_sei_find_message(CodedBitstreamContext *ctx,
-                            CodedBitstreamFragment *au,
-                            uint32_t payload_type,
-                            SEIRawMessage **iter)
-{
-    int err, i, j, found;
-
-    found = 0;
-    for (i = 0; i < au->nb_units; i++) {
-        CodedBitstreamUnit *unit = &au->units[i];
-        SEIRawMessageList *list;
-
-        err = cbs_sei_get_message_list(ctx, unit, &list);
-        if (err < 0)
-            continue;
-
-        for (j = 0; j < list->nb_messages; j++) {
-            SEIRawMessage *message = &list->messages[j];
-
-            if (message->payload_type == payload_type) {
-                if (!*iter || found) {
-                    *iter = message;
-                    return 0;
-                }
-                if (message == *iter)
-                    found = 1;
-            }
-        }
-    }
-
-    return AVERROR(ENOENT);
-}
-
-static void cbs_sei_delete_message(SEIRawMessageList *list,
-                                   int position)
-{
-    SEIRawMessage *message;
-
-    av_assert0(0 <= position && position < list->nb_messages);
-
-    message = &list->messages[position];
-    av_buffer_unref(&message->payload_ref);
-    av_buffer_unref(&message->extension_data_ref);
-
-    --list->nb_messages;
-
-    if (list->nb_messages > 0) {
-        memmove(list->messages + position,
-                list->messages + position + 1,
-                (list->nb_messages - position) * sizeof(*list->messages));
-    }
-}
-
-void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx,
-                                    CodedBitstreamFragment *au,
-                                    uint32_t payload_type)
-{
-    int err, i, j;
-
-    for (i = 0; i < au->nb_units; i++) {
-        CodedBitstreamUnit *unit = &au->units[i];
-        SEIRawMessageList *list;
-
-        err = cbs_sei_get_message_list(ctx, unit, &list);
-        if (err < 0)
-            continue;
-
-        for (j = list->nb_messages - 1; j >= 0; j--) {
-            if (list->messages[j].payload_type == payload_type)
-                cbs_sei_delete_message(list, j);
-        }
-    }
-}
diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
deleted file mode 100644
index c7a7a95..0000000
--- a/libavcodec/cbs_sei.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_CBS_SEI_H
-#define AVCODEC_CBS_SEI_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "libavutil/buffer.h"
-
-#include "cbs.h"
-#include "sei.h"
-
-
-typedef struct SEIRawFillerPayload {
-    uint32_t payload_size;
-} SEIRawFillerPayload;
-
-typedef struct SEIRawUserDataRegistered {
-    uint8_t      itu_t_t35_country_code;
-    uint8_t      itu_t_t35_country_code_extension_byte;
-    uint8_t     *data;
-    AVBufferRef *data_ref;
-    size_t       data_length;
-} SEIRawUserDataRegistered;
-
-typedef struct SEIRawUserDataUnregistered {
-    uint8_t      uuid_iso_iec_11578[16];
-    uint8_t     *data;
-    AVBufferRef *data_ref;
-    size_t       data_length;
-} SEIRawUserDataUnregistered;
-
-typedef struct SEIRawMasteringDisplayColourVolume {
-    uint16_t display_primaries_x[3];
-    uint16_t display_primaries_y[3];
-    uint16_t white_point_x;
-    uint16_t white_point_y;
-    uint32_t max_display_mastering_luminance;
-    uint32_t min_display_mastering_luminance;
-} SEIRawMasteringDisplayColourVolume;
-
-typedef struct SEIRawContentLightLevelInfo {
-    uint16_t max_content_light_level;
-    uint16_t max_pic_average_light_level;
-} SEIRawContentLightLevelInfo;
-
-typedef struct SEIRawAlternativeTransferCharacteristics {
-    uint8_t preferred_transfer_characteristics;
-} SEIRawAlternativeTransferCharacteristics;
-
-typedef struct SEIRawMessage {
-    uint32_t     payload_type;
-    uint32_t     payload_size;
-    void        *payload;
-    AVBufferRef *payload_ref;
-    uint8_t     *extension_data;
-    AVBufferRef *extension_data_ref;
-    size_t       extension_bit_length;
-} SEIRawMessage;
-
-typedef struct SEIRawMessageList {
-    SEIRawMessage *messages;
-    int         nb_messages;
-    int         nb_messages_allocated;
-} SEIRawMessageList;
-
-
-typedef struct SEIMessageState {
-    // The type of the payload being written.
-    uint32_t payload_type;
-    // When reading, contains the size of the payload to allow finding the
-    // end of variable-length fields (such as user_data_payload_byte[]).
-    // (When writing, the size will be derived from the total number of
-    // bytes actually written.)
-    uint32_t payload_size;
-    // When writing, indicates that payload extension data is present so
-    // all extended fields must be written.  May be updated by the writer
-    // to indicate that extended fields have been written, so the extension
-    // end bits must be written too.
-    uint8_t  extension_present;
-} SEIMessageState;
-
-struct GetBitContext;
-struct PutBitContext;
-
-typedef int (*SEIMessageReadFunction)(CodedBitstreamContext *ctx,
-                                      struct GetBitContext *rw,
-                                      void *current,
-                                      SEIMessageState *sei);
-
-typedef int (*SEIMessageWriteFunction)(CodedBitstreamContext *ctx,
-                                       struct PutBitContext *rw,
-                                       void *current,
-                                       SEIMessageState *sei);
-
-typedef struct SEIMessageTypeDescriptor {
-    // Payload type for the message.  (-1 in this field ends a list.)
-    int     type;
-    // Valid in a prefix SEI NAL unit (always for H.264).
-    uint8_t prefix;
-    // Valid in a suffix SEI NAL unit (never for H.264).
-    uint8_t suffix;
-    // Size of the decomposed structure.
-    size_t  size;
-    // Read bitstream into SEI message.
-    SEIMessageReadFunction  read;
-    // Write bitstream from SEI message.
-    SEIMessageWriteFunction write;
-} SEIMessageTypeDescriptor;
-
-// Macro for the read/write pair.  The clumsy cast is needed because the
-// current pointer is typed in all of the read/write functions but has to
-// be void here to fit all cases.
-#define SEI_MESSAGE_RW(codec, name) \
-    .read  = (SEIMessageReadFunction) cbs_ ## codec ## _read_  ## name, \
-    .write = (SEIMessageWriteFunction)cbs_ ## codec ## _write_ ## name
-
-// End-of-list sentinel element.
-#define SEI_MESSAGE_TYPE_END { .type = -1 }
-
-
-/**
- * Find the type descriptor for the given payload type.
- *
- * Returns NULL if the payload type is not known.
- */
-const SEIMessageTypeDescriptor *ff_cbs_sei_find_type(CodedBitstreamContext *ctx,
-                                                     int payload_type);
-
-/**
- * Allocate a new payload for the given SEI message.
- */
-int ff_cbs_sei_alloc_message_payload(SEIRawMessage *message,
-                                     const SEIMessageTypeDescriptor *desc);
-
-/**
- * Allocate a new empty SEI message in a message list.
- *
- * The new message is in place nb_messages - 1.
- */
-int ff_cbs_sei_list_add(SEIRawMessageList *list);
-
-/**
- * Free all SEI messages in a message list.
- */
-void ff_cbs_sei_free_message_list(SEIRawMessageList *list);
-
-/**
- * Add an SEI message to an access unit.
- *
- * Will add to an existing SEI NAL unit, or create a new one for the
- * message if there is no suitable existing one.
- *
- * Takes a new reference to payload_buf, if set.  If payload_buf is
- * NULL then the new message will not be reference counted.
- */
-int ff_cbs_sei_add_message(CodedBitstreamContext *ctx,
-                           CodedBitstreamFragment *au,
-                           int prefix,
-                           uint32_t     payload_type,
-                           void        *payload_data,
-                           AVBufferRef *payload_buf);
-
-/**
- * Iterate over messages with the given payload type in an access unit.
- *
- * Set message to NULL in the first call.  Returns 0 while more messages
- * are available, AVERROR(ENOENT) when all messages have been found.
- */
-int ff_cbs_sei_find_message(CodedBitstreamContext *ctx,
-                            CodedBitstreamFragment *au,
-                            uint32_t payload_type,
-                            SEIRawMessage **message);
-
-/**
- * Delete all messages with the given payload type from an access unit.
- */
-void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx,
-                                    CodedBitstreamFragment *au,
-                                    uint32_t payload_type);
-
-#endif /* AVCODEC_CBS_SEI_H */
diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c
deleted file mode 100644
index 9114e61..0000000
--- a/libavcodec/cbs_sei_syntax_template.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-static int FUNC(filler_payload)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     SEIRawFillerPayload *current, SEIMessageState *state)
-{
-    int err, i;
-
-    HEADER("Filler Payload");
-
-#ifdef READ
-    current->payload_size = state->payload_size;
-#endif
-
-    for (i = 0; i < current->payload_size; i++)
-        fixed(8, ff_byte, 0xff);
-
-    return 0;
-}
-
-static int FUNC(user_data_registered)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     SEIRawUserDataRegistered *current, SEIMessageState *state)
-{
-    int err, i, j;
-
-    HEADER("User Data Registered ITU-T T.35");
-
-    u(8, itu_t_t35_country_code, 0x00, 0xff);
-    if (current->itu_t_t35_country_code != 0xff)
-        i = 1;
-    else {
-        u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
-        i = 2;
-    }
-
-#ifdef READ
-    if (state->payload_size < i) {
-        av_log(ctx->log_ctx, AV_LOG_ERROR,
-               "Invalid SEI user data registered payload.\n");
-        return AVERROR_INVALIDDATA;
-    }
-    current->data_length = state->payload_size - i;
-#endif
-
-    allocate(current->data, current->data_length);
-    for (j = 0; j < current->data_length; j++)
-        xu(8, itu_t_t35_payload_byte[], current->data[j], 0x00, 0xff, 1, i + j);
-
-    return 0;
-}
-
-static int FUNC(user_data_unregistered)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     SEIRawUserDataUnregistered *current, SEIMessageState *state)
-{
-    int err, i;
-
-    HEADER("User Data Unregistered");
-
-#ifdef READ
-    if (state->payload_size < 16) {
-        av_log(ctx->log_ctx, AV_LOG_ERROR,
-               "Invalid SEI user data unregistered payload.\n");
-        return AVERROR_INVALIDDATA;
-    }
-    current->data_length = state->payload_size - 16;
-#endif
-
-    for (i = 0; i < 16; i++)
-        us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
-
-    allocate(current->data, current->data_length);
-
-    for (i = 0; i < current->data_length; i++)
-        xu(8, user_data_payload_byte[i], current->data[i], 0x00, 0xff, 1, i);
-
-    return 0;
-}
-
-static int FUNC(mastering_display_colour_volume)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     SEIRawMasteringDisplayColourVolume *current, SEIMessageState *state)
-{
-    int err, c;
-
-    HEADER("Mastering Display Colour Volume");
-
-    for (c = 0; c < 3; c++) {
-        ubs(16, display_primaries_x[c], 1, c);
-        ubs(16, display_primaries_y[c], 1, c);
-    }
-
-    ub(16, white_point_x);
-    ub(16, white_point_y);
-
-    ub(32, max_display_mastering_luminance);
-    ub(32, min_display_mastering_luminance);
-
-    return 0;
-}
-
-static int FUNC(content_light_level_info)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     SEIRawContentLightLevelInfo *current, SEIMessageState *state)
-{
-    int err;
-
-    HEADER("Content Light Level Information");
-
-    ub(16, max_content_light_level);
-    ub(16, max_pic_average_light_level);
-
-    return 0;
-}
-
-static int FUNC(alternative_transfer_characteristics)
-    (CodedBitstreamContext *ctx, RWContext *rw,
-     SEIRawAlternativeTransferCharacteristics *current,
-     SEIMessageState *state)
-{
-    int err;
-
-    HEADER("Alternative Transfer Characteristics");
-
-    ub(8, preferred_transfer_characteristics);
-
-    return 0;
-}
-
-static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw,
-                         SEIRawMessage *current)
-{
-    const SEIMessageTypeDescriptor *desc;
-    int err, i;
-
-    desc = ff_cbs_sei_find_type(ctx, current->payload_type);
-    if (desc) {
-        SEIMessageState state = {
-            .payload_type      = current->payload_type,
-            .payload_size      = current->payload_size,
-            .extension_present = current->extension_bit_length > 0,
-        };
-        int start_position, current_position, bits_written;
-
-#ifdef READ
-        CHECK(ff_cbs_sei_alloc_message_payload(current, desc));
-#endif
-
-        start_position = bit_position(rw);
-
-        CHECK(desc->READWRITE(ctx, rw, current->payload, &state));
-
-        current_position = bit_position(rw);
-        bits_written = current_position - start_position;
-
-        if (byte_alignment(rw) || state.extension_present ||
-            bits_written < 8 * current->payload_size) {
-            size_t bits_left;
-
-#ifdef READ
-            GetBitContext tmp = *rw;
-            int trailing_bits, trailing_zero_bits;
-
-            bits_left = 8 * current->payload_size - bits_written;
-            if (bits_left > 8)
-                skip_bits_long(&tmp, bits_left - 8);
-            trailing_bits = get_bits(&tmp, FFMIN(bits_left, 8));
-            if (trailing_bits == 0) {
-                // The trailing bits must contain a bit_equal_to_one, so
-                // they can't all be zero.
-                return AVERROR_INVALIDDATA;
-            }
-            trailing_zero_bits = ff_ctz(trailing_bits);
-            current->extension_bit_length =
-                bits_left - 1 - trailing_zero_bits;
-#endif
-
-            if (current->extension_bit_length > 0) {
-                allocate(current->extension_data,
-                         (current->extension_bit_length + 7) / 8);
-
-                bits_left = current->extension_bit_length;
-                for (i = 0; bits_left > 0; i++) {
-                    int length = FFMIN(bits_left, 8);
-                    xu(length, reserved_payload_extension_data,
-                       current->extension_data[i],
-                       0, MAX_UINT_BITS(length), 0);
-                    bits_left -= length;
-                }
-            }
-
-            fixed(1, bit_equal_to_one, 1);
-            while (byte_alignment(rw))
-                fixed(1, bit_equal_to_zero, 0);
-        }
-
-#ifdef WRITE
-        current->payload_size = (put_bits_count(rw) - start_position) / 8;
-#endif
-    } else {
-        uint8_t *data;
-
-        allocate(current->payload, current->payload_size);
-        data = current->payload;
-
-        for (i = 0; i < current->payload_size; i++)
-            xu(8, payload_byte[i], data[i], 0, 255, 1, i);
-    }
-
-    return 0;
-}
-
-static int FUNC(message_list)(CodedBitstreamContext *ctx, RWContext *rw,
-                              SEIRawMessageList *current, int prefix)
-{
-    SEIRawMessage *message;
-    int err, k;
-
-#ifdef READ
-    for (k = 0;; k++) {
-        uint32_t payload_type = 0;
-        uint32_t payload_size = 0;
-        uint32_t tmp;
-
-        while (show_bits(rw, 8) == 0xff) {
-            fixed(8, ff_byte, 0xff);
-            payload_type += 255;
-        }
-        xu(8, last_payload_type_byte, tmp, 0, 254, 0);
-        payload_type += tmp;
-
-        while (show_bits(rw, 8) == 0xff) {
-            fixed(8, ff_byte, 0xff);
-            payload_size += 255;
-        }
-        xu(8, last_payload_size_byte, tmp, 0, 254, 0);
-        payload_size += tmp;
-
-        CHECK(ff_cbs_sei_list_add(current));
-        message = &current->messages[k];
-
-        message->payload_type = payload_type;
-        message->payload_size = payload_size;
-
-        CHECK(FUNC(message)(ctx, rw, message));
-
-        if (!cbs_h2645_read_more_rbsp_data(rw))
-            break;
-    }
-#else
-    for (k = 0; k < current->nb_messages; k++) {
-        PutBitContext start_state;
-        uint32_t tmp;
-        int trace, i;
-
-        message = &current->messages[k];
-
-        // We write the payload twice in order to find the size.  Trace
-        // output is switched off for the first write.
-        trace = ctx->trace_enable;
-        ctx->trace_enable = 0;
-
-        start_state = *rw;
-        for (i = 0; i < 2; i++) {
-            *rw = start_state;
-
-            tmp = message->payload_type;
-            while (tmp >= 255) {
-                fixed(8, ff_byte, 0xff);
-                tmp -= 255;
-            }
-            xu(8, last_payload_type_byte, tmp, 0, 254, 0);
-
-            tmp = message->payload_size;
-            while (tmp >= 255) {
-                fixed(8, ff_byte, 0xff);
-                tmp -= 255;
-            }
-            xu(8, last_payload_size_byte, tmp, 0, 254, 0);
-
-            err = FUNC(message)(ctx, rw, message);
-            ctx->trace_enable = trace;
-            if (err < 0)
-                return err;
-        }
-    }
-#endif
-
-    return 0;
-}
diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c
index 39b2bd1..82fcda9 100644
--- a/libavcodec/cdxl.c
+++ b/libavcodec/cdxl.c
@@ -41,7 +41,6 @@
 typedef struct CDXLVideoContext {
     AVCodecContext *avctx;
     int            bpp;
-    int            type;
     int            format;
     int            padded_bits;
     const uint8_t  *palette;
@@ -64,19 +63,14 @@
 
 static void import_palette(CDXLVideoContext *c, uint32_t *new_palette)
 {
-    if (c->type == 1) {
-        for (int i = 0; i < c->palette_size / 2; i++) {
-            unsigned rgb = AV_RB16(&c->palette[i * 2]);
-            unsigned r   = ((rgb >> 8) & 0xF) * 0x11;
-            unsigned g   = ((rgb >> 4) & 0xF) * 0x11;
-            unsigned b   =  (rgb       & 0xF) * 0x11;
-            AV_WN32(&new_palette[i], (0xFFU << 24) | (r << 16) | (g << 8) | b);
-        }
-    } else {
-        for (int i = 0; i < c->palette_size / 3; i++) {
-            unsigned rgb = AV_RB24(&c->palette[i * 3]);
-            AV_WN32(&new_palette[i], (0xFFU << 24) | rgb);
-        }
+    int i;
+
+    for (i = 0; i < c->palette_size / 2; i++) {
+        unsigned rgb = AV_RB16(&c->palette[i * 2]);
+        unsigned r   = ((rgb >> 8) & 0xF) * 0x11;
+        unsigned g   = ((rgb >> 4) & 0xF) * 0x11;
+        unsigned b   =  (rgb       & 0xF) * 0x11;
+        AV_WN32(&new_palette[i], (0xFFU << 24) | (r << 16) | (g << 8) | b);
     }
 }
 
@@ -250,7 +244,6 @@
 
     if (buf_size < 32)
         return AVERROR_INVALIDDATA;
-    c->type         = buf[0];
     encoding        = buf[1] & 7;
     c->format       = buf[1] & 0xE0;
     w               = AV_RB16(&buf[14]);
@@ -261,11 +254,7 @@
     c->video        = c->palette + c->palette_size;
     c->video_size   = buf_size - c->palette_size - 32;
 
-    if (c->type > 1)
-        return AVERROR_INVALIDDATA;
-    if (c->type == 1 && c->palette_size > 512)
-        return AVERROR_INVALIDDATA;
-    if (c->type == 0 && c->palette_size > 768)
+    if (c->palette_size > 512)
         return AVERROR_INVALIDDATA;
     if (buf_size < c->palette_size + 32)
         return AVERROR_INVALIDDATA;
diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index 920995a..a96b1ae 100644
--- a/libavcodec/celp_math.c
+++ b/libavcodec/celp_math.c
@@ -29,7 +29,6 @@
 #include "celp_math.h"
 #include "libavutil/common.h"
 
-#ifdef G729_BITEXACT
 static const uint16_t exp2a[]=
 {
      0,  1435,  2901,  4400,  5931,  7496,  9096, 10730,
@@ -55,7 +54,6 @@
     result= (result<<3) + ((result*exp2b[(power>>5)&31])>>17);
     return result + ((result*(power&31)*89)>>22);
 }
-#endif
 
 /**
  * Table used to compute log2(x)
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index dfd56ae..a2b9c7c 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -436,7 +436,7 @@
             }
             init_plane_defaults(s);
         } else if (tag == SubbandNumber) {
-            if (s->subband_num != 0 && data == 1 && (s->transform_type == 0 || s->transform_type == 2))  // hack
+            if (s->subband_num != 0 && data == 1)  // hack
                 s->level++;
             av_log(avctx, AV_LOG_DEBUG, "Subband number %"PRIu16"\n", data);
             s->subband_num = data;
@@ -617,12 +617,6 @@
             s->peak.level   = 0;
         } else if (tag == -PeakLevel && s->peak.offset) {
             s->peak.level = data;
-            if (s->peak.offset < 4 - bytestream2_tell(&s->peak.base) ||
-                s->peak.offset > 4 + bytestream2_get_bytes_left(&s->peak.base)
-            ) {
-                ret = AVERROR_INVALIDDATA;
-                goto end;
-            }
             bytestream2_seek(&s->peak.base, s->peak.offset - 4, SEEK_CUR);
         } else
             av_log(avctx, AV_LOG_DEBUG,  "Unknown tag %i data %x\n", tag, data);
@@ -1378,12 +1372,6 @@
     if (dst == src || psrc->transform_type == 0)
         return 0;
 
-    if (pdst->plane[0].idwt_size != psrc->plane[0].idwt_size ||
-        pdst->a_format != psrc->a_format ||
-        pdst->a_width != psrc->a_width ||
-        pdst->a_height != psrc->a_height)
-        free_buffers(pdst);
-
     pdst->a_format = psrc->a_format;
     pdst->a_width  = psrc->a_width;
     pdst->a_height = psrc->a_height;
diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 42bbf99..5554bae 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -33,7 +33,6 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "cfhd.h"
-#include "cfhdencdsp.h"
 #include "put_bits.h"
 #include "internal.h"
 #include "thread.h"
@@ -240,8 +239,6 @@
     Runbook  rb[321];
     Codebook cb[513];
     int16_t *alpha;
-
-    CFHDEncDSPContext dsp;
 } CFHDEncContext;
 
 static av_cold int cfhd_encode_init(AVCodecContext *avctx)
@@ -270,10 +267,10 @@
         int width  = i ? avctx->width >> s->chroma_h_shift : avctx->width;
         int height = i ? FFALIGN(avctx->height >> s->chroma_v_shift, 8) :
                          FFALIGN(avctx->height >> s->chroma_v_shift, 8);
-        ptrdiff_t stride = (FFALIGN(width / 8, 8) + 64) * 8;
+        ptrdiff_t stride = FFALIGN(width / 8, 8) * 8;
 
-        w8 = FFALIGN(width / 8, 8) + 64;
-        h8 = FFALIGN(height, 8) / 8;
+        w8 = FFALIGN(width / 8, 8);
+        h8 = height / 8;
         w4 = w8 * 2;
         h4 = h8 * 2;
         w2 = w4 * 2;
@@ -362,8 +359,6 @@
             s->lut[i] = last;
     }
 
-    ff_cfhdencdsp_init(&s->dsp);
-
     if (s->planes != 4)
         return 0;
 
@@ -374,6 +369,42 @@
     return 0;
 }
 
+static av_always_inline void filter(int16_t *input, ptrdiff_t in_stride,
+                          int16_t *low, ptrdiff_t low_stride,
+                          int16_t *high, ptrdiff_t high_stride,
+                          int len)
+{
+    low[(0>>1) * low_stride]   = av_clip_int16(input[0*in_stride] + input[1*in_stride]);
+    high[(0>>1) * high_stride] = av_clip_int16((5 * input[0*in_stride] - 11 * input[1*in_stride] +
+                                                4 * input[2*in_stride] +  4 * input[3*in_stride] -
+                                                1 * input[4*in_stride] -  1 * input[5*in_stride] + 4) >> 3);
+
+    for (int i = 2; i < len - 2; i += 2) {
+        low[(i>>1) * low_stride]   = av_clip_int16(input[i*in_stride] + input[(i+1)*in_stride]);
+        high[(i>>1) * high_stride] = av_clip_int16(((-input[(i-2)*in_stride] - input[(i-1)*in_stride] +
+                                                      input[(i+2)*in_stride] + input[(i+3)*in_stride] + 4) >> 3) +
+                                                      input[(i+0)*in_stride] - input[(i+1)*in_stride]);
+    }
+
+    low[((len-2)>>1) * low_stride]   = av_clip_int16(input[((len-2)+0)*in_stride] + input[((len-2)+1)*in_stride]);
+    high[((len-2)>>1) * high_stride] = av_clip_int16((11* input[((len-2)+0)*in_stride] - 5 * input[((len-2)+1)*in_stride] -
+                                                      4 * input[((len-2)-1)*in_stride] - 4 * input[((len-2)-2)*in_stride] +
+                                                      1 * input[((len-2)-3)*in_stride] + 1 * input[((len-2)-4)*in_stride] + 4) >> 3);
+}
+
+static void horiz_filter(int16_t *input, int16_t *low, int16_t *high,
+                         int width)
+{
+    filter(input, 1, low, 1, high, 1, width);
+}
+
+static void vert_filter(int16_t *input, ptrdiff_t in_stride,
+                        int16_t *low, ptrdiff_t low_stride,
+                        int16_t *high, ptrdiff_t high_stride, int len)
+{
+    filter(input, in_stride, low, low_stride, high, high_stride, len);
+}
+
 static void quantize_band(int16_t *input, int width, int a_width,
                           int height, unsigned quantization)
 {
@@ -423,7 +454,6 @@
                              const AVFrame *frame, int *got_packet)
 {
     CFHDEncContext *s = avctx->priv_data;
-    CFHDEncDSPContext *dsp = &s->dsp;
     PutByteContext *pby = &s->pby;
     PutBitContext *pb = &s->pb;
     const Codebook *const cb = s->cb;
@@ -450,9 +480,12 @@
             in_stride = avctx->width;
         }
 
-        dsp->horiz_filter(input, low, high,
-                          in_stride, a_width, a_width,
-                          width * 2, height * 2);
+        for (int i = 0; i < height * 2; i++) {
+            horiz_filter(input, low, high, width * 2);
+            input += in_stride;
+            low += a_width;
+            high += a_width;
+        }
 
         input = s->plane[plane].l_h[7];
         low = s->plane[plane].subband[7];
@@ -460,17 +493,23 @@
         high = s->plane[plane].subband[9];
         high_stride = s->plane[plane].band[2][0].a_width;
 
-        dsp->vert_filter(input, low, high,
-                         a_width, low_stride, high_stride,
-                         width, height * 2);
+        for (int i = 0; i < width; i++) {
+            vert_filter(input, a_width, low, low_stride, high, high_stride, height * 2);
+            input++;
+            low++;
+            high++;
+        }
 
         input = s->plane[plane].l_h[6];
         low = s->plane[plane].l_h[7];
         high = s->plane[plane].subband[8];
 
-        dsp->vert_filter(input, low, high,
-                         a_width, low_stride, high_stride,
-                         width, height * 2);
+        for (int i = 0; i < width; i++) {
+            vert_filter(input, a_width, low, low_stride, high, high_stride, height * 2);
+            input++;
+            low++;
+            high++;
+        }
 
         a_width = s->plane[plane].band[1][0].a_width;
         width = s->plane[plane].band[1][0].width;
@@ -488,25 +527,34 @@
         }
 
         input = s->plane[plane].l_h[7];
-        dsp->horiz_filter(input, low, high,
-                          a_width * 2, low_stride, high_stride,
-                          width * 2, height * 2);
+        for (int i = 0; i < height * 2; i++) {
+            horiz_filter(input, low, high, width * 2);
+            input += a_width * 2;
+            low += low_stride;
+            high += high_stride;
+        }
 
         input = s->plane[plane].l_h[4];
         low = s->plane[plane].subband[4];
         high = s->plane[plane].subband[6];
 
-        dsp->vert_filter(input, low, high,
-                         a_width, low_stride, high_stride,
-                         width, height * 2);
+        for (int i = 0; i < width; i++) {
+            vert_filter(input, a_width, low, low_stride, high, high_stride, height * 2);
+            input++;
+            low++;
+            high++;
+        }
 
         input = s->plane[plane].l_h[3];
         low = s->plane[plane].l_h[4];
         high = s->plane[plane].subband[5];
 
-        dsp->vert_filter(input, low, high,
-                         a_width, low_stride, high_stride,
-                         width, height * 2);
+        for (int i = 0; i < width; i++) {
+            vert_filter(input, a_width, low, low_stride, high, high_stride, height * 2);
+            input++;
+            low++;
+            high++;
+        }
 
         a_width = s->plane[plane].band[0][0].a_width;
         width = s->plane[plane].band[0][0].width;
@@ -526,25 +574,34 @@
         }
 
         input = s->plane[plane].l_h[4];
-        dsp->horiz_filter(input, low, high,
-                          a_width * 2, low_stride, high_stride,
-                          width * 2, height * 2);
+        for (int i = 0; i < height * 2; i++) {
+            horiz_filter(input, low, high, width * 2);
+            input += a_width * 2;
+            low += low_stride;
+            high += high_stride;
+        }
 
         low = s->plane[plane].subband[1];
         high = s->plane[plane].subband[3];
         input = s->plane[plane].l_h[1];
 
-        dsp->vert_filter(input, low, high,
-                         a_width, low_stride, high_stride,
-                         width, height * 2);
+        for (int i = 0; i < width; i++) {
+            vert_filter(input, a_width, low, low_stride, high, high_stride, height * 2);
+            input++;
+            low++;
+            high++;
+        }
 
         low = s->plane[plane].subband[0];
         high = s->plane[plane].subband[2];
         input = s->plane[plane].l_h[0];
 
-        dsp->vert_filter(input, low, high,
-                         a_width, low_stride, high_stride,
-                         width, height * 2);
+        for (int i = 0; i < width; i++) {
+            vert_filter(input, a_width, low, low_stride, high, high_stride, height * 2);
+            input++;
+            low++;
+            high++;
+        }
     }
 
     ret = ff_alloc_packet2(avctx, pkt, 64LL + s->planes * (2LL * avctx->width * avctx->height + 1000LL), 0);
@@ -593,7 +650,7 @@
     bytestream2_put_be16(pby, avctx->height);
 
     bytestream2_put_be16(pby, -FrameNumber);
-    bytestream2_put_be16(pby, frame->pts & 0xFFFF);
+    bytestream2_put_be16(pby, avctx->frame_number);
 
     bytestream2_put_be16(pby, Precision);
     bytestream2_put_be16(pby, avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12);
@@ -742,7 +799,7 @@
 
                 for (int m = 0; m < height; m++) {
                     for (int j = 0; j < stride; j++) {
-                        int16_t index = j >= width ? 0 : FFSIGN(data[j]) * lut[FFABS(data[j])];
+                        int16_t index = FFSIGN(data[j]) * lut[FFABS(data[j])];
 
                         if (index < 0)
                             index += 512;
diff --git a/libavcodec/cfhdencdsp.c b/libavcodec/cfhdencdsp.c
deleted file mode 100644
index b979e9e..0000000
--- a/libavcodec/cfhdencdsp.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2015-2016 Kieran Kunhya <kieran@kunhya.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavutil/common.h"
-#include "libavutil/avassert.h"
-
-#include "cfhdencdsp.h"
-
-static av_always_inline void filter(int16_t *input, ptrdiff_t in_stride,
-                          int16_t *low, ptrdiff_t low_stride,
-                          int16_t *high, ptrdiff_t high_stride,
-                          int len)
-{
-    low[(0>>1) * low_stride]   = av_clip_int16(input[0*in_stride] + input[1*in_stride]);
-    high[(0>>1) * high_stride] = av_clip_int16((5 * input[0*in_stride] - 11 * input[1*in_stride] +
-                                                4 * input[2*in_stride] +  4 * input[3*in_stride] -
-                                                1 * input[4*in_stride] -  1 * input[5*in_stride] + 4) >> 3);
-
-    for (int i = 2; i < len - 2; i += 2) {
-        low[(i>>1) * low_stride]   = av_clip_int16(input[i*in_stride] + input[(i+1)*in_stride]);
-        high[(i>>1) * high_stride] = av_clip_int16(((-input[(i-2)*in_stride] - input[(i-1)*in_stride] +
-                                                      input[(i+2)*in_stride] + input[(i+3)*in_stride] + 4) >> 3) +
-                                                      input[(i+0)*in_stride] - input[(i+1)*in_stride]);
-    }
-
-    low[((len-2)>>1) * low_stride]   = av_clip_int16(input[((len-2)+0)*in_stride] + input[((len-2)+1)*in_stride]);
-    high[((len-2)>>1) * high_stride] = av_clip_int16((11* input[((len-2)+0)*in_stride] - 5 * input[((len-2)+1)*in_stride] -
-                                                      4 * input[((len-2)-1)*in_stride] - 4 * input[((len-2)-2)*in_stride] +
-                                                      1 * input[((len-2)-3)*in_stride] + 1 * input[((len-2)-4)*in_stride] + 4) >> 3);
-}
-
-static void horiz_filter(int16_t *input, int16_t *low, int16_t *high,
-                         ptrdiff_t in_stride, ptrdiff_t low_stride,
-                         ptrdiff_t high_stride,
-                         int width, int height)
-{
-    for (int i = 0; i < height; i++) {
-        filter(input, 1, low, 1, high, 1, width);
-        input += in_stride;
-        low += low_stride;
-        high += high_stride;
-    }
-}
-
-static void vert_filter(int16_t *input, int16_t *low, int16_t *high,
-                        ptrdiff_t in_stride, ptrdiff_t low_stride,
-                        ptrdiff_t high_stride,
-                        int width, int height)
-{
-    for (int i = 0; i < width; i++)
-        filter(&input[i], in_stride, &low[i], low_stride, &high[i], high_stride, height);
-}
-
-av_cold void ff_cfhdencdsp_init(CFHDEncDSPContext *c)
-{
-    c->horiz_filter = horiz_filter;
-    c->vert_filter = vert_filter;
-
-    if (ARCH_X86)
-        ff_cfhdencdsp_init_x86(c);
-}
diff --git a/libavcodec/cfhdencdsp.h b/libavcodec/cfhdencdsp.h
deleted file mode 100644
index b3aac8d..0000000
--- a/libavcodec/cfhdencdsp.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_CFHDENCDSP_H
-#define AVCODEC_CFHDENCDSP_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-typedef struct CFHDEncDSPContext {
-    void (*horiz_filter)(int16_t *input, int16_t *low, int16_t *high,
-                         ptrdiff_t in_stride, ptrdiff_t low_stride,
-                         ptrdiff_t high_stride,
-                         int width, int height);
-
-    void (*vert_filter)(int16_t *input, int16_t *low, int16_t *high,
-                        ptrdiff_t in_stride, ptrdiff_t low_stride,
-                        ptrdiff_t high_stride,
-                        int width, int height);
-} CFHDEncDSPContext;
-
-void ff_cfhdencdsp_init(CFHDEncDSPContext *c);
-
-void ff_cfhdencdsp_init_x86(CFHDEncDSPContext *c);
-
-#endif /* AVCODEC_CFHDENCDSP_H */
diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index d70cb4b..17148a3 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -477,7 +477,7 @@
         return ret;
 
     if (s->palette_video) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
         if (pal && size == AVPALETTE_SIZE) {
             s->frame->palette_has_changed = 1;
diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index 4c9b961..9eaa972 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -182,7 +182,7 @@
         return AVERROR(ENOMEM);
 
     if (!(s->codebook_closest = av_malloc_array((avctx->width * avctx->height) >> 2, sizeof(*s->codebook_closest))))
-        return AVERROR(ENOMEM);
+        return AVERROR(ENOMEM);;
 
     for (x = 0; x < (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 4 : 3); x++)
         if (!(s->pict_bufs[x] = av_malloc((avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4) * (avctx->width * avctx->height) >> 2)))
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 79ba888..7342557 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -24,7 +24,6 @@
  * ClearVideo decoder
  */
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/codec.h b/libavcodec/codec.h
index 729df0e..0ccbf0e 100644
--- a/libavcodec/codec.h
+++ b/libavcodec/codec.h
@@ -259,7 +259,7 @@
     const AVCodecDefault *defaults;
 
     /**
-     * Initialize codec static data, called from av_codec_iterate().
+     * Initialize codec static data, called from avcodec_register().
      *
      * This is not intended for time consuming operations as it is
      * run for every codec regardless of that codec being used.
@@ -273,7 +273,7 @@
      * Encode data to an AVPacket.
      *
      * @param      avctx          codec context
-     * @param      avpkt          output AVPacket
+     * @param      avpkt          output AVPacket (may contain a user-provided buffer)
      * @param[in]  frame          AVFrame containing the raw data to be encoded
      * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
      *                            non-empty packet was returned in avpkt.
@@ -281,20 +281,7 @@
      */
     int (*encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt,
                    const struct AVFrame *frame, int *got_packet_ptr);
-    /**
-     * Decode picture or subtitle data.
-     *
-     * @param      avctx          codec context
-     * @param      outdata        codec type dependent output struct
-     * @param[out] got_frame_ptr  decoder sets to 0 or 1 to indicate that a
-     *                            non-empty frame or subtitle was returned in
-     *                            outdata.
-     * @param[in]  avpkt          AVPacket containing the data to be decoded
-     * @return amount of bytes read from the packet on success, negative error
-     *         code on failure
-     */
-    int (*decode)(struct AVCodecContext *avctx, void *outdata,
-                  int *got_frame_ptr, struct AVPacket *avpkt);
+    int (*decode)(struct AVCodecContext *, void *outdata, int *outdata_size, struct AVPacket *avpkt);
     int (*close)(struct AVCodecContext *);
     /**
      * Encode API with decoupled frame/packet dataflow. This function is called
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 17f8a14..404c460 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1427,14 +1427,6 @@
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
     },
     {
-        .id        = AV_CODEC_ID_VVC,
-        .type      = AVMEDIA_TYPE_VIDEO,
-        .name      = "vvc",
-        .long_name = NULL_IF_CONFIG_SMALL("H.266 / VVC (Versatile Video Coding)"),
-        .props     = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
-        .profiles  = NULL_IF_CONFIG_SMALL(ff_vvc_profiles),
-    },
-    {
         .id        = AV_CODEC_ID_Y41P,
         .type      = AVMEDIA_TYPE_VIDEO,
         .name      = "y41p",
@@ -1842,20 +1834,6 @@
         .long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
     },
-    {
-        .id        = AV_CODEC_ID_SIMBIOSIS_IMX,
-        .type      = AVMEDIA_TYPE_VIDEO,
-        .name      = "simbiosis_imx",
-        .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"),
-        .props     = AV_CODEC_PROP_LOSSY,
-    },
-    {
-        .id        = AV_CODEC_ID_SGA_VIDEO,
-        .type      = AVMEDIA_TYPE_VIDEO,
-        .name      = "sga",
-        .long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
-        .props     = AV_CODEC_PROP_LOSSY,
-    },
 
     /* various PCM "codecs" */
     {
@@ -2103,13 +2081,6 @@
         .long_name = NULL_IF_CONFIG_SMALL("PCM Archimedes VIDC"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
     },
-    {
-        .id        = AV_CODEC_ID_PCM_SGA,
-        .type      = AVMEDIA_TYPE_AUDIO,
-        .name      = "pcm_sga",
-        .long_name = NULL_IF_CONFIG_SMALL("PCM SGA"),
-        .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
-    },
 
     /* various ADPCM codecs */
     {
@@ -3475,13 +3446,6 @@
         .mime_types= MT("application/octet-stream"),
     },
     {
-        .id        = AV_CODEC_ID_MPEG2TS,
-        .type      = AVMEDIA_TYPE_DATA,
-        .name      = "mpegts",
-        .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-TS stream"),
-        .mime_types= MT("application/MP2T"),
-    },
-    {
         .id        = AV_CODEC_ID_WRAPPED_AVFRAME,
         .type      = AVMEDIA_TYPE_VIDEO,
         .name      = "wrapped_avframe",
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index ab7bc68..6133e03 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -244,8 +244,6 @@
     AV_CODEC_ID_PGX,
     AV_CODEC_ID_AVS3,
     AV_CODEC_ID_MSP2,
-    AV_CODEC_ID_VVC,
-#define AV_CODEC_ID_H266 AV_CODEC_ID_VVC
 
     AV_CODEC_ID_Y41P = 0x8000,
     AV_CODEC_ID_AVRP,
@@ -305,8 +303,6 @@
     AV_CODEC_ID_IPU,
     AV_CODEC_ID_ARGO,
     AV_CODEC_ID_CRI,
-    AV_CODEC_ID_SIMBIOSIS_IMX,
-    AV_CODEC_ID_SGA_VIDEO,
 
     /* various PCM "codecs" */
     AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
@@ -347,7 +343,6 @@
     AV_CODEC_ID_PCM_F16LE,
     AV_CODEC_ID_PCM_F24LE,
     AV_CODEC_ID_PCM_VIDC,
-    AV_CODEC_ID_PCM_SGA,
 
     /* various ADPCM codecs */
     AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index a9de3c8..1968f2f 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -44,7 +44,6 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/lfg.h"
-#include "libavutil/mem_internal.h"
 
 #include "audiodsp.h"
 #include "avcodec.h"
diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
index 5f12a99..bf09e1a 100644
--- a/libavcodec/cpia.c
+++ b/libavcodec/cpia.c
@@ -230,5 +230,4 @@
     .close          = cpia_decode_end,
     .decode         = cpia_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index 3312606..5234f49 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -80,13 +80,10 @@
     int pos = 0;
 
     while (count > 0) {
-        uint32_t a0, a1, a2, a3;
-        if (bytestream2_get_bytes_left(gb) < 4)
-            break;
-        a0 = bytestream2_get_le32(gb);
-        a1 = bytestream2_get_le32(gb);
-        a2 = bytestream2_get_le32(gb);
-        a3 = bytestream2_get_le32(gb);
+        uint32_t a0 = bytestream2_get_le32(gb);
+        uint32_t a1 = bytestream2_get_le32(gb);
+        uint32_t a2 = bytestream2_get_le32(gb);
+        uint32_t a3 = bytestream2_get_le32(gb);
         dst[pos] = (((a0 >> 1) & 0xE00) | (a0 & 0x1FF)) << shift;
         pos++;
         if (pos >= w) {
@@ -184,7 +181,6 @@
         char codec_name[1024];
         uint32_t key, length;
         float framerate;
-        int width, height;
 
         key    = bytestream2_get_le32(gb);
         length = bytestream2_get_le32(gb);
@@ -200,14 +196,11 @@
         case 100:
             if (length < 16)
                 return AVERROR_INVALIDDATA;
-            width   = bytestream2_get_le32(gb);
-            height  = bytestream2_get_le32(gb);
+            avctx->width   = bytestream2_get_le32(gb);
+            avctx->height  = bytestream2_get_le32(gb);
             s->color_model = bytestream2_get_le32(gb);
             if (bytestream2_get_le32(gb) != 1)
                 return AVERROR_INVALIDDATA;
-            ret = ff_set_dimensions(avctx, width, height);
-            if (ret < 0)
-                return ret;
             length -= 16;
             goto skip;
         case 101:
@@ -335,9 +328,6 @@
         for (int y = 0; y < avctx->height; y++) {
             uint16_t *dst = (uint16_t *)(p->data[0] + y * p->linesize[0]);
 
-            if (get_bits_left(&gbit) < avctx->width * bps)
-                break;
-
             for (int x = 0; x < avctx->width; x++)
                 dst[x] = get_bits(&gbit, bps) << shift;
         }
diff --git a/libavcodec/cri_parser.c b/libavcodec/cri_parser.c
deleted file mode 100644
index 9790747..0000000
--- a/libavcodec/cri_parser.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * CRI parser
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * CRI parser
- */
-
-#include "libavutil/bswap.h"
-#include "libavutil/common.h"
-
-#include "parser.h"
-
-typedef struct CRIParser {
-    ParseContext pc;
-    int count;
-    int chunk;
-    int read_bytes;
-    int skip_bytes;
-} CRIParser;
-
-#define KEY (((uint64_t)'\1' << 56) | ((uint64_t)'\0' << 48) | \
-             ((uint64_t)'\0' << 40) | ((uint64_t)'\0' << 32) | \
-             ((uint64_t)'\4' << 24) | ((uint64_t)'\0' << 16) | \
-             ((uint64_t)'\0' <<  8) | ((uint64_t)'\0' <<  0))
-
-static int cri_parse(AVCodecParserContext *s, AVCodecContext *avctx,
-                     const uint8_t **poutbuf, int *poutbuf_size,
-                     const uint8_t *buf, int buf_size)
-{
-    CRIParser *bpc = s->priv_data;
-    uint64_t state = bpc->pc.state64;
-    int next = END_NOT_FOUND, i = 0;
-
-    s->pict_type = AV_PICTURE_TYPE_I;
-    s->key_frame = 1;
-    s->duration  = 1;
-
-    *poutbuf_size = 0;
-    *poutbuf = NULL;
-
-    for (; i < buf_size; i++) {
-        state = (state << 8) | buf[i];
-        bpc->read_bytes++;
-
-        if (bpc->skip_bytes > 0) {
-            bpc->skip_bytes--;
-            if (bpc->skip_bytes == 0)
-                bpc->read_bytes = 0;
-        } else {
-            if (state != KEY)
-                continue;
-        }
-
-        if (bpc->skip_bytes == 0 && bpc->read_bytes >= 8) {
-            bpc->skip_bytes = av_bswap32(state & 0xFFFFFFFF);
-            bpc->chunk = state >> 32;
-            bpc->read_bytes = 0;
-            bpc->count++;
-        }
-
-        if (bpc->chunk == 0x01000000 && bpc->skip_bytes == 4 &&
-            bpc->read_bytes == 0 && bpc->count > 1) {
-            next = i - 7;
-            break;
-        }
-    }
-
-    bpc->pc.state64 = state;
-    if (ff_combine_frame(&bpc->pc, next, &buf, &buf_size) < 0) {
-        *poutbuf = NULL;
-        *poutbuf_size = 0;
-        return buf_size;
-    }
-
-    *poutbuf      = buf;
-    *poutbuf_size = buf_size;
-
-    return next;
-}
-
-AVCodecParser ff_cri_parser = {
-    .codec_ids      = { AV_CODEC_ID_CRI },
-    .priv_data_size = sizeof(CRIParser),
-    .parser_parse   = cri_parse,
-    .parser_close   = ff_parse_close,
-};
diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c
index f5c93e9..d50ddd6 100644
--- a/libavcodec/cscd.c
+++ b/libavcodec/cscd.c
@@ -93,7 +93,7 @@
     case 1: { // zlib compression
 #if CONFIG_ZLIB
         unsigned long dlen = c->decomp_size;
-        if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK || dlen != c->decomp_size) {
+        if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK) {
             av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
             return AVERROR_INVALIDDATA;
         }
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index ec57afd..61d7f36 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -553,12 +553,6 @@
 
             tmp_frame->format        = AV_PIX_FMT_CUDA;
             tmp_frame->hw_frames_ctx = av_buffer_ref(ctx->hwframe);
-            if (!tmp_frame->hw_frames_ctx) {
-                ret = AVERROR(ENOMEM);
-                av_frame_free(&tmp_frame);
-                goto error;
-            }
-
             tmp_frame->width         = avctx->width;
             tmp_frame->height        = avctx->height;
 
@@ -634,9 +628,6 @@
     }
 
 error:
-    if (ret < 0)
-        av_frame_unref(frame);
-
     if (mapped_frame)
         eret = CHECK_CU(ctx->cvdl->cuvidUnmapVideoFrame(ctx->cudecoder, mapped_frame));
 
@@ -999,7 +990,7 @@
     }
 
     ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
-    ctx->cuparseinfo.ulMaxDisplayDelay = (avctx->flags & AV_CODEC_FLAG_LOW_DELAY) ? 0 : 4;
+    ctx->cuparseinfo.ulMaxDisplayDelay = 4;
     ctx->cuparseinfo.pUserData = avctx;
     ctx->cuparseinfo.pfnSequenceCallback = cuvid_handle_video_sequence;
     ctx->cuparseinfo.pfnDecodePicture = cuvid_handle_picture_decode;
diff --git a/libavcodec/dca_core.h b/libavcodec/dca_core.h
index 86bfa62..10128d1 100644
--- a/libavcodec/dca_core.h
+++ b/libavcodec/dca_core.h
@@ -24,7 +24,7 @@
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 2f8060d..747fdaf 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -21,7 +21,6 @@
 #define BITSTREAM_READER_LE
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem_internal.h"
 
 #include "dcadec.h"
 #include "dcadata.h"
diff --git a/libavcodec/dca_lbr.h b/libavcodec/dca_lbr.h
index e6856a2..6d4c0a8 100644
--- a/libavcodec/dca_lbr.h
+++ b/libavcodec/dca_lbr.h
@@ -23,7 +23,7 @@
 
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index 3aaad6d..bc0aa65 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -22,7 +22,7 @@
 #define AVCODEC_DCA_XLL_H
 
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c
index 643b0cc..1b646a7 100644
--- a/libavcodec/dcadata.c
+++ b/libavcodec/dcadata.c
@@ -22,7 +22,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #include "dca.h"
 #include "dcadata.h"
diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c
index 9d00ebd..fade1a6 100644
--- a/libavcodec/dcadsp.c
+++ b/libavcodec/dcadsp.c
@@ -19,7 +19,6 @@
  */
 
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 
 #include "dcadsp.h"
 #include "dcamath.h"
@@ -329,7 +328,7 @@
     int i;
 
     for (i = 0; i < len; i++)
-        dst[i] += (unsigned)mul15(src[i], coeff);
+        dst[i] += mul15(src[i], coeff);
 }
 
 static void dmix_scale_c(int32_t *dst, int scale, ptrdiff_t len)
diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index a40d2e0..34b3e94 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -28,7 +28,6 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/ffmath.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "dca.h"
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c7dbf7b..5a1849f 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -43,6 +43,7 @@
 #include "decode.h"
 #include "hwconfig.h"
 #include "internal.h"
+#include "packet_internal.h"
 #include "thread.h"
 
 typedef struct FramePool {
@@ -66,8 +67,7 @@
 
 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
 {
-    int ret;
-    buffer_size_t size;
+    int size, ret;
     const uint8_t *data;
     uint32_t flags;
     int64_t val;
@@ -145,42 +145,68 @@
 
 #define IS_EMPTY(pkt) (!(pkt)->data)
 
-static int copy_packet_props(AVPacket *dst, const AVPacket *src)
+static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt)
 {
-    int ret = av_packet_copy_props(dst, src);
-    if (ret < 0)
-        return ret;
-
-    dst->size = src->size; // HACK: Needed for ff_decode_frame_props().
-    dst->data = (void*)1;  // HACK: Needed for IS_EMPTY().
-
-    return 0;
-}
-
-static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
-{
-    AVPacket tmp = { 0 };
     int ret = 0;
 
+    ret = avpriv_packet_list_put(&avci->pkt_props, &avci->pkt_props_tail, pkt,
+                                 av_packet_copy_props, 0);
+    if (ret < 0)
+        return ret;
+    avci->pkt_props_tail->pkt.size = pkt->size; // HACK: Needed for ff_decode_frame_props().
+    avci->pkt_props_tail->pkt.data = (void*)1;  // HACK: Needed for IS_EMPTY().
+
     if (IS_EMPTY(avci->last_pkt_props)) {
-        if (av_fifo_size(avci->pkt_props) >= sizeof(*pkt)) {
-            av_fifo_generic_read(avci->pkt_props, avci->last_pkt_props,
-                                 sizeof(*avci->last_pkt_props), NULL);
-        } else
-            return copy_packet_props(avci->last_pkt_props, pkt);
+        ret = avpriv_packet_list_get(&avci->pkt_props,
+                                     &avci->pkt_props_tail,
+                                     avci->last_pkt_props);
+        av_assert0(ret != AVERROR(EAGAIN));
     }
+    return ret;
+}
 
-    if (av_fifo_space(avci->pkt_props) < sizeof(*pkt)) {
-        ret = av_fifo_grow(avci->pkt_props, sizeof(*pkt));
-        if (ret < 0)
-            return ret;
-    }
+static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
+{
+    int ret;
 
-    ret = copy_packet_props(&tmp, pkt);
+    /* move the original frame to our backup */
+    av_frame_unref(avci->to_free);
+    av_frame_move_ref(avci->to_free, frame);
+
+    /* now copy everything except the AVBufferRefs back
+     * note that we make a COPY of the side data, so calling av_frame_free() on
+     * the caller's frame will work properly */
+    ret = av_frame_copy_props(frame, avci->to_free);
     if (ret < 0)
         return ret;
 
-    av_fifo_generic_write(avci->pkt_props, &tmp, sizeof(tmp), NULL);
+    memcpy(frame->data,     avci->to_free->data,     sizeof(frame->data));
+    memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
+    if (avci->to_free->extended_data != avci->to_free->data) {
+        int planes = avci->to_free->channels;
+        int size   = planes * sizeof(*frame->extended_data);
+
+        if (!size) {
+            av_frame_unref(frame);
+            return AVERROR_BUG;
+        }
+
+        frame->extended_data = av_malloc(size);
+        if (!frame->extended_data) {
+            av_frame_unref(frame);
+            return AVERROR(ENOMEM);
+        }
+        memcpy(frame->extended_data, avci->to_free->extended_data,
+               size);
+    } else
+        frame->extended_data = frame->data;
+
+    frame->format         = avci->to_free->format;
+    frame->width          = avci->to_free->width;
+    frame->height         = avci->to_free->height;
+    frame->channel_layout = avci->to_free->channel_layout;
+    frame->nb_samples     = avci->to_free->nb_samples;
+    frame->channels       = avci->to_free->channels;
 
     return 0;
 }
@@ -241,10 +267,8 @@
     if (ret < 0)
         goto finish;
 
-#if FF_API_OLD_ENCDEC
     if (avctx->codec->receive_frame)
         avci->compat_decode_consumed += pkt->size;
-#endif
 
     return 0;
 finish:
@@ -348,14 +372,21 @@
     if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
         if (frame->flags & AV_FRAME_FLAG_DISCARD)
             got_frame = 0;
+        if (got_frame)
+            frame->best_effort_timestamp = guess_correct_pts(avctx,
+                                                             frame->pts,
+                                                             frame->pkt_dts);
     } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
         uint8_t *side;
-        buffer_size_t side_size;
+        int side_size;
         uint32_t discard_padding = 0;
         uint8_t skip_reason = 0;
         uint8_t discard_reason = 0;
 
         if (ret >= 0 && got_frame) {
+            frame->best_effort_timestamp = guess_correct_pts(avctx,
+                                                             frame->pts,
+                                                             frame->pkt_dts);
             if (frame->format == AV_SAMPLE_FMT_NONE)
                 frame->format = avctx->sample_fmt;
             if (!frame->channel_layout)
@@ -491,9 +522,7 @@
         }
     }
 
-#if FF_API_OLD_ENCDEC
     avci->compat_decode_consumed += ret;
-#endif
 
     if (ret >= pkt->size || ret < 0) {
         av_packet_unref(pkt);
@@ -550,10 +579,6 @@
         avci->draining_done = 1;
 
     if (!ret) {
-        frame->best_effort_timestamp = guess_correct_pts(avctx,
-                                                         frame->pts,
-                                                         frame->pkt_dts);
-
         /* the only case where decode data is not set should be decoders
          * that do not call ff_get_buffer() */
         av_assert0((frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) ||
@@ -717,54 +742,6 @@
     return 0;
 }
 
-#if FF_API_OLD_ENCDEC
-FF_DISABLE_DEPRECATION_WARNINGS
-static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
-{
-    int ret;
-
-    /* move the original frame to our backup */
-    av_frame_unref(avci->to_free);
-    av_frame_move_ref(avci->to_free, frame);
-
-    /* now copy everything except the AVBufferRefs back
-     * note that we make a COPY of the side data, so calling av_frame_free() on
-     * the caller's frame will work properly */
-    ret = av_frame_copy_props(frame, avci->to_free);
-    if (ret < 0)
-        return ret;
-
-    memcpy(frame->data,     avci->to_free->data,     sizeof(frame->data));
-    memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
-    if (avci->to_free->extended_data != avci->to_free->data) {
-        int planes = avci->to_free->channels;
-        int size   = planes * sizeof(*frame->extended_data);
-
-        if (!size) {
-            av_frame_unref(frame);
-            return AVERROR_BUG;
-        }
-
-        frame->extended_data = av_malloc(size);
-        if (!frame->extended_data) {
-            av_frame_unref(frame);
-            return AVERROR(ENOMEM);
-        }
-        memcpy(frame->extended_data, avci->to_free->extended_data,
-               size);
-    } else
-        frame->extended_data = frame->data;
-
-    frame->format         = avci->to_free->format;
-    frame->width          = avci->to_free->width;
-    frame->height         = avci->to_free->height;
-    frame->channel_layout = avci->to_free->channel_layout;
-    frame->nb_samples     = avci->to_free->nb_samples;
-    frame->channels       = avci->to_free->channels;
-
-    return 0;
-}
-
 static int compat_decode(AVCodecContext *avctx, AVFrame *frame,
                          int *got_frame, const AVPacket *pkt)
 {
@@ -860,8 +837,6 @@
 {
     return compat_decode(avctx, frame, got_frame_ptr, avpkt);
 }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 
 static void get_subtitle_defaults(AVSubtitle *sub)
 {
@@ -870,58 +845,55 @@
 }
 
 #define UTF8_MAX_BYTES 4 /* 5 and 6 bytes sequences should not be used */
-static int recode_subtitle(AVCodecContext *avctx, AVPacket **outpkt,
-                           AVPacket *inpkt, AVPacket *buf_pkt)
+static int recode_subtitle(AVCodecContext *avctx,
+                           AVPacket *outpkt, const AVPacket *inpkt)
 {
 #if CONFIG_ICONV
     iconv_t cd = (iconv_t)-1;
     int ret = 0;
     char *inb, *outb;
     size_t inl, outl;
+    AVPacket tmp;
 #endif
 
-    if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_PRE_DECODER || inpkt->size == 0) {
-        *outpkt = inpkt;
+    if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_PRE_DECODER || inpkt->size == 0)
         return 0;
-    }
 
 #if CONFIG_ICONV
+    cd = iconv_open("UTF-8", avctx->sub_charenc);
+    av_assert0(cd != (iconv_t)-1);
+
     inb = inpkt->data;
     inl = inpkt->size;
 
     if (inl >= INT_MAX / UTF8_MAX_BYTES - AV_INPUT_BUFFER_PADDING_SIZE) {
         av_log(avctx, AV_LOG_ERROR, "Subtitles packet is too big for recoding\n");
-        return AVERROR(ERANGE);
+        ret = AVERROR(ENOMEM);
+        goto end;
     }
 
-    cd = iconv_open("UTF-8", avctx->sub_charenc);
-    av_assert0(cd != (iconv_t)-1);
-
-    ret = av_new_packet(buf_pkt, inl * UTF8_MAX_BYTES);
+    ret = av_new_packet(&tmp, inl * UTF8_MAX_BYTES);
     if (ret < 0)
         goto end;
-    ret = av_packet_copy_props(buf_pkt, inpkt);
-    if (ret < 0)
-        goto end;
-    outb = buf_pkt->data;
-    outl = buf_pkt->size;
+    outpkt->buf  = tmp.buf;
+    outpkt->data = tmp.data;
+    outpkt->size = tmp.size;
+    outb = outpkt->data;
+    outl = outpkt->size;
 
     if (iconv(cd, &inb, &inl, &outb, &outl) == (size_t)-1 ||
         iconv(cd, NULL, NULL, &outb, &outl) == (size_t)-1 ||
-        outl >= buf_pkt->size || inl != 0) {
+        outl >= outpkt->size || inl != 0) {
         ret = FFMIN(AVERROR(errno), -1);
         av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
                "from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
+        av_packet_unref(&tmp);
         goto end;
     }
-    buf_pkt->size -= outl;
-    memset(buf_pkt->data + buf_pkt->size, 0, outl);
-    *outpkt = buf_pkt;
+    outpkt->size -= outl;
+    memset(outpkt->data + outpkt->size, 0, outl);
 
-    ret = 0;
 end:
-    if (ret < 0)
-        av_packet_unref(buf_pkt);
     if (cd != (iconv_t)-1)
         iconv_close(cd);
     return ret;
@@ -1027,7 +999,7 @@
                              int *got_sub_ptr,
                              AVPacket *avpkt)
 {
-    int ret = 0;
+    int i, ret = 0;
 
     if (!avpkt->data && avpkt->size) {
         av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
@@ -1044,60 +1016,69 @@
     get_subtitle_defaults(sub);
 
     if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) {
-        AVCodecInternal *avci = avctx->internal;
-        AVPacket *pkt;
+        AVPacket pkt_recoded = *avpkt;
 
-        ret = recode_subtitle(avctx, &pkt, avpkt, avci->buffer_pkt);
-        if (ret < 0)
-            return ret;
+        ret = recode_subtitle(avctx, &pkt_recoded, avpkt);
+        if (ret < 0) {
+            *got_sub_ptr = 0;
+        } else {
+             ret = extract_packet_props(avctx->internal, &pkt_recoded);
+             if (ret < 0)
+                return ret;
 
-        if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE)
-            sub->pts = av_rescale_q(avpkt->pts,
-                                    avctx->pkt_timebase, AV_TIME_BASE_Q);
-        ret = avctx->codec->decode(avctx, sub, got_sub_ptr, pkt);
-        av_assert1((ret >= 0) >= !!*got_sub_ptr &&
-                   !!*got_sub_ptr >= !!sub->num_rects);
+            if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE)
+                sub->pts = av_rescale_q(avpkt->pts,
+                                        avctx->pkt_timebase, AV_TIME_BASE_Q);
+            ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);
+            av_assert1((ret >= 0) >= !!*got_sub_ptr &&
+                       !!*got_sub_ptr >= !!sub->num_rects);
 
 #if FF_API_ASS_TIMING
-        if (avctx->sub_text_format == FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS
-            && *got_sub_ptr && sub->num_rects) {
-            const AVRational tb = avctx->pkt_timebase.num ? avctx->pkt_timebase
-                                  : avctx->time_base;
-            int err = convert_sub_to_old_ass_form(sub, avpkt, tb);
-            if (err < 0)
-                ret = err;
-        }
+            if (avctx->sub_text_format == FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS
+                && *got_sub_ptr && sub->num_rects) {
+                const AVRational tb = avctx->pkt_timebase.num ? avctx->pkt_timebase
+                                                              : avctx->time_base;
+                int err = convert_sub_to_old_ass_form(sub, avpkt, tb);
+                if (err < 0)
+                    ret = err;
+            }
 #endif
 
-        if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
-            avctx->pkt_timebase.num) {
-            AVRational ms = { 1, 1000 };
-            sub->end_display_time = av_rescale_q(avpkt->duration,
-                                                 avctx->pkt_timebase, ms);
-        }
+            if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
+                avctx->pkt_timebase.num) {
+                AVRational ms = { 1, 1000 };
+                sub->end_display_time = av_rescale_q(avpkt->duration,
+                                                     avctx->pkt_timebase, ms);
+            }
 
-        if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
-            sub->format = 0;
-        else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
-            sub->format = 1;
+            if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
+                sub->format = 0;
+            else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
+                sub->format = 1;
 
-        for (unsigned i = 0; i < sub->num_rects; i++) {
-            if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_IGNORE &&
-                sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
-                av_log(avctx, AV_LOG_ERROR,
-                       "Invalid UTF-8 in decoded subtitles text; "
-                       "maybe missing -sub_charenc option\n");
-                avsubtitle_free(sub);
-                ret = AVERROR_INVALIDDATA;
-                break;
+            for (i = 0; i < sub->num_rects; i++) {
+                if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_IGNORE &&
+                    sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
+                    av_log(avctx, AV_LOG_ERROR,
+                           "Invalid UTF-8 in decoded subtitles text; "
+                           "maybe missing -sub_charenc option\n");
+                    avsubtitle_free(sub);
+                    ret = AVERROR_INVALIDDATA;
+                    break;
+                }
+            }
+
+            if (avpkt->data != pkt_recoded.data) { // did we recode?
+                /* prevent from destroying side data from original packet */
+                pkt_recoded.side_data = NULL;
+                pkt_recoded.side_data_elems = 0;
+
+                av_packet_unref(&pkt_recoded);
             }
         }
 
         if (*got_sub_ptr)
             avctx->frame_number++;
-
-        if (pkt == avci->buffer_pkt) // did we recode?
-            av_packet_unref(avci->buffer_pkt);
     }
 
     return ret;
@@ -1710,7 +1691,7 @@
 
 static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
 {
-    buffer_size_t size;
+    int size;
     const uint8_t *side_metadata;
 
     AVDictionary **frame_md = &frame->metadata;
@@ -1740,9 +1721,10 @@
         { AV_PKT_DATA_S12M_TIMECODE,              AV_FRAME_DATA_S12M_TIMECODE },
     };
 
-    if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt))
-        av_fifo_generic_read(avctx->internal->pkt_props,
-                             pkt, sizeof(*pkt), NULL);
+    if (IS_EMPTY(pkt))
+        avpriv_packet_list_get(&avctx->internal->pkt_props,
+                               &avctx->internal->pkt_props_tail,
+                               pkt);
 
     if (pkt) {
         frame->pts = pkt->pts;
@@ -1756,7 +1738,7 @@
         frame->pkt_size     = pkt->size;
 
         for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
-            buffer_size_t size;
+            int size;
             uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, &size);
             if (packet_sd) {
                 AVFrameSideData *frame_sd = av_frame_new_side_data(frame,
diff --git a/libavcodec/dirac_arith.c b/libavcodec/dirac_arith.c
index 69b6280..36142fe 100644
--- a/libavcodec/dirac_arith.c
+++ b/libavcodec/dirac_arith.c
@@ -28,7 +28,7 @@
 #include "dirac_arith.h"
 
 
-static const uint16_t dirac_prob[256] = {
+const uint16_t ff_dirac_prob[256] = {
     0,    2,    5,    8,    11,   15,   20,   24,
     29,   35,   41,   47,   53,   60,   67,   74,
     82,   89,   97,   106,  114,  123,  132,  141,
@@ -88,8 +88,8 @@
     int i;
 
     for (i = 0; i < 256; i++) {
-        ff_dirac_prob_branchless[i][0] =  dirac_prob[255-i];
-        ff_dirac_prob_branchless[i][1] = -dirac_prob[i];
+        ff_dirac_prob_branchless[i][0] =  ff_dirac_prob[255-i];
+        ff_dirac_prob_branchless[i][1] = -ff_dirac_prob[i];
     }
 }
 
diff --git a/libavcodec/dirac_arith.h b/libavcodec/dirac_arith.h
index 350a58f..79526a7 100644
--- a/libavcodec/dirac_arith.h
+++ b/libavcodec/dirac_arith.h
@@ -86,6 +86,7 @@
 } DiracArith;
 
 extern const uint8_t ff_dirac_next_ctx[DIRAC_CTX_COUNT];
+extern const uint16_t ff_dirac_prob[256];
 extern int16_t ff_dirac_prob_branchless[256][2];
 
 static inline void renorm(DiracArith *c)
diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
index c5a0371..2e2fa7e 100644
--- a/libavcodec/dirac_vlc.c
+++ b/libavcodec/dirac_vlc.c
@@ -16,8 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "dirac_vlc.h"
 
 enum {
@@ -45,7 +43,7 @@
     uint16_t  state;     /* Expected state for the next byte */
 } LUTState;
 
-static const DECLARE_ALIGNED(32, LUTState, dirac_golomb_lut)[1024] = {
+const DECLARE_ALIGNED(32, LUTState, ff_dirac_golomb_lut)[1024] = {
     { +16,  0,  0,  0,  0, 5, +1, 0,  0, STATE_FOLLOW },
     { +17,  0,  0,  0,  0, 5, +1, 0,  0, STATE_FOLLOW },
     {  +8,  0,  0,  0,  0, 4, +1, 1,  0,  STATE_START },
@@ -1089,13 +1087,13 @@
         dst += lut.num;                                \
         if (dst >= last)                               \
             return coeffs;                             \
-        lut = dirac_golomb_lut[lut.state + *buf++];    \
+        lut = ff_dirac_golomb_lut[lut.state + *buf++]; \
     } while (0)
 
 int ff_dirac_golomb_read_16bit(const uint8_t *buf, int bytes,
                                uint8_t *_dst, int coeffs)
 {
-    LUTState lut = dirac_golomb_lut[*buf++];
+    LUTState lut = ff_dirac_golomb_lut[*buf++];
     int16_t *dst = (int16_t *)_dst, *last = dst + coeffs;
     uint16_t val = 0;
 
@@ -1115,7 +1113,7 @@
 int ff_dirac_golomb_read_32bit(const uint8_t *buf, int bytes,
                                uint8_t *_dst, int coeffs)
 {
-    LUTState lut = dirac_golomb_lut[*buf++];
+    LUTState lut = ff_dirac_golomb_lut[*buf++];
     int32_t *dst = (int32_t *)_dst, *last = dst + coeffs;
     uint32_t val = 0;
 
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index b9999cd..ed42bc3 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -26,7 +26,6 @@
  * @author Marco Gerards <marco@gnu.org>, David Conrad, Jordi Ortiz <nenjordi@gmail.com>
  */
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index 3a69a0f..154be89 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -932,7 +932,7 @@
     49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
 };
 
-static const CIDEntry dnxhd_cid_table[] = {
+const CIDEntry ff_dnxhd_cid_table[] = {
     { 1235, 1920, 1080, 917504, 917504,
       0, 6, 10, 4,
       dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight,
@@ -1075,31 +1075,31 @@
       { 0 }, { 5888, 255} },
 };
 
-const CIDEntry *ff_dnxhd_get_cid_table(int cid)
+int ff_dnxhd_get_cid_table(int cid)
 {
-    for (int i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++)
-        if (dnxhd_cid_table[i].cid == cid)
-            return &dnxhd_cid_table[i];
-    return NULL;
+    int i;
+    for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++)
+        if (ff_dnxhd_cid_table[i].cid == cid)
+            return i;
+    return -1;
 }
 
 int avpriv_dnxhd_get_frame_size(int cid)
 {
-    const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
-    if (!entry)
-        return -1;
-    return entry->frame_size;
+    int i = ff_dnxhd_get_cid_table(cid);
+    if (i<0)
+        return i;
+    return ff_dnxhd_cid_table[i].frame_size;
 }
 
 int avpriv_dnxhd_get_hr_frame_size(int cid, int w, int h)
 {
-    const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
-    int result;
+    int result, i = ff_dnxhd_get_cid_table(cid);
 
-    if (!entry)
-        return -1;
+    if (i < 0)
+        return i;
 
-    result = ((h + 15) / 16) * ((w + 15) / 16) * (int64_t)entry->packet_scale.num / entry->packet_scale.den;
+    result = ((h + 15) / 16) * ((w + 15) / 16) * (int64_t)ff_dnxhd_cid_table[i].packet_scale.num / ff_dnxhd_cid_table[i].packet_scale.den;
     result = (result + 2048) / 4096 * 4096;
 
     return FFMAX(result, 8192);
@@ -1107,10 +1107,10 @@
 
 int avpriv_dnxhd_get_interlaced(int cid)
 {
-    const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
-    if (!entry)
-        return -1;
-    return entry->flags & DNXHD_INTERLACED ? 1 : 0;
+    int i = ff_dnxhd_get_cid_table(cid);
+    if (i < 0)
+        return i;
+    return ff_dnxhd_cid_table[i].flags & DNXHD_INTERLACED ? 1 : 0;
 }
 
 static int dnxhd_find_hr_cid(AVCodecContext *avctx)
@@ -1140,8 +1140,8 @@
 
     if (!mbs)
         return 0;
-    for (i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++) {
-        const CIDEntry *cid = &dnxhd_cid_table[i];
+    for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
+        const CIDEntry *cid = &ff_dnxhd_cid_table[i];
         int interlaced = cid->flags & DNXHD_INTERLACED ? 1 : 0;
         if (cid->width == avctx->width && cid->height == avctx->height &&
             interlaced == !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) &&
@@ -1163,8 +1163,8 @@
 void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel)
 {
     int i, j;
-    for (i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++) {
-        const CIDEntry *cid = &dnxhd_cid_table[i];
+    for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
+        const CIDEntry *cid = &ff_dnxhd_cid_table[i];
         for (j = 0; j < FF_ARRAY_ELEMS(cid->bit_rates); j++) {
             if (!cid->bit_rates[j])
                 break;
diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h
index 898079c..cfa6b0c 100644
--- a/libavcodec/dnxhddata.h
+++ b/libavcodec/dnxhddata.h
@@ -58,7 +58,9 @@
     AVRational packet_scale;
 } CIDEntry;
 
-const CIDEntry *ff_dnxhd_get_cid_table(int cid);
+extern const CIDEntry ff_dnxhd_cid_table[];
+
+int ff_dnxhd_get_cid_table(int cid);
 int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth);
 void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel);
 
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index cb0fdd3..f6dfa4a 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -25,8 +25,6 @@
  */
 
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "get_bits.h"
@@ -112,19 +110,18 @@
 static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
 {
     if (cid != ctx->cid) {
-        const CIDEntry *cid_table = ff_dnxhd_get_cid_table(cid);
+        int index;
 
-        if (!cid_table) {
+        if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {
             av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %"PRIu32"\n", cid);
             return AVERROR(ENOSYS);
         }
-        if (cid_table->bit_depth != bitdepth &&
-            cid_table->bit_depth != DNXHD_VARIABLE) {
-            av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n",
-                   cid_table->bit_depth, bitdepth);
+        if (ff_dnxhd_cid_table[index].bit_depth != bitdepth &&
+            ff_dnxhd_cid_table[index].bit_depth != DNXHD_VARIABLE) {
+            av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, bitdepth);
             return AVERROR_INVALIDDATA;
         }
-        ctx->cid_table = cid_table;
+        ctx->cid_table = &ff_dnxhd_cid_table[index];
         av_log(ctx->avctx, AV_LOG_VERBOSE, "Profile cid %"PRIu32".\n", cid);
 
         ff_free_vlc(&ctx->ac_vlc);
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 2461c51..91eeb47 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -25,7 +25,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
@@ -351,7 +350,7 @@
 static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
 {
     DNXHDEncContext *ctx = avctx->priv_data;
-    int i, ret;
+    int i, index, ret;
 
     switch (avctx->pix_fmt) {
     case AV_PIX_FMT_YUV422P:
@@ -411,8 +410,10 @@
         return AVERROR(EINVAL);
     }
 
-    ctx->cid_table = ff_dnxhd_get_cid_table(ctx->cid);
-    av_assert0(ctx->cid_table);
+    index = ff_dnxhd_get_cid_table(ctx->cid);
+    av_assert0(index >= 0);
+
+    ctx->cid_table = &ff_dnxhd_cid_table[index];
 
     ctx->m.avctx    = avctx;
     ctx->m.mb_intra = 1;
diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h
index 9e4c869..7b0d862 100644
--- a/libavcodec/dnxhdenc.h
+++ b/libavcodec/dnxhdenc.h
@@ -28,8 +28,6 @@
 
 #include "config.h"
 
-#include "libavutil/mem_internal.h"
-
 #include "mpegvideo.h"
 #include "dnxhddata.h"
 
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index ecb2f48..429612e 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -21,586 +21,13 @@
 #include "libavutil/float_dsp.h"
 #include "libavutil/thread.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 
 #include "internal.h"
 #include "get_bits.h"
+#include "put_bits.h"
 #include "dolby_e.h"
-#include "kbdwin.h"
 #include "fft.h"
 
-#define MAX_SEGMENTS    2
-
-#define MAX_GROUPS      8
-#define MAX_EXPONENTS   304
-#define MAX_MANTISSAS   1024
-
-#define MAX_MSTR_EXP    2
-#define MAX_BIAS_EXP    50
-
-typedef struct DBEGroup {
-    uint8_t         nb_exponent;
-    uint8_t         nb_bias_exp[MAX_MSTR_EXP];
-    uint16_t        exp_ofs;
-    uint16_t        mnt_ofs;
-    const uint8_t   *nb_mantissa;
-    uint8_t         imdct_idx;
-    uint8_t         imdct_phs;
-    uint16_t        win_len;
-    uint16_t        dst_ofs;
-    uint16_t        win_ofs;
-    uint16_t        src_ofs;
-} DBEGroup;
-
-typedef struct DBEChannel {
-    int     gr_code;
-    int     bw_code;
-
-    int         nb_groups;
-    int         nb_mstr_exp;
-    DBEGroup    groups[MAX_GROUPS];
-
-    int     exp_strategy[MAX_GROUPS];
-    int     exponents[MAX_EXPONENTS];
-    int     bap[MAX_EXPONENTS];
-    int     idx[MAX_EXPONENTS];
-
-    DECLARE_ALIGNED(32, float, mantissas)[MAX_MANTISSAS];
-} DBEChannel;
-
-typedef struct DBEDecodeContext {
-    AVCodecContext  *avctx;
-    DBEContext  dectx;
-
-    DBEChannel  channels[MAX_SEGMENTS][MAX_CHANNELS];
-
-    DECLARE_ALIGNED(32, float, history)[MAX_CHANNELS][256];
-
-    FFTContext          imdct[3];
-    AVFloatDSPContext   *fdsp;
-} DBEDecodeContext;
-
-static const int8_t lfe_channel_tab[MAX_PROG_CONF + 1] = {
-     5,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  5, 5
-};
-
-static const uint8_t ch_reorder_4[4] = { 0, 2, 1, 3 };
-static const uint8_t ch_reorder_6[6] = { 0, 2, 4, 1, 3, 5 };
-static const uint8_t ch_reorder_8[8] = { 0, 2, 6, 4, 1, 3, 7, 5 };
-static const uint8_t ch_reorder_n[8] = { 0, 2, 4, 6, 1, 3, 5, 7 };
-
-
-static const uint8_t nb_groups_tab[4] = { 1, 8, 7, 1 };
-
-static const uint8_t nb_mstr_exp_tab[4] = { 2, 2, 2, 1 };
-
-static const uint8_t nb_mantissa_38[38] = {
-     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
-     2,  2,  2,  2,  2,  2,  3,  3,  3,  4,  4,  4,  5,  5,  6,  6,
-     7,  8,  9, 10, 11, 12,
-};
-
-static const uint8_t nb_mantissa_44[44] = {
-     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,
-     2,  2,  2,  2,  2,  3,  3,  3,  3,  4,  4,  5,  5,  6,  7,  7,
-     8,  9, 10, 11, 12, 13, 15, 16, 18, 20, 22, 25,
-};
-
-static const uint8_t nb_mantissa_50[50] = {
-     1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,
-     3,  4,  4,  5,  5,  6,  6,  7,  8,  9,  9, 10, 12, 13, 14, 16,
-    18, 19, 22, 24, 27, 29, 32, 36, 40, 44, 49, 54, 60, 66, 74, 82,
-    90, 100,
-};
-
-static const uint8_t imdct_bits_tab[3] = { 8, 9, 11 };
-
-static const DBEGroup grp_tab_0[1] = {
-    { 50, { 27, 23 }, 0, 0, nb_mantissa_50, 2, 0, 1152, 0, 1408, 0 },
-};
-
-static const DBEGroup grp_tab_1[8] = {
-    { 38, { 12, 26 }, 0, 0, nb_mantissa_38, 0, 0, 192, 0, 256, 0 },
-    { 38, { 12, 26 }, 38, 128, nb_mantissa_38, 0, 1, 256, 64, 448, 0 },
-    { 38, { 12, 26 }, 76, 256, nb_mantissa_38, 0, 1, 256, 192, 704, 0 },
-    { 38, { 12, 26 }, 114, 384, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
-    { 38, { 12, 26 }, 152, 512, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
-    { 38, { 12, 26 }, 190, 640, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
-    { 38, { 12, 26 }, 228, 768, nb_mantissa_38, 0, 1, 256, 704, 0, 0 },
-    { 38, { 12, 26 }, 266, 896, nb_mantissa_38, 0, 1, 256, 832, 0, 0 },
-};
-
-static const DBEGroup grp_tab_2[7] = {
-    { 38, { 12, 26 }, 0, 0, nb_mantissa_38, 0, 0, 192, 0, 256, 0 },
-    { 38, { 12, 26 }, 38, 128, nb_mantissa_38, 0, 1, 256, 64, 448, 0 },
-    { 38, { 12, 26 }, 76, 256, nb_mantissa_38, 0, 1, 256, 192, 704, 0 },
-    { 38, { 12, 26 }, 114, 384, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
-    { 38, { 12, 26 }, 152, 512, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
-    { 38, { 12, 26 }, 190, 640, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
-    { 44, { 19, 25 }, 228, 768, nb_mantissa_44, 1, 1, 448, 704, 960, 64 },
-};
-
-static const DBEGroup grp_tab_3[1] = {
-    { 21, { 21 }, 0, 0, nb_mantissa_50, 2, 0, 1152, 0, 1408, 0 },
-};
-
-static const DBEGroup grp_tab_4[1] = {
-    { 50, { 27, 23 }, 0, 0, nb_mantissa_50, 2, 2, 1152, 0, 1408, 896 },
-};
-
-static const DBEGroup grp_tab_5[8] = {
-    { 38, { 12, 26 }, 0, 0, nb_mantissa_38, 0, 1, 256, 64, 0, 0 },
-    { 38, { 12, 26 }, 38, 128, nb_mantissa_38, 0, 1, 256, 192, 0, 0 },
-    { 38, { 12, 26 }, 76, 256, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
-    { 38, { 12, 26 }, 114, 384, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
-    { 38, { 12, 26 }, 152, 512, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
-    { 38, { 12, 26 }, 190, 640, nb_mantissa_38, 0, 1, 256, 704, 3008, 0 },
-    { 38, { 12, 26 }, 228, 768, nb_mantissa_38, 0, 1, 256, 832, 2752, 0 },
-    { 38, { 12, 26 }, 266, 896, nb_mantissa_38, 0, 2, 192, 960, 2560, 64 },
-};
-
-static const DBEGroup grp_tab_6[7] = {
-    { 44, { 19, 25 }, 0, 0, nb_mantissa_44, 1, 1, 448, 0, 3264, 0 },
-    { 38, { 12, 26 }, 44, 256, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
-    { 38, { 12, 26 }, 82, 384, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
-    { 38, { 12, 26 }, 120, 512, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
-    { 38, { 12, 26 }, 158, 640, nb_mantissa_38, 0, 1, 256, 704, 3008, 0 },
-    { 38, { 12, 26 }, 196, 768, nb_mantissa_38, 0, 1, 256, 832, 2752, 0 },
-    { 38, { 12, 26 }, 234, 896, nb_mantissa_38, 0, 2, 192, 960, 2560, 64 },
-};
-
-static const DBEGroup grp_tab_7[1] = {
-    { 21, { 21 }, 0, 0, nb_mantissa_50, 2, 2, 1152, 0, 1408, 896 },
-};
-
-static const DBEGroup *const frm_ofs_tab[2][4] = {
-    { grp_tab_0, grp_tab_1, grp_tab_2, grp_tab_3 },
-    { grp_tab_4, grp_tab_5, grp_tab_6, grp_tab_7 }
-};
-
-static const uint8_t mantissa_size1[16][4] = {
-    {  0,  0,  0,  0 }, {  2,  1,  1,  1 }, {  3,  2,  1,  1 }, {  4,  3,  2,  1 },
-    {  5,  4,  3,  2 }, {  6,  5,  4,  3 }, {  7,  6,  5,  4 }, {  8,  7,  6,  5 },
-    {  9,  8,  7,  6 }, { 10,  9,  8,  7 }, { 11, 10,  9,  8 }, { 12, 11, 10,  9 },
-    { 13, 12, 11, 10 }, { 14, 13, 12, 11 }, { 15, 14, 13, 12 }, { 16, 15, 14, 13 },
-};
-
-static const uint8_t mantissa_size2[16][4] = {
-    {  0,  0,  0,  0 }, {  2,  1,  2,  2 }, {  3,  2,  3,  3 }, {  4,  3,  4,  4 },
-    {  5,  4,  5,  5 }, {  6,  5,  6,  6 }, {  7,  6,  7,  7 }, {  8,  7,  8,  8 },
-    {  9,  8,  9,  9 }, { 10,  9, 10, 10 }, { 11, 10, 11, 11 }, { 12, 11, 12, 12 },
-    { 13, 12, 13, 13 }, { 14, 13, 14, 14 }, { 15, 14, 15, 15 }, { 16, 15, 16, 16 },
-};
-
-static const float start_window[192] = {
-    0.00161569379826, 0.00185748233347, 0.00198562758548, 0.00207834078104,
-    0.00215717748523, 0.00223067096393, 0.00230299213147, 0.00237651215396,
-    0.00245275561606, 0.00253281402069, 0.00261754673613, 0.00270768786168,
-    0.00280390761895, 0.00290684998656, 0.00301715751161, 0.00313548872798,
-    0.00326253122934, 0.00339901215995, 0.00354570716636, 0.00370344845023,
-    0.00387313232586, 0.00405572653911, 0.00425227750970, 0.00446391759265,
-    0.00469187240551, 0.00493746822816, 0.00520213944619, 0.00548743597507,
-    0.00579503056737, 0.00612672586953, 0.00648446105606, 0.00687031782873,
-    0.00728652552677, 0.00773546505205, 0.00821967127415, 0.00874183354619,
-    0.00930479393832, 0.00991154278653, 0.01056521116692, 0.01126905994567,
-    0.01202646513050, 0.01284089936559, 0.01371590957417, 0.01465509096066,
-    0.01566205783408, 0.01674041199523, 0.01789370972358, 0.01912542867865,
-    0.02043893626265, 0.02183746113793, 0.02332406961796, 0.02490164852364,
-    0.02657289580178, 0.02834031974193, 0.03020624702903, 0.03217283918354,
-    0.03424211623810, 0.03641598586180, 0.03869627565015, 0.04108476601498,
-    0.04358322107390, 0.04619341515939, 0.04891715301882, 0.05175628239149,
-
-    0.05471237327267, 0.05778734733755, 0.06098291402413, 0.06430101352084,
-    0.06774345212186, 0.07131188644726, 0.07500780649199, 0.07883251748595,
-    0.08278712056651, 0.08687249228061, 0.09108926295730, 0.09543779401074,
-    0.09991815425851, 0.10453009536427, 0.10927302653894, 0.11414598865987,
-    0.11914762799220, 0.12427616972097, 0.12952939152560, 0.13490459744934,
-    0.14039859233595, 0.14600765712201, 0.15172752528722, 0.15755336077528,
-    0.16347973770491, 0.16950062219342, 0.17560935661442, 0.18179864660619,
-    0.18806055113821, 0.19438647593012, 0.20076717050010, 0.20719272909882,
-    0.21365259576030, 0.22013557367283, 0.22662983904194, 0.23312295958328,
-    0.23960191774666, 0.24605313873388, 0.25246252333253, 0.25881548554631,
-    0.26509699495987, 0.27129162373316, 0.27738359807707, 0.28335685401987,
-    0.28919509723179, 0.29488186663467, 0.30040060148455, 0.30573471157819,
-    0.31086765019993, 0.31578298939317, 0.32046449711227, 0.32489621578468,
-    0.32906254179156, 0.33294830535654, 0.33653885031840, 0.33982011325336,
-    0.34277870140679, 0.34540196889300, 0.34767809062480, 0.34959613344194,
-    0.35114612391958, 0.35231911235422, 0.35310723244504, 0.35350375621308,
-
-    0.35350314372945, 0.35310108725579, 0.35229454943591, 0.35108179521634,
-    0.34946241721522, 0.34743735430290, 0.34500890320420, 0.34218072298001,
-    0.33895783229541, 0.33534659943168, 0.33135472505060, 0.32699121776996,
-    0.32226636266000, 0.31719168282019, 0.31177989424432, 0.30604485422875,
-    0.30000150362379, 0.29366580327088, 0.28705466500775, 0.28018587766131,
-    0.27307802848095, 0.26575042049535, 0.25822298630189, 0.25051619882000,
-    0.24265097955783, 0.23464860495522, 0.22653061137548, 0.21831869932335,
-    0.21003463746705, 0.20170016703857, 0.19333690717811, 0.18496626177620,
-    0.17660932835062, 0.16828680947474, 0.16001892724986, 0.15182534128597,
-    0.14372507062477, 0.13573642000364, 0.12787691082233, 0.12016321713317,
-    0.11261110693234, 0.10523538898282, 0.09804986534955, 0.09106728977263,
-    0.08429933194438, 0.07775654768810, 0.07144835495683, 0.06538301547324,
-    0.05956762170687, 0.05400808871425, 0.04870915012107, 0.04367435714993,
-    0.03890607899172, 0.03440550179663, 0.03017262174627, 0.02620622428513,
-    0.02250383492507, 0.01906161305732, 0.01587412848221, 0.01293388032354,
-    0.01023019677288, 0.00774641320626, 0.00545109736891, 0.00325868651263,
-};
-
-static const float short_window2[192] = {
-    0.00018861094606, 0.00033433010202, 0.00050309624485, 0.00070306161748,
-    0.00093995174533, 0.00121913067128, 0.00154606505568, 0.00192647806126,
-    0.00236641248692, 0.00287225985240, 0.00345077377440, 0.00410907465023,
-    0.00485464855241, 0.00569534163219, 0.00663935063508, 0.00769520981249,
-    0.00887177436246, 0.01017820046395, 0.01162392194150, 0.01321862359335,
-    0.01497221122468, 0.01689477844427, 0.01899657030441, 0.02128794388846,
-    0.02377932597692, 0.02648116795039, 0.02940389811590, 0.03255787167130,
-    0.03595331854986, 0.03960028941437, 0.04350860009563, 0.04768777479454,
-    0.05214698838949, 0.05689500821121, 0.06194013566525, 0.06729014809766,
-    0.07295224131210, 0.07893297315602, 0.08523820859989, 0.09187306673620,
-    0.09884187012422, 0.10614809690222, 0.11379433608064, 0.12178224641797,
-    0.13011251926531, 0.13878484574660, 0.14779788861830, 0.15714925912610,
-    0.16683549914631, 0.17685206886673, 0.18719334022589, 0.19785259629099,
-    0.20882203671372, 0.22009278936030, 0.23165492816694, 0.24349749722585,
-    0.25560854105961, 0.26797514099368, 0.28058345748882, 0.29341877824732,
-    0.30646557185942, 0.31970754671026, 0.33312771482295, 0.34670846027024,
-
-    0.36043161174692, 0.37427851885723, 0.38823013163645, 0.40226708279486,
-    0.41636977214436, 0.43051845264462, 0.44469331748632, 0.45887458761470,
-    0.47304259908636, 0.48717788964798, 0.50126128392546, 0.51527397661778,
-    0.52919761310050, 0.54301436685998, 0.55670701320069, 0.57025899869448,
-    0.58365450587230, 0.59687851269542, 0.60991684638414, 0.62275623122793,
-    0.63538433005035, 0.64778977905593, 0.65996221584264, 0.67189230042379,
-    0.68357172916486, 0.69499324160511, 0.70615062019861, 0.71703868307548,
-    0.72765326998919, 0.73799122168099, 0.74805035295521, 0.75782941981995,
-    0.76732808110520, 0.77654685502339, 0.78548707118622, 0.79415081863423,
-    0.80254089047207, 0.81066072573188, 0.81851434910893, 0.82610630922734,
-    0.83344161609862, 0.84052567843230, 0.84736424144524, 0.85396332579459,
-    0.86032916822973, 0.86646816451999, 0.87238681516918, 0.87809167437532,
-    0.88358930263537, 0.88888622333073, 0.89398888356256, 0.89890361943564,
-    0.90363662591861, 0.90819393133744, 0.91258137648979, 0.91680459830070,
-    0.92086901787718, 0.92477983276087, 0.92854201312583, 0.93216030163834,
-    0.93563921662343, 0.93898305819384, 0.94219591693690, 0.94528168477979,
-
-    0.94823843319821, 0.95106834367330, 0.95377776558539, 0.95636718335775,
-    0.95883679961479, 0.96118650212341, 0.96341583179195, 0.96552395212906,
-    0.96750962060547, 0.96937116231768, 0.97110644638309, 0.97271286544154,
-    0.97418731862798, 0.97552619834964, 0.97672538116257, 0.97778022299974,
-    0.97868555895586, 0.97943570778357, 0.98002448120255, 0.98044519806866,
-    0.98069070339493, 0.98075339216123, 0.98062523779637, 0.98029782516478,
-    0.97976238784222, 0.97900984942031, 0.97803086854002, 0.97681588731895,
-    0.97535518280755, 0.97363892108474, 0.97165721358452, 0.96940017523145,
-    0.96685798395452, 0.96402094114589, 0.96087953263194, 0.95742448973047,
-    0.95364684997699, 0.94953801711660, 0.94508981997396, 0.94029456983253,
-    0.93514511597504, 0.92963489905951, 0.92375800202883, 0.91750919827624,
-    0.91088399681406, 0.90387868421832, 0.89649036314692, 0.88871698725397,
-    0.88055739234735, 0.87201132366062, 0.86307945913336, 0.85376342861693,
-    0.84406582894455, 0.83399023482637, 0.82354120554757, 0.81272428745995,
-    0.80154601230457, 0.79001389138101, 0.77813640562199, 0.76592299164227,
-    0.75338402384395, 0.74053079267526, 0.72737547915460, 0.71393112578527,
-};
-
-static const float short_window3[64] = {
-    0.00326887936450, 0.00550242900936, 0.00786846643791, 0.01045683453520,
-    0.01330402120132, 0.01643221072863, 0.01985798040609, 0.02359509464766,
-    0.02765559221954, 0.03205025893128, 0.03678884369614, 0.04188015679495,
-    0.04733210987781, 0.05315172583924, 0.05934513287609, 0.06591755045290,
-    0.07287327156378, 0.08021564389822, 0.08794705152307, 0.09606889811179,
-    0.10458159240070, 0.11348453632940, 0.12277611617809, 0.13245369691511,
-    0.14251361989876, 0.15295120402567, 0.16376075037904, 0.17493555039885,
-    0.18646789757072, 0.19834910260891, 0.21056951208995, 0.22311853047787,
-    0.23598464546683, 0.24915545655419, 0.26261770674500, 0.27635731727778,
-    0.29035942525136, 0.30460842402318, 0.31908800624032, 0.33378120935681,
-    0.34867046348260, 0.36373764140285, 0.37896411059909, 0.39433078709788,
-    0.40981819096657, 0.42540650327031, 0.44107562429959, 0.45680523287270,
-    0.47257484651351, 0.48836388230077, 0.50415171818214, 0.51991775454258,
-    0.53564147581496, 0.55130251191887, 0.56688069931047, 0.58235614142007,
-    0.59770926827271, 0.61292089506118, 0.62797227945823, 0.64284517745255,
-    0.65752189749349, 0.67198535273209, 0.68621911114984, 0.70020744337099,
-};
-
-static const uint8_t dc_code_tab[5] = { 0, 0, 0, 1, 1 };
-
-static const uint8_t ht_code_tab[5] = { 0, 0, 1, 2, 2 };
-
-static const uint8_t band_ofs_tab[3][4] = {
-    { 12, 8, 4, 0 }, { 14, 10, 6, 0 }, { 12, 8, 4, 0 }
-};
-
-static const uint8_t band_low_tab[3] = { 9, 17, 24 };
-
-static const uint16_t fast_gain_tab[8] = {
-    128, 256, 384, 512, 640, 768, 896, 1024
-};
-
-static const uint16_t slow_decay_tab[2][2] = { { 27, -1 }, { 32, 21 } };
-
-static const uint16_t misc_decay_tab[3][2][2] = {
-    { { 354, -1 }, { 425, 425 } },
-    { { 266, -1 }, { 320,  -1 } },
-    { { 213, -1 }, { 256,  -1 } }
-};
-
-static const uint16_t fast_decay_tab[3][2][2][50] = {
-    {{{
-        142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
-        142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
-        142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
-        142, 142, 142, 142, 142, 142, 142, 142,
-    }, {
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-    }}, {{
-        170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
-        170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
-        170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
-        170, 170, 170, 170, 170, 170, 170, 170,
-    }, {
-         64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
-         64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
-         64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
-         64,  64,  64,  64,  64,  64,  64,  64,
-    }}}, {{{
-        266, 266, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106,
-    }, {
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,
-    }}, {{
-        319, 319, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128,
-    }, {
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,
-    }}}, {{{
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-    }, {
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-    }}, {{
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
-    }, {
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-    }}}
-};
-
-static const uint16_t fast_gain_adj_tab[3][2][62] = {
-    {{
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   1,   2,   4,   7,  11,  16,  29,  44,  59,
-         76,  94, 116, 142, 179, 221, 252, 285, 312, 334,
-    }, {
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          2,   5,   8,  10,  15,  28,  42,  57,  75,  93,
-        115, 140, 177, 219, 247, 280, 308, 330, 427, 533,
-    }}, {{
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   2,   5,   8,  12,  21,  35,  51,  69,  89,
-        111, 138, 176, 220, 251, 284, 312, 334,
-    }, {
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   2,
-          5,   8,  11,  18,  33,  49,  65,  84, 106, 132,
-        168, 214, 245, 279, 308, 329, 427, 533,
-    }}, {{
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   1,   4,   7,  10,  17,
-         31,  47,  65,  84, 107, 134, 171, 215, 250, 283,
-        312, 334,
-    }, {
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-          0,   0,   0,   0,   3,   6,   9,  13,  27,  43,
-         60,  79, 100, 126, 160, 207, 242, 276, 307, 329,
-        427, 533,
-    }}
-};
-
-static const uint16_t slow_gain_tab[3][2][50] = {
-    {{
-        3072, 3072, 3072, 3072, 3072, 3072, 1063, 1063, 1063, 1063,
-        1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,
-        1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,
-        1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,
-    }, {
-        3072, 3072, 3072, 3072, 3072, 3072,  850,  850,  850,  850,
-         850,  850,  850,  850,  850,  850,  850,  850,  850,  850,
-         850,  850,  850,  850,  850,  850,  850,  850,  850,  850,
-         850,  850,  850,  850,  850,  850,  850,  850,
-    }}, {{
-        3072, 1212, 1212, 1212,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,
-    }, {
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,
-    }}, {{
-        3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
-    }, {
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-    }}
-};
-
-static const uint16_t hearing_thresh_tab[3][3][50] = {
-    {{
-        1403, 1141, 1000,  959,  948,  957,  946,  925,  899,  871,
-         843,  815,  789,  766,  745,  727,  705,  687,  681,  686,
-         701,  725,  768,  854,  940, 1018, 1075, 1103, 1111, 1106,
-        1098, 1105, 1142, 1237, 1419, 1721, 2169, 2805,
-    }, {
-        1401, 1130,  995,  957,  947,  955,  941,  918,  890,  861,
-         831,  803,  777,  754,  734,  717,  698,  684,  682,  692,
-         712,  743,  798,  894,  976, 1045, 1091, 1109, 1110, 1102,
-        1098, 1116, 1174, 1300, 1526, 1884, 2401, 3072,
-    }, {
-        1393, 1086,  974,  949,  957,  941,  913,  878,  843,  808,
-         777,  750,  727,  708,  695,  686,  681,  689,  714,  752,
-         811,  888,  971, 1044, 1087, 1108, 1110, 1102, 1098, 1115,
-        1172, 1290, 1489, 1812, 2293, 2964, 3072, 3072,
-    }}, {{
-        1412, 1343, 1141, 1047, 1000,  974,  959,  951,  948,  947,
-         957,  953,  946,  936,  925,  906,  878,  850,  822,  795,
-         771,  745,  719,  700,  687,  681,  685,  701,  733,  784,
-         885,  977, 1047, 1092, 1110, 1108, 1099, 1102, 1138, 1233,
-        1413, 1711, 2157, 2797,
-    }, {
-        1412, 1336, 1130, 1040,  995,  970,  957,  950,  947,  947,
-         955,  950,  941,  930,  918,  897,  868,  838,  810,  783,
-         759,  734,  710,  693,  684,  681,  690,  712,  752,  823,
-         924, 1009, 1069, 1102, 1111, 1104, 1098, 1111, 1168, 1295,
-        1518, 1873, 2388, 3072,
-    }, {
-        1411, 1293, 1086, 1009,  974,  957,  949,  947,  957,  951,
-         941,  928,  913,  896,  878,  852,  817,  785,  756,  732,
-         713,  695,  683,  682,  689,  710,  746,  811,  906,  992,
-        1061, 1099, 1111, 1106, 1098, 1107, 1155, 1266, 1471, 1799,
-        2277, 2945, 3072, 3072,
-    }}, {{
-        1431, 1412, 1403, 1379, 1343, 1293, 1229, 1180, 1125, 1075,
-        1040, 1014,  996,  979,  965,  957,  951,  948,  947,  957,
-         951,  940,  924,  903,  877,  846,  815,  785,  753,  725,
-         702,  686,  681,  689,  714,  760,  847,  947, 1028, 1083,
-        1108, 1109, 1101, 1100, 1132, 1222, 1402, 1705, 2160, 2803,
-    }, {
-        1431, 1412, 1401, 1375, 1336, 1278, 1215, 1168, 1115, 1066,
-        1032, 1008,  991,  975,  962,  954,  950,  947,  947,  955,
-         948,  935,  916,  894,  866,  835,  803,  772,  742,  715,
-         695,  683,  683,  697,  729,  784,  887,  982, 1054, 1096,
-        1111, 1106, 1098, 1107, 1159, 1281, 1505, 1865, 2391, 3072,
-    }, {
-        1427, 1411, 1393, 1353, 1293, 1215, 1160, 1118, 1072, 1031,
-        1003,  984,  971,  960,  952,  948,  947,  957,  952,  941,
-         924,  902,  876,  847,  815,  781,  750,  723,  700,  685,
-         681,  691,  719,  766,  858,  958, 1039, 1089, 1109, 1108,
-        1099, 1102, 1141, 1245, 1442, 1766, 2250, 2930, 3072, 3072,
-    }}
-};
-
-static const int16_t lwc_gain_tab[11][7] = {
-    {   -21,  -197,  -271,  -466, 32767, 32767, 32767 },
-    {  -197,   -29,  -244,  -271,  -540, 32767, 32767 },
-    {  -271,  -244,   -29,  -249,  -271,  -593, 32767 },
-    {  -466,  -271,  -249,   -29,  -251,  -271,  -632 },
-    {  -540,  -271,  -251,   -29,  -251,  -271,  -664 },
-    {  -593,  -271,  -251,   -29,  -252,  -271,  -690 },
-    {  -632,  -271,  -252,   -29,  -252,  -271,  -711 },
-    {  -664,  -271,  -252,   -29,  -252,  -271,  -730 },
-    {  -690,  -271,  -252,   -29,  -252,  -271,  -745 },
-    {  -711,  -271,  -252,   -29,  -253,  -271,  -759 },
-    {  -730,  -271,  -253,   -29,  -253,  -271,  -771 },
-};
-
-static const int16_t lwc_adj_tab[7] = {
-    -192, -320, -448, -512, -448, -320, -192,
-};
-
-static const uint8_t log_add_tab[212] = {
-    64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52, 51, 50,
-    49, 48, 47, 47, 46, 45, 44, 44, 43, 42, 41, 41, 40, 39, 38, 38,
-    37, 36, 36, 35, 35, 34, 33, 33, 32, 32, 31, 30, 30, 29, 29, 28,
-    28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 21,
-    20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15,
-    15, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11,
-    10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,
-     7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,
-     5,  5,  5,  5,  5,  5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
-     4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,
-     2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-     2,  2,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
-     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
-     1,  1,  0,  0,
-};
-
-static const uint8_t bap_tab[64] = {
-     0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,  4,
-     4,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,
-     8,  8,  8,  9,  9,  9,  9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
-    12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15,
-};
-
-static float mantissa_tab1[17][4];
-static float mantissa_tab2[17][4];
-static float mantissa_tab3[17][4];
-static float exponent_tab[50];
-static float gain_tab[1024];
-
-DECLARE_ALIGNED(32, static float, window)[3712];
-
 static int skip_input(DBEContext *s, int nb_words)
 {
     if (nb_words > s->input_size) {
@@ -616,7 +43,7 @@
 static int parse_key(DBEContext *s)
 {
     if (s->key_present) {
-        const uint8_t *key = s->input;
+        uint8_t *key = s->input;
         int      ret = skip_input(s, 1);
         if (ret < 0)
             return ret;
@@ -625,11 +52,105 @@
     return 0;
 }
 
-static int parse_metadata_ext(DBEDecodeContext *s1)
+static int convert_input(DBEContext *s, int nb_words, int key)
 {
-    DBEContext *s = &s1->dectx;
-    if (s->metadata.mtd_ext_size)
-        return skip_input(s, s->key_present + s->metadata.mtd_ext_size + 1);
+    uint8_t *src = s->input;
+    uint8_t *dst = s->buffer;
+    PutBitContext pb;
+    int i;
+
+    av_assert0(nb_words <= 1024u);
+
+    if (nb_words > s->input_size) {
+        av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    switch (s->word_bits) {
+    case 16:
+        for (i = 0; i < nb_words; i++, src += 2, dst += 2)
+            AV_WB16(dst, AV_RB16(src) ^ key);
+        break;
+    case 20:
+        init_put_bits(&pb, s->buffer, sizeof(s->buffer));
+        for (i = 0; i < nb_words; i++, src += 3)
+            put_bits(&pb, 20, AV_RB24(src) >> 4 ^ key);
+        flush_put_bits(&pb);
+        break;
+    case 24:
+        for (i = 0; i < nb_words; i++, src += 3, dst += 3)
+            AV_WB24(dst, AV_RB24(src) ^ key);
+        break;
+    default:
+        av_assert0(0);
+    }
+
+    return init_get_bits(&s->gb, s->buffer, nb_words * s->word_bits);
+}
+
+static int parse_metadata(DBEContext *s)
+{
+    int i, ret, key, mtd_size;
+
+    if ((key = parse_key(s)) < 0)
+        return key;
+    if ((ret = convert_input(s, 1, key)) < 0)
+        return ret;
+
+    skip_bits(&s->gb, 4);
+    mtd_size = get_bits(&s->gb, 10);
+    if (!mtd_size) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid metadata size\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    if ((ret = convert_input(s, mtd_size, key)) < 0)
+        return ret;
+
+    skip_bits(&s->gb, 14);
+    s->prog_conf = get_bits(&s->gb, 6);
+    if (s->prog_conf > MAX_PROG_CONF) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid program configuration\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    s->nb_channels = nb_channels_tab[s->prog_conf];
+    s->nb_programs = nb_programs_tab[s->prog_conf];
+
+    s->fr_code      = get_bits(&s->gb, 4);
+    s->fr_code_orig = get_bits(&s->gb, 4);
+    if (!sample_rate_tab[s->fr_code] ||
+        !sample_rate_tab[s->fr_code_orig]) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    skip_bits_long(&s->gb, 88);
+    for (i = 0; i < s->nb_channels; i++)
+        s->ch_size[i] = get_bits(&s->gb, 10);
+    s->mtd_ext_size = get_bits(&s->gb, 8);
+    s->meter_size   = get_bits(&s->gb, 8);
+
+    skip_bits_long(&s->gb, 10 * s->nb_programs);
+    for (i = 0; i < s->nb_channels; i++) {
+        s->rev_id[i]     = get_bits(&s->gb,  4);
+        skip_bits1(&s->gb);
+        s->begin_gain[i] = get_bits(&s->gb, 10);
+        s->end_gain[i]   = get_bits(&s->gb, 10);
+    }
+
+    if (get_bits_left(&s->gb) < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "Read past end of metadata\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    return skip_input(s, mtd_size + 1);
+}
+
+static int parse_metadata_ext(DBEContext *s)
+{
+    if (s->mtd_ext_size)
+        return skip_input(s, s->key_present + s->mtd_ext_size + 1);
     return 0;
 }
 
@@ -757,9 +278,8 @@
     }
 }
 
-static int parse_bit_alloc(DBEDecodeContext *s1, DBEChannel *c)
+static int parse_bit_alloc(DBEContext *s, DBEChannel *c)
 {
-    DBEContext *s = &s1->dectx;
     DBEGroup *p, *g;
     int bap_strategy[MAX_GROUPS], fg_spc[MAX_GROUPS];
     int fg_ofs[MAX_GROUPS], msk_mod[MAX_GROUPS];
@@ -791,7 +311,7 @@
 
     for (i = 0, p = NULL, g = c->groups; i < c->nb_groups; i++, p = g, g++) {
         if (c->exp_strategy[i] || bap_strategy[i]) {
-            bit_allocate(g->nb_exponent, g->imdct_idx, s->metadata.fr_code,
+            bit_allocate(g->nb_exponent, g->imdct_idx, s->fr_code,
                          c->exponents + g->exp_ofs, c->bap + g->exp_ofs,
                          fg_spc[i], fg_ofs[i], msk_mod[i], snr_ofs);
         } else {
@@ -891,18 +411,17 @@
     return 0;
 }
 
-static int parse_channel(DBEDecodeContext *s1, int ch, int seg_id)
+static int parse_channel(DBEContext *s, int ch, int seg_id)
 {
-    DBEContext *s = &s1->dectx;
-    DBEChannel *c = &s1->channels[seg_id][ch];
+    DBEChannel *c = &s->channels[seg_id][ch];
     int i, ret;
 
-    if (s->metadata.rev_id[ch] > 1) {
-        avpriv_report_missing_feature(s->avctx, "Encoder revision %d", s->metadata.rev_id[ch]);
+    if (s->rev_id[ch] > 1) {
+        avpriv_report_missing_feature(s->avctx, "Encoder revision %d", s->rev_id[ch]);
         return AVERROR_PATCHWELCOME;
     }
 
-    if (ch == lfe_channel_tab[s->metadata.prog_conf]) {
+    if (ch == lfe_channel_tab[s->prog_conf]) {
         c->gr_code = 3;
         c->bw_code = 29;
     } else {
@@ -927,7 +446,7 @@
 
     if ((ret = parse_exponents(s, c)) < 0)
         return ret;
-    if ((ret = parse_bit_alloc(s1, c)) < 0)
+    if ((ret = parse_bit_alloc(s, c)) < 0)
         return ret;
     if ((ret = parse_indices(s, c)) < 0)
         return ret;
@@ -942,45 +461,42 @@
     return 0;
 }
 
-static int parse_audio(DBEDecodeContext *s1, int start, int end, int seg_id)
+static int parse_audio(DBEContext *s, int start, int end, int seg_id)
 {
-    DBEContext *s = &s1->dectx;
     int ch, ret, key;
 
     if ((key = parse_key(s)) < 0)
         return key;
 
     for (ch = start; ch < end; ch++) {
-        if (!s->metadata.ch_size[ch]) {
-            s1->channels[seg_id][ch].nb_groups = 0;
+        if (!s->ch_size[ch]) {
+            s->channels[seg_id][ch].nb_groups = 0;
             continue;
         }
-        ret = ff_dolby_e_convert_input(s, s->metadata.ch_size[ch], key);
-        if (ret < 0)
+        if ((ret = convert_input(s, s->ch_size[ch], key)) < 0)
             return ret;
-        if ((ret = parse_channel(s1, ch, seg_id)) < 0) {
-            if (s1->avctx->err_recognition & AV_EF_EXPLODE)
+        if ((ret = parse_channel(s, ch, seg_id)) < 0) {
+            if (s->avctx->err_recognition & AV_EF_EXPLODE)
                 return ret;
-            s1->channels[seg_id][ch].nb_groups = 0;
+            s->channels[seg_id][ch].nb_groups = 0;
         }
-        if ((ret = skip_input(s, s->metadata.ch_size[ch])) < 0)
+        if ((ret = skip_input(s, s->ch_size[ch])) < 0)
             return ret;
     }
 
     return skip_input(s, 1);
 }
 
-static int parse_meter(DBEDecodeContext *s1)
+static int parse_meter(DBEContext *s)
 {
-    DBEContext *s = &s1->dectx;
-    if (s->metadata.meter_size)
-        return skip_input(s, s->key_present + s->metadata.meter_size + 1);
+    if (s->meter_size)
+        return skip_input(s, s->key_present + s->meter_size + 1);
     return 0;
 }
 
-static void imdct_calc(DBEDecodeContext *s1, DBEGroup *g, float *result, float *values)
+static void imdct_calc(DBEContext *s, DBEGroup *g, float *result, float *values)
 {
-    FFTContext *imdct = &s1->imdct[g->imdct_idx];
+    FFTContext *imdct = &s->imdct[g->imdct_idx];
     int n   = 1 << imdct_bits_tab[g->imdct_idx];
     int n2  = n >> 1;
     int i;
@@ -1004,7 +520,7 @@
     }
 }
 
-static void transform(DBEDecodeContext *s1, DBEChannel *c, float *history, float *output)
+static void transform(DBEContext *s, DBEChannel *c, float *history, float *output)
 {
     LOCAL_ALIGNED_32(float, buffer, [2048]);
     LOCAL_ALIGNED_32(float, result, [1152]);
@@ -1017,8 +533,8 @@
         float *dst = result + g->dst_ofs;
         float *win = window + g->win_ofs;
 
-        imdct_calc(s1, g, buffer, c->mantissas + g->mnt_ofs);
-        s1->fdsp->vector_fmul_add(dst, src, win, dst, g->win_len);
+        imdct_calc(s, g, buffer, c->mantissas + g->mnt_ofs);
+        s->fdsp->vector_fmul_add(dst, src, win, dst, g->win_len);
     }
 
     for (i = 0; i < 256; i++)
@@ -1029,7 +545,7 @@
         history[i] = result[896 + i];
 }
 
-static void apply_gain(DBEDecodeContext *s, int begin, int end, float *output)
+static void apply_gain(DBEContext *s, int begin, int end, float *output)
 {
     if (begin == 960 && end == 960)
         return;
@@ -1046,17 +562,16 @@
     }
 }
 
-static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
+static int filter_frame(DBEContext *s, AVFrame *frame)
 {
-    const DolbyEHeaderInfo *const metadata = &s->dectx.metadata;
     const uint8_t *reorder;
     int ch, ret;
 
-    if (metadata->nb_channels == 4)
+    if (s->nb_channels == 4)
         reorder = ch_reorder_4;
-    else if (metadata->nb_channels == 6)
+    else if (s->nb_channels == 6)
         reorder = ch_reorder_6;
-    else if (metadata->nb_programs == 1 && !(s->avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE))
+    else if (s->nb_programs == 1 && !(s->avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE))
         reorder = ch_reorder_8;
     else
         reorder = ch_reorder_n;
@@ -1065,11 +580,11 @@
     if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0)
         return ret;
 
-    for (ch = 0; ch < metadata->nb_channels; ch++) {
+    for (ch = 0; ch < s->nb_channels; ch++) {
         float *output = (float *)frame->extended_data[reorder[ch]];
         transform(s, &s->channels[0][ch], s->history[ch], output);
         transform(s, &s->channels[1][ch], s->history[ch], output + FRAME_SAMPLES / 2);
-        apply_gain(s, metadata->begin_gain[ch], metadata->end_gain[ch], output);
+        apply_gain(s, s->begin_gain[ch], s->end_gain[ch], output);
     }
 
     return 0;
@@ -1078,21 +593,39 @@
 static int dolby_e_decode_frame(AVCodecContext *avctx, void *data,
                                 int *got_frame_ptr, AVPacket *avpkt)
 {
-    DBEDecodeContext *s1 = avctx->priv_data;
-    DBEContext *s = &s1->dectx;
-    int i, j, ret;
+    DBEContext *s = avctx->priv_data;
+    int i, j, hdr, ret;
 
-    if ((ret = ff_dolby_e_parse_header(s, avpkt->data, avpkt->size)) < 0)
-        return ret;
+    if (avpkt->size < 3)
+        return AVERROR_INVALIDDATA;
 
-    if (s->metadata.nb_programs > 1 && !s->metadata.multi_prog_warned) {
-        av_log(avctx, AV_LOG_WARNING, "Stream has %d programs (configuration %d), "
-               "channels will be output in native order.\n",
-               s->metadata.nb_programs, s->metadata.prog_conf);
-        s->metadata.multi_prog_warned = 1;
+    hdr = AV_RB24(avpkt->data);
+    if ((hdr & 0xfffffe) == 0x7888e) {
+        s->word_bits = 24;
+    } else if ((hdr & 0xffffe0) == 0x788e0) {
+        s->word_bits = 20;
+    } else if ((hdr & 0xfffe00) == 0x78e00) {
+        s->word_bits = 16;
+    } else {
+        av_log(avctx, AV_LOG_ERROR, "Invalid frame header\n");
+        return AVERROR_INVALIDDATA;
     }
 
-    switch (s->metadata.nb_channels) {
+    s->word_bytes  = s->word_bits + 7 >> 3;
+    s->input       = avpkt->data + s->word_bytes;
+    s->input_size  = avpkt->size / s->word_bytes - 1;
+    s->key_present = hdr >> 24 - s->word_bits & 1;
+
+    if ((ret = parse_metadata(s)) < 0)
+        return ret;
+
+    if (s->nb_programs > 1 && !s->multi_prog_warned) {
+        av_log(avctx, AV_LOG_WARNING, "Stream has %d programs (configuration %d), "
+               "channels will be output in native order.\n", s->nb_programs, s->prog_conf);
+        s->multi_prog_warned = 1;
+    }
+
+    switch (s->nb_channels) {
     case 4:
         avctx->channel_layout = AV_CH_LAYOUT_4POINT0;
         break;
@@ -1104,25 +637,25 @@
         break;
     }
 
-    avctx->channels    = s->metadata.nb_channels;
-    avctx->sample_rate = s->metadata.sample_rate;
+    avctx->channels    = s->nb_channels;
+    avctx->sample_rate = sample_rate_tab[s->fr_code];
     avctx->sample_fmt  = AV_SAMPLE_FMT_FLTP;
 
-    i = s->metadata.nb_channels / 2;
-    j = s->metadata.nb_channels;
-    if ((ret = parse_audio(s1, 0, i, 0)) < 0)
+    i = s->nb_channels / 2;
+    j = s->nb_channels;
+    if ((ret = parse_audio(s, 0, i, 0)) < 0)
         return ret;
-    if ((ret = parse_audio(s1, i, j, 0)) < 0)
+    if ((ret = parse_audio(s, i, j, 0)) < 0)
         return ret;
-    if ((ret = parse_metadata_ext(s1)) < 0)
+    if ((ret = parse_metadata_ext(s)) < 0)
         return ret;
-    if ((ret = parse_audio(s1, 0, i, 1)) < 0)
+    if ((ret = parse_audio(s, 0, i, 1)) < 0)
         return ret;
-    if ((ret = parse_audio(s1, i, j, 1)) < 0)
+    if ((ret = parse_audio(s, i, j, 1)) < 0)
         return ret;
-    if ((ret = parse_meter(s1)) < 0)
+    if ((ret = parse_meter(s)) < 0)
         return ret;
-    if ((ret = filter_frame(s1, data)) < 0)
+    if ((ret = filter_frame(s, data)) < 0)
         return ret;
 
     *got_frame_ptr = 1;
@@ -1131,14 +664,14 @@
 
 static av_cold void dolby_e_flush(AVCodecContext *avctx)
 {
-    DBEDecodeContext *s = avctx->priv_data;
+    DBEContext *s = avctx->priv_data;
 
     memset(s->history, 0, sizeof(s->history));
 }
 
 static av_cold int dolby_e_close(AVCodecContext *avctx)
 {
-    DBEDecodeContext *s = avctx->priv_data;
+    DBEContext *s = avctx->priv_data;
     int i;
 
     for (i = 0; i < 3; i++)
@@ -1238,7 +771,7 @@
 static av_cold int dolby_e_init(AVCodecContext *avctx)
 {
     static AVOnce init_once = AV_ONCE_INIT;
-    DBEDecodeContext *s = avctx->priv_data;
+    DBEContext *s = avctx->priv_data;
     int i;
 
     if (ff_thread_once(&init_once, init_tables))
@@ -1251,8 +784,8 @@
     if (!(s->fdsp = avpriv_float_dsp_alloc(0)))
         return AVERROR(ENOMEM);
 
-    s->dectx.metadata.multi_prog_warned = !!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE);
-    s->dectx.avctx = s->avctx = avctx;
+    s->multi_prog_warned = !!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE);
+    s->avctx = avctx;
     return 0;
 }
 
@@ -1261,7 +794,7 @@
     .long_name      = NULL_IF_CONFIG_SMALL("Dolby E"),
     .type           = AVMEDIA_TYPE_AUDIO,
     .id             = AV_CODEC_ID_DOLBY_E,
-    .priv_data_size = sizeof(DBEDecodeContext),
+    .priv_data_size = sizeof(DBEContext),
     .init           = dolby_e_init,
     .decode         = dolby_e_decode_frame,
     .close          = dolby_e_close,
diff --git a/libavcodec/dolby_e.h b/libavcodec/dolby_e.h
index 9f0c065..ae04bf6 100644
--- a/libavcodec/dolby_e.h
+++ b/libavcodec/dolby_e.h
@@ -21,23 +21,70 @@
 #ifndef AVCODEC_DOLBY_E_H
 #define AVCODEC_DOLBY_E_H
 
-#include <stdint.h>
+#include "libavutil/float_dsp.h"
+#include "libavutil/libm.h"
+#include "libavutil/mem.h"
+
+#include "internal.h"
 #include "get_bits.h"
+#include "kbdwin.h"
+#include "fft.h"
 
 #define FRAME_SAMPLES   1792
 
 #define MAX_PROG_CONF   23
 #define MAX_PROGRAMS    8
 #define MAX_CHANNELS    8
+#define MAX_SEGMENTS    2
 
-/**
- * @struct DolbyEHeaderInfo
- * Coded Dolby E header values up to end_gain element, plus derived values.
- */
-typedef struct DolbyEHeaderInfo {
-    /** @name Coded elements
-     * @{
-     */
+#define MAX_GROUPS      8
+#define MAX_EXPONENTS   304
+#define MAX_MANTISSAS   1024
+
+#define MAX_MSTR_EXP    2
+#define MAX_BIAS_EXP    50
+
+typedef struct DBEGroup {
+    uint8_t         nb_exponent;
+    uint8_t         nb_bias_exp[MAX_MSTR_EXP];
+    uint16_t        exp_ofs;
+    uint16_t        mnt_ofs;
+    const uint8_t   *nb_mantissa;
+    uint8_t         imdct_idx;
+    uint8_t         imdct_phs;
+    uint16_t        win_len;
+    uint16_t        dst_ofs;
+    uint16_t        win_ofs;
+    uint16_t        src_ofs;
+} DBEGroup;
+
+typedef struct DBEChannel {
+    int     gr_code;
+    int     bw_code;
+
+    int         nb_groups;
+    int         nb_mstr_exp;
+    DBEGroup    groups[MAX_GROUPS];
+
+    int     exp_strategy[MAX_GROUPS];
+    int     exponents[MAX_EXPONENTS];
+    int     bap[MAX_EXPONENTS];
+    int     idx[MAX_EXPONENTS];
+
+    DECLARE_ALIGNED(32, float, mantissas)[MAX_MANTISSAS];
+} DBEChannel;
+
+typedef struct DBEContext {
+    AVCodecContext  *avctx;
+    GetBitContext   gb;
+
+    uint8_t     *input;
+    int         input_size;
+
+    int         word_bits;
+    int         word_bytes;
+    int         key_present;
+
     int         prog_conf;
     int         nb_channels;
     int         nb_programs;
@@ -52,52 +99,549 @@
     int         rev_id[MAX_CHANNELS];
     int         begin_gain[MAX_CHANNELS];
     int         end_gain[MAX_CHANNELS];
-    /** @} */
 
-    /** @name Derived values
-     * @{
-     */
     int         multi_prog_warned;
 
-    int         sample_rate;
-    /** @} */
-} DolbyEHeaderInfo;
+    DBEChannel  channels[MAX_SEGMENTS][MAX_CHANNELS];
 
-/**
- * @struct DBEContext
- * Dolby E reading context used by decoder and parser.
- */
-typedef struct DBEContext {
-    void        *avctx;
-    GetBitContext   gb;
+    DECLARE_ALIGNED(32, float, history)[MAX_CHANNELS][256];
 
-    const uint8_t *input;
-    int         input_size;
-
-    int         word_bits;
-    int         word_bytes;
-    int         key_present;
-
-    DolbyEHeaderInfo metadata;
+    FFTContext          imdct[3];
+    AVFloatDSPContext   *fdsp;
 
     uint8_t     buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE];
 } DBEContext;
 
-/**
- * Use the provided key to transform the input into data (put into s->buffer)
- * suitable for further processing and initialize s->gb to read said data.
- */
-int ff_dolby_e_convert_input(DBEContext *s, int nb_words, int key);
+static const uint8_t nb_programs_tab[MAX_PROG_CONF + 1] = {
+    2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 1, 2, 3, 3, 4, 5, 6, 1, 2, 3, 4, 1, 1
+};
 
-/**
- * Initialize DBEContext and parse Dolby E metadata.
- * Set word_bits/word_bytes, input, input_size, key_present
- * and parse the header up to the end_gain element.
- * @param[out] s DBEContext.
- * @param[in]  buf raw input buffer.
- * @param[in]  buf_size must be 3 bytes at least.
- * @return Returns 0 on success, AVERROR_INVALIDDATA on error
- */
-int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size);
+static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = {
+    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8
+};
+
+static const int8_t lfe_channel_tab[MAX_PROG_CONF + 1] = {
+     5,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  5, 5
+};
+
+static const uint8_t ch_reorder_4[4] = { 0, 2, 1, 3 };
+static const uint8_t ch_reorder_6[6] = { 0, 2, 4, 1, 3, 5 };
+static const uint8_t ch_reorder_8[8] = { 0, 2, 6, 4, 1, 3, 7, 5 };
+static const uint8_t ch_reorder_n[8] = { 0, 2, 4, 6, 1, 3, 5, 7 };
+
+static const uint16_t sample_rate_tab[16] = {
+    0, 42965, 43008, 44800, 53706, 53760
+};
+
+static const uint8_t nb_groups_tab[4] = { 1, 8, 7, 1 };
+
+static const uint8_t nb_mstr_exp_tab[4] = { 2, 2, 2, 1 };
+
+static const uint8_t nb_mantissa_38[38] = {
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
+     2,  2,  2,  2,  2,  2,  3,  3,  3,  4,  4,  4,  5,  5,  6,  6,
+     7,  8,  9, 10, 11, 12,
+};
+
+static const uint8_t nb_mantissa_44[44] = {
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,
+     2,  2,  2,  2,  2,  3,  3,  3,  3,  4,  4,  5,  5,  6,  7,  7,
+     8,  9, 10, 11, 12, 13, 15, 16, 18, 20, 22, 25,
+};
+
+static const uint8_t nb_mantissa_50[50] = {
+     1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,
+     3,  4,  4,  5,  5,  6,  6,  7,  8,  9,  9, 10, 12, 13, 14, 16,
+    18, 19, 22, 24, 27, 29, 32, 36, 40, 44, 49, 54, 60, 66, 74, 82,
+    90, 100,
+};
+
+static const uint8_t imdct_bits_tab[3] = { 8, 9, 11 };
+
+static const DBEGroup grp_tab_0[1] = {
+    { 50, { 27, 23 }, 0, 0, nb_mantissa_50, 2, 0, 1152, 0, 1408, 0 },
+};
+
+static const DBEGroup grp_tab_1[8] = {
+    { 38, { 12, 26 }, 0, 0, nb_mantissa_38, 0, 0, 192, 0, 256, 0 },
+    { 38, { 12, 26 }, 38, 128, nb_mantissa_38, 0, 1, 256, 64, 448, 0 },
+    { 38, { 12, 26 }, 76, 256, nb_mantissa_38, 0, 1, 256, 192, 704, 0 },
+    { 38, { 12, 26 }, 114, 384, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
+    { 38, { 12, 26 }, 152, 512, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
+    { 38, { 12, 26 }, 190, 640, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
+    { 38, { 12, 26 }, 228, 768, nb_mantissa_38, 0, 1, 256, 704, 0, 0 },
+    { 38, { 12, 26 }, 266, 896, nb_mantissa_38, 0, 1, 256, 832, 0, 0 },
+};
+
+static const DBEGroup grp_tab_2[7] = {
+    { 38, { 12, 26 }, 0, 0, nb_mantissa_38, 0, 0, 192, 0, 256, 0 },
+    { 38, { 12, 26 }, 38, 128, nb_mantissa_38, 0, 1, 256, 64, 448, 0 },
+    { 38, { 12, 26 }, 76, 256, nb_mantissa_38, 0, 1, 256, 192, 704, 0 },
+    { 38, { 12, 26 }, 114, 384, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
+    { 38, { 12, 26 }, 152, 512, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
+    { 38, { 12, 26 }, 190, 640, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
+    { 44, { 19, 25 }, 228, 768, nb_mantissa_44, 1, 1, 448, 704, 960, 64 },
+};
+
+static const DBEGroup grp_tab_3[1] = {
+    { 21, { 21 }, 0, 0, nb_mantissa_50, 2, 0, 1152, 0, 1408, 0 },
+};
+
+static const DBEGroup grp_tab_4[1] = {
+    { 50, { 27, 23 }, 0, 0, nb_mantissa_50, 2, 2, 1152, 0, 1408, 896 },
+};
+
+static const DBEGroup grp_tab_5[8] = {
+    { 38, { 12, 26 }, 0, 0, nb_mantissa_38, 0, 1, 256, 64, 0, 0 },
+    { 38, { 12, 26 }, 38, 128, nb_mantissa_38, 0, 1, 256, 192, 0, 0 },
+    { 38, { 12, 26 }, 76, 256, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
+    { 38, { 12, 26 }, 114, 384, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
+    { 38, { 12, 26 }, 152, 512, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
+    { 38, { 12, 26 }, 190, 640, nb_mantissa_38, 0, 1, 256, 704, 3008, 0 },
+    { 38, { 12, 26 }, 228, 768, nb_mantissa_38, 0, 1, 256, 832, 2752, 0 },
+    { 38, { 12, 26 }, 266, 896, nb_mantissa_38, 0, 2, 192, 960, 2560, 64 },
+};
+
+static const DBEGroup grp_tab_6[7] = {
+    { 44, { 19, 25 }, 0, 0, nb_mantissa_44, 1, 1, 448, 0, 3264, 0 },
+    { 38, { 12, 26 }, 44, 256, nb_mantissa_38, 0, 1, 256, 320, 0, 0 },
+    { 38, { 12, 26 }, 82, 384, nb_mantissa_38, 0, 1, 256, 448, 0, 0 },
+    { 38, { 12, 26 }, 120, 512, nb_mantissa_38, 0, 1, 256, 576, 0, 0 },
+    { 38, { 12, 26 }, 158, 640, nb_mantissa_38, 0, 1, 256, 704, 3008, 0 },
+    { 38, { 12, 26 }, 196, 768, nb_mantissa_38, 0, 1, 256, 832, 2752, 0 },
+    { 38, { 12, 26 }, 234, 896, nb_mantissa_38, 0, 2, 192, 960, 2560, 64 },
+};
+
+static const DBEGroup grp_tab_7[1] = {
+    { 21, { 21 }, 0, 0, nb_mantissa_50, 2, 2, 1152, 0, 1408, 896 },
+};
+
+static const DBEGroup *const frm_ofs_tab[2][4] = {
+    { grp_tab_0, grp_tab_1, grp_tab_2, grp_tab_3 },
+    { grp_tab_4, grp_tab_5, grp_tab_6, grp_tab_7 }
+};
+
+static const uint8_t mantissa_size1[16][4] = {
+    {  0,  0,  0,  0 }, {  2,  1,  1,  1 }, {  3,  2,  1,  1 }, {  4,  3,  2,  1 },
+    {  5,  4,  3,  2 }, {  6,  5,  4,  3 }, {  7,  6,  5,  4 }, {  8,  7,  6,  5 },
+    {  9,  8,  7,  6 }, { 10,  9,  8,  7 }, { 11, 10,  9,  8 }, { 12, 11, 10,  9 },
+    { 13, 12, 11, 10 }, { 14, 13, 12, 11 }, { 15, 14, 13, 12 }, { 16, 15, 14, 13 },
+};
+
+static const uint8_t mantissa_size2[16][4] = {
+    {  0,  0,  0,  0 }, {  2,  1,  2,  2 }, {  3,  2,  3,  3 }, {  4,  3,  4,  4 },
+    {  5,  4,  5,  5 }, {  6,  5,  6,  6 }, {  7,  6,  7,  7 }, {  8,  7,  8,  8 },
+    {  9,  8,  9,  9 }, { 10,  9, 10, 10 }, { 11, 10, 11, 11 }, { 12, 11, 12, 12 },
+    { 13, 12, 13, 13 }, { 14, 13, 14, 14 }, { 15, 14, 15, 15 }, { 16, 15, 16, 16 },
+};
+
+static const float start_window[192] = {
+    0.00161569379826, 0.00185748233347, 0.00198562758548, 0.00207834078104,
+    0.00215717748523, 0.00223067096393, 0.00230299213147, 0.00237651215396,
+    0.00245275561606, 0.00253281402069, 0.00261754673613, 0.00270768786168,
+    0.00280390761895, 0.00290684998656, 0.00301715751161, 0.00313548872798,
+    0.00326253122934, 0.00339901215995, 0.00354570716636, 0.00370344845023,
+    0.00387313232586, 0.00405572653911, 0.00425227750970, 0.00446391759265,
+    0.00469187240551, 0.00493746822816, 0.00520213944619, 0.00548743597507,
+    0.00579503056737, 0.00612672586953, 0.00648446105606, 0.00687031782873,
+    0.00728652552677, 0.00773546505205, 0.00821967127415, 0.00874183354619,
+    0.00930479393832, 0.00991154278653, 0.01056521116692, 0.01126905994567,
+    0.01202646513050, 0.01284089936559, 0.01371590957417, 0.01465509096066,
+    0.01566205783408, 0.01674041199523, 0.01789370972358, 0.01912542867865,
+    0.02043893626265, 0.02183746113793, 0.02332406961796, 0.02490164852364,
+    0.02657289580178, 0.02834031974193, 0.03020624702903, 0.03217283918354,
+    0.03424211623810, 0.03641598586180, 0.03869627565015, 0.04108476601498,
+    0.04358322107390, 0.04619341515939, 0.04891715301882, 0.05175628239149,
+
+    0.05471237327267, 0.05778734733755, 0.06098291402413, 0.06430101352084,
+    0.06774345212186, 0.07131188644726, 0.07500780649199, 0.07883251748595,
+    0.08278712056651, 0.08687249228061, 0.09108926295730, 0.09543779401074,
+    0.09991815425851, 0.10453009536427, 0.10927302653894, 0.11414598865987,
+    0.11914762799220, 0.12427616972097, 0.12952939152560, 0.13490459744934,
+    0.14039859233595, 0.14600765712201, 0.15172752528722, 0.15755336077528,
+    0.16347973770491, 0.16950062219342, 0.17560935661442, 0.18179864660619,
+    0.18806055113821, 0.19438647593012, 0.20076717050010, 0.20719272909882,
+    0.21365259576030, 0.22013557367283, 0.22662983904194, 0.23312295958328,
+    0.23960191774666, 0.24605313873388, 0.25246252333253, 0.25881548554631,
+    0.26509699495987, 0.27129162373316, 0.27738359807707, 0.28335685401987,
+    0.28919509723179, 0.29488186663467, 0.30040060148455, 0.30573471157819,
+    0.31086765019993, 0.31578298939317, 0.32046449711227, 0.32489621578468,
+    0.32906254179156, 0.33294830535654, 0.33653885031840, 0.33982011325336,
+    0.34277870140679, 0.34540196889300, 0.34767809062480, 0.34959613344194,
+    0.35114612391958, 0.35231911235422, 0.35310723244504, 0.35350375621308,
+
+    0.35350314372945, 0.35310108725579, 0.35229454943591, 0.35108179521634,
+    0.34946241721522, 0.34743735430290, 0.34500890320420, 0.34218072298001,
+    0.33895783229541, 0.33534659943168, 0.33135472505060, 0.32699121776996,
+    0.32226636266000, 0.31719168282019, 0.31177989424432, 0.30604485422875,
+    0.30000150362379, 0.29366580327088, 0.28705466500775, 0.28018587766131,
+    0.27307802848095, 0.26575042049535, 0.25822298630189, 0.25051619882000,
+    0.24265097955783, 0.23464860495522, 0.22653061137548, 0.21831869932335,
+    0.21003463746705, 0.20170016703857, 0.19333690717811, 0.18496626177620,
+    0.17660932835062, 0.16828680947474, 0.16001892724986, 0.15182534128597,
+    0.14372507062477, 0.13573642000364, 0.12787691082233, 0.12016321713317,
+    0.11261110693234, 0.10523538898282, 0.09804986534955, 0.09106728977263,
+    0.08429933194438, 0.07775654768810, 0.07144835495683, 0.06538301547324,
+    0.05956762170687, 0.05400808871425, 0.04870915012107, 0.04367435714993,
+    0.03890607899172, 0.03440550179663, 0.03017262174627, 0.02620622428513,
+    0.02250383492507, 0.01906161305732, 0.01587412848221, 0.01293388032354,
+    0.01023019677288, 0.00774641320626, 0.00545109736891, 0.00325868651263,
+};
+
+static const float short_window2[192] = {
+    0.00018861094606, 0.00033433010202, 0.00050309624485, 0.00070306161748,
+    0.00093995174533, 0.00121913067128, 0.00154606505568, 0.00192647806126,
+    0.00236641248692, 0.00287225985240, 0.00345077377440, 0.00410907465023,
+    0.00485464855241, 0.00569534163219, 0.00663935063508, 0.00769520981249,
+    0.00887177436246, 0.01017820046395, 0.01162392194150, 0.01321862359335,
+    0.01497221122468, 0.01689477844427, 0.01899657030441, 0.02128794388846,
+    0.02377932597692, 0.02648116795039, 0.02940389811590, 0.03255787167130,
+    0.03595331854986, 0.03960028941437, 0.04350860009563, 0.04768777479454,
+    0.05214698838949, 0.05689500821121, 0.06194013566525, 0.06729014809766,
+    0.07295224131210, 0.07893297315602, 0.08523820859989, 0.09187306673620,
+    0.09884187012422, 0.10614809690222, 0.11379433608064, 0.12178224641797,
+    0.13011251926531, 0.13878484574660, 0.14779788861830, 0.15714925912610,
+    0.16683549914631, 0.17685206886673, 0.18719334022589, 0.19785259629099,
+    0.20882203671372, 0.22009278936030, 0.23165492816694, 0.24349749722585,
+    0.25560854105961, 0.26797514099368, 0.28058345748882, 0.29341877824732,
+    0.30646557185942, 0.31970754671026, 0.33312771482295, 0.34670846027024,
+
+    0.36043161174692, 0.37427851885723, 0.38823013163645, 0.40226708279486,
+    0.41636977214436, 0.43051845264462, 0.44469331748632, 0.45887458761470,
+    0.47304259908636, 0.48717788964798, 0.50126128392546, 0.51527397661778,
+    0.52919761310050, 0.54301436685998, 0.55670701320069, 0.57025899869448,
+    0.58365450587230, 0.59687851269542, 0.60991684638414, 0.62275623122793,
+    0.63538433005035, 0.64778977905593, 0.65996221584264, 0.67189230042379,
+    0.68357172916486, 0.69499324160511, 0.70615062019861, 0.71703868307548,
+    0.72765326998919, 0.73799122168099, 0.74805035295521, 0.75782941981995,
+    0.76732808110520, 0.77654685502339, 0.78548707118622, 0.79415081863423,
+    0.80254089047207, 0.81066072573188, 0.81851434910893, 0.82610630922734,
+    0.83344161609862, 0.84052567843230, 0.84736424144524, 0.85396332579459,
+    0.86032916822973, 0.86646816451999, 0.87238681516918, 0.87809167437532,
+    0.88358930263537, 0.88888622333073, 0.89398888356256, 0.89890361943564,
+    0.90363662591861, 0.90819393133744, 0.91258137648979, 0.91680459830070,
+    0.92086901787718, 0.92477983276087, 0.92854201312583, 0.93216030163834,
+    0.93563921662343, 0.93898305819384, 0.94219591693690, 0.94528168477979,
+
+    0.94823843319821, 0.95106834367330, 0.95377776558539, 0.95636718335775,
+    0.95883679961479, 0.96118650212341, 0.96341583179195, 0.96552395212906,
+    0.96750962060547, 0.96937116231768, 0.97110644638309, 0.97271286544154,
+    0.97418731862798, 0.97552619834964, 0.97672538116257, 0.97778022299974,
+    0.97868555895586, 0.97943570778357, 0.98002448120255, 0.98044519806866,
+    0.98069070339493, 0.98075339216123, 0.98062523779637, 0.98029782516478,
+    0.97976238784222, 0.97900984942031, 0.97803086854002, 0.97681588731895,
+    0.97535518280755, 0.97363892108474, 0.97165721358452, 0.96940017523145,
+    0.96685798395452, 0.96402094114589, 0.96087953263194, 0.95742448973047,
+    0.95364684997699, 0.94953801711660, 0.94508981997396, 0.94029456983253,
+    0.93514511597504, 0.92963489905951, 0.92375800202883, 0.91750919827624,
+    0.91088399681406, 0.90387868421832, 0.89649036314692, 0.88871698725397,
+    0.88055739234735, 0.87201132366062, 0.86307945913336, 0.85376342861693,
+    0.84406582894455, 0.83399023482637, 0.82354120554757, 0.81272428745995,
+    0.80154601230457, 0.79001389138101, 0.77813640562199, 0.76592299164227,
+    0.75338402384395, 0.74053079267526, 0.72737547915460, 0.71393112578527,
+};
+
+static const float short_window3[64] = {
+    0.00326887936450, 0.00550242900936, 0.00786846643791, 0.01045683453520,
+    0.01330402120132, 0.01643221072863, 0.01985798040609, 0.02359509464766,
+    0.02765559221954, 0.03205025893128, 0.03678884369614, 0.04188015679495,
+    0.04733210987781, 0.05315172583924, 0.05934513287609, 0.06591755045290,
+    0.07287327156378, 0.08021564389822, 0.08794705152307, 0.09606889811179,
+    0.10458159240070, 0.11348453632940, 0.12277611617809, 0.13245369691511,
+    0.14251361989876, 0.15295120402567, 0.16376075037904, 0.17493555039885,
+    0.18646789757072, 0.19834910260891, 0.21056951208995, 0.22311853047787,
+    0.23598464546683, 0.24915545655419, 0.26261770674500, 0.27635731727778,
+    0.29035942525136, 0.30460842402318, 0.31908800624032, 0.33378120935681,
+    0.34867046348260, 0.36373764140285, 0.37896411059909, 0.39433078709788,
+    0.40981819096657, 0.42540650327031, 0.44107562429959, 0.45680523287270,
+    0.47257484651351, 0.48836388230077, 0.50415171818214, 0.51991775454258,
+    0.53564147581496, 0.55130251191887, 0.56688069931047, 0.58235614142007,
+    0.59770926827271, 0.61292089506118, 0.62797227945823, 0.64284517745255,
+    0.65752189749349, 0.67198535273209, 0.68621911114984, 0.70020744337099,
+};
+
+static const uint8_t dc_code_tab[5] = { 0, 0, 0, 1, 1 };
+
+static const uint8_t ht_code_tab[5] = { 0, 0, 1, 2, 2 };
+
+static const uint8_t band_ofs_tab[3][4] = {
+    { 12, 8, 4, 0 }, { 14, 10, 6, 0 }, { 12, 8, 4, 0 }
+};
+
+static const uint8_t band_low_tab[3] = { 9, 17, 24 };
+
+static const uint16_t fast_gain_tab[8] = {
+    128, 256, 384, 512, 640, 768, 896, 1024
+};
+
+static const uint16_t slow_decay_tab[2][2] = { { 27, -1 }, { 32, 21 } };
+
+static const uint16_t misc_decay_tab[3][2][2] = {
+    { { 354, -1 }, { 425, 425 } },
+    { { 266, -1 }, { 320,  -1 } },
+    { { 213, -1 }, { 256,  -1 } }
+};
+
+static const uint16_t fast_decay_tab[3][2][2][50] = {
+    {{{
+        142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
+        142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
+        142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
+        142, 142, 142, 142, 142, 142, 142, 142,
+    }, {
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+    }}, {{
+        170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
+        170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
+        170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
+        170, 170, 170, 170, 170, 170, 170, 170,
+    }, {
+         64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
+         64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
+         64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
+         64,  64,  64,  64,  64,  64,  64,  64,
+    }}}, {{{
+        266, 266, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106,
+    }, {
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,
+    }}, {{
+        319, 319, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128,
+    }, {
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,
+    }}}, {{{
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+        106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+    }, {
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+    }}, {{
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+        128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+    }, {
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+         -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+    }}}
+};
+
+static const uint16_t fast_gain_adj_tab[3][2][62] = {
+    {{
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   1,   2,   4,   7,  11,  16,  29,  44,  59,
+         76,  94, 116, 142, 179, 221, 252, 285, 312, 334,
+    }, {
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          2,   5,   8,  10,  15,  28,  42,  57,  75,  93,
+        115, 140, 177, 219, 247, 280, 308, 330, 427, 533,
+    }}, {{
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   2,   5,   8,  12,  21,  35,  51,  69,  89,
+        111, 138, 176, 220, 251, 284, 312, 334,
+    }, {
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   2,
+          5,   8,  11,  18,  33,  49,  65,  84, 106, 132,
+        168, 214, 245, 279, 308, 329, 427, 533,
+    }}, {{
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   1,   4,   7,  10,  17,
+         31,  47,  65,  84, 107, 134, 171, 215, 250, 283,
+        312, 334,
+    }, {
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+          0,   0,   0,   0,   3,   6,   9,  13,  27,  43,
+         60,  79, 100, 126, 160, 207, 242, 276, 307, 329,
+        427, 533,
+    }}
+};
+
+static const uint16_t slow_gain_tab[3][2][50] = {
+    {{
+        3072, 3072, 3072, 3072, 3072, 3072, 1063, 1063, 1063, 1063,
+        1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,
+        1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,
+        1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,
+    }, {
+        3072, 3072, 3072, 3072, 3072, 3072,  850,  850,  850,  850,
+         850,  850,  850,  850,  850,  850,  850,  850,  850,  850,
+         850,  850,  850,  850,  850,  850,  850,  850,  850,  850,
+         850,  850,  850,  850,  850,  850,  850,  850,
+    }}, {{
+        3072, 1212, 1212, 1212,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,
+    }, {
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,
+    }}, {{
+        3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+         999,  999,  999,  999,  999,  999,  999,  999,  999,  999,
+    }, {
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+    }}
+};
+
+static const uint16_t hearing_thresh_tab[3][3][50] = {
+    {{
+        1403, 1141, 1000,  959,  948,  957,  946,  925,  899,  871,
+         843,  815,  789,  766,  745,  727,  705,  687,  681,  686,
+         701,  725,  768,  854,  940, 1018, 1075, 1103, 1111, 1106,
+        1098, 1105, 1142, 1237, 1419, 1721, 2169, 2805,
+    }, {
+        1401, 1130,  995,  957,  947,  955,  941,  918,  890,  861,
+         831,  803,  777,  754,  734,  717,  698,  684,  682,  692,
+         712,  743,  798,  894,  976, 1045, 1091, 1109, 1110, 1102,
+        1098, 1116, 1174, 1300, 1526, 1884, 2401, 3072,
+    }, {
+        1393, 1086,  974,  949,  957,  941,  913,  878,  843,  808,
+         777,  750,  727,  708,  695,  686,  681,  689,  714,  752,
+         811,  888,  971, 1044, 1087, 1108, 1110, 1102, 1098, 1115,
+        1172, 1290, 1489, 1812, 2293, 2964, 3072, 3072,
+    }}, {{
+        1412, 1343, 1141, 1047, 1000,  974,  959,  951,  948,  947,
+         957,  953,  946,  936,  925,  906,  878,  850,  822,  795,
+         771,  745,  719,  700,  687,  681,  685,  701,  733,  784,
+         885,  977, 1047, 1092, 1110, 1108, 1099, 1102, 1138, 1233,
+        1413, 1711, 2157, 2797,
+    }, {
+        1412, 1336, 1130, 1040,  995,  970,  957,  950,  947,  947,
+         955,  950,  941,  930,  918,  897,  868,  838,  810,  783,
+         759,  734,  710,  693,  684,  681,  690,  712,  752,  823,
+         924, 1009, 1069, 1102, 1111, 1104, 1098, 1111, 1168, 1295,
+        1518, 1873, 2388, 3072,
+    }, {
+        1411, 1293, 1086, 1009,  974,  957,  949,  947,  957,  951,
+         941,  928,  913,  896,  878,  852,  817,  785,  756,  732,
+         713,  695,  683,  682,  689,  710,  746,  811,  906,  992,
+        1061, 1099, 1111, 1106, 1098, 1107, 1155, 1266, 1471, 1799,
+        2277, 2945, 3072, 3072,
+    }}, {{
+        1431, 1412, 1403, 1379, 1343, 1293, 1229, 1180, 1125, 1075,
+        1040, 1014,  996,  979,  965,  957,  951,  948,  947,  957,
+         951,  940,  924,  903,  877,  846,  815,  785,  753,  725,
+         702,  686,  681,  689,  714,  760,  847,  947, 1028, 1083,
+        1108, 1109, 1101, 1100, 1132, 1222, 1402, 1705, 2160, 2803,
+    }, {
+        1431, 1412, 1401, 1375, 1336, 1278, 1215, 1168, 1115, 1066,
+        1032, 1008,  991,  975,  962,  954,  950,  947,  947,  955,
+         948,  935,  916,  894,  866,  835,  803,  772,  742,  715,
+         695,  683,  683,  697,  729,  784,  887,  982, 1054, 1096,
+        1111, 1106, 1098, 1107, 1159, 1281, 1505, 1865, 2391, 3072,
+    }, {
+        1427, 1411, 1393, 1353, 1293, 1215, 1160, 1118, 1072, 1031,
+        1003,  984,  971,  960,  952,  948,  947,  957,  952,  941,
+         924,  902,  876,  847,  815,  781,  750,  723,  700,  685,
+         681,  691,  719,  766,  858,  958, 1039, 1089, 1109, 1108,
+        1099, 1102, 1141, 1245, 1442, 1766, 2250, 2930, 3072, 3072,
+    }}
+};
+
+static const int16_t lwc_gain_tab[11][7] = {
+    {   -21,  -197,  -271,  -466, 32767, 32767, 32767 },
+    {  -197,   -29,  -244,  -271,  -540, 32767, 32767 },
+    {  -271,  -244,   -29,  -249,  -271,  -593, 32767 },
+    {  -466,  -271,  -249,   -29,  -251,  -271,  -632 },
+    {  -540,  -271,  -251,   -29,  -251,  -271,  -664 },
+    {  -593,  -271,  -251,   -29,  -252,  -271,  -690 },
+    {  -632,  -271,  -252,   -29,  -252,  -271,  -711 },
+    {  -664,  -271,  -252,   -29,  -252,  -271,  -730 },
+    {  -690,  -271,  -252,   -29,  -252,  -271,  -745 },
+    {  -711,  -271,  -252,   -29,  -253,  -271,  -759 },
+    {  -730,  -271,  -253,   -29,  -253,  -271,  -771 },
+};
+
+static const int16_t lwc_adj_tab[7] = {
+    -192, -320, -448, -512, -448, -320, -192,
+};
+
+static const uint8_t log_add_tab[212] = {
+    64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52, 51, 50,
+    49, 48, 47, 47, 46, 45, 44, 44, 43, 42, 41, 41, 40, 39, 38, 38,
+    37, 36, 36, 35, 35, 34, 33, 33, 32, 32, 31, 30, 30, 29, 29, 28,
+    28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 21,
+    20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15,
+    15, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11,
+    10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,
+     7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,
+     5,  5,  5,  5,  5,  5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
+     4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,
+     2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+     2,  2,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
+     1,  1,  0,  0,
+};
+
+static const uint8_t bap_tab[64] = {
+     0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,  4,
+     4,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,
+     8,  8,  8,  9,  9,  9,  9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
+    12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15,
+};
+
+static float mantissa_tab1[17][4];
+static float mantissa_tab2[17][4];
+static float mantissa_tab3[17][4];
+static float exponent_tab[50];
+static float gain_tab[1024];
+
+DECLARE_ALIGNED(32, static float, window)[3712];
 
 #endif
diff --git a/libavcodec/dolby_e_parse.c b/libavcodec/dolby_e_parse.c
deleted file mode 100644
index ffedcd9..0000000
--- a/libavcodec/dolby_e_parse.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2017 foo86
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "get_bits.h"
-#include "put_bits.h"
-#include "dolby_e.h"
-
-static const uint8_t nb_programs_tab[MAX_PROG_CONF + 1] = {
-    2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 1, 2, 3, 3, 4, 5, 6, 1, 2, 3, 4, 1, 1
-};
-
-static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = {
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8
-};
-
-static const uint16_t sample_rate_tab[16] = {
-    0, 42965, 43008, 44800, 53706, 53760
-};
-
-static int skip_input(DBEContext *s, int nb_words)
-{
-    if (nb_words > s->input_size) {
-        return AVERROR_INVALIDDATA;
-    }
-
-    s->input      += nb_words * s->word_bytes;
-    s->input_size -= nb_words;
-    return 0;
-}
-
-static int parse_key(DBEContext *s)
-{
-    if (s->key_present) {
-        const uint8_t *key = s->input;
-        int      ret = skip_input(s, 1);
-        if (ret < 0)
-            return ret;
-        return AV_RB24(key) >> 24 - s->word_bits;
-    }
-    return 0;
-}
-
-int ff_dolby_e_convert_input(DBEContext *s, int nb_words, int key)
-{
-    const uint8_t *src = s->input;
-    uint8_t *dst = s->buffer;
-    PutBitContext pb;
-    int i;
-
-    av_assert0(nb_words <= 1024u);
-
-    if (nb_words > s->input_size) {
-        if (s->avctx)
-            av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    switch (s->word_bits) {
-    case 16:
-        for (i = 0; i < nb_words; i++, src += 2, dst += 2)
-            AV_WB16(dst, AV_RB16(src) ^ key);
-        break;
-    case 20:
-        init_put_bits(&pb, s->buffer, sizeof(s->buffer));
-        for (i = 0; i < nb_words; i++, src += 3)
-            put_bits(&pb, 20, AV_RB24(src) >> 4 ^ key);
-        flush_put_bits(&pb);
-        break;
-    case 24:
-        for (i = 0; i < nb_words; i++, src += 3, dst += 3)
-            AV_WB24(dst, AV_RB24(src) ^ key);
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    return init_get_bits(&s->gb, s->buffer, nb_words * s->word_bits);
-}
-
-int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size)
-{
-    DolbyEHeaderInfo *const header = &s->metadata;
-    int hdr, ret, key, mtd_size;
-
-    if (buf_size < 3)
-        return AVERROR_INVALIDDATA;
-
-    hdr = AV_RB24(buf);
-    if ((hdr & 0xfffffe) == 0x7888e) {
-        s->word_bits = 24;
-    } else if ((hdr & 0xffffe0) == 0x788e0) {
-        s->word_bits = 20;
-    } else if ((hdr & 0xfffe00) == 0x78e00) {
-        s->word_bits = 16;
-    } else {
-        if (s->avctx)
-            av_log(s->avctx, AV_LOG_ERROR, "Invalid frame header\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    s->word_bytes  = s->word_bits + 7 >> 3;
-    s->input       = buf + s->word_bytes;
-    s->input_size  = buf_size / s->word_bytes - 1;
-    s->key_present = hdr >> 24 - s->word_bits & 1;
-
-    if ((key = parse_key(s)) < 0)
-        return key;
-    if ((ret = ff_dolby_e_convert_input(s, 1, key)) < 0)
-        return ret;
-
-    skip_bits(&s->gb, 4);
-    mtd_size = get_bits(&s->gb, 10);
-    if (!mtd_size) {
-        if (s->avctx)
-            av_log(s->avctx, AV_LOG_ERROR, "Invalid metadata size\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    if ((ret = ff_dolby_e_convert_input(s, mtd_size, key)) < 0)
-        return ret;
-
-    skip_bits(&s->gb, 14);
-    header->prog_conf = get_bits(&s->gb, 6);
-    if (header->prog_conf > MAX_PROG_CONF) {
-        if (s->avctx)
-            av_log(s->avctx, AV_LOG_ERROR, "Invalid program configuration\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    header->nb_channels = nb_channels_tab[header->prog_conf];
-    header->nb_programs = nb_programs_tab[header->prog_conf];
-
-    header->fr_code      = get_bits(&s->gb, 4);
-    header->fr_code_orig = get_bits(&s->gb, 4);
-    if (!(header->sample_rate = sample_rate_tab[header->fr_code]) ||
-        !sample_rate_tab[header->fr_code_orig]) {
-        if (s->avctx)
-            av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    skip_bits_long(&s->gb, 88);
-    for (int i = 0; i < header->nb_channels; i++)
-        header->ch_size[i] = get_bits(&s->gb, 10);
-    header->mtd_ext_size = get_bits(&s->gb, 8);
-    header->meter_size   = get_bits(&s->gb, 8);
-
-    skip_bits_long(&s->gb, 10 * header->nb_programs);
-    for (int i = 0; i < header->nb_channels; i++) {
-        header->rev_id[i]     = get_bits(&s->gb,  4);
-        skip_bits1(&s->gb);
-        header->begin_gain[i] = get_bits(&s->gb, 10);
-        header->end_gain[i]   = get_bits(&s->gb, 10);
-    }
-
-    if (get_bits_left(&s->gb) < 0) {
-        if (s->avctx)
-            av_log(s->avctx, AV_LOG_ERROR, "Read past end of metadata\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    return skip_input(s, mtd_size + 1);
-}
diff --git a/libavcodec/dolby_e_parser.c b/libavcodec/dolby_e_parser.c
deleted file mode 100644
index 3ae973b..0000000
--- a/libavcodec/dolby_e_parser.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2017 foo86
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "dolby_e.h"
-#include "get_bits.h"
-#include "put_bits.h"
-
-typedef struct DBEParseContext {
-    DBEContext dectx;
-} DBEParseContext;
-
-static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx,
-                        const uint8_t **poutbuf, int *poutbuf_size,
-                        const uint8_t *buf, int buf_size)
-{
-    DBEParseContext *s1 = s2->priv_data;
-    DBEContext *s = &s1->dectx;
-    int ret;
-
-    if ((ret = ff_dolby_e_parse_header(s, buf, buf_size)) < 0)
-        goto end;
-
-    s2->duration = FRAME_SAMPLES;
-    switch (s->metadata.nb_channels) {
-    case 4:
-        avctx->channel_layout = AV_CH_LAYOUT_4POINT0;
-        break;
-    case 6:
-        avctx->channel_layout = AV_CH_LAYOUT_5POINT1;
-        break;
-    case 8:
-        avctx->channel_layout = AV_CH_LAYOUT_7POINT1;
-        break;
-    }
-
-    avctx->channels    = s->metadata.nb_channels;
-    avctx->sample_rate = s->metadata.sample_rate;
-    avctx->sample_fmt  = AV_SAMPLE_FMT_FLTP;
-
-end:
-    /* always return the full packet. this parser isn't doing any splitting or
-       combining, only packet analysis */
-    *poutbuf      = buf;
-    *poutbuf_size = buf_size;
-    return buf_size;
-}
-
-AVCodecParser ff_dolby_e_parser = {
-    .codec_ids      = { AV_CODEC_ID_DOLBY_E },
-    .priv_data_size = sizeof(DBEParseContext),
-    .parser_parse   = dolby_e_parse,
-};
diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 5372e3d..b1833ed 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -23,43 +23,10 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/timecode.h"
 #include "bytestream.h"
 #include "avcodec.h"
 #include "internal.h"
 
-enum DPX_TRC {
-    DPX_TRC_USER_DEFINED       = 0,
-    DPX_TRC_PRINTING_DENSITY   = 1,
-    DPX_TRC_LINEAR             = 2,
-    DPX_TRC_LOGARITHMIC        = 3,
-    DPX_TRC_UNSPECIFIED_VIDEO  = 4,
-    DPX_TRC_SMPTE_274          = 5,
-    DPX_TRC_ITU_R_709_4        = 6,
-    DPX_TRC_ITU_R_601_625      = 7,
-    DPX_TRC_ITU_R_601_525      = 8,
-    DPX_TRC_SMPTE_170          = 9,
-    DPX_TRC_ITU_R_624_4_PAL    = 10,
-    DPX_TRC_Z_LINEAR           = 11,
-    DPX_TRC_Z_HOMOGENEOUS      = 12,
-};
-
-enum DPX_COL_SPEC {
-    DPX_COL_SPEC_USER_DEFINED       = 0,
-    DPX_COL_SPEC_PRINTING_DENSITY   = 1,
-    /* 2 = N/A */
-    /* 3 = N/A */
-    DPX_COL_SPEC_UNSPECIFIED_VIDEO  = 4,
-    DPX_COL_SPEC_SMPTE_274          = 5,
-    DPX_COL_SPEC_ITU_R_709_4        = 6,
-    DPX_COL_SPEC_ITU_R_601_625      = 7,
-    DPX_COL_SPEC_ITU_R_601_525      = 8,
-    DPX_COL_SPEC_SMPTE_170          = 9,
-    DPX_COL_SPEC_ITU_R_624_4_PAL    = 10,
-    /* 11 = N/A */
-    /* 12 = N/A */
-};
-
 static unsigned int read16(const uint8_t **ptr, int is_big)
 {
     unsigned int temp;
@@ -159,15 +126,14 @@
     AVFrame *const p = data;
     uint8_t *ptr[AV_NUM_DATA_POINTERS];
     uint32_t header_version, version = 0;
-    char creator[101] = { 0 };
-    char input_device[33] = { 0 };
+    char creator[101];
+    char input_device[33];
 
     unsigned int offset;
     int magic_num, endian;
-    int x, y, stride, i, j, ret;
+    int x, y, stride, i, ret;
     int w, h, bits_per_color, descriptor, elements, packing;
-    int yuv, color_trc, color_spec;
-    int encoding, need_align = 0, unpadded_10bit = 0;
+    int encoding, need_align = 0;
 
     unsigned int rgbBuffer = 0;
     int n_datum = 0;
@@ -226,8 +192,6 @@
     // Need to end in 0x320 to read the descriptor
     buf += 20;
     descriptor = buf[0];
-    color_trc = buf[1];
-    color_spec = buf[2];
 
     // Need to end in 0x323 to read the bits per color
     buf += 3;
@@ -252,109 +216,31 @@
     else
         avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
 
-    /* preferred frame rate from Motion-picture film header */
     if (offset >= 1724 + 4) {
         buf = avpkt->data + 1724;
         i = read32(&buf, endian);
-        if(i && i != 0xFFFFFFFF) {
+        if(i) {
             AVRational q = av_d2q(av_int2float(i), 4096);
             if (q.num > 0 && q.den > 0)
                 avctx->framerate = q;
         }
     }
 
-    /* alternative frame rate from television header */
-    if (offset >= 1940 + 4 &&
-        !(avctx->framerate.num && avctx->framerate.den)) {
-        buf = avpkt->data + 1940;
-        i = read32(&buf, endian);
-        if(i && i != 0xFFFFFFFF) {
-            AVRational q = av_d2q(av_int2float(i), 4096);
-            if (q.num > 0 && q.den > 0)
-                avctx->framerate = q;
-        }
-    }
-
-    /* SMPTE TC from television header */
-    if (offset >= 1920 + 4) {
-        uint32_t tc;
-        uint32_t *tc_sd;
-        char tcbuf[AV_TIMECODE_STR_SIZE];
-
-        buf = avpkt->data + 1920;
-        // read32 to native endian, av_bswap32 to opposite of native for
-        // compatibility with av_timecode_make_smpte_tc_string2 etc
-        tc = av_bswap32(read32(&buf, endian));
-
-        if (i != 0xFFFFFFFF) {
-            AVFrameSideData *tcside =
-                av_frame_new_side_data(p, AV_FRAME_DATA_S12M_TIMECODE,
-                                       sizeof(uint32_t) * 4);
-            if (!tcside)
-                return AVERROR(ENOMEM);
-
-            tc_sd = (uint32_t*)tcside->data;
-            tc_sd[0] = 1;
-            tc_sd[1] = tc;
-
-            av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate,
-                                              tc_sd[1], 0, 0);
-            av_dict_set(&p->metadata, "timecode", tcbuf, 0);
-        }
-    }
-
-    /* color range from television header */
-    if (offset >= 1964 + 4) {
-        buf = avpkt->data + 1952;
-        i = read32(&buf, endian);
-
-        buf = avpkt->data + 1964;
-        j = read32(&buf, endian);
-
-        if (i != 0xFFFFFFFF && j != 0xFFFFFFFF) {
-            float minCV, maxCV;
-            minCV = av_int2float(i);
-            maxCV = av_int2float(j);
-            if (bits_per_color >= 1 &&
-                minCV == 0.0f && maxCV == ((1<<bits_per_color) - 1)) {
-                avctx->color_range = AVCOL_RANGE_JPEG;
-            } else if (bits_per_color >= 8 &&
-                       minCV == (1  <<(bits_per_color - 4)) &&
-                       maxCV == (235<<(bits_per_color - 8))) {
-                avctx->color_range = AVCOL_RANGE_MPEG;
-            }
-        }
-    }
-
     switch (descriptor) {
-    case 1:  // R
-    case 2:  // G
-    case 3:  // B
-    case 4:  // A
     case 6:  // Y
         elements = 1;
-        yuv = 1;
-        break;
-    case 50: // RGB
-        elements = 3;
-        yuv = 0;
         break;
     case 52: // ABGR
     case 51: // RGBA
+    case 103: // UYVA4444
         elements = 4;
-        yuv = 0;
+        break;
+    case 50: // RGB
+    case 102: // UYV444
+        elements = 3;
         break;
     case 100: // UYVY422
         elements = 2;
-        yuv = 1;
-        break;
-    case 102: // UYV444
-        elements = 3;
-        yuv = 1;
-        break;
-    case 103: // UYVA4444
-        elements = 4;
-        yuv = 1;
         break;
     default:
         avpriv_report_missing_feature(avctx, "Descriptor %d", descriptor);
@@ -389,10 +275,8 @@
     case 16:
         stride = 2 * avctx->width * elements;
         break;
-    case 32:
-        stride = 4 * avctx->width * elements;
-        break;
     case 1:
+    case 32:
     case 64:
         avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color);
         return AVERROR_PATCHWELCOME;
@@ -400,82 +284,6 @@
         return AVERROR_INVALIDDATA;
     }
 
-    switch (color_trc) {
-    case DPX_TRC_LINEAR:
-        avctx->color_trc = AVCOL_TRC_LINEAR;
-        break;
-    case DPX_TRC_SMPTE_274:
-    case DPX_TRC_ITU_R_709_4:
-        avctx->color_trc = AVCOL_TRC_BT709;
-        break;
-    case DPX_TRC_ITU_R_601_625:
-    case DPX_TRC_ITU_R_601_525:
-    case DPX_TRC_SMPTE_170:
-        avctx->color_trc = AVCOL_TRC_SMPTE170M;
-        break;
-    case DPX_TRC_ITU_R_624_4_PAL:
-        avctx->color_trc = AVCOL_TRC_GAMMA28;
-        break;
-    case DPX_TRC_USER_DEFINED:
-    case DPX_TRC_UNSPECIFIED_VIDEO:
-        /* Nothing to do */
-        break;
-    default:
-        av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX transfer characteristic "
-            "%d to color_trc.\n", color_trc);
-        break;
-    }
-
-    switch (color_spec) {
-    case DPX_COL_SPEC_SMPTE_274:
-    case DPX_COL_SPEC_ITU_R_709_4:
-        avctx->color_primaries = AVCOL_PRI_BT709;
-        break;
-    case DPX_COL_SPEC_ITU_R_601_625:
-    case DPX_COL_SPEC_ITU_R_624_4_PAL:
-        avctx->color_primaries = AVCOL_PRI_BT470BG;
-        break;
-    case DPX_COL_SPEC_ITU_R_601_525:
-    case DPX_COL_SPEC_SMPTE_170:
-        avctx->color_primaries = AVCOL_PRI_SMPTE170M;
-        break;
-    case DPX_COL_SPEC_USER_DEFINED:
-    case DPX_COL_SPEC_UNSPECIFIED_VIDEO:
-        /* Nothing to do */
-        break;
-    default:
-        av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX color specification "
-            "%d to color_primaries.\n", color_spec);
-        break;
-    }
-
-    if (yuv) {
-        switch (color_spec) {
-        case DPX_COL_SPEC_SMPTE_274:
-        case DPX_COL_SPEC_ITU_R_709_4:
-            avctx->colorspace = AVCOL_SPC_BT709;
-            break;
-        case DPX_COL_SPEC_ITU_R_601_625:
-        case DPX_COL_SPEC_ITU_R_624_4_PAL:
-            avctx->colorspace = AVCOL_SPC_BT470BG;
-            break;
-        case DPX_COL_SPEC_ITU_R_601_525:
-        case DPX_COL_SPEC_SMPTE_170:
-            avctx->colorspace = AVCOL_SPC_SMPTE170M;
-            break;
-        case DPX_COL_SPEC_USER_DEFINED:
-        case DPX_COL_SPEC_UNSPECIFIED_VIDEO:
-            /* Nothing to do */
-            break;
-        default:
-            av_log(avctx, AV_LOG_INFO, "Cannot map DPX color specification "
-                "%d to colorspace.\n", color_spec);
-            break;
-        }
-    } else {
-        avctx->colorspace = AVCOL_SPC_RGB;
-    }
-
     // Table 3c: Runs will always break at scan line boundaries. Packing
     // will always break to the next 32-bit word at scan-line boundaries.
     // Unfortunately, the encoder produced invalid files, so attempt
@@ -497,14 +305,6 @@
     }
 
     switch (1000 * descriptor + 10 * bits_per_color + endian) {
-    case 1081:
-    case 1080:
-    case 2081:
-    case 2080:
-    case 3081:
-    case 3080:
-    case 4081:
-    case 4080:
     case 6081:
     case 6080:
         avctx->pix_fmt = AV_PIX_FMT_GRAY8;
@@ -513,20 +313,6 @@
     case 6120:
         avctx->pix_fmt = AV_PIX_FMT_GRAY12;
         break;
-    case 1320:
-    case 2320:
-    case 3320:
-    case 4320:
-    case 6320:
-        avctx->pix_fmt = AV_PIX_FMT_GRAYF32LE;
-        break;
-    case 1321:
-    case 2321:
-    case 3321:
-    case 4321:
-    case 6321:
-        avctx->pix_fmt = AV_PIX_FMT_GRAYF32BE;
-        break;
     case 50081:
     case 50080:
         avctx->pix_fmt = AV_PIX_FMT_RGB24;
@@ -577,18 +363,6 @@
     case 51160:
         avctx->pix_fmt = AV_PIX_FMT_RGBA64LE;
         break;
-    case 50320:
-        avctx->pix_fmt = AV_PIX_FMT_GBRPF32LE;
-        break;
-    case 50321:
-        avctx->pix_fmt = AV_PIX_FMT_GBRPF32BE;
-        break;
-    case 51320:
-        avctx->pix_fmt = AV_PIX_FMT_GBRAPF32LE;
-        break;
-    case 51321:
-        avctx->pix_fmt = AV_PIX_FMT_GBRAPF32BE;
-        break;
     case 100081:
         avctx->pix_fmt = AV_PIX_FMT_UYVY422;
         break;
@@ -599,8 +373,7 @@
         avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
         break;
     default:
-        av_log(avctx, AV_LOG_ERROR, "Unsupported format %d\n",
-               1000 * descriptor + 10 * bits_per_color + endian);
+        av_log(avctx, AV_LOG_ERROR, "Unsupported format\n");
         return AVERROR_PATCHWELCOME;
     }
 
@@ -617,12 +390,6 @@
     input_device[32] = '\0';
     av_dict_set(&p->metadata, "Input Device", input_device, 0);
 
-    // Some devices do not pad 10bit samples to whole 32bit words per row
-    if (!memcmp(input_device, "Scanity", 7) ||
-        !memcmp(creator, "Lasergraphics Inc.", 18)) {
-        unpadded_10bit = 1;
-    }
-
     // Move pointer to offset from start of file
     buf =  avpkt->data + offset;
 
@@ -655,7 +422,7 @@
                     read10in32(&buf, &rgbBuffer,
                                &n_datum, endian, shift);
             }
-            if (!unpadded_10bit)
+            if (memcmp(input_device, "Scanity", 7))
                 n_datum = 0;
             for (i = 0; i < elements; i++)
                 ptr[i] += p->linesize[i];
@@ -698,36 +465,6 @@
             buf += need_align;
         }
         break;
-    case 32:
-        if (elements == 1) {
-            av_image_copy_plane(ptr[0], p->linesize[0],
-                                buf, stride,
-                                elements * avctx->width * 4, avctx->height);
-        } else {
-            for (y = 0; y < avctx->height; y++) {
-                ptr[0] = p->data[0] + y * p->linesize[0];
-                ptr[1] = p->data[1] + y * p->linesize[1];
-                ptr[2] = p->data[2] + y * p->linesize[2];
-                ptr[3] = p->data[3] + y * p->linesize[3];
-                for (x = 0; x < avctx->width; x++) {
-                    AV_WN32(ptr[2], AV_RN32(buf));
-                    AV_WN32(ptr[0], AV_RN32(buf + 4));
-                    AV_WN32(ptr[1], AV_RN32(buf + 8));
-                    if (avctx->pix_fmt == AV_PIX_FMT_GBRAPF32BE ||
-                        avctx->pix_fmt == AV_PIX_FMT_GBRAPF32LE) {
-                        AV_WN32(ptr[3], AV_RN32(buf + 12));
-                        buf += 4;
-                        ptr[3] += 4;
-                    }
-
-                    buf += 12;
-                    ptr[2] += 4;
-                    ptr[0] += 4;
-                    ptr[1] += 4;
-                }
-            }
-        }
-        break;
     case 16:
         elements *= 2;
     case 8:
diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
index 21d1d9f..9814c9e 100644
--- a/libavcodec/dsddec.c
+++ b/libavcodec/dsddec.c
@@ -66,7 +66,7 @@
 
 typedef struct ThreadData {
     AVFrame *frame;
-    const AVPacket *avpkt;
+    AVPacket *avpkt;
 } ThreadData;
 
 static int dsd_channel(AVCodecContext *avctx, void *tdata, int j, int threadnr)
@@ -75,7 +75,7 @@
     DSDContext *s = avctx->priv_data;
     ThreadData *td = tdata;
     AVFrame *frame = td->frame;
-    const AVPacket *avpkt = td->avpkt;
+    AVPacket *avpkt = td->avpkt;
     int src_next, src_stride;
     float *dst = ((float **)frame->extended_data)[j];
 
diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c
index 568757d..71da65c 100644
--- a/libavcodec/dss_sp.c
+++ b/libavcodec/dss_sp.c
@@ -22,7 +22,6 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index 84d19b9..3fd710d 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -27,7 +27,6 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "internal.h"
 #include "get_bits.h"
 #include "avcodec.h"
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index a0647e5..c526091 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -38,7 +38,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 233e2b6..21a8b84 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -30,7 +30,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
@@ -318,8 +317,9 @@
         65536,  65536,  32768,  21845,  16384,  13107,  10923,  9362,  8192,  4096,  3641,  3277,  2979,  2731,  2341,  1260,
 };
 
-/* DV100 weights are pre-zigzagged, inverted and multiplied by 2^16
+/* DV100 weights are pre-zigzagged, inverted and multiplied by 2^(dv100_weight_shift)
    (in DV100 the AC components are divided by the spec weights) */
+static const int dv100_weight_shift = 16;
 static const int dv_weight_1080[2][64] = {
     { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
       58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c
index f314bce..7143a11 100644
--- a/libavcodec/dxtory.c
+++ b/libavcodec/dxtory.c
@@ -264,8 +264,8 @@
             V[huvborder] = src[3] + 0x80;
             src += 4;
         }
-        Y1 += pic->linesize[0] * 2;
-        Y2 += pic->linesize[0] * 2;
+        Y1 += pic->linesize[0] << 1;
+        Y2 += pic->linesize[0] << 1;
         U  += pic->linesize[1];
         V  += pic->linesize[2];
     }
diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c
index aa14e47..72c38f5 100644
--- a/libavcodec/dxva2_av1.c
+++ b/libavcodec/dxva2_av1.c
@@ -62,7 +62,6 @@
     const AV1RawFilmGrainParams *film_grain = &h->cur_frame.film_grain;
 
     unsigned char remap_lr_type[4] = { AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ };
-    int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain;
 
     memset(pp, 0, sizeof(*pp));
 
@@ -100,7 +99,7 @@
     pp->coding.integer_mv                   = frame_header->force_integer_mv || !(frame_header->frame_type & 1);
     pp->coding.cdef                         = seq->enable_cdef;
     pp->coding.restoration                  = seq->enable_restoration;
-    pp->coding.film_grain                   = seq->film_grain_params_present && !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
+    pp->coding.film_grain                   = seq->film_grain_params_present;
     pp->coding.intrabc                      = frame_header->allow_intrabc;
     pp->coding.high_precision_mv            = frame_header->allow_high_precision_mv;
     pp->coding.switchable_motion_mode       = frame_header->is_motion_mode_switchable;
@@ -216,7 +215,7 @@
     }
 
     /* Film grain */
-    if (apply_grain) {
+    if (film_grain->apply_grain) {
         pp->film_grain.apply_grain              = 1;
         pp->film_grain.scaling_shift_minus8     = film_grain->grain_scaling_minus_8;
         pp->film_grain.chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma;
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 356bb67..8e1032f 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -24,7 +24,7 @@
  * E-AC-3 encoder
  */
 
-#define AC3ENC_FLOAT 1
+#define CONFIG_AC3ENC_FLOAT 1
 
 #include "libavutil/attributes.h"
 #include "ac3enc.h"
@@ -32,10 +32,13 @@
 #include "eac3_data.h"
 
 
+#define AC3ENC_TYPE AC3ENC_TYPE_EAC3
+#include "ac3enc_opts_template.c"
+
 static const AVClass eac3enc_class = {
     .class_name = "E-AC-3 Encoder",
     .item_name  = av_default_item_name,
-    .option     = &ff_ac3_enc_options[2], /* First two options are AC-3 only. */
+    .option     = ac3_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
@@ -262,6 +265,6 @@
     .priv_class      = &eac3enc_class,
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
-    .defaults        = ff_ac3_enc_defaults,
-    .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .defaults        = ac3_defaults,
+    .caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index 2c03aa5..7f28abb 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -28,8 +28,6 @@
  * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_MAD
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bytestream.h"
@@ -351,5 +349,4 @@
     .close          = decode_end,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index 197ba6f..1308c07 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -29,9 +29,6 @@
  */
 
 #define BITSTREAM_READER_LE
-
-#include "libavutil/mem_internal.h"
-
 #include "aandcttab.h"
 #include "avcodec.h"
 #include "bytestream.h"
diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c
index 2be2737..96536b1 100644
--- a/libavcodec/eatqi.c
+++ b/libavcodec/eatqi.c
@@ -26,8 +26,6 @@
  * @see http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TQI
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
@@ -191,5 +189,4 @@
     .close          = tqi_decode_end,
     .decode         = tqi_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 282337e..2e540ba 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -152,10 +152,6 @@
 
     if (CONFIG_FRAME_THREAD_ENCODER &&
         avci->frame_thread_encoder && (avctx->active_thread_type & FF_THREAD_FRAME))
-        /* This might modify frame, but it doesn't matter, because
-         * the frame properties used below are not used for video
-         * (due to the delay inherent in frame threaded encoding, it makes
-         *  no sense to use the properties of the current frame anyway). */
         ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
     else {
         ret = avctx->codec->encode2(avctx, avpkt, frame, &got_packet);
@@ -360,7 +356,6 @@
     return 0;
 }
 
-#if FF_API_OLD_ENCDEC
 static int compat_encode(AVCodecContext *avctx, AVPacket *avpkt,
                          int *got_packet, const AVFrame *frame)
 {
@@ -461,4 +456,3 @@
 
     return ret;
 }
-#endif
diff --git a/libavcodec/exif.c b/libavcodec/exif.c
index 0b656fd..2874772 100644
--- a/libavcodec/exif.c
+++ b/libavcodec/exif.c
@@ -95,15 +95,22 @@
         ret = ff_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata);
     } else {
         const char *name = exif_get_tag_name(id);
-        char buf[7];
+        char *use_name   = (char*) name;
 
-        if (!name) {
-            name = buf;
-            snprintf(buf, sizeof(buf), "0x%04X", id);
+        if (!use_name) {
+            use_name = av_malloc(7);
+            if (!use_name) {
+                return AVERROR(ENOMEM);
+            }
+            snprintf(use_name, 7, "0x%04X", id);
         }
 
-        ret = exif_add_metadata(logctx, count, type, name, NULL,
+        ret = exif_add_metadata(logctx, count, type, use_name, NULL,
                                 gbytes, le, metadata);
+
+        if (!name) {
+            av_freep(&use_name);
+        }
     }
 
     bytestream2_seek(gbytes, cur_pos, SEEK_SET);
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 8a714c1..6e6ce42 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -29,6 +29,8 @@
  *
  * For more information on the OpenEXR format, visit:
  *  http://openexr.com/
+ *
+ * exr_half2float() is credited to Aaftab Munshi, Dan Ginsburg, Dave Shreiner.
  */
 
 #include <float.h>
@@ -52,7 +54,6 @@
 #include "exrdsp.h"
 #include "get_bits.h"
 #include "internal.h"
-#include "half2float.h"
 #include "mathops.h"
 #include "thread.h"
 
@@ -65,8 +66,8 @@
     EXR_PXR24,
     EXR_B44,
     EXR_B44A,
-    EXR_DWAA,
-    EXR_DWAB,
+    EXR_DWA,
+    EXR_DWB,
     EXR_UNKN,
 };
 
@@ -90,12 +91,6 @@
     EXR_TILE_ROUND_UNKNOWN,
 };
 
-typedef struct HuffEntry {
-    uint8_t  len;
-    uint16_t sym;
-    uint32_t code;
-} HuffEntry;
-
 typedef struct EXRChannel {
     int xsub, ysub;
     enum ExrPixelType pixel_type;
@@ -118,28 +113,9 @@
     uint8_t *bitmap;
     uint16_t *lut;
 
-    uint8_t *ac_data;
-    unsigned ac_size;
-
-    uint8_t *dc_data;
-    unsigned dc_size;
-
-    uint8_t *rle_data;
-    unsigned rle_size;
-
-    uint8_t *rle_raw_data;
-    unsigned rle_raw_size;
-
-    float block[3][64];
-
     int ysize, xsize;
 
     int channel_line_size;
-
-    int run_sym;
-    HuffEntry *he;
-    uint64_t *freq;
-    VLC vlc;
 } EXRThreadData;
 
 typedef struct EXRContext {
@@ -158,7 +134,6 @@
     const AVPixFmtDescriptor *desc;
 
     int w, h;
-    uint32_t sar;
     int32_t xmax, xmin;
     int32_t ymax, ymin;
     uint32_t xdelta, ydelta;
@@ -167,8 +142,6 @@
 
     EXRTileAttribute tile_attr; /* header data attribute of tile */
     int is_tile; /* 0 if scanline, 1 if tile */
-    int is_multipart;
-    int current_part;
 
     int is_luma;/* 1 if there is an Y plane */
 
@@ -179,22 +152,77 @@
     EXRChannel *channels;
     int nb_channels;
     int current_channel_offset;
-    uint32_t chunk_count;
 
     EXRThreadData *thread_data;
 
     const char *layer;
-    int selected_part;
 
     enum AVColorTransferCharacteristic apply_trc_type;
     float gamma;
     union av_intfloat32 gamma_table[65536];
-
-    uint32_t mantissatable[2048];
-    uint32_t exponenttable[64];
-    uint16_t offsettable[64];
 } EXRContext;
 
+/* -15 stored using a single precision bias of 127 */
+#define HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP 0x38000000
+
+/* max exponent value in single precision that will be converted
+ * to Inf or Nan when stored as a half-float */
+#define HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP 0x47800000
+
+/* 255 is the max exponent biased value */
+#define FLOAT_MAX_BIASED_EXP (0xFF << 23)
+
+#define HALF_FLOAT_MAX_BIASED_EXP (0x1F << 10)
+
+/**
+ * Convert a half float as a uint16_t into a full float.
+ *
+ * @param hf half float as uint16_t
+ *
+ * @return float value
+ */
+static union av_intfloat32 exr_half2float(uint16_t hf)
+{
+    unsigned int sign = (unsigned int) (hf >> 15);
+    unsigned int mantissa = (unsigned int) (hf & ((1 << 10) - 1));
+    unsigned int exp = (unsigned int) (hf & HALF_FLOAT_MAX_BIASED_EXP);
+    union av_intfloat32 f;
+
+    if (exp == HALF_FLOAT_MAX_BIASED_EXP) {
+        // we have a half-float NaN or Inf
+        // half-float NaNs will be converted to a single precision NaN
+        // half-float Infs will be converted to a single precision Inf
+        exp = FLOAT_MAX_BIASED_EXP;
+        mantissa <<= 13; // preserve half-float NaN bits if set
+    } else if (exp == 0x0) {
+        // convert half-float zero/denorm to single precision value
+        if (mantissa) {
+            mantissa <<= 1;
+            exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
+            // check for leading 1 in denorm mantissa
+            while (!(mantissa & (1 << 10))) {
+                // for every leading 0, decrement single precision exponent by 1
+                // and shift half-float mantissa value to the left
+                mantissa <<= 1;
+                exp -= (1 << 23);
+            }
+            // clamp the mantissa to 10 bits
+            mantissa &= ((1 << 10) - 1);
+            // shift left to generate single-precision mantissa of 23 bits
+            mantissa <<= 13;
+        }
+    } else {
+        // shift left to generate single-precision mantissa of 23 bits
+        mantissa <<= 13;
+        // generate single precision biased exponent value
+        exp = (exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
+    }
+
+    f.i = (sign << 31) | exp | mantissa;
+
+    return f;
+}
+
 static int zip_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
                           int uncompressed_size, EXRThreadData *td)
 {
@@ -212,10 +240,10 @@
     return 0;
 }
 
-static int rle(uint8_t *dst, const uint8_t *src,
-               int compressed_size, int uncompressed_size)
+static int rle_uncompress(EXRContext *ctx, const uint8_t *src, int compressed_size,
+                          int uncompressed_size, EXRThreadData *td)
 {
-    uint8_t *d      = dst;
+    uint8_t *d      = td->tmp;
     const int8_t *s = src;
     int ssize       = compressed_size;
     int dsize       = uncompressed_size;
@@ -251,14 +279,6 @@
     if (dend != d)
         return AVERROR_INVALIDDATA;
 
-    return 0;
-}
-
-static int rle_uncompress(EXRContext *ctx, const uint8_t *src, int compressed_size,
-                          int uncompressed_size, EXRThreadData *td)
-{
-    rle(td->tmp, src, compressed_size, uncompressed_size);
-
     av_assert1(uncompressed_size % 2 == 0);
 
     ctx->dsp.predictor(td->tmp, uncompressed_size);
@@ -294,15 +314,25 @@
 }
 
 #define HUF_ENCBITS 16  // literal (value) bit length
-#define HUF_ENCSIZE ((1 << HUF_ENCBITS) + 1)  // encoding table size
+#define HUF_DECBITS 14  // decoding bit size (>= 8)
 
-static void huf_canonical_code_table(uint64_t *freq)
+#define HUF_ENCSIZE ((1 << HUF_ENCBITS) + 1)  // encoding table size
+#define HUF_DECSIZE (1 << HUF_DECBITS)        // decoding table size
+#define HUF_DECMASK (HUF_DECSIZE - 1)
+
+typedef struct HufDec {
+    int len;
+    int lit;
+    int *p;
+} HufDec;
+
+static void huf_canonical_code_table(uint64_t *hcode)
 {
     uint64_t c, n[59] = { 0 };
     int i;
 
-    for (i = 0; i < HUF_ENCSIZE; i++)
-        n[freq[i]] += 1;
+    for (i = 0; i < HUF_ENCSIZE; ++i)
+        n[hcode[i]] += 1;
 
     c = 0;
     for (i = 58; i > 0; --i) {
@@ -312,10 +342,10 @@
     }
 
     for (i = 0; i < HUF_ENCSIZE; ++i) {
-        int l = freq[i];
+        int l = hcode[i];
 
         if (l > 0)
-            freq[i] = l | (n[l]++ << 6);
+            hcode[i] = l | (n[l]++ << 6);
     }
 }
 
@@ -325,7 +355,7 @@
 #define LONGEST_LONG_RUN    (255 + SHORTEST_LONG_RUN)
 
 static int huf_unpack_enc_table(GetByteContext *gb,
-                                int32_t im, int32_t iM, uint64_t *freq)
+                                int32_t im, int32_t iM, uint64_t *hcode)
 {
     GetBitContext gbit;
     int ret = init_get_bits8(&gbit, gb->buffer, bytestream2_get_bytes_left(gb));
@@ -333,7 +363,7 @@
         return ret;
 
     for (; im <= iM; im++) {
-        uint64_t l = freq[im] = get_bits(&gbit, 6);
+        uint64_t l = hcode[im] = get_bits(&gbit, 6);
 
         if (l == LONG_ZEROCODE_RUN) {
             int zerun = get_bits(&gbit, 8) + SHORTEST_LONG_RUN;
@@ -342,7 +372,7 @@
                 return AVERROR_INVALIDDATA;
 
             while (zerun--)
-                freq[im++] = 0;
+                hcode[im++] = 0;
 
             im--;
         } else if (l >= SHORT_ZEROCODE_RUN) {
@@ -352,128 +382,202 @@
                 return AVERROR_INVALIDDATA;
 
             while (zerun--)
-                freq[im++] = 0;
+                hcode[im++] = 0;
 
             im--;
         }
     }
 
     bytestream2_skip(gb, (get_bits_count(&gbit) + 7) / 8);
-    huf_canonical_code_table(freq);
+    huf_canonical_code_table(hcode);
 
     return 0;
 }
 
-static int huf_build_dec_table(EXRContext *s,
-                               EXRThreadData *td, int im, int iM)
+static int huf_build_dec_table(const uint64_t *hcode, int im,
+                               int iM, HufDec *hdecod)
 {
-    int j = 0;
+    for (; im <= iM; im++) {
+        uint64_t c = hcode[im] >> 6;
+        int i, l = hcode[im] & 63;
 
-    td->run_sym = -1;
-    for (int i = im; i < iM; i++) {
-        td->he[j].sym = i;
-        td->he[j].len = td->freq[i] & 63;
-        td->he[j].code = td->freq[i] >> 6;
-        if (td->he[j].len > 32) {
-            avpriv_request_sample(s->avctx, "Too big code length");
-            return AVERROR_PATCHWELCOME;
+        if (c >> l)
+            return AVERROR_INVALIDDATA;
+
+        if (l > HUF_DECBITS) {
+            HufDec *pl = hdecod + (c >> (l - HUF_DECBITS));
+            if (pl->len)
+                return AVERROR_INVALIDDATA;
+
+            pl->lit++;
+
+            pl->p = av_realloc(pl->p, pl->lit * sizeof(int));
+            if (!pl->p)
+                return AVERROR(ENOMEM);
+
+            pl->p[pl->lit - 1] = im;
+        } else if (l) {
+            HufDec *pl = hdecod + (c << (HUF_DECBITS - l));
+
+            for (i = 1 << (HUF_DECBITS - l); i > 0; i--, pl++) {
+                if (pl->len || pl->p)
+                    return AVERROR_INVALIDDATA;
+                pl->len = l;
+                pl->lit = im;
+            }
         }
-        if (td->he[j].len > 0)
-            j++;
-        else
-            td->run_sym = i;
     }
 
-    if (im > 0)
-        td->run_sym = 0;
-    else if (iM < 65535)
-        td->run_sym = 65535;
-
-    if (td->run_sym == -1) {
-        avpriv_request_sample(s->avctx, "No place for run symbol");
-        return AVERROR_PATCHWELCOME;
-    }
-
-    td->he[j].sym = td->run_sym;
-    td->he[j].len = td->freq[iM] & 63;
-    if (td->he[j].len > 32) {
-        avpriv_request_sample(s->avctx, "Too big code length");
-        return AVERROR_PATCHWELCOME;
-    }
-    td->he[j].code = td->freq[iM] >> 6;
-    j++;
-
-    ff_free_vlc(&td->vlc);
-    return ff_init_vlc_sparse(&td->vlc, 12, j,
-                              &td->he[0].len, sizeof(td->he[0]), sizeof(td->he[0].len),
-                              &td->he[0].code, sizeof(td->he[0]), sizeof(td->he[0].code),
-                              &td->he[0].sym, sizeof(td->he[0]), sizeof(td->he[0].sym), 0);
+    return 0;
 }
 
-static int huf_decode(VLC *vlc, GetByteContext *gb, int nbits, int run_sym,
-                      int no, uint16_t *out)
+#define get_char(c, lc, gb)                                                   \
+{                                                                             \
+        c   = (c << 8) | bytestream2_get_byte(gb);                            \
+        lc += 8;                                                              \
+}
+
+#define get_code(po, rlc, c, lc, gb, out, oe, outb)                           \
+{                                                                             \
+        if (po == rlc) {                                                      \
+            if (lc < 8)                                                       \
+                get_char(c, lc, gb);                                          \
+            lc -= 8;                                                          \
+                                                                              \
+            cs = c >> lc;                                                     \
+                                                                              \
+            if (out + cs > oe || out == outb)                                 \
+                return AVERROR_INVALIDDATA;                                   \
+                                                                              \
+            s = out[-1];                                                      \
+                                                                              \
+            while (cs-- > 0)                                                  \
+                *out++ = s;                                                   \
+        } else if (out < oe) {                                                \
+            *out++ = po;                                                      \
+        } else {                                                              \
+            return AVERROR_INVALIDDATA;                                       \
+        }                                                                     \
+}
+
+static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
+                      GetByteContext *gb, int nbits,
+                      int rlc, int no, uint16_t *out)
 {
-    GetBitContext gbit;
-    int oe = 0;
+    uint64_t c        = 0;
+    uint16_t *outb    = out;
+    uint16_t *oe      = out + no;
+    const uint8_t *ie = gb->buffer + (nbits + 7) / 8; // input byte size
+    uint8_t cs;
+    uint16_t s;
+    int i, lc = 0;
 
-    init_get_bits(&gbit, gb->buffer, nbits);
-    while (get_bits_left(&gbit) > 0 && oe < no) {
-        uint16_t x = get_vlc2(&gbit, vlc->table, 12, 2);
+    while (gb->buffer < ie) {
+        get_char(c, lc, gb);
 
-        if (x == run_sym) {
-            int run = get_bits(&gbit, 8);
-            uint16_t fill = out[oe - 1];
+        while (lc >= HUF_DECBITS) {
+            const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK];
 
-            while (run-- > 0)
-                out[oe++] = fill;
+            if (pl.len) {
+                lc -= pl.len;
+                get_code(pl.lit, rlc, c, lc, gb, out, oe, outb);
+            } else {
+                int j;
+
+                if (!pl.p)
+                    return AVERROR_INVALIDDATA;
+
+                for (j = 0; j < pl.lit; j++) {
+                    int l = hcode[pl.p[j]] & 63;
+
+                    while (lc < l && bytestream2_get_bytes_left(gb) > 0)
+                        get_char(c, lc, gb);
+
+                    if (lc >= l) {
+                        if ((hcode[pl.p[j]] >> 6) ==
+                            ((c >> (lc - l)) & ((1LL << l) - 1))) {
+                            lc -= l;
+                            get_code(pl.p[j], rlc, c, lc, gb, out, oe, outb);
+                            break;
+                        }
+                    }
+                }
+
+                if (j == pl.lit)
+                    return AVERROR_INVALIDDATA;
+            }
+        }
+    }
+
+    i   = (8 - nbits) & 7;
+    c >>= i;
+    lc -= i;
+
+    while (lc > 0) {
+        const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK];
+
+        if (pl.len && lc >= pl.len) {
+            lc -= pl.len;
+            get_code(pl.lit, rlc, c, lc, gb, out, oe, outb);
         } else {
-            out[oe++] = x;
+            return AVERROR_INVALIDDATA;
         }
     }
 
+    if (out - outb != no)
+        return AVERROR_INVALIDDATA;
     return 0;
 }
 
-static int huf_uncompress(EXRContext *s,
-                          EXRThreadData *td,
-                          GetByteContext *gb,
+static int huf_uncompress(GetByteContext *gb,
                           uint16_t *dst, int dst_size)
 {
-    int32_t im, iM;
+    int32_t src_size, im, iM;
     uint32_t nBits;
-    int ret;
+    uint64_t *freq;
+    HufDec *hdec;
+    int ret, i;
 
+    src_size = bytestream2_get_le32(gb);
     im       = bytestream2_get_le32(gb);
     iM       = bytestream2_get_le32(gb);
     bytestream2_skip(gb, 4);
     nBits = bytestream2_get_le32(gb);
     if (im < 0 || im >= HUF_ENCSIZE ||
-        iM < 0 || iM >= HUF_ENCSIZE)
+        iM < 0 || iM >= HUF_ENCSIZE ||
+        src_size < 0)
         return AVERROR_INVALIDDATA;
 
     bytestream2_skip(gb, 4);
 
-    if (!td->freq)
-        td->freq = av_malloc_array(HUF_ENCSIZE, sizeof(*td->freq));
-    if (!td->he)
-        td->he = av_calloc(HUF_ENCSIZE, sizeof(*td->he));
-    if (!td->freq || !td->he) {
+    freq = av_mallocz_array(HUF_ENCSIZE, sizeof(*freq));
+    hdec = av_mallocz_array(HUF_DECSIZE, sizeof(*hdec));
+    if (!freq || !hdec) {
         ret = AVERROR(ENOMEM);
-        return ret;
+        goto fail;
     }
 
-    memset(td->freq, 0, sizeof(*td->freq) * HUF_ENCSIZE);
-    if ((ret = huf_unpack_enc_table(gb, im, iM, td->freq)) < 0)
-        return ret;
+    if ((ret = huf_unpack_enc_table(gb, im, iM, freq)) < 0)
+        goto fail;
 
     if (nBits > 8 * bytestream2_get_bytes_left(gb)) {
         ret = AVERROR_INVALIDDATA;
-        return ret;
+        goto fail;
     }
 
-    if ((ret = huf_build_dec_table(s, td, im, iM)) < 0)
-        return ret;
-    return huf_decode(&td->vlc, gb, nBits, td->run_sym, dst_size, dst);
+    if ((ret = huf_build_dec_table(freq, im, iM, hdec)) < 0)
+        goto fail;
+    ret = huf_decode(freq, hdec, gb, nBits, iM, dst_size, dst);
+
+fail:
+    for (i = 0; i < HUF_DECSIZE; i++)
+        if (hdec)
+            av_freep(&hdec[i].p);
+
+    av_free(freq);
+    av_free(hdec);
+
+    return ret;
 }
 
 static inline void wdec14(uint16_t l, uint16_t h, uint16_t *a, uint16_t *b)
@@ -621,8 +725,7 @@
 
     maxval = reverse_lut(td->bitmap, td->lut);
 
-    bytestream2_skip(&gb, 4);
-    ret = huf_uncompress(s, td, &gb, tmp, dsize / sizeof(uint16_t));
+    ret = huf_uncompress(&gb, tmp, dsize / sizeof(uint16_t));
     if (ret)
         return ret;
 
@@ -880,292 +983,6 @@
     return 0;
 }
 
-static int ac_uncompress(EXRContext *s, GetByteContext *gb, float *block)
-{
-    int ret = 0, n = 1;
-
-    while (n < 64) {
-        uint16_t val = bytestream2_get_ne16(gb);
-
-        if (val == 0xff00) {
-            n = 64;
-        } else if ((val >> 8) == 0xff) {
-            n += val & 0xff;
-        } else {
-            ret = n;
-            block[ff_zigzag_direct[n]] = av_int2float(half2float(val,
-                                                      s->mantissatable,
-                                                      s->exponenttable,
-                                                      s->offsettable));
-            n++;
-        }
-    }
-
-    return ret;
-}
-
-static void idct_1d(float *blk, int step)
-{
-    const float a = .5f * cosf(    M_PI / 4.f);
-    const float b = .5f * cosf(    M_PI / 16.f);
-    const float c = .5f * cosf(    M_PI / 8.f);
-    const float d = .5f * cosf(3.f*M_PI / 16.f);
-    const float e = .5f * cosf(5.f*M_PI / 16.f);
-    const float f = .5f * cosf(3.f*M_PI / 8.f);
-    const float g = .5f * cosf(7.f*M_PI / 16.f);
-
-    float alpha[4], beta[4], theta[4], gamma[4];
-
-    alpha[0] = c * blk[2 * step];
-    alpha[1] = f * blk[2 * step];
-    alpha[2] = c * blk[6 * step];
-    alpha[3] = f * blk[6 * step];
-
-    beta[0] = b * blk[1 * step] + d * blk[3 * step] + e * blk[5 * step] + g * blk[7 * step];
-    beta[1] = d * blk[1 * step] - g * blk[3 * step] - b * blk[5 * step] - e * blk[7 * step];
-    beta[2] = e * blk[1 * step] - b * blk[3 * step] + g * blk[5 * step] + d * blk[7 * step];
-    beta[3] = g * blk[1 * step] - e * blk[3 * step] + d * blk[5 * step] - b * blk[7 * step];
-
-    theta[0] = a * (blk[0 * step] + blk[4 * step]);
-    theta[3] = a * (blk[0 * step] - blk[4 * step]);
-
-    theta[1] = alpha[0] + alpha[3];
-    theta[2] = alpha[1] - alpha[2];
-
-    gamma[0] = theta[0] + theta[1];
-    gamma[1] = theta[3] + theta[2];
-    gamma[2] = theta[3] - theta[2];
-    gamma[3] = theta[0] - theta[1];
-
-    blk[0 * step] = gamma[0] + beta[0];
-    blk[1 * step] = gamma[1] + beta[1];
-    blk[2 * step] = gamma[2] + beta[2];
-    blk[3 * step] = gamma[3] + beta[3];
-
-    blk[4 * step] = gamma[3] - beta[3];
-    blk[5 * step] = gamma[2] - beta[2];
-    blk[6 * step] = gamma[1] - beta[1];
-    blk[7 * step] = gamma[0] - beta[0];
-}
-
-static void dct_inverse(float *block)
-{
-    for (int i = 0; i < 8; i++)
-        idct_1d(block + i, 8);
-
-    for (int i = 0; i < 8; i++) {
-        idct_1d(block, 1);
-        block += 8;
-    }
-}
-
-static void convert(float y, float u, float v,
-                    float *b, float *g, float *r)
-{
-    *r = y               + 1.5747f * v;
-    *g = y - 0.1873f * u - 0.4682f * v;
-    *b = y + 1.8556f * u;
-}
-
-static float to_linear(float x, float scale)
-{
-    float ax = fabsf(x);
-
-    if (ax <= 1.f) {
-        return FFSIGN(x) * powf(ax, 2.2f * scale);
-    } else {
-        const float log_base = expf(2.2f * scale);
-
-        return FFSIGN(x) * powf(log_base, ax - 1.f);
-    }
-}
-
-static int dwa_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
-                          int uncompressed_size, EXRThreadData *td)
-{
-    int64_t version, lo_usize, lo_size;
-    int64_t ac_size, dc_size, rle_usize, rle_csize, rle_raw_size;
-    int64_t ac_count, dc_count, ac_compression;
-    const int dc_w = td->xsize >> 3;
-    const int dc_h = td->ysize >> 3;
-    GetByteContext gb, agb;
-    int skip, ret;
-
-    if (compressed_size <= 88)
-        return AVERROR_INVALIDDATA;
-
-    version = AV_RL64(src + 0);
-    if (version != 2)
-        return AVERROR_INVALIDDATA;
-
-    lo_usize = AV_RL64(src + 8);
-    lo_size = AV_RL64(src + 16);
-    ac_size = AV_RL64(src + 24);
-    dc_size = AV_RL64(src + 32);
-    rle_csize = AV_RL64(src + 40);
-    rle_usize = AV_RL64(src + 48);
-    rle_raw_size = AV_RL64(src + 56);
-    ac_count = AV_RL64(src + 64);
-    dc_count = AV_RL64(src + 72);
-    ac_compression = AV_RL64(src + 80);
-
-    if (compressed_size < 88LL + lo_size + ac_size + dc_size + rle_csize)
-        return AVERROR_INVALIDDATA;
-
-    bytestream2_init(&gb, src + 88, compressed_size - 88);
-    skip = bytestream2_get_le16(&gb);
-    if (skip < 2)
-        return AVERROR_INVALIDDATA;
-
-    bytestream2_skip(&gb, skip - 2);
-
-    if (lo_size > 0) {
-        if (lo_usize > uncompressed_size)
-            return AVERROR_INVALIDDATA;
-        bytestream2_skip(&gb, lo_size);
-    }
-
-    if (ac_size > 0) {
-        unsigned long dest_len = ac_count * 2LL;
-        GetByteContext agb = gb;
-
-        if (ac_count > 3LL * td->xsize * s->scan_lines_per_block)
-            return AVERROR_INVALIDDATA;
-
-        av_fast_padded_malloc(&td->ac_data, &td->ac_size, dest_len);
-        if (!td->ac_data)
-            return AVERROR(ENOMEM);
-
-        switch (ac_compression) {
-        case 0:
-            ret = huf_uncompress(s, td, &agb, (int16_t *)td->ac_data, ac_count);
-            if (ret < 0)
-                return ret;
-            break;
-        case 1:
-            if (uncompress(td->ac_data, &dest_len, agb.buffer, ac_size) != Z_OK ||
-                dest_len != ac_count * 2LL)
-                return AVERROR_INVALIDDATA;
-            break;
-        default:
-            return AVERROR_INVALIDDATA;
-        }
-
-        bytestream2_skip(&gb, ac_size);
-    }
-
-    if (dc_size > 0) {
-        unsigned long dest_len = dc_count * 2LL;
-        GetByteContext agb = gb;
-
-        if (dc_count > (6LL * td->xsize * td->ysize + 63) / 64)
-            return AVERROR_INVALIDDATA;
-
-        av_fast_padded_malloc(&td->dc_data, &td->dc_size, FFALIGN(dest_len, 64) * 2);
-        if (!td->dc_data)
-            return AVERROR(ENOMEM);
-
-        if (uncompress(td->dc_data + FFALIGN(dest_len, 64), &dest_len, agb.buffer, dc_size) != Z_OK ||
-            (dest_len != dc_count * 2LL))
-            return AVERROR_INVALIDDATA;
-
-        s->dsp.predictor(td->dc_data + FFALIGN(dest_len, 64), dest_len);
-        s->dsp.reorder_pixels(td->dc_data, td->dc_data + FFALIGN(dest_len, 64), dest_len);
-
-        bytestream2_skip(&gb, dc_size);
-    }
-
-    if (rle_raw_size > 0 && rle_csize > 0 && rle_usize > 0) {
-        unsigned long dest_len = rle_usize;
-
-        av_fast_padded_malloc(&td->rle_data, &td->rle_size, rle_usize);
-        if (!td->rle_data)
-            return AVERROR(ENOMEM);
-
-        av_fast_padded_malloc(&td->rle_raw_data, &td->rle_raw_size, rle_raw_size);
-        if (!td->rle_raw_data)
-            return AVERROR(ENOMEM);
-
-        if (uncompress(td->rle_data, &dest_len, gb.buffer, rle_csize) != Z_OK ||
-            (dest_len != rle_usize))
-            return AVERROR_INVALIDDATA;
-
-        ret = rle(td->rle_raw_data, td->rle_data, rle_usize, rle_raw_size);
-        if (ret < 0)
-            return ret;
-        bytestream2_skip(&gb, rle_csize);
-    }
-
-    bytestream2_init(&agb, td->ac_data, ac_count * 2);
-
-    for (int y = 0; y < td->ysize; y += 8) {
-        for (int x = 0; x < td->xsize; x += 8) {
-            memset(td->block, 0, sizeof(td->block));
-
-            for (int j = 0; j < 3; j++) {
-                float *block = td->block[j];
-                const int idx = (x >> 3) + (y >> 3) * dc_w + dc_w * dc_h * j;
-                uint16_t *dc = (uint16_t *)td->dc_data;
-                union av_intfloat32 dc_val;
-
-                dc_val.i = half2float(dc[idx], s->mantissatable,
-                                      s->exponenttable, s->offsettable);
-
-                block[0] = dc_val.f;
-                ac_uncompress(s, &agb, block);
-                dct_inverse(block);
-            }
-
-            {
-                const float scale = s->pixel_type == EXR_FLOAT ? 2.f : 1.f;
-                const int o = s->nb_channels == 4;
-                float *bo = ((float *)td->uncompressed_data) +
-                    y * td->xsize * s->nb_channels + td->xsize * (o + 0) + x;
-                float *go = ((float *)td->uncompressed_data) +
-                    y * td->xsize * s->nb_channels + td->xsize * (o + 1) + x;
-                float *ro = ((float *)td->uncompressed_data) +
-                    y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x;
-                float *yb = td->block[0];
-                float *ub = td->block[1];
-                float *vb = td->block[2];
-
-                for (int yy = 0; yy < 8; yy++) {
-                    for (int xx = 0; xx < 8; xx++) {
-                        const int idx = xx + yy * 8;
-
-                        convert(yb[idx], ub[idx], vb[idx], &bo[xx], &go[xx], &ro[xx]);
-
-                        bo[xx] = to_linear(bo[xx], scale);
-                        go[xx] = to_linear(go[xx], scale);
-                        ro[xx] = to_linear(ro[xx], scale);
-                    }
-
-                    bo += td->xsize * s->nb_channels;
-                    go += td->xsize * s->nb_channels;
-                    ro += td->xsize * s->nb_channels;
-                }
-            }
-        }
-    }
-
-    if (s->nb_channels < 4)
-        return 0;
-
-    for (int y = 0; y < td->ysize && td->rle_raw_data; y++) {
-        uint32_t *ao = ((uint32_t *)td->uncompressed_data) + y * td->xsize * s->nb_channels;
-        uint8_t *ai0 = td->rle_raw_data + y * td->xsize;
-        uint8_t *ai1 = td->rle_raw_data + y * td->xsize + rle_raw_size / 2;
-
-        for (int x = 0; x < td->xsize; x++) {
-            uint16_t ha = ai0[x] | (ai1[x] << 8);
-
-            ao[x] = half2float(ha, s->mantissatable, s->exponenttable, s->offsettable);
-        }
-    }
-
-    return 0;
-}
-
 static int decode_block(AVCodecContext *avctx, void *tdata,
                         int jobnr, int threadnr)
 {
@@ -1197,8 +1014,6 @@
             return AVERROR_INVALIDDATA;
 
         src  = buf + line_offset + 20;
-        if (s->is_multipart)
-            src += 4;
 
         tile_x = AV_RL32(src - 20);
         tile_y = AV_RL32(src - 16);
@@ -1234,8 +1049,6 @@
             return AVERROR_INVALIDDATA;
 
         src  = buf + line_offset + 8;
-        if (s->is_multipart)
-            src += 4;
         line = AV_RL32(src - 8);
 
         if (line < s->ymin || line > s->ymax)
@@ -1321,10 +1134,6 @@
         case EXR_B44A:
             ret = b44_uncompress(s, src, data_size, uncompressed_size, td);
             break;
-        case EXR_DWAA:
-        case EXR_DWAB:
-            ret = dwa_uncompress(s, src, data_size, uncompressed_size, td);
-            break;
         }
         if (ret < 0) {
             av_log(avctx, AV_LOG_ERROR, "decode_block() failed.\n");
@@ -1351,6 +1160,7 @@
         channel_buffer[3] = src + (td->xsize * s->channel_offsets[3]) + data_window_offset;
 
     if (s->desc->flags & AV_PIX_FMT_FLAG_FLOAT) {
+
         /* todo: change this when a floating point pixel format with luma with alpha is implemented */
         int channel_count = s->channel_offsets[3] >= 0 ? 4 : rgb_channel_count;
         if (s->is_luma) {
@@ -1373,9 +1183,7 @@
                 memset(ptr_x, 0, bxmin);
                 ptr_x += window_xoffset;
 
-                if (s->pixel_type == EXR_FLOAT ||
-                    s->compression == EXR_DWAA ||
-                    s->compression == EXR_DWAB) {
+                if (s->pixel_type == EXR_FLOAT) {
                     // 32-bit
                     union av_intfloat32 t;
                     if (trc_func && c < 3) {
@@ -1384,18 +1192,13 @@
                             t.f = trc_func(t.f);
                             *ptr_x++ = t;
                         }
-                    } else if (one_gamma != 1.f) {
+                    } else {
                         for (x = 0; x < xsize; x++) {
                             t.i = bytestream_get_le32(&src);
                             if (t.f > 0.0f && c < 3)  /* avoid negative values */
                                 t.f = powf(t.f, one_gamma);
                             *ptr_x++ = t;
                         }
-                    } else {
-                        for (x = 0; x < xsize; x++) {
-                            t.i = bytestream_get_le32(&src);
-                            *ptr_x++ = t;
-                        }
                     }
                 } else if (s->pixel_type == EXR_HALF) {
                     // 16-bit
@@ -1405,11 +1208,7 @@
                         }
                     } else {
                         for (x = 0; x < xsize; x++) {
-                            ptr_x[0].i = half2float(bytestream_get_le16(&src),
-                                                    s->mantissatable,
-                                                    s->exponenttable,
-                                                    s->offsettable);
-                            ptr_x++;
+                            *ptr_x++ = exr_half2float(bytestream_get_le16(&src));;
                         }
                     }
                 }
@@ -1466,23 +1265,6 @@
     return 0;
 }
 
-static void skip_header_chunk(EXRContext *s)
-{
-    GetByteContext *gb = &s->gb;
-
-    while (bytestream2_get_bytes_left(gb) > 0) {
-        if (!bytestream2_peek_byte(gb))
-            break;
-
-        // Process unknown variables
-        for (int i = 0; i < 2; i++) // value_name and value_type
-            while (bytestream2_get_byte(gb) != 0);
-
-        // Skip variable length
-        bytestream2_skip(gb, bytestream2_get_le32(gb));
-    }
-}
-
 /**
  * Check if the variable name corresponds to its data type.
  *
@@ -1500,22 +1282,21 @@
                                  const char *value_type,
                                  unsigned int minimum_length)
 {
-    GetByteContext *gb = &s->gb;
     int var_size = -1;
 
-    if (bytestream2_get_bytes_left(gb) >= minimum_length &&
-        !strcmp(gb->buffer, value_name)) {
+    if (bytestream2_get_bytes_left(&s->gb) >= minimum_length &&
+        !strcmp(s->gb.buffer, value_name)) {
         // found value_name, jump to value_type (null terminated strings)
-        gb->buffer += strlen(value_name) + 1;
-        if (!strcmp(gb->buffer, value_type)) {
-            gb->buffer += strlen(value_type) + 1;
-            var_size = bytestream2_get_le32(gb);
+        s->gb.buffer += strlen(value_name) + 1;
+        if (!strcmp(s->gb.buffer, value_type)) {
+            s->gb.buffer += strlen(value_type) + 1;
+            var_size = bytestream2_get_le32(&s->gb);
             // don't go read past boundaries
-            if (var_size > bytestream2_get_bytes_left(gb))
+            if (var_size > bytestream2_get_bytes_left(&s->gb))
                 var_size = 0;
         } else {
             // value_type not found, reset the buffer
-            gb->buffer -= strlen(value_name) + 1;
+            s->gb.buffer -= strlen(value_name) + 1;
             av_log(s->avctx, AV_LOG_WARNING,
                    "Unknown data type %s for header variable %s.\n",
                    value_type, value_name);
@@ -1528,8 +1309,7 @@
 static int decode_header(EXRContext *s, AVFrame *frame)
 {
     AVDictionary *metadata = NULL;
-    GetByteContext *gb = &s->gb;
-    int magic_number, version, flags;
+    int magic_number, version, i, flags, sar = 0;
     int layer_match = 0;
     int ret;
     int dup_channels = 0;
@@ -1553,16 +1333,14 @@
     s->tile_attr.xSize    = -1;
     s->tile_attr.ySize    = -1;
     s->is_tile            = 0;
-    s->is_multipart       = 0;
     s->is_luma            = 0;
-    s->current_part       = 0;
 
-    if (bytestream2_get_bytes_left(gb) < 10) {
+    if (bytestream2_get_bytes_left(&s->gb) < 10) {
         av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
         return AVERROR_INVALIDDATA;
     }
 
-    magic_number = bytestream2_get_le32(gb);
+    magic_number = bytestream2_get_le32(&s->gb);
     if (magic_number != 20000630) {
         /* As per documentation of OpenEXR, it is supposed to be
          * int 20000630 little-endian */
@@ -1570,60 +1348,28 @@
         return AVERROR_INVALIDDATA;
     }
 
-    version = bytestream2_get_byte(gb);
+    version = bytestream2_get_byte(&s->gb);
     if (version != 2) {
         avpriv_report_missing_feature(s->avctx, "Version %d", version);
         return AVERROR_PATCHWELCOME;
     }
 
-    flags = bytestream2_get_le24(gb);
+    flags = bytestream2_get_le24(&s->gb);
 
     if (flags & 0x02)
         s->is_tile = 1;
-    if (flags & 0x10)
-        s->is_multipart = 1;
     if (flags & 0x08) {
         avpriv_report_missing_feature(s->avctx, "deep data");
         return AVERROR_PATCHWELCOME;
     }
+    if (flags & 0x10) {
+        avpriv_report_missing_feature(s->avctx, "multipart");
+        return AVERROR_PATCHWELCOME;
+    }
 
     // Parse the header
-    while (bytestream2_get_bytes_left(gb) > 0) {
+    while (bytestream2_get_bytes_left(&s->gb) > 0 && *s->gb.buffer) {
         int var_size;
-
-        while (s->is_multipart && s->current_part < s->selected_part &&
-               bytestream2_get_bytes_left(gb) > 0) {
-            if (bytestream2_peek_byte(gb)) {
-                skip_header_chunk(s);
-            } else {
-                bytestream2_skip(gb, 1);
-                if (!bytestream2_peek_byte(gb))
-                    break;
-            }
-            bytestream2_skip(gb, 1);
-            s->current_part++;
-        }
-
-        if (!bytestream2_peek_byte(gb)) {
-            if (!s->is_multipart)
-                break;
-            bytestream2_skip(gb, 1);
-            if (s->current_part == s->selected_part) {
-                while (bytestream2_get_bytes_left(gb) > 0) {
-                    if (bytestream2_peek_byte(gb)) {
-                        skip_header_chunk(s);
-                    } else {
-                        bytestream2_skip(gb, 1);
-                        if (!bytestream2_peek_byte(gb))
-                            break;
-                    }
-                }
-            }
-            if (!bytestream2_peek_byte(gb))
-                break;
-            s->current_part++;
-        }
-
         if ((var_size = check_header_variable(s, "channels",
                                               "chlist", 38)) >= 0) {
             GetByteContext ch_gb;
@@ -1632,7 +1378,7 @@
                 goto fail;
             }
 
-            bytestream2_init(&ch_gb, gb->buffer, var_size);
+            bytestream2_init(&ch_gb, s->gb.buffer, var_size);
 
             while (bytestream2_get_bytes_left(&ch_gb) >= 19) {
                 EXRChannel *channel;
@@ -1769,7 +1515,7 @@
             }
 
             // skip one last byte and update main gb
-            gb->buffer = ch_gb.buffer + 1;
+            s->gb.buffer = ch_gb.buffer + 1;
             continue;
         } else if ((var_size = check_header_variable(s, "dataWindow", "box2i",
                                                      31)) >= 0) {
@@ -1779,10 +1525,10 @@
                 goto fail;
             }
 
-            xmin   = bytestream2_get_le32(gb);
-            ymin   = bytestream2_get_le32(gb);
-            xmax   = bytestream2_get_le32(gb);
-            ymax   = bytestream2_get_le32(gb);
+            xmin   = bytestream2_get_le32(&s->gb);
+            ymin   = bytestream2_get_le32(&s->gb);
+            xmax   = bytestream2_get_le32(&s->gb);
+            ymax   = bytestream2_get_le32(&s->gb);
 
             if (xmin > xmax || ymin > ymax ||
                 (unsigned)xmax - xmin >= INT_MAX ||
@@ -1800,20 +1546,14 @@
             continue;
         } else if ((var_size = check_header_variable(s, "displayWindow",
                                                      "box2i", 34)) >= 0) {
-            int32_t sx, sy, dx, dy;
-
             if (!var_size) {
                 ret = AVERROR_INVALIDDATA;
                 goto fail;
             }
 
-            sx = bytestream2_get_le32(gb);
-            sy = bytestream2_get_le32(gb);
-            dx = bytestream2_get_le32(gb);
-            dy = bytestream2_get_le32(gb);
-
-            s->w = dx - sx + 1;
-            s->h = dy - sy + 1;
+            bytestream2_skip(&s->gb, 8);
+            s->w = bytestream2_get_le32(&s->gb) + 1;
+            s->h = bytestream2_get_le32(&s->gb) + 1;
 
             continue;
         } else if ((var_size = check_header_variable(s, "lineOrder",
@@ -1824,7 +1564,7 @@
                 goto fail;
             }
 
-            line_order = bytestream2_get_byte(gb);
+            line_order = bytestream2_get_byte(&s->gb);
             av_log(s->avctx, AV_LOG_DEBUG, "line order: %d.\n", line_order);
             if (line_order > 2) {
                 av_log(s->avctx, AV_LOG_ERROR, "Unknown line order.\n");
@@ -1840,7 +1580,7 @@
                 goto fail;
             }
 
-            s->sar = bytestream2_get_le32(gb);
+            sar = bytestream2_get_le32(&s->gb);
 
             continue;
         } else if ((var_size = check_header_variable(s, "compression",
@@ -1851,12 +1591,10 @@
             }
 
             if (s->compression == EXR_UNKN)
-                s->compression = bytestream2_get_byte(gb);
-            else {
-                bytestream2_skip(gb, 1);
+                s->compression = bytestream2_get_byte(&s->gb);
+            else
                 av_log(s->avctx, AV_LOG_WARNING,
                        "Found more than one compression attribute.\n");
-            }
 
             continue;
         } else if ((var_size = check_header_variable(s, "tiles",
@@ -1867,10 +1605,10 @@
                 av_log(s->avctx, AV_LOG_WARNING,
                        "Found tile attribute and scanline flags. Exr will be interpreted as scanline.\n");
 
-            s->tile_attr.xSize = bytestream2_get_le32(gb);
-            s->tile_attr.ySize = bytestream2_get_le32(gb);
+            s->tile_attr.xSize = bytestream2_get_le32(&s->gb);
+            s->tile_attr.ySize = bytestream2_get_le32(&s->gb);
 
-            tileLevel = bytestream2_get_byte(gb);
+            tileLevel = bytestream2_get_byte(&s->gb);
             s->tile_attr.level_mode = tileLevel & 0x0f;
             s->tile_attr.level_round = (tileLevel >> 4) & 0x0f;
 
@@ -1893,85 +1631,29 @@
                                                      "string", 1)) >= 0) {
             uint8_t key[256] = { 0 };
 
-            bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
+            bytestream2_get_buffer(&s->gb, key, FFMIN(sizeof(key) - 1, var_size));
             av_dict_set(&metadata, "writer", key, 0);
 
             continue;
-        } else if ((var_size = check_header_variable(s, "framesPerSecond",
-                                                     "rational", 33)) >= 0) {
-            if (!var_size) {
-                ret = AVERROR_INVALIDDATA;
-                goto fail;
-            }
-
-            s->avctx->framerate.num = bytestream2_get_le32(gb);
-            s->avctx->framerate.den = bytestream2_get_le32(gb);
-
-            continue;
-        } else if ((var_size = check_header_variable(s, "chunkCount",
-                                                     "int", 23)) >= 0) {
-
-            s->chunk_count = bytestream2_get_le32(gb);
-
-            continue;
-        } else if ((var_size = check_header_variable(s, "type",
-                                                     "string", 16)) >= 0) {
-            uint8_t key[256] = { 0 };
-
-            bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
-            if (strncmp("scanlineimage", key, var_size) &&
-                strncmp("tiledimage", key, var_size))
-                return AVERROR_PATCHWELCOME;
-
-            continue;
-        } else if ((var_size = check_header_variable(s, "preview",
-                                                     "preview", 16)) >= 0) {
-            uint32_t pw = bytestream2_get_le32(gb);
-            uint32_t ph = bytestream2_get_le32(gb);
-            int64_t psize = 4LL * pw * ph;
-
-            if (psize >= bytestream2_get_bytes_left(gb))
-                return AVERROR_INVALIDDATA;
-
-            bytestream2_skip(gb, psize);
-
-            continue;
         }
 
         // Check if there are enough bytes for a header
-        if (bytestream2_get_bytes_left(gb) <= 9) {
+        if (bytestream2_get_bytes_left(&s->gb) <= 9) {
             av_log(s->avctx, AV_LOG_ERROR, "Incomplete header\n");
             ret = AVERROR_INVALIDDATA;
             goto fail;
         }
 
         // Process unknown variables
-        {
-            uint8_t name[256] = { 0 };
-            uint8_t type[256] = { 0 };
-            uint8_t value[256] = { 0 };
-            int i = 0, size;
+        for (i = 0; i < 2; i++) // value_name and value_type
+            while (bytestream2_get_byte(&s->gb) != 0);
 
-            while (bytestream2_get_bytes_left(gb) > 0 &&
-                   bytestream2_peek_byte(gb) && i < 255) {
-                name[i++] = bytestream2_get_byte(gb);
-            }
-
-            bytestream2_skip(gb, 1);
-            i = 0;
-            while (bytestream2_get_bytes_left(gb) > 0 &&
-                   bytestream2_peek_byte(gb) && i < 255) {
-                type[i++] = bytestream2_get_byte(gb);
-            }
-            bytestream2_skip(gb, 1);
-            size = bytestream2_get_le32(gb);
-
-            bytestream2_get_buffer(gb, value, FFMIN(sizeof(value) - 1, size));
-            if (!strcmp(type, "string"))
-                av_dict_set(&metadata, name, value, 0);
-        }
+        // Skip variable length
+        bytestream2_skip(&s->gb, bytestream2_get_le32(&s->gb));
     }
 
+    ff_set_sar(s->avctx, av_d2q(av_int2float(sar), 255));
+
     if (s->compression == EXR_UNKN) {
         av_log(s->avctx, AV_LOG_ERROR, "Missing compression attribute.\n");
         ret = AVERROR_INVALIDDATA;
@@ -1986,7 +1668,7 @@
         }
     }
 
-    if (bytestream2_get_bytes_left(gb) <= 0) {
+    if (bytestream2_get_bytes_left(&s->gb) <= 0) {
         av_log(s->avctx, AV_LOG_ERROR, "Incomplete frame.\n");
         ret = AVERROR_INVALIDDATA;
         goto fail;
@@ -1995,7 +1677,7 @@
     frame->metadata = metadata;
 
     // aaand we are done
-    bytestream2_skip(gb, 1);
+    bytestream2_skip(&s->gb, 1);
     return 0;
 fail:
     av_dict_free(&metadata);
@@ -2006,7 +1688,6 @@
                         int *got_frame, AVPacket *avpkt)
 {
     EXRContext *s = avctx->priv_data;
-    GetByteContext *gb = &s->gb;
     ThreadFrame frame = { .f = data };
     AVFrame *picture = data;
     uint8_t *ptr;
@@ -2019,18 +1700,11 @@
     uint64_t start_next_scanline;
     PutByteContext offset_table_writer;
 
-    bytestream2_init(gb, avpkt->data, avpkt->size);
+    bytestream2_init(&s->gb, avpkt->data, avpkt->size);
 
     if ((ret = decode_header(s, picture)) < 0)
         return ret;
 
-    if ((s->compression == EXR_DWAA || s->compression == EXR_DWAB) &&
-        s->pixel_type == EXR_HALF) {
-        s->current_channel_offset *= 2;
-        for (int i = 0; i < 4; i++)
-            s->channel_offsets[i] *= 2;
-    }
-
     switch (s->pixel_type) {
     case EXR_FLOAT:
     case EXR_HALF:
@@ -2085,12 +1759,8 @@
     case EXR_PIZ:
     case EXR_B44:
     case EXR_B44A:
-    case EXR_DWAA:
         s->scan_lines_per_block = 32;
         break;
-    case EXR_DWAB:
-        s->scan_lines_per_block = 256;
-        break;
     default:
         avpriv_report_missing_feature(avctx, "Compression %d", s->compression);
         return AVERROR_PATCHWELCOME;
@@ -2107,8 +1777,6 @@
     if ((ret = ff_set_dimensions(avctx, s->w, s->h)) < 0)
         return ret;
 
-    ff_set_sar(s->avctx, av_d2q(av_int2float(s->sar), 255));
-
     s->desc          = av_pix_fmt_desc_get(avctx->pix_fmt);
     if (!s->desc)
         return AVERROR_INVALIDDATA;
@@ -2132,14 +1800,14 @@
     if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
         return ret;
 
-    if (bytestream2_get_bytes_left(gb)/8 < nb_blocks)
+    if (bytestream2_get_bytes_left(&s->gb)/8 < nb_blocks)
         return AVERROR_INVALIDDATA;
 
     // check offset table and recreate it if need
-    if (!s->is_tile && bytestream2_peek_le64(gb) == 0) {
+    if (!s->is_tile && bytestream2_peek_le64(&s->gb) == 0) {
         av_log(s->avctx, AV_LOG_DEBUG, "recreating invalid scanline offset table\n");
 
-        start_offset_table = bytestream2_tell(gb);
+        start_offset_table = bytestream2_tell(&s->gb);
         start_next_scanline = start_offset_table + nb_blocks * 8;
         bytestream2_init_writer(&offset_table_writer, &avpkt->data[start_offset_table], nb_blocks * 8);
 
@@ -2148,10 +1816,10 @@
             bytestream2_put_le64(&offset_table_writer, start_next_scanline);
 
             /* get len of next scanline */
-            bytestream2_seek(gb, start_next_scanline + 4, SEEK_SET);/* skip line number */
-            start_next_scanline += (bytestream2_get_le32(gb) + 8);
+            bytestream2_seek(&s->gb, start_next_scanline + 4, SEEK_SET);/* skip line number */
+            start_next_scanline += (bytestream2_get_le32(&s->gb) + 8);
         }
-        bytestream2_seek(gb, start_offset_table, SEEK_SET);
+        bytestream2_seek(&s->gb, start_offset_table, SEEK_SET);
     }
 
     // save pointer we are going to use in decode_block
@@ -2196,8 +1864,6 @@
     float one_gamma = 1.0f / s->gamma;
     avpriv_trc_function trc_func = NULL;
 
-    half2float_table(s->mantissatable, s->exponenttable, s->offsettable);
-
     s->avctx              = avctx;
 
     ff_exrdsp_init(&s->dsp);
@@ -2209,18 +1875,18 @@
     trc_func = avpriv_get_trc_function_from_trc(s->apply_trc_type);
     if (trc_func) {
         for (i = 0; i < 65536; ++i) {
-            t.i = half2float(i, s->mantissatable, s->exponenttable, s->offsettable);
+            t = exr_half2float(i);
             t.f = trc_func(t.f);
             s->gamma_table[i] = t;
         }
     } else {
         if (one_gamma > 0.9999f && one_gamma < 1.0001f) {
             for (i = 0; i < 65536; ++i) {
-                s->gamma_table[i].i = half2float(i, s->mantissatable, s->exponenttable, s->offsettable);
+                s->gamma_table[i] = exr_half2float(i);
             }
         } else {
             for (i = 0; i < 65536; ++i) {
-                t.i = half2float(i, s->mantissatable, s->exponenttable, s->offsettable);
+                t = exr_half2float(i);
                 /* If negative value we reuse half value */
                 if (t.f <= 0.0f) {
                     s->gamma_table[i] = t;
@@ -2250,13 +1916,6 @@
         av_freep(&td->tmp);
         av_freep(&td->bitmap);
         av_freep(&td->lut);
-        av_freep(&td->he);
-        av_freep(&td->freq);
-        av_freep(&td->ac_data);
-        av_freep(&td->dc_data);
-        av_freep(&td->rle_data);
-        av_freep(&td->rle_raw_data);
-        ff_free_vlc(&td->vlc);
     }
 
     av_freep(&s->thread_data);
@@ -2270,8 +1929,6 @@
 static const AVOption options[] = {
     { "layer", "Set the decoding layer", OFFSET(layer),
         AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
-    { "part",  "Set the decoding part", OFFSET(selected_part),
-        AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VD },
     { "gamma", "Set the float gamma value when decoding", OFFSET(gamma),
         AV_OPT_TYPE_FLOAT, { .dbl = 1.0f }, 0.001, FLT_MAX, VD },
 
diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c
deleted file mode 100644
index db9000a..0000000
--- a/libavcodec/exrenc.c
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * OpenEXR encoder
- */
-
-#include <float.h>
-#include <zlib.h>
-
-#include "libavutil/avassert.h"
-#include "libavutil/opt.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/pixdesc.h"
-#include "avcodec.h"
-#include "bytestream.h"
-#include "internal.h"
-#include "float2half.h"
-
-enum ExrCompr {
-    EXR_RAW,
-    EXR_RLE,
-    EXR_ZIP1,
-    EXR_ZIP16,
-    EXR_NBCOMPR,
-};
-
-enum ExrPixelType {
-    EXR_UINT,
-    EXR_HALF,
-    EXR_FLOAT,
-    EXR_UNKNOWN,
-};
-
-static const char abgr_chlist[4] = { 'A', 'B', 'G', 'R' };
-static const char bgr_chlist[4] = { 'B', 'G', 'R', 'A' };
-static const uint8_t gbra_order[4] = { 3, 1, 0, 2 };
-static const uint8_t gbr_order[4] = { 1, 0, 2, 0 };
-
-typedef struct EXRScanlineData {
-    uint8_t *compressed_data;
-    unsigned int compressed_size;
-
-    uint8_t *uncompressed_data;
-    unsigned int uncompressed_size;
-
-    uint8_t *tmp;
-    unsigned int tmp_size;
-
-    int64_t actual_size;
-} EXRScanlineData;
-
-typedef struct EXRContext {
-    const AVClass *class;
-
-    int compression;
-    int pixel_type;
-    int planes;
-    int nb_scanlines;
-    int scanline_height;
-    float gamma;
-    const char *ch_names;
-    const uint8_t *ch_order;
-    PutByteContext pb;
-
-    EXRScanlineData *scanline;
-
-    uint16_t basetable[512];
-    uint8_t shifttable[512];
-} EXRContext;
-
-static int encode_init(AVCodecContext *avctx)
-{
-    EXRContext *s = avctx->priv_data;
-
-    float2half_tables(s->basetable, s->shifttable);
-
-    switch (avctx->pix_fmt) {
-    case AV_PIX_FMT_GBRPF32:
-        s->planes = 3;
-        s->ch_names = bgr_chlist;
-        s->ch_order = gbr_order;
-        break;
-    case AV_PIX_FMT_GBRAPF32:
-        s->planes = 4;
-        s->ch_names = abgr_chlist;
-        s->ch_order = gbra_order;
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    switch (s->compression) {
-    case EXR_RAW:
-    case EXR_RLE:
-    case EXR_ZIP1:
-        s->scanline_height = 1;
-        s->nb_scanlines = avctx->height;
-        break;
-    case EXR_ZIP16:
-        s->scanline_height = 16;
-        s->nb_scanlines = (avctx->height + s->scanline_height - 1) / s->scanline_height;
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    s->scanline = av_calloc(s->nb_scanlines, sizeof(*s->scanline));
-    if (!s->scanline)
-        return AVERROR(ENOMEM);
-
-    return 0;
-}
-
-static int encode_close(AVCodecContext *avctx)
-{
-    EXRContext *s = avctx->priv_data;
-
-    for (int y = 0; y < s->nb_scanlines && s->scanline; y++) {
-        EXRScanlineData *scanline = &s->scanline[y];
-
-        av_freep(&scanline->tmp);
-        av_freep(&scanline->compressed_data);
-        av_freep(&scanline->uncompressed_data);
-    }
-
-    av_freep(&s->scanline);
-
-    return 0;
-}
-
-static void reorder_pixels(uint8_t *dst, const uint8_t *src, ptrdiff_t size)
-{
-    const ptrdiff_t half_size = (size + 1) / 2;
-    uint8_t *t1 = dst;
-    uint8_t *t2 = dst + half_size;
-
-    for (ptrdiff_t i = 0; i < half_size; i++) {
-        t1[i] = *(src++);
-        t2[i] = *(src++);
-    }
-}
-
-static void predictor(uint8_t *src, ptrdiff_t size)
-{
-    int p = src[0];
-
-    for (ptrdiff_t i = 1; i < size; i++) {
-        int d = src[i] - p + 384;
-
-        p = src[i];
-        src[i] = d;
-    }
-}
-
-static int64_t rle_compress(uint8_t *out, int64_t out_size,
-                            const uint8_t *in, int64_t in_size)
-{
-    int64_t i = 0, o = 0, run = 1, copy = 0;
-
-    while (i < in_size) {
-        while (i + run < in_size && in[i] == in[i + run] && run < 128)
-            run++;
-
-        if (run >= 3) {
-            if (o + 2 >= out_size)
-                return -1;
-            out[o++] = run - 1;
-            out[o++] = in[i];
-            i += run;
-        } else {
-            if (i + run < in_size)
-                copy += run;
-            while (i + copy < in_size && copy < 127 && in[i + copy] != in[i + copy - 1])
-                copy++;
-
-            if (o + 1 + copy >= out_size)
-                return -1;
-            out[o++] = -copy;
-
-            for (int x = 0; x < copy; x++)
-                out[o + x] = in[i + x];
-
-            o += copy;
-            i += copy;
-            copy = 0;
-        }
-
-        run = 1;
-    }
-
-    return o;
-}
-
-static int encode_scanline_rle(EXRContext *s, const AVFrame *frame)
-{
-    const int64_t element_size = s->pixel_type == EXR_HALF ? 2LL : 4LL;
-
-    for (int y = 0; y < frame->height; y++) {
-        EXRScanlineData *scanline = &s->scanline[y];
-        int64_t tmp_size = element_size * s->planes * frame->width;
-        int64_t max_compressed_size = tmp_size * 3 / 2;
-
-        av_fast_padded_malloc(&scanline->uncompressed_data, &scanline->uncompressed_size, tmp_size);
-        if (!scanline->uncompressed_data)
-            return AVERROR(ENOMEM);
-
-        av_fast_padded_malloc(&scanline->tmp, &scanline->tmp_size, tmp_size);
-        if (!scanline->tmp)
-            return AVERROR(ENOMEM);
-
-        av_fast_padded_malloc(&scanline->compressed_data, &scanline->compressed_size, max_compressed_size);
-        if (!scanline->compressed_data)
-            return AVERROR(ENOMEM);
-
-        switch (s->pixel_type) {
-        case EXR_FLOAT:
-            for (int p = 0; p < s->planes; p++) {
-                int ch = s->ch_order[p];
-
-                memcpy(scanline->uncompressed_data + frame->width * 4 * p,
-                       frame->data[ch] + y * frame->linesize[ch], frame->width * 4);
-            }
-            break;
-        case EXR_HALF:
-            for (int p = 0; p < s->planes; p++) {
-                int ch = s->ch_order[p];
-                uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + frame->width * 2 * p);
-                uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
-
-                for (int x = 0; x < frame->width; x++)
-                    dst[x] = float2half(src[x], s->basetable, s->shifttable);
-            }
-            break;
-        }
-
-        reorder_pixels(scanline->tmp, scanline->uncompressed_data, tmp_size);
-        predictor(scanline->tmp, tmp_size);
-        scanline->actual_size = rle_compress(scanline->compressed_data,
-                                             max_compressed_size,
-                                             scanline->tmp, tmp_size);
-
-        if (scanline->actual_size <= 0 || scanline->actual_size >= tmp_size) {
-            FFSWAP(uint8_t *, scanline->uncompressed_data, scanline->compressed_data);
-            FFSWAP(int, scanline->uncompressed_size, scanline->compressed_size);
-            scanline->actual_size = tmp_size;
-        }
-    }
-
-    return 0;
-}
-
-static int encode_scanline_zip(EXRContext *s, const AVFrame *frame)
-{
-    const int64_t element_size = s->pixel_type == EXR_HALF ? 2LL : 4LL;
-
-    for (int y = 0; y < s->nb_scanlines; y++) {
-        EXRScanlineData *scanline = &s->scanline[y];
-        const int scanline_height = FFMIN(s->scanline_height, frame->height - y * s->scanline_height);
-        int64_t tmp_size = element_size * s->planes * frame->width * scanline_height;
-        int64_t max_compressed_size = tmp_size * 3 / 2;
-        unsigned long actual_size, source_size;
-
-        av_fast_padded_malloc(&scanline->uncompressed_data, &scanline->uncompressed_size, tmp_size);
-        if (!scanline->uncompressed_data)
-            return AVERROR(ENOMEM);
-
-        av_fast_padded_malloc(&scanline->tmp, &scanline->tmp_size, tmp_size);
-        if (!scanline->tmp)
-            return AVERROR(ENOMEM);
-
-        av_fast_padded_malloc(&scanline->compressed_data, &scanline->compressed_size, max_compressed_size);
-        if (!scanline->compressed_data)
-            return AVERROR(ENOMEM);
-
-        switch (s->pixel_type) {
-        case EXR_FLOAT:
-            for (int l = 0; l < scanline_height; l++) {
-                const int scanline_size = frame->width * 4 * s->planes;
-
-                for (int p = 0; p < s->planes; p++) {
-                    int ch = s->ch_order[p];
-
-                    memcpy(scanline->uncompressed_data + scanline_size * l + p * frame->width * 4,
-                           frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch],
-                           frame->width * 4);
-                }
-            }
-            break;
-        case EXR_HALF:
-            for (int l = 0; l < scanline_height; l++) {
-                const int scanline_size = frame->width * 2 * s->planes;
-
-                for (int p = 0; p < s->planes; p++) {
-                    int ch = s->ch_order[p];
-                    uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + scanline_size * l + p * frame->width * 2);
-                    uint32_t *src = (uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]);
-
-                    for (int x = 0; x < frame->width; x++)
-                        dst[x] = float2half(src[x], s->basetable, s->shifttable);
-                }
-            }
-            break;
-        }
-
-        reorder_pixels(scanline->tmp, scanline->uncompressed_data, tmp_size);
-        predictor(scanline->tmp, tmp_size);
-        source_size = tmp_size;
-        actual_size = max_compressed_size;
-        compress(scanline->compressed_data, &actual_size,
-                 scanline->tmp, source_size);
-
-        scanline->actual_size = actual_size;
-        if (scanline->actual_size >= tmp_size) {
-            FFSWAP(uint8_t *, scanline->uncompressed_data, scanline->compressed_data);
-            FFSWAP(int, scanline->uncompressed_size, scanline->compressed_size);
-            scanline->actual_size = tmp_size;
-        }
-    }
-
-    return 0;
-}
-
-static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
-                        const AVFrame *frame, int *got_packet)
-{
-    EXRContext *s = avctx->priv_data;
-    PutByteContext *pb = &s->pb;
-    int64_t offset;
-    int ret;
-    int64_t out_size = 2048LL + avctx->height * 16LL +
-                      av_image_get_buffer_size(avctx->pix_fmt,
-                                               avctx->width,
-                                               avctx->height, 64) * 3LL / 2;
-
-    if ((ret = ff_alloc_packet2(avctx, pkt, out_size, out_size)) < 0)
-        return ret;
-
-    bytestream2_init_writer(pb, pkt->data, pkt->size);
-
-    bytestream2_put_le32(pb, 20000630);
-    bytestream2_put_byte(pb, 2);
-    bytestream2_put_le24(pb, 0);
-    bytestream2_put_buffer(pb, "channels\0chlist\0", 16);
-    bytestream2_put_le32(pb, s->planes * 18 + 1);
-
-    for (int p = 0; p < s->planes; p++) {
-        bytestream2_put_byte(pb, s->ch_names[p]);
-        bytestream2_put_byte(pb, 0);
-        bytestream2_put_le32(pb, s->pixel_type);
-        bytestream2_put_le32(pb, 0);
-        bytestream2_put_le32(pb, 1);
-        bytestream2_put_le32(pb, 1);
-    }
-    bytestream2_put_byte(pb, 0);
-
-    bytestream2_put_buffer(pb, "compression\0compression\0", 24);
-    bytestream2_put_le32(pb, 1);
-    bytestream2_put_byte(pb, s->compression);
-
-    bytestream2_put_buffer(pb, "dataWindow\0box2i\0", 17);
-    bytestream2_put_le32(pb, 16);
-    bytestream2_put_le32(pb, 0);
-    bytestream2_put_le32(pb, 0);
-    bytestream2_put_le32(pb, avctx->width - 1);
-    bytestream2_put_le32(pb, avctx->height - 1);
-
-    bytestream2_put_buffer(pb, "displayWindow\0box2i\0", 20);
-    bytestream2_put_le32(pb, 16);
-    bytestream2_put_le32(pb, 0);
-    bytestream2_put_le32(pb, 0);
-    bytestream2_put_le32(pb, avctx->width - 1);
-    bytestream2_put_le32(pb, avctx->height - 1);
-
-    bytestream2_put_buffer(pb, "lineOrder\0lineOrder\0", 20);
-    bytestream2_put_le32(pb, 1);
-    bytestream2_put_byte(pb, 0);
-
-    bytestream2_put_buffer(pb, "screenWindowCenter\0v2f\0", 23);
-    bytestream2_put_le32(pb, 8);
-    bytestream2_put_le64(pb, 0);
-
-    bytestream2_put_buffer(pb, "screenWindowWidth\0float\0", 24);
-    bytestream2_put_le32(pb, 4);
-    bytestream2_put_le32(pb, av_float2int(1.f));
-
-    if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
-        bytestream2_put_buffer(pb, "pixelAspectRatio\0float\0", 23);
-        bytestream2_put_le32(pb, 4);
-        bytestream2_put_le32(pb, av_float2int(av_q2d(avctx->sample_aspect_ratio)));
-    }
-
-    if (avctx->framerate.num && avctx->framerate.den) {
-        bytestream2_put_buffer(pb, "framesPerSecond\0rational\0", 25);
-        bytestream2_put_le32(pb, 8);
-        bytestream2_put_le32(pb, avctx->framerate.num);
-        bytestream2_put_le32(pb, avctx->framerate.den);
-    }
-
-    bytestream2_put_buffer(pb, "gamma\0float\0", 12);
-    bytestream2_put_le32(pb, 4);
-    bytestream2_put_le32(pb, av_float2int(s->gamma));
-
-    bytestream2_put_buffer(pb, "writer\0string\0", 14);
-    bytestream2_put_le32(pb, 4);
-    bytestream2_put_buffer(pb, "lavc", 4);
-    bytestream2_put_byte(pb, 0);
-
-    switch (s->compression) {
-    case EXR_RAW:
-        /* nothing to do */
-        break;
-    case EXR_RLE:
-        encode_scanline_rle(s, frame);
-        break;
-    case EXR_ZIP16:
-    case EXR_ZIP1:
-        encode_scanline_zip(s, frame);
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    switch (s->compression) {
-    case EXR_RAW:
-        offset = bytestream2_tell_p(pb) + avctx->height * 8LL;
-
-        if (s->pixel_type == EXR_FLOAT) {
-
-            for (int y = 0; y < avctx->height; y++) {
-                bytestream2_put_le64(pb, offset);
-                offset += avctx->width * s->planes * 4 + 8;
-            }
-
-            for (int y = 0; y < avctx->height; y++) {
-                bytestream2_put_le32(pb, y);
-                bytestream2_put_le32(pb, s->planes * avctx->width * 4);
-                for (int p = 0; p < s->planes; p++) {
-                    int ch = s->ch_order[p];
-                    bytestream2_put_buffer(pb, frame->data[ch] + y * frame->linesize[ch],
-                                           avctx->width * 4);
-                }
-            }
-        } else {
-            for (int y = 0; y < avctx->height; y++) {
-                bytestream2_put_le64(pb, offset);
-                offset += avctx->width * s->planes * 2 + 8;
-            }
-
-            for (int y = 0; y < avctx->height; y++) {
-                bytestream2_put_le32(pb, y);
-                bytestream2_put_le32(pb, s->planes * avctx->width * 2);
-                for (int p = 0; p < s->planes; p++) {
-                    int ch = s->ch_order[p];
-                    uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
-
-                    for (int x = 0; x < frame->width; x++)
-                        bytestream2_put_le16(pb, float2half(src[x], s->basetable, s->shifttable));
-                }
-            }
-        }
-        break;
-    case EXR_ZIP16:
-    case EXR_ZIP1:
-    case EXR_RLE:
-        offset = bytestream2_tell_p(pb) + s->nb_scanlines * 8LL;
-
-        for (int y = 0; y < s->nb_scanlines; y++) {
-            EXRScanlineData *scanline = &s->scanline[y];
-
-            bytestream2_put_le64(pb, offset);
-            offset += scanline->actual_size + 8;
-        }
-
-        for (int y = 0; y < s->nb_scanlines; y++) {
-            EXRScanlineData *scanline = &s->scanline[y];
-
-            bytestream2_put_le32(pb, y * s->scanline_height);
-            bytestream2_put_le32(pb, scanline->actual_size);
-            bytestream2_put_buffer(pb, scanline->compressed_data,
-                                   scanline->actual_size);
-        }
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    av_shrink_packet(pkt, bytestream2_tell_p(pb));
-
-    pkt->flags |= AV_PKT_FLAG_KEY;
-    *got_packet = 1;
-
-    return 0;
-}
-
-#define OFFSET(x) offsetof(EXRContext, x)
-#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-static const AVOption options[] = {
-    { "compression", "set compression type", OFFSET(compression), AV_OPT_TYPE_INT,   {.i64=0}, 0, EXR_NBCOMPR-1, VE, "compr" },
-    { "none",        "none",                 0,                   AV_OPT_TYPE_CONST, {.i64=EXR_RAW}, 0, 0, VE, "compr" },
-    { "rle" ,        "RLE",                  0,                   AV_OPT_TYPE_CONST, {.i64=EXR_RLE}, 0, 0, VE, "compr" },
-    { "zip1",        "ZIP1",                 0,                   AV_OPT_TYPE_CONST, {.i64=EXR_ZIP1}, 0, 0, VE, "compr" },
-    { "zip16",       "ZIP16",                0,                   AV_OPT_TYPE_CONST, {.i64=EXR_ZIP16}, 0, 0, VE, "compr" },
-    { "format", "set pixel type", OFFSET(pixel_type), AV_OPT_TYPE_INT,   {.i64=EXR_FLOAT}, EXR_HALF, EXR_UNKNOWN-1, VE, "pixel" },
-    { "half" ,       NULL,                   0,                   AV_OPT_TYPE_CONST, {.i64=EXR_HALF},  0, 0, VE, "pixel" },
-    { "float",       NULL,                   0,                   AV_OPT_TYPE_CONST, {.i64=EXR_FLOAT}, 0, 0, VE, "pixel" },
-    { "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.001, FLT_MAX, VE },
-    { NULL},
-};
-
-static const AVClass exr_class = {
-    .class_name = "exr",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_exr_encoder = {
-    .name           = "exr",
-    .long_name      = NULL_IF_CONFIG_SMALL("OpenEXR image"),
-    .priv_data_size = sizeof(EXRContext),
-    .priv_class     = &exr_class,
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_EXR,
-    .init           = encode_init,
-    .encode2        = encode_frame,
-    .close          = encode_close,
-    .capabilities   = AV_CODEC_CAP_FRAME_THREADS,
-    .pix_fmts       = (const enum AVPixelFormat[]) {
-                                                 AV_PIX_FMT_GBRPF32,
-                                                 AV_PIX_FMT_GBRAPF32,
-                                                 AV_PIX_FMT_NONE },
-};
diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c
index 9de42d2..1dda310 100644
--- a/libavcodec/fastaudio.c
+++ b/libavcodec/fastaudio.c
@@ -1,7 +1,5 @@
 /*
  * MOFLEX Fast Audio decoder
- * Copyright (c) 2015-2016 Florian Nouwt
- * Copyright (c) 2017 Adib Surani
  * Copyright (c) 2020 Paul B Mahol
  *
  * This file is part of FFmpeg.
@@ -91,7 +89,7 @@
 
     pos = *ppos;
     pos += bits;
-    r = src[(pos - 1) / 32] >> ((-pos) & 31);
+    r = src[(pos - 1) / 32] >> (32 - pos % 32);
     *ppos = pos;
 
     return r & ((1 << bits) - 1);
diff --git a/libavcodec/fft-internal.h b/libavcodec/fft-internal.h
index 3bd5a11..0a8f7d0 100644
--- a/libavcodec/fft-internal.h
+++ b/libavcodec/fft-internal.h
@@ -34,7 +34,7 @@
         (dim) = (are) * (bim) + (aim) * (bre);  \
     } while (0)
 
-#else /* FFT_FLOAT */
+#else
 
 #define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits)))
 
@@ -52,6 +52,33 @@
 
 #define FIX15(a) av_clip(SCALE_FLOAT(a, 31), -2147483647, 2147483647)
 
+#else /* FFT_FIXED_32 */
+
+#include "fft.h"
+#include "mathops.h"
+
+void ff_mdct_calcw_c(FFTContext *s, FFTDouble *output, const FFTSample *input);
+
+#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767)
+
+#define sqrthalf ((int16_t)((1<<15)*M_SQRT1_2))
+
+#define BF(x, y, a, b) do {                     \
+        x = (a - b) >> 1;                       \
+        y = (a + b) >> 1;                       \
+    } while (0)
+
+#define CMULS(dre, dim, are, aim, bre, bim, sh) do {            \
+        (dre) = (MUL16(are, bre) - MUL16(aim, bim)) >> sh;      \
+        (dim) = (MUL16(are, bim) + MUL16(aim, bre)) >> sh;      \
+    } while (0)
+
+#define CMUL(dre, dim, are, aim, bre, bim)      \
+    CMULS(dre, dim, are, aim, bre, bim, 15)
+
+#define CMULL(dre, dim, are, aim, bre, bim)     \
+    CMULS(dre, dim, are, aim, bre, bim, 0)
+
 #endif /* FFT_FIXED_32 */
 
 #endif /* FFT_FLOAT */
diff --git a/libavcodec/fft.h b/libavcodec/fft.h
index e03ca01..c858570 100644
--- a/libavcodec/fft.h
+++ b/libavcodec/fft.h
@@ -32,8 +32,7 @@
 
 #include <stdint.h>
 #include "config.h"
-
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #if FFT_FLOAT
 
@@ -52,6 +51,12 @@
 
 typedef int32_t FFTSample;
 
+#else /* FFT_FIXED_32 */
+
+#define FFT_NAME(x) x ## _fixed
+
+typedef int16_t FFTSample;
+
 #endif /* FFT_FIXED_32 */
 
 typedef struct FFTComplex {
@@ -102,6 +107,7 @@
     void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
     void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
     void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
+    void (*mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input);
     enum fft_permutation_type fft_permutation;
     enum mdct_permutation_type mdct_permutation;
     uint32_t *revtab32;
@@ -109,16 +115,8 @@
 
 #if CONFIG_HARDCODED_TABLES
 #define COSTABLE_CONST const
-#define ff_init_ff_cos_tabs(index)
 #else
 #define COSTABLE_CONST
-#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs)
-
-/**
- * Initialize the cosine table in ff_cos_tabs[index]
- * @param index index in ff_cos_tabs array of the table to initialize
- */
-void ff_init_ff_cos_tabs(int index);
 #endif
 
 #define COSTABLE(size) \
@@ -140,6 +138,14 @@
 extern COSTABLE(131072);
 extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[18];
 
+#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs)
+
+/**
+ * Initialize the cosine table in ff_cos_tabs[index]
+ * @param index index in ff_cos_tabs array of the table to initialize
+ */
+void ff_init_ff_cos_tabs(int index);
+
 #define ff_fft_init FFT_NAME(ff_fft_init)
 #define ff_fft_end  FFT_NAME(ff_fft_end)
 
@@ -156,6 +162,8 @@
 void ff_fft_init_mips(FFTContext *s);
 void ff_fft_init_ppc(FFTContext *s);
 
+void ff_fft_fixed_init_arm(FFTContext *s);
+
 void ff_fft_end(FFTContext *s);
 
 #define ff_mdct_init FFT_NAME(ff_mdct_init)
diff --git a/libavcodec/ttmlenc.h b/libavcodec/fft_fixed.c
similarity index 71%
copy from libavcodec/ttmlenc.h
copy to libavcodec/fft_fixed.c
index c1dd5ec..3d3bd2f 100644
--- a/libavcodec/ttmlenc.h
+++ b/libavcodec/fft_fixed.c
@@ -1,7 +1,4 @@
 /*
- * TTML subtitle encoder shared functionality
- * Copyright (c) 2020 24i
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -19,10 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_TTMLENC_H
-#define AVCODEC_TTMLENC_H
-
-#define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc"
-#define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1)
-
-#endif /* AVCODEC_TTMLENC_H */
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 0
+#include "fft_template.c"
diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
index 3012372..8825e39 100644
--- a/libavcodec/fft_template.c
+++ b/libavcodec/fft_template.c
@@ -113,10 +113,6 @@
     { init_ff_cos_tabs_131072, AV_ONCE_INIT },
 };
 
-av_cold void ff_init_ff_cos_tabs(int index)
-{
-    ff_thread_once(&cos_tabs_init_once[index].control, cos_tabs_init_once[index].func);
-}
 #endif
 COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = {
     NULL, NULL, NULL, NULL,
@@ -152,6 +148,12 @@
     else                  return split_radix_permutation(i, m, inverse)*4 - 1;
 }
 
+av_cold void ff_init_ff_cos_tabs(int index)
+{
+#if (!CONFIG_HARDCODED_TABLES) && (!FFT_FIXED_32)
+    ff_thread_once(&cos_tabs_init_once[index].control, cos_tabs_init_once[index].func);
+#endif
+}
 
 static const int avx_tab[] = {
     0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15
@@ -234,7 +236,11 @@
     if (ARCH_ARM)     ff_fft_init_arm(s);
     if (ARCH_PPC)     ff_fft_init_ppc(s);
     if (ARCH_X86)     ff_fft_init_x86(s);
+    if (CONFIG_MDCT)  s->mdct_calcw = s->mdct_calc;
     if (HAVE_MIPSFPU) ff_fft_init_mips(s);
+#else
+    if (CONFIG_MDCT)  s->mdct_calcw = ff_mdct_calcw_c;
+    if (ARCH_ARM)     ff_fft_fixed_init_arm(s);
 #endif
     for(j=4; j<=nbits; j++) {
         ff_init_ff_cos_tabs(j);
@@ -242,7 +248,7 @@
 #endif /* FFT_FIXED_32 */
 
 
-    if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) {
+    if (s->fft_permutation == FF_FFT_PERM_AVX) {
         fft_perm_avx(s);
     } else {
 #define PROCESS_FFT_PERM_SWAP_LSBS(num) do {\
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 0a3f425..c704373 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -786,7 +786,7 @@
 
             if (f->version == 2) {
                 int idx = get_symbol(c, state, 0);
-                if (idx >= (unsigned)f->quant_table_count) {
+                if (idx > (unsigned)f->quant_table_count) {
                     av_log(f->avctx, AV_LOG_ERROR,
                            "quant_table_index out of range\n");
                     return AVERROR_INVALIDDATA;
diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index ef5f3f4..95baaed 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -22,7 +22,6 @@
  */
 
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/fits.c b/libavcodec/fits.c
index 97fa7ab..25c33e0 100644
--- a/libavcodec/fits.c
+++ b/libavcodec/fits.c
@@ -205,12 +205,8 @@
         } else if (!strcmp(keyword, "GROUPS") && sscanf(value, "%c", &c) == 1) {
             header->groups = (c == 'T');
         } else if (!strcmp(keyword, "GCOUNT") && sscanf(value, "%"SCNd64"", &t) == 1) {
-            if (t < 0 || t > INT_MAX)
-                return AVERROR_INVALIDDATA;
             header->gcount = t;
         } else if (!strcmp(keyword, "PCOUNT") && sscanf(value, "%"SCNd64"", &t) == 1) {
-            if (t < 0 || t > INT_MAX)
-                return AVERROR_INVALIDDATA;
             header->pcount = t;
         }
         dict_set_if_not_null(metadata, keyword, value);
diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c
index 802aa5b..32a79cd 100644
--- a/libavcodec/fitsdec.c
+++ b/libavcodec/fitsdec.c
@@ -63,7 +63,7 @@
     int i, j;
 
     header->data_min = DBL_MAX;
-    header->data_max = -DBL_MAX;
+    header->data_max = DBL_MIN;
     switch (header->bitpix) {
 #define CASE_N(a, t, rd) \
     case a: \
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index 9481f80..f55cb0f 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -179,7 +179,7 @@
     return 0;
 }
 
-static int flashsv_decode_block(AVCodecContext *avctx, const AVPacket *avpkt,
+static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,
                                 GetBitContext *gb, int block_size,
                                 int width, int height, int x_pos, int y_pos,
                                 int blk_idx)
diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
index 430b680..6603d0d 100644
--- a/libavcodec/flashsv2enc.c
+++ b/libavcodec/flashsv2enc.c
@@ -142,7 +142,6 @@
 {
     int row, col;
     Block *b;
-    memset(blocks, 0, s->cols * s->rows * sizeof(*blocks));
     for (col = 0; col < s->cols; col++) {
         for (row = 0; row < s->rows; row++) {
             b = blocks + (col + row * s->cols);
@@ -175,33 +174,6 @@
 #endif
 }
 
-static int update_block_dimensions(FlashSV2Context *s, int block_width, int block_height)
-{
-    s->block_width  = block_width;
-    s->block_height = block_height;
-    s->rows = (s->image_height + s->block_height - 1) / s->block_height;
-    s->cols = (s->image_width  + s->block_width  - 1) / s->block_width;
-    if (s->rows * s->cols > s->blocks_size / sizeof(Block)) {
-        s->frame_blocks = av_realloc_array(s->frame_blocks, s->rows, s->cols * sizeof(Block));
-        s->key_blocks = av_realloc_array(s->key_blocks, s->cols, s->rows * sizeof(Block));
-        if (!s->frame_blocks || !s->key_blocks) {
-            av_log(s->avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
-            return AVERROR(ENOMEM);
-        }
-        s->blocks_size = s->rows * s->cols * sizeof(Block);
-    }
-    init_blocks(s, s->frame_blocks, s->encbuffer, s->databuffer);
-    init_blocks(s, s->key_blocks, s->keybuffer, 0);
-
-    av_fast_malloc(&s->blockbuffer, &s->blockbuffer_size, block_width * block_height * 6);
-    if (!s->blockbuffer) {
-        av_log(s->avctx, AV_LOG_ERROR, "Could not allocate block buffer.\n");
-        return AVERROR(ENOMEM);
-    }
-    return 0;
-}
-
-
 static av_cold int flashsv2_encode_init(AVCodecContext * avctx)
 {
     FlashSV2Context *s = avctx->priv_data;
@@ -239,19 +211,39 @@
     s->image_width  = avctx->width;
     s->image_height = avctx->height;
 
+    s->block_width  = (s->image_width /  12) & ~15;
+    s->block_height = (s->image_height / 12) & ~15;
+
+    if(!s->block_width)
+        s->block_width = 1;
+    if(!s->block_height)
+        s->block_height = 1;
+
+    s->rows = (s->image_height + s->block_height - 1) / s->block_height;
+    s->cols = (s->image_width +  s->block_width -  1) / s->block_width;
+
     s->frame_size  = s->image_width * s->image_height * 3;
+    s->blocks_size = s->rows * s->cols * sizeof(Block);
 
     s->encbuffer     = av_mallocz(s->frame_size);
     s->keybuffer     = av_mallocz(s->frame_size);
     s->databuffer    = av_mallocz(s->frame_size * 6);
     s->current_frame = av_mallocz(s->frame_size);
     s->key_frame     = av_mallocz(s->frame_size);
+    s->frame_blocks  = av_mallocz(s->blocks_size);
+    s->key_blocks    = av_mallocz(s->blocks_size);
     if (!s->encbuffer || !s->keybuffer || !s->databuffer
-        || !s->current_frame || !s->key_frame) {
+        || !s->current_frame || !s->key_frame || !s->key_blocks
+        || !s->frame_blocks) {
         av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
         return AVERROR(ENOMEM);
     }
 
+    s->blockbuffer      = NULL;
+    s->blockbuffer_size = 0;
+
+    init_blocks(s, s->frame_blocks, s->encbuffer, s->databuffer);
+    init_blocks(s, s->key_blocks,   s->keybuffer, 0);
     reset_stats(s);
 #ifndef FLASHSV2_DUMB
     s->total_bits = 1;
@@ -260,7 +252,7 @@
     s->use_custom_palette =  0;
     s->palette_type       = -1;        // so that the palette will be generated in reconfigure_at_keyframe
 
-    return update_block_dimensions(s, 64, 64);
+    return 0;
 }
 
 static int new_key_frame(FlashSV2Context * s)
@@ -808,10 +800,29 @@
     int block_width  = optimum_block_width (s);
     int block_height = optimum_block_height(s);
 
+    s->rows = (s->image_height + block_height - 1) / block_height;
+    s->cols = (s->image_width  + block_width  - 1) / block_width;
+
     if (block_width != s->block_width || block_height != s->block_height) {
-        res = update_block_dimensions(s, block_width, block_height);
-        if (res < 0)
-            return res;
+        s->block_width  = block_width;
+        s->block_height = block_height;
+        if (s->rows * s->cols > s->blocks_size / sizeof(Block)) {
+            s->frame_blocks = av_realloc_array(s->frame_blocks, s->rows, s->cols * sizeof(Block));
+            s->key_blocks = av_realloc_array(s->key_blocks, s->cols, s->rows * sizeof(Block));
+            if (!s->frame_blocks || !s->key_blocks) {
+                av_log(s->avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
+                return -1;
+            }
+            s->blocks_size = s->rows * s->cols * sizeof(Block);
+        }
+        init_blocks(s, s->frame_blocks, s->encbuffer, s->databuffer);
+        init_blocks(s, s->key_blocks, s->keybuffer, 0);
+
+        av_fast_malloc(&s->blockbuffer, &s->blockbuffer_size, block_width * block_height * 6);
+        if (!s->blockbuffer) {
+            av_log(s->avctx, AV_LOG_ERROR, "Could not allocate block buffer.\n");
+            return AVERROR(ENOMEM);
+        }
     }
 
     s->use15_7 = optimum_use15_7(s);
diff --git a/libavcodec/float2half.h b/libavcodec/float2half.h
deleted file mode 100644
index e051250..0000000
--- a/libavcodec/float2half.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_FLOAT2HALF_H
-#define AVCODEC_FLOAT2HALF_H
-
-#include <stdint.h>
-
-static void float2half_tables(uint16_t *basetable, uint8_t *shifttable)
-{
-    for (int i = 0; i < 256; i++) {
-        int e = i - 127;
-
-        if (e < -24) { // Very small numbers map to zero
-            basetable[i|0x000]  = 0x0000;
-            basetable[i|0x100]  = 0x8000;
-            shifttable[i|0x000] = 24;
-            shifttable[i|0x100] = 24;
-        } else if (e < -14) { // Small numbers map to denorms
-            basetable[i|0x000] = (0x0400>>(-e-14));
-            basetable[i|0x100] = (0x0400>>(-e-14)) | 0x8000;
-            shifttable[i|0x000] = -e-1;
-            shifttable[i|0x100] = -e-1;
-        } else if (e <= 15) { // Normal numbers just lose precision
-            basetable[i|0x000] = ((e + 15) << 10);
-            basetable[i|0x100] = ((e + 15) << 10) | 0x8000;
-            shifttable[i|0x000] = 13;
-            shifttable[i|0x100] = 13;
-        } else if (e < 128) { // Large numbers map to Infinity
-            basetable[i|0x000]  = 0x7C00;
-            basetable[i|0x100]  = 0xFC00;
-            shifttable[i|0x000] = 24;
-            shifttable[i|0x100] = 24;
-        } else { // Infinity and NaN's stay Infinity and NaN's
-            basetable[i|0x000]  = 0x7C00;
-            basetable[i|0x100]  = 0xFC00;
-            shifttable[i|0x000] = 13;
-            shifttable[i|0x100] = 13;
-        }
-    }
-}
-
-static uint16_t float2half(uint32_t f, uint16_t *basetable, uint8_t *shifttable)
-{
-    uint16_t h;
-
-    h = basetable[(f >> 23) & 0x1ff] + ((f & 0x007fffff) >> shifttable[(f >> 23) & 0x1ff]);
-
-    return h;
-}
-
-#endif /* AVCODEC_FLOAT2HALF_H */
diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index 3701b08..5bee96a 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -440,8 +440,6 @@
             memcpy(dst, src, avctx->width * s->bpp);
             dst -= frame->linesize[0];
             src += s->stride * 4;
-            if (bytestream2_tell_p(pb) < y*s->stride * 4)
-                break;
         }
     } else {
         unsigned block, nb_blocks;
diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index 778317d..83229f6 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -22,6 +22,7 @@
 
 #include "frame_thread_encoder.h"
 
+#include "libavutil/fifo.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -31,32 +32,27 @@
 #include "thread.h"
 
 #define MAX_THREADS 64
-/* There can be as many as MAX_THREADS + 1 outstanding tasks.
- * An additional + 1 is needed so that one can distinguish
- * the case of zero and MAX_THREADS + 1 outstanding tasks modulo
- * the number of buffers. */
-#define BUFFER_SIZE (MAX_THREADS + 2)
+#define BUFFER_SIZE (2*MAX_THREADS)
 
 typedef struct{
-    AVFrame  *indata;
-    AVPacket *outdata;
-    int       return_code;
-    int       finished;
+    void *indata;
+    void *outdata;
+    int64_t return_code;
+    unsigned index;
 } Task;
 
 typedef struct{
     AVCodecContext *parent_avctx;
     pthread_mutex_t buffer_mutex;
 
-    pthread_mutex_t task_fifo_mutex; /* Used to guard (next_)task_index */
+    AVFifoBuffer *task_fifo;
+    pthread_mutex_t task_fifo_mutex;
     pthread_cond_t task_fifo_cond;
 
-    unsigned max_tasks;
-    Task tasks[BUFFER_SIZE];
-    pthread_mutex_t finished_task_mutex; /* Guards tasks[i].finished */
+    Task finished_tasks[BUFFER_SIZE];
+    pthread_mutex_t finished_task_mutex;
     pthread_cond_t finished_task_cond;
 
-    unsigned next_task_index;
     unsigned task_index;
     unsigned finished_task_index;
 
@@ -67,32 +63,28 @@
 static void * attribute_align_arg worker(void *v){
     AVCodecContext *avctx = v;
     ThreadContext *c = avctx->internal->frame_thread_encoder;
+    AVPacket *pkt = NULL;
 
     while (!atomic_load(&c->exit)) {
         int got_packet = 0, ret;
-        AVPacket *pkt;
         AVFrame *frame;
-        Task *task;
-        unsigned task_index;
+        Task task;
+
+        if(!pkt) pkt = av_packet_alloc();
+        if(!pkt) continue;
+        av_init_packet(pkt);
 
         pthread_mutex_lock(&c->task_fifo_mutex);
-        while (c->next_task_index == c->task_index || atomic_load(&c->exit)) {
+        while (av_fifo_size(c->task_fifo) <= 0 || atomic_load(&c->exit)) {
             if (atomic_load(&c->exit)) {
                 pthread_mutex_unlock(&c->task_fifo_mutex);
                 goto end;
             }
             pthread_cond_wait(&c->task_fifo_cond, &c->task_fifo_mutex);
         }
-        task_index         = c->next_task_index;
-        c->next_task_index = (c->next_task_index + 1) % c->max_tasks;
+        av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL);
         pthread_mutex_unlock(&c->task_fifo_mutex);
-        /* The main thread ensures that any two outstanding tasks have
-         * different indices, ergo each worker thread owns its element
-         * of c->tasks with the exception of finished, which is shared
-         * with the main thread and guarded by finished_task_mutex. */
-        task  = &c->tasks[task_index];
-        frame = task->indata;
-        pkt   = task->outdata;
+        frame = task.indata;
 
         ret = avctx->codec->encode2(avctx, pkt, frame, &got_packet);
         if(got_packet) {
@@ -107,13 +99,15 @@
         pthread_mutex_lock(&c->buffer_mutex);
         av_frame_unref(frame);
         pthread_mutex_unlock(&c->buffer_mutex);
+        av_frame_free(&frame);
         pthread_mutex_lock(&c->finished_task_mutex);
-        task->return_code = ret;
-        task->finished    = 1;
+        c->finished_tasks[task.index].outdata = pkt; pkt = NULL;
+        c->finished_tasks[task.index].return_code = ret;
         pthread_cond_signal(&c->finished_task_cond);
         pthread_mutex_unlock(&c->finished_task_mutex);
     }
 end:
+    av_free(pkt);
     pthread_mutex_lock(&c->buffer_mutex);
     avcodec_close(avctx);
     pthread_mutex_unlock(&c->buffer_mutex);
@@ -187,6 +181,10 @@
 
     c->parent_avctx = avctx;
 
+    c->task_fifo = av_fifo_alloc_array(BUFFER_SIZE, sizeof(Task));
+    if(!c->task_fifo)
+        goto fail;
+
     pthread_mutex_init(&c->task_fifo_mutex, NULL);
     pthread_mutex_init(&c->finished_task_mutex, NULL);
     pthread_mutex_init(&c->buffer_mutex, NULL);
@@ -194,13 +192,6 @@
     pthread_cond_init(&c->finished_task_cond, NULL);
     atomic_init(&c->exit, 0);
 
-    c->max_tasks = avctx->thread_count + 2;
-    for (unsigned i = 0; i < c->max_tasks; i++) {
-        if (!(c->tasks[i].indata  = av_frame_alloc()) ||
-            !(c->tasks[i].outdata = av_packet_alloc()))
-            goto fail;
-    }
-
     for(i=0; i<avctx->thread_count ; i++){
         AVDictionary *tmp = NULL;
         int ret;
@@ -262,9 +253,21 @@
          pthread_join(c->worker[i], NULL);
     }
 
-    for (unsigned i = 0; i < c->max_tasks; i++) {
-        av_frame_free(&c->tasks[i].indata);
-        av_packet_free(&c->tasks[i].outdata);
+    while (av_fifo_size(c->task_fifo) > 0) {
+        Task task;
+        AVFrame *frame;
+        av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL);
+        frame = task.indata;
+        av_frame_free(&frame);
+        task.indata = NULL;
+    }
+
+    for (i=0; i<BUFFER_SIZE; i++) {
+        if (c->finished_tasks[i].outdata != NULL) {
+            AVPacket *pkt = c->finished_tasks[i].outdata;
+            av_packet_free(&pkt);
+            c->finished_tasks[i].outdata = NULL;
+        }
     }
 
     pthread_mutex_destroy(&c->task_fifo_mutex);
@@ -272,47 +275,55 @@
     pthread_mutex_destroy(&c->buffer_mutex);
     pthread_cond_destroy(&c->task_fifo_cond);
     pthread_cond_destroy(&c->finished_task_cond);
+    av_fifo_freep(&c->task_fifo);
     av_freep(&avctx->internal->frame_thread_encoder);
 }
 
-int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
-                                 AVFrame *frame, int *got_packet_ptr)
-{
+int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr){
     ThreadContext *c = avctx->internal->frame_thread_encoder;
-    Task *outtask;
+    Task task;
+    int ret;
 
     av_assert1(!*got_packet_ptr);
 
     if(frame){
-        av_frame_move_ref(c->tasks[c->task_index].indata, frame);
+        AVFrame *new = av_frame_alloc();
+        if(!new)
+            return AVERROR(ENOMEM);
+        ret = av_frame_ref(new, frame);
+        if(ret < 0) {
+            av_frame_free(&new);
+            return ret;
+        }
 
+        task.index = c->task_index;
+        task.indata = (void*)new;
         pthread_mutex_lock(&c->task_fifo_mutex);
-        c->task_index = (c->task_index + 1) % c->max_tasks;
+        av_fifo_generic_write(c->task_fifo, &task, sizeof(task), NULL);
         pthread_cond_signal(&c->task_fifo_cond);
         pthread_mutex_unlock(&c->task_fifo_mutex);
+
+        c->task_index = (c->task_index+1) % BUFFER_SIZE;
     }
 
-    outtask = &c->tasks[c->finished_task_index];
     pthread_mutex_lock(&c->finished_task_mutex);
-    /* The access to task_index in the following code is ok,
-     * because it is only ever changed by the main thread. */
     if (c->task_index == c->finished_task_index ||
-        (frame && !outtask->finished &&
-         (c->task_index - c->finished_task_index + c->max_tasks) % c->max_tasks <= avctx->thread_count)) {
+        (frame && !c->finished_tasks[c->finished_task_index].outdata &&
+         (c->task_index - c->finished_task_index) % BUFFER_SIZE <= avctx->thread_count)) {
             pthread_mutex_unlock(&c->finished_task_mutex);
             return 0;
         }
-    while (!outtask->finished) {
+
+    while (!c->finished_tasks[c->finished_task_index].outdata) {
         pthread_cond_wait(&c->finished_task_cond, &c->finished_task_mutex);
     }
-    pthread_mutex_unlock(&c->finished_task_mutex);
-    /* We now own outtask completely: No worker thread touches it any more,
-     * because there is no outstanding task with this index. */
-    outtask->finished = 0;
-    av_packet_move_ref(pkt, outtask->outdata);
+    task = c->finished_tasks[c->finished_task_index];
+    *pkt = *(AVPacket*)(task.outdata);
     if(pkt->data)
         *got_packet_ptr = 1;
-    c->finished_task_index = (c->finished_task_index + 1) % c->max_tasks;
+    av_freep(&c->finished_tasks[c->finished_task_index].outdata);
+    c->finished_task_index = (c->finished_task_index+1) % BUFFER_SIZE;
+    pthread_mutex_unlock(&c->finished_task_mutex);
 
-    return outtask->return_code;
+    return task.return_code;
 }
diff --git a/libavcodec/frame_thread_encoder.h b/libavcodec/frame_thread_encoder.h
index c400d6b..1f79553 100644
--- a/libavcodec/frame_thread_encoder.h
+++ b/libavcodec/frame_thread_encoder.h
@@ -25,7 +25,6 @@
 
 int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options);
 void ff_frame_thread_encoder_free(AVCodecContext *avctx);
-int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
-                                 AVFrame *frame, int *got_packet_ptr);
+int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr);
 
 #endif /* AVCODEC_FRAME_THREAD_ENCODER_H */
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 68b1b9d..f6aa636 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -30,7 +30,6 @@
 
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "blockdsp.h"
@@ -41,7 +40,6 @@
 #include "internal.h"
 #include "jpegtables.h"
 #include "mjpeg.h"
-#include "mjpegdec.h"
 
 #define EPIC_PIX_STACK_SIZE 1024
 #define EPIC_PIX_STACK_MAX  (EPIC_PIX_STACK_SIZE - 1)
@@ -160,24 +158,45 @@
     int        cursor_hot_x, cursor_hot_y;
 } G2MContext;
 
+static av_cold int build_vlc(VLC *vlc, const uint8_t *bits_table,
+                             const uint8_t *val_table, int nb_codes,
+                             int is_ac)
+{
+    uint8_t  huff_size[256] = { 0 };
+    uint16_t huff_code[256];
+    uint16_t huff_sym[256];
+    int i;
+
+    ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
+
+    for (i = 0; i < 256; i++)
+        huff_sym[i] = i + 16 * is_ac;
+
+    if (is_ac)
+        huff_sym[0] = 16 * 256;
+
+    return ff_init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1,
+                              huff_code, 2, 2, huff_sym, 2, 2, 0);
+}
+
 static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)
 {
     int ret;
 
-    ret = ff_mjpeg_build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,
-                             avpriv_mjpeg_val_dc, 0, avctx);
+    ret = build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,
+                    avpriv_mjpeg_val_dc, 12, 0);
     if (ret)
         return ret;
-    ret = ff_mjpeg_build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,
-                             avpriv_mjpeg_val_dc, 0, avctx);
+    ret = build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,
+                    avpriv_mjpeg_val_dc, 12, 0);
     if (ret)
         return ret;
-    ret = ff_mjpeg_build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,
-                             avpriv_mjpeg_val_ac_luminance, 1, avctx);
+    ret = build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,
+                    avpriv_mjpeg_val_ac_luminance, 251, 1);
     if (ret)
         return ret;
-    ret = ff_mjpeg_build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,
-                             avpriv_mjpeg_val_ac_chrominance, 1, avctx);
+    ret = build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,
+                    avpriv_mjpeg_val_ac_chrominance, 251, 1);
     if (ret)
         return ret;
 
diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c
index 9e2ebf6..9357f17 100644
--- a/libavcodec/g722enc.c
+++ b/libavcodec/g722enc.c
@@ -64,6 +64,19 @@
     c->band[1].scale_factor = 2;
     c->prev_samples_pos = 22;
 
+    if (avctx->trellis) {
+        int frontier = 1 << avctx->trellis;
+        int max_paths = frontier * FREEZE_INTERVAL;
+        int i;
+        for (i = 0; i < 2; i++) {
+            c->paths[i] = av_mallocz_array(max_paths, sizeof(**c->paths));
+            c->node_buf[i] = av_mallocz_array(frontier, 2 * sizeof(**c->node_buf));
+            c->nodep_buf[i] = av_mallocz_array(frontier, 2 * sizeof(**c->nodep_buf));
+            if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i])
+                return AVERROR(ENOMEM);
+        }
+    }
+
     if (avctx->frame_size) {
         /* validate frame size */
         if (avctx->frame_size & 1 || avctx->frame_size > MAX_FRAME_SIZE) {
@@ -97,18 +110,6 @@
                    avctx->trellis);
             avctx->trellis = new_trellis;
         }
-        if (avctx->trellis) {
-            int frontier = 1 << avctx->trellis;
-            int max_paths = frontier * FREEZE_INTERVAL;
-
-            for (int i = 0; i < 2; i++) {
-                c->paths[i]     = av_calloc(max_paths, sizeof(**c->paths));
-                c->node_buf[i]  = av_calloc(frontier, 2 * sizeof(**c->node_buf));
-                c->nodep_buf[i] = av_calloc(frontier, 2 * sizeof(**c->nodep_buf));
-                if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i])
-                    return AVERROR(ENOMEM);
-            }
-        }
     }
 
     ff_g722dsp_init(&c->dsp);
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index 0c47458..1deff49 100644
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -29,1077 +29,6 @@
 #include "celp_math.h"
 #include "g723_1.h"
 
-const int16_t ff_g723_1_cos_tab[COS_TBL_SIZE + 1] = {
-    16384,  16383,  16379,  16373,  16364,  16353,  16340,  16324,
-    16305,  16284,  16261,  16235,  16207,  16176,  16143,  16107,
-    16069,  16029,  15986,  15941,  15893,  15843,  15791,  15736,
-    15679,  15619,  15557,  15493,  15426,  15357,  15286,  15213,
-    15137,  15059,  14978,  14896,  14811,  14724,  14635,  14543,
-    14449,  14354,  14256,  14155,  14053,  13949,  13842,  13733,
-    13623,  13510,  13395,  13279,  13160,  13039,  12916,  12792,
-    12665,  12537,  12406,  12274,  12140,  12004,  11866,  11727,
-    11585,  11442,  11297,  11151,  11003,  10853,  10702,  10549,
-    10394,  10238,  10080,   9921,   9760,   9598,   9434,   9269,
-     9102,   8935,   8765,   8595,   8423,   8250,   8076,   7900,
-     7723,   7545,   7366,   7186,   7005,   6823,   6639,   6455,
-     6270,   6084,   5897,   5708,   5520,   5330,   5139,   4948,
-     4756,   4563,   4370,   4176,   3981,   3786,   3590,   3393,
-     3196,   2999,   2801,   2603,   2404,   2205,   2006,   1806,
-     1606,   1406,   1205,   1005,    804,    603,    402,    201,
-        0,   -201,   -402,   -603,   -804,  -1005,  -1205,  -1406,
-    -1606,  -1806,  -2006,  -2205,  -2404,  -2603,  -2801,  -2999,
-    -3196,  -3393,  -3590,  -3786,  -3981,  -4176,  -4370,  -4563,
-    -4756,  -4948,  -5139,  -5330,  -5520,  -5708,  -5897,  -6084,
-    -6270,  -6455,  -6639,  -6823,  -7005,  -7186,  -7366,  -7545,
-    -7723,  -7900,  -8076,  -8250,  -8423,  -8595,  -8765,  -8935,
-    -9102,  -9269,  -9434,  -9598,  -9760,  -9921, -10080, -10238,
-   -10394, -10549, -10702, -10853, -11003, -11151, -11297, -11442,
-   -11585, -11727, -11866, -12004, -12140, -12274, -12406, -12537,
-   -12665, -12792, -12916, -13039, -13160, -13279, -13395, -13510,
-   -13623, -13733, -13842, -13949, -14053, -14155, -14256, -14354,
-   -14449, -14543, -14635, -14724, -14811, -14896, -14978, -15059,
-   -15137, -15213, -15286, -15357, -15426, -15493, -15557, -15619,
-   -15679, -15736, -15791, -15843, -15893, -15941, -15986, -16029,
-   -16069, -16107, -16143, -16176, -16207, -16235, -16261, -16284,
-   -16305, -16324, -16340, -16353, -16364, -16373, -16379, -16383,
-   -16384, -16383, -16379, -16373, -16364, -16353, -16340, -16324,
-   -16305, -16284, -16261, -16235, -16207, -16176, -16143, -16107,
-   -16069, -16029, -15986, -15941, -15893, -15843, -15791, -15736,
-   -15679, -15619, -15557, -15493, -15426, -15357, -15286, -15213,
-   -15137, -15059, -14978, -14896, -14811, -14724, -14635, -14543,
-   -14449, -14354, -14256, -14155, -14053, -13949, -13842, -13733,
-   -13623, -13510, -13395, -13279, -13160, -13039, -12916, -12792,
-   -12665, -12537, -12406, -12274, -12140, -12004, -11866, -11727,
-   -11585, -11442, -11297, -11151, -11003, -10853, -10702, -10549,
-   -10394, -10238, -10080,  -9921,  -9760,  -9598,  -9434,  -9269,
-    -9102,  -8935,  -8765,  -8595,  -8423,  -8250,  -8076,  -7900,
-    -7723,  -7545,  -7366,  -7186,  -7005,  -6823,  -6639,  -6455,
-    -6270,  -6084,  -5897,  -5708,  -5520,  -5330,  -5139,  -4948,
-    -4756,  -4563,  -4370,  -4176,  -3981,  -3786,  -3590,  -3393,
-    -3196,  -2999,  -2801,  -2603,  -2404,  -2205,  -2006,  -1806,
-    -1606,  -1406,  -1205,  -1005,   -804,   -603,   -402,   -201,
-        0,    201,    402,    603,    804,   1005,   1205,   1406,
-     1606,   1806,   2006,   2205,   2404,   2603,   2801,   2999,
-     3196,   3393,   3590,   3786,   3981,   4176,   4370,   4563,
-     4756,   4948,   5139,   5330,   5520,   5708,   5897,   6084,
-     6270,   6455,   6639,   6823,   7005,   7186,   7366,   7545,
-     7723,   7900,   8076,   8250,   8423,   8595,   8765,   8935,
-     9102,   9269,   9434,   9598,   9760,   9921,  10080,  10238,
-    10394,  10549,  10702,  10853,  11003,  11151,  11297,  11442,
-    11585,  11727,  11866,  12004,  12140,  12274,  12406,  12537,
-    12665,  12792,  12916,  13039,  13160,  13279,  13395,  13510,
-    13623,  13733,  13842,  13949,  14053,  14155,  14256,  14354,
-    14449,  14543,  14635,  14724,  14811,  14896,  14978,  15059,
-    15137,  15213,  15286,  15357,  15426,  15493,  15557,  15619,
-    15679,  15736,  15791,  15843,  15893,  15941,  15986,  16029,
-    16069,  16107,  16143,  16176,  16207,  16235,  16261,  16284,
-    16305,  16324,  16340,  16353,  16364,  16373,  16379,  16383,
-    16384
-};
-
-const int16_t ff_g723_1_lsp_band0[LSP_CB_SIZE][3] = {
-    {    0,      0,      0}, { -270,  -1372,  -1032}, { -541,  -1650,  -1382},
-    { -723,  -2011,  -2213}, { -941,  -1122,  -1942}, { -780,  -1145,  -2454},
-    { -884,  -1309,  -1373}, {-1051,  -1523,  -1766}, {-1083,  -1622,  -2300},
-    { -777,  -1377,  -2147}, { -935,  -1467,  -2763}, { -802,  -1327,  -3471},
-    { -935,  -1959,  -3999}, { -240,    -89,    222}, { -661,   -257,   -160},
-    { -994,   -466,   -419}, { -188,   -164,   -278}, { -342,   -512,   -415},
-    { -607,   -511,   -797}, {   16,     19,   -716}, {  374,    425,   -972},
-    { -346,    245,   -282}, { -265,    506,   -754}, { -620,   -147,   1955},
-    { -742,   -860,   2597}, { -150,   -352,   2704}, {  305,    880,   1954},
-    {  123,    731,   2766}, { -348,    765,   3327}, {  618,    221,   3258},
-    { -178,    -47,   4219}, {  393,   1304,   3842}, {  698,   1702,   4801},
-    {   63,   -584,   1229}, { -215,   -732,   1704}, {  172,   -335,   1909},
-    {   -2,    216,   1797}, {  353,    127,   2205}, {-1208,    188,     11},
-    { -513,    -75,   -683}, { -973,    222,   -646}, { -616,   -843,   -388},
-    { -950,  -1113,   -359}, {-1431,   -623,   -705}, {-1398,  -1063,   -178},
-    {  -45,   -461,     35}, {   -9,   -657,   -216}, {  127,  -1078,     95},
-    { -950,  -1156,    584}, {-1480,  -1494,    449}, { -120,   -705,    516},
-    { -368,   -961,    727}, { -378,   -526,    973}, { -793,   -614,    676},
-    { -801,   -755,   1287}, {-1476,   -340,   1636}, { -505,  -1254,   1543},
-    {-1243,  -1622,   1532}, { -776,  -1477,   -655}, {-1151,  -1296,   -823},
-    {-1153,  -1672,  -1124}, {-1291,  -2003,  -1702}, { -622,  -1283,     57},
-    { -471,  -1611,    509}, {-1060,  -1570,   -139}, { -873,  -2156,   -536},
-    {-1716,  -2021,   -364}, {-2150,  -3218,  -1291}, {-1248,  -1945,  -2904},
-    {-1215,  -2633,  -2855}, {  167,   -244,     84}, {  349,   -412,   -217},
-    {  -40,   -352,    632}, {  227,   -529,    405}, {   68,   -383,   -443},
-    {  167,   -558,   -706}, { -275,   -854,    -14}, { -351,  -1089,   -449},
-    {  341,    -72,   -289}, {  603,   -106,   -474}, {  322,   -219,   -649},
-    {  179,   -317,   -998}, {  450,   -291,   -996}, {  555,    195,   -525},
-    {  784,    272,   -831}, { -148,   -384,   -849}, {   82,   -536,  -1357},
-    {  238,   -172,  -1354}, {  422,   -268,  -1841}, {  297,   -737,  -2079},
-    { -111,   -801,   -598}, {    1,   -668,   -984}, { -131,   -818,  -1299},
-    { -329,   -521,  -1310}, { -151,   -778,  -1834}, {  -93,   -352,  -1746},
-    { -568,   -640,  -1821}, { -509,   -941,  -2183}, {  464,   -815,  -1250},
-    {   79,  -1133,  -1597}, { -184,  -1353,  -2123}, { -196,   -410,  -2427},
-    { -192,   -833,  -2810}, { -259,  -1382,  -3045}, { -217,      4,  -1166},
-    { -800,   -325,  -1219}, { -363,   -830,   -898}, { -661,  -1134,   -960},
-    { -386,   -980,  -1501}, { -627,  -1159,  -1722}, { -903,   -829,   -855},
-    { -685,   -829,  -1313}, {-1065,   -959,  -1405}, {  441,     25,   -847},
-    {  655,    -27,  -1181}, { 1159,   -110,   -705}, {  856,    253,  -1671},
-    {  415,    404,     -1}, {  322,    903,   -398}, {  670,    499,   -292},
-    {  803,    591,   -610}, { 1144,    591,   -814}, {  717,    183,    393},
-    {  857,    381,    106}, {  609,     62,    -27}, {  792,    198,   -325},
-    {  735,    805,     88}, { 1142,    812,     78}, { 1028,    366,   -292},
-    { 1309,    743,   -237}, { 1615,    589,    -79}, { 1010,    639,   -243},
-    {  999,    964,   -311}, { 1500,   1137,   -615}, {  988,    357,    646},
-    { 1227,    667,    683}, { 1164,   1565,    894}, { 1392,   2015,    477},
-    { 1138,    533,    250}, { 1437,    896,    391}, { 1765,   1118,     99},
-    { 1112,   1090,    802}, { 1596,    846,   1134}, {  937,   1161,    279},
-    { 1719,   1254,    683}, { 1338,   1086,     35}, { 1419,   1324,    428},
-    { 1428,   1524,     40}, { 2108,   1594,     89}, { 1015,    544,   1222},
-    { 1121,    925,   1263}, { 1030,   1318,   1485}, { 1295,    789,   1817},
-    { 1323,   1272,   1909}, { 1724,   1237,   1803}, { 1797,   1689,    858},
-    { 2149,   1367,   1301}, { 2302,   1867,    761}, { 2863,   2351,   1053},
-    {   52,    163,    -76}, {  230,    309,   -492}, {  -71,    619,     39},
-    { -218,    856,    499}, { -654,    736,   -207}, { -535,   1259,    155},
-    { -480,   1476,    643}, {  262,   1081,    102}, {  309,   1592,   -182},
-    {  627,   1629,    534}, {  337,    643,    456}, {  758,    670,    713},
-    {  202,   1126,    658}, {  612,   1131,    666}, {  686,   1223,   1136},
-    { -131,    377,    525}, {   42,    708,    907}, {   87,   1488,   1035},
-    {  432,   2117,    904}, {  137,    981,   1332}, { -447,   1014,   1136},
-    { -839,   1793,   1246}, { -559,    297,    198}, { -850,    685,    446},
-    {-1273,    632,    826}, { -401,   -544,    173}, { -753,   -793,    144},
-    { -436,     -9,    772}, { -115,   -243,   1310}, { -670,   -269,    374},
-    {-1027,    -13,    639}, { -887,    -81,   1137}, {-1277,   -455,    158},
-    {-1411,   -720,    736}, {  172,     88,    403}, {  386,    255,    756},
-    { -500,    522,    910}, { -958,    659,   1388}, { -395,    301,   1344},
-    { -356,    768,   1813}, { -613,    841,   2419}, {  445,   -122,    252},
-    {  629,    -87,    723}, {  283,   -253,    870}, {  456,   -116,   1381},
-    {  757,    180,   1059}, {  532,    408,   1509}, {  947,    288,   1806},
-    { 1325,    994,   2524}, {  892,   1219,   3023}, { 1397,   1596,   3406},
-    { 1143,   1552,   2546}, { 1850,   1433,   2710}, {  -10,    134,   1002},
-    {  154,    499,   1323}, {  508,    792,   1117}, {  509,   1340,   1616},
-    {  762,    862,   1608}, {  787,    740,   2320}, {  794,   1727,   1283},
-    {  465,   2108,   1660}, { -120,   1451,   1613}, { -386,   2016,   2169},
-    {  891,   1225,   2050}, {  456,   1480,   2185}, { 1493,   1283,   1209},
-    { 1397,   1636,   1518}, { 1776,   1738,   1552}, { 1572,   1698,   2141},
-    { 1389,   2126,   1271}, { 1959,   2413,   1119}, { 1365,   2892,   1505},
-    { 2206,   1971,   1623}, { 2076,   1950,   2280}, { 1717,   2291,   1867},
-    { 2366,   2515,   1953}, { 2865,   2838,   2522}, { 2535,   3465,   2011},
-    { 3381,   4127,   2638}, {  836,   2667,   2289}, { 1761,   2773,   2337},
-    { 1415,   3325,   2911}, { 2354,   3138,   3126}, { 2659,   4192,   4010},
-    { 1048,   1786,   1818}, { 1242,   2111,   2240}, { 1512,   2079,   2780},
-    { 1573,   2491,   3138}, { 2230,   2377,   2782}, {  416,   1773,   2704},
-    {  725,   2336,   3297}, { 1252,   2373,   3978}, { 2094,   2268,   3568},
-    { 2011,   2712,   4528}, { 1341,   3507,   3876}, { 1216,   3919,   4922},
-    { 1693,   4793,   6012}
-};
-
-const int16_t ff_g723_1_lsp_band1[LSP_CB_SIZE][3] = {
-    {    0,      0,      0}, {-2114,  -1302,     76}, {-2652,  -1278,  -1368},
-    {-2847,   -828,   -349}, {-3812,  -2190,   -349}, {-3946,   -364,   -449},
-    {-2725,  -4492,  -3607}, {-3495,  -4764,  -1744}, {  -51,   -756,     84},
-    { -153,  -1191,    504}, {  108,  -1418,   1167}, { -835,   -896,    390},
-    { -569,  -1702,     87}, {-1151,  -1818,    933}, {-1826,  -2547,    411},
-    {-1842,  -1818,   1451}, {-2438,  -1611,    781}, {-2747,  -2477,   1311},
-    { -940,   1252,    477}, {-1629,   1688,    602}, {-1202,    617,    280},
-    {-1737,    393,    580}, {-1528,   1077,   1199}, {-2165,   -161,   1408},
-    {-2504,  -1087,   2371}, {-3458,   -175,   1395}, {-1397,    -98,   -843},
-    {-2252,   -177,  -1149}, {-1489,   -726,  -1283}, {-1558,   -265,  -1744},
-    {-1867,   -821,  -1897}, {-2062,  -1516,  -2340}, {-2595,  -1142,  -2861},
-    {  170,     46,   -819}, { -193,   -204,  -1151}, {  326,   -196,  -1532},
-    {  780,    329,   -816}, {  201,    369,  -1243}, {  650,   -209,  -1060},
-    { 1144,    -15,  -1216}, { 1203,   -259,  -1867}, { -890,   -564,  -1430},
-    { -638,   -852,  -1921}, {  177,   -739,  -1358}, { -261,   -526,  -1666},
-    {  206,   -407,  -2255}, {  338,   -526,   -822}, {  421,  -1095,  -1009},
-    {  765,   -607,  -1408}, {  825,  -1295,  -2004}, {  357,   -905,  -1815},
-    {  -58,  -1248,  -1588}, { -596,  -1436,  -2046}, {  -73,  -1159,  -2116},
-    { -115,  -1382,  -2581}, { -160,  -1723,  -1952}, {   -6,  -2196,  -2954},
-    { -649,  -1705,  -2603}, { -617,  -1453,  -3282}, { -949,  -2019,  -3102},
-    { -812,   1544,   1937}, {-1854,    574,   2000}, {-1463,   1140,   2649},
-    {-2683,   1748,   1452}, {-2486,   2241,   2523}, {  783,   1910,   1435},
-    {  581,   2682,   1376}, {  236,   2197,   1885}, { -453,   2943,   2057},
-    { -682,   2178,   2565}, {-1342,   3201,   3328}, { -288,   -184,    262},
-    {  121,   -149,   -183}, {  758,   -412,    206}, { 1038,   -204,    853},
-    { 1577,   -457,    700}, {  937,   -640,   -567}, { 1508,   -528,  -1024},
-    { -225,   -527,   -427}, { -564,  -1095,   -332}, { -742,   -353,   -186},
-    {-1288,   -459,     84}, {-1853,   -484,   -274}, {-1554,   -731,    825},
-    {-2425,   -234,    382}, {-1722,    293,   -271}, {-2515,    425,   -564},
-    {-2599,    818,    464}, { -358,    118,   -375}, { -613,    198,   -874},
-    { -690,    683,   -324}, {-1352,   1155,   -168}, {-1093,    129,   -324},
-    {-1184,    611,   -858}, {  433,    386,   -372}, { -120,    486,   -634},
-    {  234,    851,   -631}, {  602,    128,     46}, { 1099,    410,    159},
-    {  715,   -145,   -424}, { 1198,    -85,   -593}, { 1390,    367,   -358},
-    { 1683,    362,   -964}, { 1711,    622,     45}, { 2033,    833,   -383},
-    { 2890,    549,   -506}, {    7,    401,     52}, {   72,    811,    415},
-    {  566,    668,     41}, {  467,   1218,    130}, {   68,    957,   -187},
-    {  -25,   1649,   -103}, { -661,    260,    214}, { -925,    -94,    612},
-    { -321,   -422,    965}, { -788,   -672,   1783}, {  400,   -673,    779},
-    {  741,   -595,   1635}, { -161,    307,    657}, { -382,    836,    871},
-    { -814,    400,   1223}, {  364,    606,   1247}, {   57,     75,   1571},
-    {  151,    471,   2287}, {  -81,   1021,   1502}, {  227,   1470,   1097},
-    {  658,   1275,   1653}, {  664,   1478,   2377}, {  263,   -127,    444},
-    {  264,     89,    969}, {  794,    171,    576}, {  821,    186,   1226},
-    {  404,    462,    517}, {  339,    918,    794}, { 1280,   1423,    196},
-    { 1453,   2019,    365}, { 1615,   1481,    672}, { 2394,   1708,    508},
-    {  806,   1238,    573}, {  713,   1158,   1078}, { 1285,   1436,   1232},
-    { 1790,   1188,   1141}, {  765,    643,    864}, { 1032,    797,   1279},
-    {  900,    563,   1827}, { 1514,    673,   2312}, { 1544,   1129,   3240},
-    { 1469,   1050,   1594}, { 1945,   1318,   1988}, { 2397,   2026,   2060},
-    { 3538,   2057,   2620}, { 1249,   -118,     74}, { 1727,    194,    421},
-    { 2078,    -50,   -463}, {  970,    688,   -432}, { 1149,    952,   -110},
-    { 1254,   1275,   -651}, { 1386,    929,    401}, { 1960,   1167,    232},
-    {  407,   -752,   -243}, {  859,  -1118,    172}, { -227,   -860,   -992},
-    { -796,  -1175,  -1380}, {    8,  -1282,   -388}, {  353,  -1781,  -1037},
-    { -732,   -397,   -807}, { -853,    -28,  -1342}, {-1229,  -1207,  -1959},
-    {-1015,  -1125,  -2543}, {-1452,  -1791,  -2725}, {-1891,  -2416,  -3269},
-    { -918,  -1629,   -783}, { -580,  -2155,   -698}, {-1097,  -2364,    -96},
-    {-1387,  -1513,      7}, {-1588,  -2076,   -664}, {-1473,  -2740,   -784},
-    {-2378,  -3149,    -56}, {-2856,  -2092,   -169}, {-3391,  -3708,    316},
-    {-1176,   -890,   -614}, {-1944,  -1061,   -800}, { -299,  -1517,  -1000},
-    { -640,  -1850,  -1526}, {-1454,  -1536,  -1233}, {-1890,  -1955,  -1756},
-    {-1086,  -1921,  -2122}, { -750,  -2325,  -2260}, {-1325,  -2413,  -2673},
-    {-1114,  -2542,  -3459}, {-1341,  -2901,  -3963}, {-1160,  -2226,  -1393},
-    {-1001,  -2772,  -1573}, {-1594,  -2641,  -1978}, {-1534,  -3046,  -2624},
-    {-2224,  -2196,   -675}, {-2807,  -3054,  -1102}, {-2008,  -2840,  -1186},
-    {-1980,  -3332,  -1695}, {-1715,  -3562,   -505}, {-2527,  -4000,  -1887},
-    {-2333,  -2734,  -2296}, {-3440,  -2401,  -3211}, {-2008,  -3528,  -3337},
-    {-2247,  -3291,  -4510}, { -475,    949,    155}, { -149,   1365,    545},
-    { -757,   1644,   1083}, { -217,   2053,   1353}, {-1433,   2301,   1462},
-    {  495,   1661,    529}, {   10,   2037,    740}, { 2082,   1898,    978},
-    { 2831,   2294,    911}, {  842,    793,    420}, { 1223,   1023,    863},
-    { 1237,    451,    780}, { 1744,    708,    822}, { 1533,    284,   1384},
-    { 2135,    609,   1538}, { 2305,    626,    540}, { 2368,   1187,    955},
-    { 2586,   1255,     -7}, { 3116,   1131,    726}, { 3431,   1730,    428},
-    { 2734,   1648,   1307}, { 2988,   1231,   2010}, { 3523,   2024,   1488},
-    { 1034,   1657,    871}, { 1206,   2163,   1036}, { 1807,   2372,   1233},
-    { 1808,   1769,   1493}, { 1573,   2332,   1779}, { 1216,   1609,   1866},
-    { 1480,   1898,   2513}, {  465,   2708,   2776}, {  771,   3638,   3338},
-    { 1869,   2599,   2623}, { 2825,   2745,   2468}, { 2638,   2439,   1585},
-    { 2094,   2970,   1308}, { 2022,   3057,   1999}, { 3428,   2912,   1816},
-    { 4536,   2974,   2129}, { 1046,   2563,   2086}, { 1363,   3562,   2318},
-    { 2511,   1891,   2984}, { 1866,   2306,   3986}, { 3272,   2924,   3682},
-    { 3146,   3564,   2272}, { 3592,   3968,   2822}, { 2431,   3369,   3069},
-    { 1931,   4709,   3090}, { 2629,   4220,   3986}, { 4639,   4056,   3664},
-    { 4035,   5334,   4912}
-};
-
-const int16_t ff_g723_1_lsp_band2[LSP_CB_SIZE][4] = {
-    {    0,      0,      0,      0}, {  601,    512,   -542,    334},
-    {  428,   1087,   -484,   -132}, {  652,    622,   -391,   -572},
-    {  378,    799,    141,   -860}, { 1040,    409,    112,   -554},
-    { 1123,    670,    -75,   -847}, { 1421,    494,   -315,  -1095},
-    {  787,   1001,    114,   -460}, {  988,   1672,    216,   -681},
-    { 1007,   1241,   -132,  -1247}, { 1073,    399,    186,     -5},
-    { 1262,    193,   -694,   -129}, {  325,    196,     51,   -641},
-    {  861,    -59,    350,   -458}, { 1261,    567,    586,   -346},
-    { 1532,    885,    210,   -517}, { 2027,    937,    113,   -792},
-    { 1383,   1064,    334,     38}, { 1964,   1468,    459,    133},
-    { 2062,   1186,    -98,   -121}, { 2577,   1445,    506,   -373},
-    { 2310,   1682,     -2,   -960}, { 2876,   1939,    765,    138},
-    { 3581,   2360,    649,   -414}, {  219,    176,   -398,   -309},
-    {  434,    -78,   -435,   -880}, { -344,    301,    265,   -552},
-    { -915,    470,    657,   -380}, {  419,   -432,   -163,   -453},
-    {  351,   -953,      8,   -562}, {  789,    -43,     20,   -958},
-    {  302,   -594,   -352,  -1159}, { 1040,    108,   -668,   -924},
-    { 1333,    210,  -1217,  -1663}, {  483,    589,   -350,  -1140},
-    { 1003,    824,   -802,  -1184}, {  745,     58,   -589,  -1443},
-    {  346,    247,   -915,  -1683}, {  270,    796,   -720,  -2043},
-    { 1208,    722,   -222,   -193}, { 1486,   1180,   -412,   -672},
-    { 1722,    179,    -69,   -521}, { 2047,    860,   -666,  -1410},
-    { -146,    222,   -281,   -805}, { -189,     90,   -114,  -1307},
-    { -152,   1086,   -241,   -764}, { -439,    733,   -601,  -1302},
-    { -833,   -167,   -351,   -601}, { -856,   -422,   -411,  -1059},
-    { -747,   -355,   -582,  -1644}, { -837,    210,   -916,  -1144},
-    {-1800,     32,   -878,  -1687}, {  -48,    -23,  -1146,     52},
-    { -350,   -409,  -1656,   -364}, {  265,   -728,   -858,   -577},
-    {  458,   -247,  -1141,   -997}, {  691,   -407,  -1988,  -1161},
-    {  -66,   -104,   -705,  -1249}, { -431,    -93,  -1191,  -1844},
-    {  203,   -732,  -1000,  -1693}, {   10,   -832,  -1846,  -1819},
-    {  493,   -128,  -1436,  -1768}, {  488,   -311,  -1730,  -2540},
-    { -653,   -532,  -1150,  -1172}, {-1086,   -289,  -1706,  -1533},
-    { -699,  -1205,  -1216,  -1766}, {-1032,  -1481,  -2074,  -1523},
-    { -721,  -1220,  -2277,  -2600}, {   12,   -539,  -1484,  -1131},
-    {  -40,   -911,  -2106,   -441}, { -471,   -484,  -2267,  -1549},
-    { -141,   -988,  -3006,  -1721}, {-1545,  -2102,   -583,    342},
-    {-1383,  -2772,   -386,    -13}, {-2118,  -2589,  -1205,     72},
-    {-2147,  -3231,   -965,    390}, {-2949,  -3300,   -621,    637},
-    {-3907,  -4138,   -865,    803}, {-1287,   -845,   -375,   -548},
-    {-1416,  -1169,   -487,  -1277}, {-1400,  -1690,  -1027,   -418},
-    {-2018,  -1909,  -1188,  -1260}, {-1418,  -2222,  -2029,   -128},
-    {-2067,  -2998,  -2693,   -310}, { -950,  -1028,  -1538,    185},
-    {-1616,   -915,  -2205,   -549}, {   19,   -821,  -1145,    352},
-    {  184,  -1175,  -1356,   -627}, { -547,  -1088,  -1661,   -911},
-    { -216,  -1502,  -2197,   -948}, { -795,  -1306,  -2374,   -451},
-    { -924,  -1889,  -2796,   -680}, { -600,  -1614,  -3609,   -885},
-    {-2392,  -2528,    319,    303}, {-2908,  -2095,   -310,    573},
-    {-3460,  -2141,     49,   -113}, {-2231,   -448,    675,   -146},
-    {-2805,   -532,   1231,    479}, {-2684,   -486,   -200,    611},
-    {-3525,   -971,   -198,    704}, {-3707,    173,    349,    254},
-    {-4734,  -1447,    -34,    880}, {  777,   -512,    114,    -10},
-    { 1250,    -66,    442,     -5}, {  604,    613,    452,   -352},
-    { 1224,    777,    675,  -1014}, {-1372,    -79,  -1208,   -238},
-    {-2389,    -17,  -1157,   -818}, {-1504,   -673,  -1133,  -1060},
-    {-1984,   -799,  -2005,  -1973}, {-2037,   -798,  -1068,   -105},
-    {-3190,   -899,  -1817,   -194}, { -156,   -886,    394,   -318},
-    { -258,  -1283,    551,    202}, { -536,  -1729,    910,    331},
-    { -847,  -1109,    795,   -163}, {-1171,  -1128,    715,    519},
-    {-1080,  -1319,   1685,    668}, {-1000,  -1921,     96,    211},
-    {-1487,  -2148,    831,    174}, {-1139,   -374,    414,     -4},
-    {-1517,  -1383,    396,   -352}, {-1012,    439,    -59,   -967},
-    {-1812,    706,   -440,  -1030}, {-1971,   -329,    -34,   -827},
-    {-2472,  -1588,   -151,   -606}, {-2161,    374,   -281,     76},
-    {-3012,    231,    -15,   -690}, { 1104,    566,    721,    209},
-    { 1685,    564,    383,     98}, { 1898,    750,    792,    -97},
-    {  556,    -64,    561,    -93}, {  876,    162,    913,    -22},
-    {  961,    675,   1296,    140}, {  756,   -396,    851,    544},
-    {  360,   -303,   1341,    396}, {  878,    -22,   1464,    863},
-    { -309,   -273,    642,   -129}, { -686,    -82,    842,    454},
-    {   -5,    -47,   1069,    998}, {  -94,    967,   1277,    298},
-    { -489,    385,   1473,    746}, { -369,   -717,   1333,    242},
-    {  281,   -993,   1726,    924}, {  464,    601,   1575,   1376},
-    { -250,    206,   2339,   1175}, { -438,    377,   -597,   -285},
-    {-1020,    787,   -790,   -287}, { -458,   -410,    215,    295},
-    { -589,   -860,   -121,    797}, {-1175,    122,   -437,    466},
-    {-1480,   -121,    367,    924}, {  234,    323,    770,   -555},
-    {  145,     30,    996,     26}, {   66,    849,     93,   -145},
-    { -117,   1261,    474,   -399}, {-1495,   1051,    218,   -506},
-    {-1390,    694,    994,     88}, {  616,      7,     78,    304},
-    { 1060,     52,    -62,    835}, {  833,    454,    649,   1359},
-    { -770,    464,     47,     93}, { -574,   1199,    -39,    379},
-    {  114,    -98,    488,    485}, {  727,    244,    606,    696},
-    {  -76,    455,    671,    546}, { -565,    -13,    145,    819},
-    { -376,    569,    448,   1128}, {  218,    122,    265,   1167},
-    {  230,    738,    932,   1003}, {  138,    477,     36,    450},
-    {  404,    787,    -73,   1000}, {  497,   1259,    387,   1231},
-    {   17,    207,    195,    -79}, {  562,    358,     53,   -158},
-    {  493,    387,    478,    189}, {  678,    831,    640,    558},
-    { -197,    523,    613,     57}, {  429,    894,    769,    111},
-    {   67,   1174,    568,    511}, { 1242,    824,    251,    840},
-    { 1419,   1074,    864,    481}, {  924,   1474,    669,    724},
-    { 1539,   1879,    654,   1590}, {  445,    337,   1111,    541},
-    {  472,   1421,   1264,   1094}, {  794,    735,   1103,    668},
-    { 1055,    863,   1192,   1020}, {  778,   1105,    806,   1798},
-    { 1052,   1527,   1587,   2151}, {  881,   1552,   1265,    391},
-    {  726,    872,   1812,    601}, { 1469,    280,   1008,    616},
-    { 1403,    577,   1803,   1244}, { 1650,   1314,   1148,   1072},
-    { 1297,   1669,   1911,   1026}, { 2093,   1044,   2115,   1189},
-    { 1644,   1961,   2587,   1512}, {   25,   -315,     -9,   -106},
-    {  290,   -339,    428,   -444}, {  -68,   -783,    735,    772},
-    {  245,   -555,    468,     47}, {  334,   -895,    814,    146},
-    {  235,    368,   -964,   -959}, { -203,    315,  -1566,  -1217},
-    {  801,     17,   -276,   -354}, {  894,   -495,   -789,   -635},
-    {  716,    291,  -1189,   -357}, {  560,   -260,   -733,     -2},
-    {  679,   -508,  -1429,    211}, {  -51,    -62,   -428,    557},
-    {  322,   -638,   -211,    614}, { -878,  -1057,    -84,    -71},
-    { -388,  -1415,   -167,   -318}, { -754,  -1574,    214,   -539},
-    {-1419,  -2004,    -92,   -787}, {  -47,   -856,   -347,   -255},
-    {   23,  -1211,   -173,    320}, { -658,   -487,   -893,    353},
-    { -783,  -1587,   -584,    507}, {-1420,   -859,   -378,    441},
-    {-2095,  -1491,   -137,    439}, { -321,  -1450,  -1288,    -12},
-    { -359,  -2113,   -553,     -8}, { -831,  -1918,  -1561,     32},
-    {-1014,  -2487,  -1359,   -939}, { -475,   -311,   -169,   -236},
-    { -907,   -426,    276,   -611}, {  -96,   -400,     50,   -710},
-    { -426,  -1022,    -10,   -985}, { -197,   -258,   -744,   -575},
-    { -611,   -930,   -771,   -394}, { -267,   -776,   -612,   -939},
-    { -256,  -1346,   -802,  -1122}, { -796,  -1570,   -825,   -754},
-    {  712,    876,    141,    227}, {  981,   1509,     85,    124},
-    { 1462,   1228,    979,    -39}, { 1734,    999,   1481,    440},
-    { 2293,   1116,    769,    440}, { 2504,   1480,   1241,    356},
-    { 2474,   1909,   1558,    810}, {  917,   1134,    607,   -134},
-    {  509,   1809,    781,   -123}, { 1712,   1506,    559,   -423},
-    { 2037,   2317,    726,   -155}, { 3031,   2676,   1203,    331},
-    { 3664,   3274,   1768,    531}, { 1610,   1839,    867,    183},
-    { 1774,   1972,   1538,     97}, { 1822,   2158,   1282,    659},
-    { 2222,   2758,   1818,    900}, { 3251,   2124,   1723,    996},
-    { 3633,   2336,   2408,   1453}, { 2923,   3517,   2567,   1318},
-};
-
-const int32_t ff_g723_1_combinatorial_table[PULSE_MAX][SUBFRAME_LEN/GRID_SIZE] = {
-    {118755, 98280, 80730,  65780, 53130,
-      42504, 33649, 26334,  20349, 15504,
-      11628,  8568,  6188,   4368,  3003,
-       2002,  1287,   792,    462,   252,
-        126,    56,    21,      6,     1,
-          0,     0,     0,      0,     0},
-
-    { 23751, 20475, 17550,  14950, 12650,
-      10626,  8855,  7315,   5985,  4845,
-       3876,  3060,  2380,   1820,  1365,
-       1001,   715,   495,    330,   210,
-        126,    70,    35,     15,     5,
-          1,     0,     0,      0,     0},
-
-    {  3654,  3276,  2925,   2600,  2300,
-       2024,  1771,  1540,   1330,  1140,
-        969,   816,   680,    560,   455,
-        364,   286,   220,    165,   120,
-         84,    56,    35,     20,    10,
-          4,     1,     0,      0,     0},
-
-    {   406,   378,   351,    325,   300,
-        276,   253,   231,    210,   190,
-        171,   153,   136,    120,   105,
-         91,    78,    66,     55,    45,
-         36,    28,    21,     15,    10,
-          6,     3,     1,      0,     0},
-
-    {    29,    28,    27,     26,    25,
-         24,    23,    22,     21,    20,
-         19,    18,    17,     16,    15,
-         14,    13,    12,     11,    10,
-          9,     8,     7,      6,     5,
-          4,     3,     2,      1,     0},
-
-    {     1,     1,     1,      1,     1,
-          1,     1,     1,      1,     1,
-          1,     1,     1,      1,     1,
-          1,     1,     1,      1,     1,
-          1,     1,     1,      1,     1,
-          1,     1,     1,      1,     1},
-};
-
-const int16_t ff_g723_1_fixed_cb_gain[GAIN_LEVELS] = {
-      1,    2,    3,    4,    6,    9,   13,   18,
-     26,   38,   55,   80,  115,  166,  240,  348,
-    502,  726, 1050, 1517, 2193, 3170, 4582, 6623,
-};
-
-const int16_t ff_g723_1_adaptive_cb_gain85[85 * 20] = {
-        0,      0,      0,      0,      0,      0,      0,      0,
-        0,      0,      0,      0,      0,      0,      0,      0,
-        0,      0,      0,      0,    800,   1496,    167,   -256,
-     -338,    -39,   -136,     -1,     -4,     -6,    -73,     -8,
-      -15,     12,     23,      2,     16,     30,      3,     -5,
-     -462,   -686,    493,   2575,    311,    -13,    -28,    -14,
-     -404,     -5,    -19,     13,     20,     72,    107,    -77,
-        8,     13,     -9,    -48,   1483,    144,    784,    928,
-     1243,   -134,     -1,    -37,    -52,    -94,    -13,    -71,
-       -6,    -84,     -8,    -44,   -112,    -10,    -59,    -70,
-      -77,    275,   3522,   1056,  -1254,      0,     -4,   -757,
-      -68,    -95,      1,     16,    -59,      4,    -17,   -227,
-       -5,     21,    269,     80,   -125,    -40,   -264,    381,
-     5027,      0,      0,     -4,     -8,  -1542,      0,     -2,
-        0,      2,      0,      6,     38,     12,     81,   -117,
-      138,    332,   2215,   2574,   1339,     -1,     -6,   -299,
-     -404,   -109,     -2,    -18,    -44,    -21,    -52,   -348,
-      -11,    -27,   -181,   -210,   3685,   2883,   -887,    866,
-    -1639,   -828,   -507,    -48,    -45,   -164,   -648,    199,
-      156,   -194,   -152,     46,    368,    288,    -88,     86,
-     1396,   2146,   2235,    345,    942,   -118,   -281,   -305,
-       -7,    -54,   -182,   -190,   -292,    -29,    -45,    -47,
-      -80,   -123,   -128,    -19,     13,   4475,   3549,   -804,
-     -655,      0,  -1222,   -768,    -39,    -26,     -3,     -2,
-     -969,      0,    219,    174,      0,    179,    141,    -32,
-     -724,    254,    242,   6049,   2462,    -32,     -3,     -3,
-    -2233,   -370,     11,     10,     -3,    267,    -94,    -89,
-      108,    -38,    -36,   -909,    626,  -1713,   6121,   4561,
-    -1061,    -23,   -179,  -2287,  -1270,    -68,     65,   -233,
-      640,   -174,    477,  -1704,     40,   -111,    396,    295,
-     -350,   1391,   7985,    511,   -405,     -7,   -118,  -3892,
-      -15,    -10,     29,    170,   -678,     10,    -43,   -249,
-       -8,     34,    197,     12,   3144,   -529,    608,   2530,
-     3878,   -603,    -17,    -22,   -390,   -918,    101,   -116,
-       19,   -485,     81,    -93,   -744,    125,   -144,   -599,
-     2589,   -689,   3045,   5603,   -404,   -409,    -29,   -566,
-    -1916,    -10,    108,   -481,    128,   -885,    235,  -1041,
-       63,    -17,     75,    138,   3107,    513,   1374,  -3594,
-    -4922,   -589,    -16,   -115,   -788,  -1478,    -97,   -260,
-      -43,    681,    112,    301,    933,    154,    413,  -1079,
-     2468,   6010,   1107,   -390,   1961,   -372,  -2204,    -74,
-       -9,   -234,   -905,   -166,   -406,     58,    143,     26,
-     -295,   -719,   -132,     46,   4773,   2766,   2368,   4862,
-    -4044,  -1390,   -467,   -342,  -1443,   -998,   -806,   -690,
-     -399,  -1416,   -821,   -702,   1178,    682,    584,   1200,
-     1665,  -1879,   1443,   1701,   8562,   -169,   -215,   -127,
-     -176,  -4475,    190,   -146,    165,   -172,    195,   -149,
-     -870,    982,   -754,   -889,   2716,   9011,  -1007,    755,
-    -1785,   -450,  -4956,    -61,    -34,   -194,  -1493,    167,
-      554,   -125,   -415,     46,    296,    982,   -109,     82,
-    -2727,   7548,   1285,    938,   3420,   -453,  -3478,   -100,
-      -53,   -714,   1256,    213,   -592,    156,   -432,    -73,
-      569,  -1576,   -268,   -196,   3677,    882,   4050,   1202,
-     2323,   -825,    -47,  -1001,    -88,   -329,   -198,   -909,
-     -218,   -269,    -64,   -297,   -521,   -125,   -574,   -170,
-     2046,   -753,    122,  10102,    603,   -255,    -34,      0,
-    -6229,    -22,     94,    -15,      5,  -1261,    464,    -75,
-      -75,     27,     -4,   -372,    449,  -1815,  10690,   3870,
-     -527,    -12,   -201,  -6976,   -914,    -16,     49,   -293,
-     1184,   -106,    428,  -2525,     14,    -58,    344,    124,
-     -941,   2352,   5049,   3650,   2637,    -54,   -337,  -1556,
-     -813,   -424,    135,    290,   -725,    209,   -524,  -1125,
-      151,   -378,   -812,   -587,  -1879,    796,   3117,   9569,
-     -404,   -215,    -38,   -593,  -5589,     -9,     91,    357,
-     -151,   1097,   -464,  -1821,    -46,     19,     76,    236,
-    -1715,   2043,  -2096,   9946,   4001,   -179,   -254,   -268,
-    -6038,   -977,    213,   -219,    261,   1041,  -1240,   1272,
-      418,   -498,    511,  -2429,  -5772,   -618,  -3921,    284,
-    -3155,  -2033,    -23,   -938,     -4,   -607,   -218,  -1381,
-     -148,    100,     10,     68,  -1111,   -119,   -755,     54,
-      382,   4748,   8003,  -2064,   2198,     -8,  -1376,  -3909,
-     -260,   -294,   -110,   -186,  -2319,     48,    598,   1008,
-      -51,   -637,  -1073,    277,   -867,   3015,  11926,  -1675,
-      947,    -45,   -555,  -8681,   -171,    -54,    159,    631,
-    -2195,    -88,    308,   1219,     50,   -174,   -690,     96,
-    -4933,   -432,   6757,   3771,   1352,  -1485,    -11,  -2786,
-     -867,   -111,   -130,   2034,    178,   1135,     99,  -1555,
-      407,     35,   -557,   -311,    152,   9726,   4231,  -1928,
-     1490,     -1,  -5774,  -1092,   -226,   -135,    -90,    -39,
-    -2511,     17,   1144,    498,    -13,   -884,   -384,    175,
-     2512,    193,   9033,   5361,  -3148,   -385,     -2,  -4980,
-    -1754,   -605,    -29,  -1385,   -106,   -822,    -63,  -2956,
-      482,     37,   1735,   1030,   8464,   2844,     12,    549,
-     2132,  -4373,   -493,      0,    -18,   -277,  -1469,     -6,
-       -2,   -284,    -95,      0,  -1101,   -370,     -1,    -71,
-     2141,  -2602,   7166,   9046,  -1350,   -279,   -413,  -3134,
-    -4994,   -111,    340,   -936,   1138,  -1182,   1436,  -3957,
-      176,   -214,    590,    745,   -244,    278,  13307,   1227,
-     -161,     -3,     -4, -10808,    -91,     -1,      4,    198,
-     -226,     18,    -20,   -997,     -2,      2,    131,     12,
-    -1947,   8217,   6269,    917,  -2559,   -231,  -4121,  -2399,
-      -51,   -399,    976,    745,  -3144,    108,   -460,   -350,
-     -304,   1283,    979,    143,  -1810,   2061,  -2781,   6056,
-    10058,   -200,   -259,   -472,  -2238,  -6174,    227,   -307,
-      349,    669,   -761,   1028,   1111,  -1265,   1707,  -3717,
-     7827,   9161,  -3409,   2473,  -1510,  -3739,  -5122,   -709,
-     -373,   -139,  -4376,   1628,   1906,  -1181,  -1382,    514,
-      721,    844,   -314,    228,  -1430,   8313,   9541,  -2955,
-     1626,   -124,  -4218,  -5556,   -533,   -161,    725,    832,
-    -4841,   -257,   1499,   1721,    142,   -825,   -947,    293,
-     2819,  -4247,   5391,   8673,   2756,   -485,  -1101,  -1774,
-    -4591,   -463,    730,   -927,   1397,  -1492,   2248,  -2854,
-     -474,    714,   -907,  -1459,    141,  14552,    690,    257,
-     -112,     -1, -12926,    -29,     -4,      0,   -125,     -5,
-     -613,     -2,   -228,    -10,      0,     99,      4,      1,
-    11938,  -1859,   1806,   -962,   -884,  -8699,   -211,   -199,
-      -56,    -47,   1355,  -1316,    205,    701,   -109,    106,
-      644,   -100,     97,    -51,   3728,   1982,   2264,   4584,
-     3131,   -848,   -239,   -312,  -1282,   -598,   -451,   -515,
-     -273,  -1043,   -554,   -633,   -712,   -378,   -432,   -876,
-    -1181,    766,    720,  14303,   -216,    -85,    -35,    -31,
-   -12486,     -2,     55,     51,    -33,   1031,   -668,   -628,
-      -15,     10,      9,    189,  -4385,   4826,  10112,   1569,
-     3388,  -1173,  -1421,  -6242,   -150,   -700,   1291,   2706,
-    -2979,    420,   -462,   -969,    906,   -998,  -2091,   -324,
-     -448,   1932,  15591,  -1842,    657,    -12,   -227, -14837,
-     -207,    -26,     52,    427,  -1838,    -50,    217,   1753,
-       18,    -77,   -626,     74,  -4141,   1844,   3962,   5517,
-     6220,  -1046,   -207,   -958,  -1858,  -2361,    466,   1001,
-     -446,   1394,   -621,  -1334,   1572,   -700,  -1504,  -2094,
-      729,  -2299,  14755,   3657,   -952,    -32,   -322, -13288,
-     -816,    -55,    102,   -656,   2071,   -162,    513,  -3294,
-       42,   -133,    857,    212,  -1385,   5801,  13339,  -3137,
-     1344,   -117,  -2054, -10861,   -600,   -110,    490,   1127,
-    -4723,   -265,   1111,   2554,    113,   -476,  -1094,    257,
-     4710,   9661,   1073,  -2467,   3274,  -1354,  -5697,    -70,
-     -371,   -654,  -2777,   -308,   -633,    709,   1455,    161,
-     -941,  -1930,   -214,    493,   1843,  -3624,  12422,   6898,
-    -1559,   -207,   -802,  -9419,  -2904,   -148,    407,  -1397,
-     2748,   -775,   1526,  -5230,    175,   -344,   1182,    656,
-     1433,   2394,   2507,   1380,   8780,   -125,   -349,   -383,
-     -116,  -4705,   -209,   -219,   -366,   -120,   -201,   -211,
-     -768,  -1283,  -1343,   -740,  -1712,  12915,   5883,  -2197,
-      991,   -179, -10181,  -2112,   -294,    -60,   1350,    615,
-    -4638,   -229,   1732,    789,    103,   -781,   -356,    133,
-    15072,   2158,  -1245,    910,   -496, -13865,   -284,    -94,
-      -50,    -15,  -1986,   1145,    164,   -837,   -119,     69,
-      456,     65,    -37,     27,   4655,   7319,   4916,    586,
-    -3381,  -1322,  -3270,  -1475,    -20,   -697,  -2079,  -1396,
-    -2196,   -166,   -261,   -175,    960,   1510,   1014,    120,
-     1191,  -2140,   5120,  13498,  -1418,    -86,   -279,  -1600,
-   -11121,   -122,    155,   -372,    669,   -981,   1763,  -4218,
-      103,   -185,    443,   1168,  -1530,   -817,   8191,   9632,
-    -1452,   -143,    -40,  -4095,  -5663,   -128,    -76,    765,
-      408,    900,    480,  -4815,   -135,    -72,    726,    854,
-    -3236,    607,   1696,  -2106,  11485,   -639,    -22,   -175,
-     -270,  -8051,    119,    335,    -62,   -416,     78,    218,
-     2268,   -425,  -1189,   1476,   3203,  -1903,   -837,   9679,
-     7057,   -626,   -221,    -42,  -5718,  -3039,    372,    163,
-      -97,  -1892,   1124,    494,  -1380,    819,    360,  -4169,
-      213,   -655,  17015,    620,   -384,     -2,    -26, -17671,
-      -23,     -9,      8,   -221,    681,     -8,     24,   -644,
-        5,    -15,    399,     14,   5088,     35,  -3339,   3726,
-     8488,  -1580,      0,   -680,   -847,  -4397,    -10,   1037,
-        7,  -1157,     -8,    759,  -2636,    -18,   1730,  -1930,
-     -988,   1454,  -2688,  15039,   2682,    -59,   -129,   -441,
-   -13805,   -439,     87,   -162,    238,    907,  -1335,   2467,
-      161,   -238,    440,  -2462,  -4865,  -2842,    -53,   5495,
-     6523,  -1445,   -493,      0,  -1843,  -2597,   -844,    -16,
-       -9,   1632,    953,     18,   1937,   1131,     21,  -2188,
-     3076,  15069,  -2914,   1810,   -971,   -577, -13860,   -518,
-     -200,    -57,  -2829,    547,   2680,   -339,  -1665,    322,
-      182,    893,   -172,    107,   1311,   5355,  11054,   2299,
-    -3654,   -105,  -1750,  -7458,   -322,   -814,   -428,   -885,
-    -3613,   -184,   -751,  -1551,    292,   1194,   2465,    512,
-     4035,   5619,   4618,   1815,   1912,   -994,  -1927,  -1301,
-     -201,   -223,  -1384,  -1137,  -1583,   -447,   -622,   -511,
-     -471,   -656,   -539,   -211,  -2131,   2754,  -4501,  12879,
-     7432,   -277,   -463,  -1236, -10124,  -3371,    358,   -585,
-      756,   1675,  -2165,   3538,    967,  -1249,   2042,  -5842,
-     5618,   -515,   3219,  -4149,   4857,  -1926,    -16,   -632,
-    -1050,  -1440,    176,  -1104,    101,   1422,   -130,    815,
-    -1666,    152,   -954,   1230,   1838,  -1709,   1139,  16867,
-      716,   -206,   -178,    -79, -17366,    -31,    191,   -127,
-      118,  -1892,   1759,  -1173,    -80,     74,    -49,   -737,
-     1978,  -3845,  10050,  11854,  -2492,   -238,   -902,  -6164,
-    -8576,   -379,    464,  -1213,   2358,  -1431,   2782,  -7271,
-      301,   -585,   1529,   1803,  -2600,  11246,  11289,  -3647,
-     1463,   -412,  -7720,  -7778,   -812,   -130,   1784,   1791,
-    -7749,   -578,   2504,   2513,    232,  -1004,  -1008,    325,
-     3442,    907,   2725,   8970,   3638,   -723,    -50,   -453,
-    -4911,   -808,   -190,   -572,   -150,  -1884,   -496,  -1492,
-     -764,   -201,   -605,  -1992,   -126,  17498,   3481,  -2003,
-     1090,      0, -18689,   -739,   -244,    -72,    135,     26,
-    -3717,    -15,   2139,    425,      8,  -1165,   -231,    133,
-    -1814,   1048,  -2164,   4070,  16272,   -200,    -67,   -285,
-    -1011, -16160,    116,   -239,    138,    450,   -260,    537,
-     1801,  -1041,   2149,  -4042,   9354,  12580,  -1883,    962,
-     -617,  -5341,  -9660,   -216,    -56,    -23,  -7183,   1075,
-     1446,   -549,   -738,    110,    352,    474,    -71,     36,
-     1708,   4199,   7387,   6335,   1003,   -178,  -1076,  -3330,
-    -2449,    -61,   -437,   -770,  -1893,   -660,  -1623,  -2856,
-     -104,   -257,   -452,   -388,  -2624,   5623,  17310,  -2353,
-      592,   -420,  -1930, -18288,   -338,    -21,    900,   2772,
-    -5941,   -376,    807,   2486,     94,   -203,   -625,     85,
-     1211,   -850,   1193,  -1926,  15992,    -89,    -44,    -86,
-     -226, -15609,     62,    -88,     61,    142,   -100,    140,
-    -1182,    830,  -1165,   1880,   3983,  -2054,  11506,    -19,
-     3622,   -968,   -257,  -8080,      0,   -801,    499,  -2797,
-     1442,      4,     -2,     13,   -880,    454,  -2544,      4,
-     -786,  -1354,  16092,   7246,  -1665,    -37,   -111, -15805,
-    -3205,   -169,    -65,    772,   1330,    348,    599,  -7117,
-      -80,   -137,   1636,    736,  -4316,   -511,   6674,  11665,
-     4633,  -1137,    -15,  -2719,  -8305,  -1310,   -134,   1758,
-      208,   3073,    364,  -4752,   1220,    144,  -1887,  -3299,
-     7912,   4557,   1937,   1885,   7037,  -3821,  -1267,   -229,
-     -216,  -3022,  -2200,   -935,   -538,   -910,   -524,   -222,
-    -3398,  -1957,   -832,   -809,   3434,   2967,   5867,   8196,
-     8766,   -720,   -537,  -2101,  -4100,  -4690,   -622,  -1230,
-    -1062,  -1718,  -1484,  -2935,  -1837,  -1588,  -3139,  -4385,
-     5881,   9176,   8119,   3934,   3355,  -2111,  -5139,  -4023,
-     -944,   -687,  -3294,  -2914,  -4547,  -1412,  -2203,  -1949,
-    -1204,  -1879,  -1662,   -805
-};
-
-const int16_t ff_g723_1_adaptive_cb_gain170[170 * 20] = {
-        0,      0,      0,      0,      0,      0,      0,      0,
-        0,      0,      0,      0,      0,      0,      0,      0,
-        0,      0,      0,      0,    776,    212,    715,    670,
-      809,    -36,     -2,    -31,    -27,    -39,    -10,    -33,
-       -9,    -31,     -8,    -29,    -38,    -10,    -35,    -33,
-     1296,   1316,   -168,   -320,   -815,   -102,   -105,     -1,
-       -6,    -40,   -104,     13,     13,     25,     25,     -3,
-       64,     65,     -8,    -15,   -589,    680,   2478,    308,
-     -596,    -21,    -28,   -375,     -5,    -21,     24,     89,
-     -102,     11,    -12,    -46,    -21,     24,     90,     11,
-     -735,   -487,     -5,   2948,    468,    -33,    -14,      0,
-     -530,    -13,    -21,      0,      0,    132,     87,      0,
-       21,     13,      0,    -84,   1042,   1730,   1068,    333,
-      626,    -66,   -182,    -69,     -6,    -23,   -110,    -67,
-     -112,    -21,    -35,    -21,    -39,    -66,    -40,    -12,
-      486,   -769,   4074,   2825,  -1107,    -14,    -36,  -1013,
-     -487,    -74,     22,   -120,    191,    -83,    132,   -702,
-       32,    -52,    275,    191,   1521,   -767,   -124,   4320,
-     1026,   -141,    -35,      0,  -1139,    -64,     71,     11,
-       -5,   -401,    202,     32,    -95,     48,      7,   -270,
-     2425,   1267,   3439,    -91,  -1166,   -359,    -98,   -722,
-        0,    -83,   -187,   -509,   -266,     13,      7,     19,
-      172,     90,    244,     -6,  -1251,    975,    173,   4039,
-     2005,    -95,    -58,     -1,   -996,   -245,     74,     13,
-      -10,    308,   -240,    -42,    153,   -119,    -21,   -494,
-     1820,    632,   1322,   2062,   1031,   -202,    -24,   -106,
-     -259,    -64,    -70,   -146,    -51,   -229,    -79,   -166,
-     -114,    -39,    -83,   -129,   -447,   4904,    244,   -315,
-    -2038,    -12,  -1467,     -3,     -6,   -253,    134,      6,
-      -73,     -8,     94,      4,    -55,    610,     30,    -39,
-     -208,  -1102,    463,   -448,   5653,     -2,    -74,    -13,
-      -12,  -1950,    -14,      5,     31,     -5,    -30,     12,
-       71,    380,   -159,    154,   4739,   2600,  -1864,    856,
-    -1554,  -1371,   -412,   -212,    -44,   -147,   -752,    539,
-      295,   -247,   -135,     97,    449,    246,   -176,     81,
-     1894,   3533,     35,    -26,   2145,   -219,   -762,      0,
-        0,   -280,   -408,     -4,     -7,      3,      5,      0,
-     -248,   -462,     -4,      3,  -2699,   1841,   4072,   2443,
-     1582,   -444,   -207,  -1012,   -364,   -152,    303,    670,
-     -457,    402,   -274,   -607,    260,   -177,   -393,   -236,
-     -844,   3358,   6106,  -1059,   -537,    -43,   -688,  -2275,
-      -68,    -17,    173,    314,  -1251,    -54,    217,    395,
-      -27,    110,    200,    -34,   1251,   1016,   3020,   2210,
-     1445,    -95,    -63,   -556,   -298,   -127,    -77,   -230,
-     -187,   -168,   -137,   -407,   -110,    -89,   -266,   -194,
-     2099,   2277,   4038,   3533,  -2870,   -269,   -316,   -995,
-     -762,   -503,   -291,   -517,   -561,   -452,   -491,   -871,
-      367,    399,    707,    619,    400,  -1114,   8516,   2422,
-    -1117,     -9,    -75,  -4426,   -358,    -76,     27,   -208,
-      579,    -59,    164,  -1259,     27,    -75,    580,    165,
-    -4398,  -2011,   3912,  -2407,   2258,  -1180,   -247,   -934,
-     -353,   -311,   -540,   1050,    480,   -646,   -295,    575,
-      606,    277,   -539,    331,   1767,  -1447,   4240,   6160,
-     -757,   -190,   -127,  -1097,  -2316,    -35,    156,   -457,
-      374,   -664,    544,  -1594,     81,    -66,    195,    284,
-     1594,  -1463,   1035,   6938,   1920,   -155,   -130,    -65,
-    -2938,   -225,    142,   -100,     92,   -675,    619,   -438,
-     -186,    171,   -121,   -813,   -562,   4716,   4085,   -591,
-     2421,    -19,  -1357,  -1018,    -21,   -357,    162,    140,
-    -1175,    -20,    170,    147,     83,   -696,   -603,     87,
-     1552,   8778,   -935,    354,  -1424,   -147,  -4703,    -53,
-       -7,   -123,   -831,     88,    501,    -33,   -189,     20,
-      134,    763,    -81,     30,   4831,  -4431,     41,  -1479,
-    -2976,  -1424,  -1198,      0,   -133,   -540,   1306,    -12,
-       11,    436,   -400,      3,    877,   -804,      7,   -268,
-     2090,   1192,   1006,   1645,   4853,   -266,    -86,    -61,
-     -165,  -1437,   -152,   -128,    -73,   -210,   -119,   -101,
-     -619,   -353,   -298,   -487,   2386,   5712,   1426,    -94,
-     1350,   -347,  -1991,   -124,      0,   -111,   -832,   -207,
-     -497,     13,     32,      8,   -196,   -470,   -117,      7,
-    -1349,   1091,   1659,   8891,    313,   -111,    -72,   -168,
-    -4825,     -5,     89,    136,   -110,    732,   -592,   -900,
-       25,    -20,    -31,   -170,   9980,    916,   -381,   -808,
-       88,  -6080,    -51,     -8,    -39,      0,   -558,    232,
-       21,    492,     45,    -18,    -53,     -4,      2,      4,
-     2338,  -1031,   -248,   3928,   6484,   -333,    -64,     -3,
-     -942,  -2566,    147,     35,    -15,   -560,    247,     59,
-     -925,    408,     98,  -1555,   6166,  -1240,   -337,   3672,
-    -1277,  -2320,    -93,     -6,   -823,    -99,    466,    126,
-      -25,  -1382,    278,     75,    480,    -96,    -26,    286,
-     4377,   -132,  -2588,   1701,   4865,  -1169,     -1,   -409,
-     -176,  -1444,     35,    691,    -20,   -454,     13,    268,
-    -1299,     39,    768,   -505,   2594,   3295,   3944,   1481,
-      682,   -410,   -662,   -949,   -133,    -28,   -521,   -624,
-     -793,   -234,   -297,   -356,   -108,   -137,   -164,    -61,
-     4151,    624,    815,   4485,   2229,  -1052,    -23,    -40,
-    -1228,   -303,   -158,   -206,    -31,  -1136,   -170,   -223,
-     -565,    -84,   -111,   -610,  -3575,   -361,   4924,   2791,
-     4698,   -780,     -7,  -1480,   -475,  -1347,    -78,   1074,
-      108,    609,     61,   -839,   1025,    103,  -1412,   -800,
-    -2518,   3791,   8623,    315,   2465,   -387,   -877,  -4538,
-       -6,   -370,    582,   1325,  -1995,     48,    -73,   -166,
-      378,   -570,  -1297,    -47,   -691,   2989,   9957,   -421,
-    -1142,    -29,   -545,  -6051,    -10,    -79,    126,    420,
-    -1817,    -17,     76,    256,    -48,    208,    694,    -29,
-    -1918,    104,  -3190,  -3410,  -4440,   -224,      0,   -621,
-     -709,  -1203,     12,   -373,     20,   -399,     21,   -664,
-     -519,     28,   -864,   -924,  -3359,  -1668,   1854,   6939,
-     1430,   -688,   -169,   -209,  -2939,   -124,   -341,    380,
-      188,   1422,    706,   -785,    293,    145,   -161,   -606,
-       42,   9706,   3164,   -952,    907,      0,  -5750,   -611,
-      -55,    -50,    -25,     -8,  -1874,      2,    564,    183,
-       -2,   -537,   -175,     52,   1607,    785,   2862,   4327,
-     3307,   -157,    -37,   -500,  -1143,   -667,    -77,   -280,
-     -137,   -424,   -207,   -756,   -324,   -158,   -577,   -873,
-     6801,   3416,   2227,   1682,  -3217,  -2823,   -712,   -302,
-     -172,   -631,  -1418,   -924,   -464,   -698,   -350,   -228,
-     1335,    670,    437,    330,   3459,   3898,    364,   7841,
-    -2640,   -730,   -927,     -8,  -3753,   -425,   -823,    -76,
-      -86,  -1655,  -1865,   -174,    557,    628,     58,   1263,
-    -5902,  -3458,  -2465,  -1886,   4334,  -2126,   -730,   -371,
-     -217,  -1146,  -1245,   -888,   -520,   -679,   -398,   -283,
-     1561,    915,    652,    499,  -3710,   1133,   7849,   3443,
-     -215,   -840,    -78,  -3760,   -723,     -2,    256,   1777,
-     -543,    779,   -238,  -1649,    -48,     14,    103,     45,
-     4132,   2828,      2,  -4212,  -4116,  -1042,   -488,      0,
-    -1083,  -1034,   -713,      0,      0,   1062,    727,      0,
-     1038,    710,      0,  -1058,   5875,   8496,  -1796,   1376,
-    -1786,  -2107,  -4406,   -197,   -115,   -194,  -3047,    644,
-      931,   -493,   -713,    150,    640,    926,   -195,    150,
-     3143,   3483,   3546,   -793,   4489,   -603,   -740,   -767,
-      -38,  -1230,   -668,   -680,   -754,    152,    168,    171,
-     -861,   -954,   -971,    217,   2845,   7965,   3695,  -5432,
-     3978,   -494,  -3873,   -833,  -1801,   -966,  -1383,   -641,
-    -1796,    943,   2641,   1225,   -691,  -1934,   -897,   1319,
-     1538,    150,   7139,   2049,   3097,   -144,     -1,  -3110,
-     -256,   -585,    -14,   -670,    -65,   -192,    -18,   -892,
-     -290,    -28,  -1349,   -387,    618,   7520,   4729,   -238,
-    -3373,    -23,  -3452,  -1365,     -3,   -694,   -283,   -178,
-    -2170,      8,    109,     68,    127,   1548,    973,    -49,
-     2965,  -3013,   7912,   7076,  -1997,   -536,   -554,  -3821,
-    -3056,   -243,    545,  -1431,   1455,  -1280,   1301,  -3417,
-      361,   -367,    964,    862,   2443,   -929,  -1113,   9677,
-     4138,   -364,    -52,    -75,  -5716,  -1045,    138,    166,
-      -63,  -1443,    549,    657,   -617,    234,    281,  -2444,
-     1966,   3309,  10085,  -3399,   2105,   -236,   -668,  -6207,
-     -705,   -270,   -397,  -1210,  -2037,    408,    686,   2092,
-     -252,   -425,  -1295,    436,   -112,  -1368,   8868,   4822,
-     2048,      0,   -114,  -4800,  -1419,   -256,     -9,     61,
-      740,     33,    402,  -2610,     14,    171,  -1108,   -602,
-    -2597,    438,  -1839,   6229,   7266,   -411,    -11,   -206,
-    -2368,  -3223,     69,   -291,     49,    987,   -166,    699,
-     1152,   -194,    816,  -2763,   3454,    553,   9127,   4946,
-    -5596,   -728,    -18,  -5084,  -1493,  -1911,   -116,  -1924,
-     -308,  -1042,   -166,  -2755,   1179,    188,   3117,   1689,
-     -532,   -663,  12262,   2495,  -1004,    -17,    -26,  -9177,
-     -380,    -61,    -21,    398,    496,     81,    101,  -1867,
-      -32,    -40,    751,    152,  -2100,   1317,  -1509,  11425,
-     2997,   -269,   -105,   -139,  -7967,   -548,    168,   -193,
-      121,   1464,   -918,   1052,    384,   -240,    276,  -2090,
-     1193,  -2697,  11259,   5373,   -763,    -86,   -444,  -7737,
-    -1762,    -35,    196,   -819,   1853,   -391,    884,  -3692,
-       55,   -125,    525,    250,   2405,   -471,  11079,    203,
-      782,   -353,    -13,  -7491,     -2,    -37,     69,  -1626,
-      318,    -29,      5,   -137,   -114,     22,   -529,     -9,
-    -1871,   5685,  11290,  -2662,   1353,   -213,  -1972,  -7780,
-     -432,   -111,    649,   1289,  -3917,   -304,    923,   1834,
-      154,   -469,   -932,    220,  -3768,   5927,  -3093,   5041,
-     5212,   -866,  -2144,   -584,  -1551,  -1658,   1363,   -711,
-     1119,   1159,  -1824,    951,   1198,  -1885,    984,  -1603,
-    -2546,   9502,   5969,  -2440,   1928,   -395,  -5511,  -2175,
-     -363,   -226,   1477,    927,  -3462,   -379,   1415,    889,
-      299,  -1118,   -702,    287,  -4963,   3568,   4592,   5508,
-     3451,  -1503,   -777,  -1287,  -1851,   -727,   1080,   1391,
-    -1000,   1668,  -1199,  -1543,   1045,   -751,   -967,  -1160,
-     1745,  -2586,   3983,  10899,  -1551,   -186,   -408,   -968,
-    -7250,   -146,    275,   -424,    628,  -1161,   1720,  -2649,
-      165,   -244,    377,   1032,    867,   -456,   -727,   3369,
-    11822,    -45,    -12,    -32,   -692,  -8531,     24,     38,
-      -20,   -178,     93,    149,   -625,    329,    525,  -2431,
-     7535,   2422,   1926,   1405,   1599,  -3466,   -358,   -226,
-     -120,   -156,  -1114,   -886,   -284,   -646,   -207,   -165,
-     -735,   -236,   -188,   -137,   1041,   -735,   -142,  13209,
-     1515,    -66,    -33,     -1, -10649,   -140,     46,      9,
-       -6,   -839,    593,    114,    -96,     68,     13,  -1222,
-     7950,   6745,  -1444,  -1008,   2721,  -3857,  -2777,   -127,
-      -62,   -452,  -3273,    700,    594,    489,    415,    -88,
-    -1320,  -1120,    239,    167,  -4754,  -1379,   4522,   -578,
-    -5733,  -1379,   -116,  -1248,    -20,  -2006,   -400,   1312,
-      380,   -167,    -48,    159,  -1663,   -482,   1582,   -202,
-     3220,   5978,   5923,   2430,  -2689,   -633,  -2181,  -2141,
-     -360,   -441,  -1175,  -1164,  -2161,   -477,   -886,   -878,
-      528,    981,    972,    398,    377,   1312,  13978,  -1470,
-      677,     -8,   -105, -11925,   -132,    -28,    -30,   -321,
-    -1119,     33,    117,   1254,    -15,    -54,   -577,     60,
-    -3435,   6770,    314,   -885,   5686,   -720,  -2797,     -6,
-      -47,  -1973,   1419,     65,   -129,   -185,    366,     16,
-     1192,  -2349,   -109,    307,   3171,   8774,  -2260,   2679,
-     3069,   -613,  -4699,   -312,   -438,   -575,  -1698,    437,
-     1210,   -518,  -1435,    369,   -594,  -1643,    423,   -501,
-     5557,   1509,   5407,   -125,  -7386,  -1884,   -139,  -1784,
-        0,  -3330,   -511,  -1834,   -498,     42,     11,     41,
-     2505,    680,   2438,    -56,  -2838,   2595,  13228,    271,
-     1793,   -491,   -411, -10680,     -4,   -196,    449,   2291,
-    -2095,     47,    -42,   -219,    310,   -284,  -1447,    -29,
-      664,   -278,  14966,    951,   -711,    -26,     -4, -13672,
-      -55,    -30,     11,   -606,    253,    -38,     16,   -869,
-       28,    -12,    650,     41,    808,   1770,   8658,   5863,
-    -1486,    -39,   -191,  -4576,  -2098,   -134,    -87,   -427,
-     -935,   -289,   -633,  -3098,     73,    160,    785,    531,
-     3063,   1539,   2000,   -542,   9576,   -572,   -144,   -244,
-      -17,  -5597,   -287,   -374,   -188,    101,     51,     66,
-    -1790,   -900,  -1169,    317,    514,  14083,   -323,    896,
-     -891,    -16, -12106,     -6,    -49,    -48,   -442,     10,
-      277,    -28,   -770,     17,     27,    766,    -17,     48,
-      892,    158,   5237,  11057,  -1603,    -48,     -1,  -1674,
-    -7462,   -156,     -8,   -285,    -50,   -602,   -106,  -3534,
-       87,     15,    512,   1082,  -1612,   2564,  -4296,  12526,
-     5710,   -158,   -401,  -1126,  -9576,  -1990,    252,   -422,
-      672,   1232,  -1960,   3284,    561,   -893,   1497,  -4365,
-     4889,  -6878,    612,   6109,   4753,  -1459,  -2887,    -22,
-    -2277,  -1379,   2052,   -182,    257,  -1823,   2564,   -228,
-    -1418,   1995,   -177,  -1772,   3053,   -506,   2403,   9625,
-     1322,   -569,    -15,   -352,  -5655,   -106,     94,   -448,
-       74,  -1794,    297,  -1412,   -246,     40,   -194,   -777,
-     -754,  12904,   4480,  -2113,   1471,    -34, -10163,  -1225,
-     -272,   -132,    594,    206,  -3529,    -97,   1664,    577,
-       67,  -1159,   -402,    189,   4255,   1476,   5055,   2393,
-     2912,  -1105,   -132,  -1559,   -349,   -517,   -383,  -1313,
-     -455,   -621,   -215,   -738,   -756,   -262,   -898,   -425,
-    -1371,    535,   1417,  14604,   -997,   -114,    -17,   -122,
-   -13017,    -60,     44,    118,    -46,   1222,   -477,  -1263,
-      -83,     32,     86,    888,   5368,  -1744,   4083,  -1236,
-     3753,  -1758,   -185,  -1017,    -93,   -860,    571,  -1338,
-      434,    405,   -131,    308,  -1229,    399,   -935,    283,
-     1588,  -3097,  14415,   3699,  -1171,   -154,   -585, -12683,
-     -835,    -83,    300,  -1397,   2725,   -358,    699,  -3255,
-      113,   -221,   1030,    264,    212,   7989,   9471,  -3344,
-     2009,     -2,  -3895,  -5475,   -682,   -246,   -103,   -123,
-    -4618,     43,   1630,   1933,    -26,   -979,  -1161,    410,
-      856,   2294,   -627,   6930,   6929,    -44,   -321,    -24,
-    -2931,  -2930,   -119,     32,     87,   -362,   -970,    265,
-     -362,   -970,    265,  -2931,   2357,  -4187,   7162,   7683,
-     3371,   -339,  -1070,  -3131,  -3603,   -693,    602,  -1030,
-     1830,  -1105,   1963,  -3359,   -485,    861,  -1474,  -1581,
-      350,   4585,  14053,  -3819,   1218,     -7,  -1283, -12054,
-     -890,    -90,    -97,   -300,  -3933,     81,   1068,   3275,
-      -26,   -341,  -1045,    284,  -3248,   3531,    475,   2137,
-    11711,   -644,   -761,    -13,   -278,  -8372,    700,     94,
-     -102,    423,   -460,    -62,   2322,  -2524,   -340,  -1528,
-    -3017,   3852,   1725,   8440,   5257,   -555,   -905,   -181,
-    -4348,  -1686,    709,    317,   -405,   1554,  -1984,   -889,
-      968,  -1236,   -553,  -2708,   -909,   3196,  15512,  -2528,
-     1066,    -50,   -623, -14686,   -390,    -69,    177,    861,
-    -3026,   -140,    493,   2393,     59,   -208,  -1009,    164,
-      959,  -3370,   9617,   9545,  -1761,    -56,   -693,  -5645,
-    -5561,   -189,    197,   -563,   1978,   -558,   1963,  -5603,
-      103,   -362,   1034,   1026,   7575,  11796,  -4845,   3252,
-    -1703,  -3502,  -8493,  -1433,   -645,   -177,  -5454,   2240,
-     3488,  -1503,  -2341,    961,    787,   1226,   -503,    338,
-     6409,   1722,   1764,  -4191,   6015,  -2507,   -181,   -189,
-    -1072,  -2208,   -673,   -690,   -185,   1639,    440,    451,
-    -2353,   -632,   -647,   1538,  -2420,  12161,   5038,   1286,
-    -2098,   -357,  -9027,  -1549,   -100,   -268,   1796,    744,
-    -3740,    190,   -954,   -395,   -310,   1557,    645,    164,
-    -2232,  -1341,   7246,   9470,  -1977,   -304,   -109,  -3204,
-    -5474,   -238,   -182,    987,    593,   1290,    775,  -4188,
-     -269,   -161,    874,   1143,   1030,   7034,   4231,   1551,
-     3077,    -64,  -3019,  -1093,   -146,   -577,   -442,   -266,
-    -1816,    -97,   -666,   -400,   -193,  -1321,   -794,   -291,
-     5121,  11835,   -477,  -1749,   2298,  -1601,  -8549,    -13,
-     -186,   -322,  -3699,    149,    344,    546,   1264,    -50,
-     -718,  -1660,     66,    245,  -3328,   3827,   5921,   9976,
-    -1045,   -676,   -894,  -2140,  -6075,    -66,    777,   1203,
-    -1383,   2027,  -2330,  -3605,   -212,    244,    377,    636,
-     3813,   5718,  -4666,  -3412,   5674,   -887,  -1995,  -1329,
-     -710,  -1965,  -1331,   1086,   1628,    794,   1191,   -972,
-    -1320,  -1980,   1616,   1181,   1348,  -3672,  13154,   6938,
-    -1690,   -110,   -823, -10561,  -2938,   -174,    302,  -1082,
-     2948,   -570,   1555,  -5570,    139,   -379,   1357,    716,
-     2151,  -3586,   6949,  12131,  -1224,   -282,   -785,  -2947,
-    -8982,    -91,    470,   -912,   1521,  -1592,   2655,  -5145,
-      160,   -268,    519,    906,  -2889,   9647,  10276,  -2728,
-      995,   -509,  -5680,  -6445,   -454,    -60,   1701,   1812,
-    -6051,   -481,   1606,   1711,    175,   -586,   -624,    165,
-     6177,   2184,    555,   1985,   6589,  -2329,   -291,    -18,
-     -240,  -2650,   -823,   -209,    -74,   -748,   -264,    -67,
-    -2484,   -878,   -223,   -798,   -492,    391,  17166,   -681,
-      240,    -14,     -9, -17987,    -28,     -3,     11,    515,
-     -410,    -20,     16,    713,      7,     -5,   -252,     10,
-    12628,   5448,  -2630,   3011,  -2695,  -9733,  -1811,   -422,
-     -553,   -443,  -4199,   2027,    874,  -2321,  -1001,    483,
-     2077,    896,   -432,    495,  -3628,   -534,   3447,   7002,
-     6751,   -803,    -17,   -725,  -2992,  -2782,   -118,    763,
-      112,   1550,    228,  -1473,   1495,    220,  -1420,  -2885,
-    -5239,   5901,   8107,   3650,   4846,  -1675,  -2125,  -4012,
-     -813,  -1433,   1887,   2592,  -2920,   1167,  -1315,  -1806,
-     1550,  -1745,  -2398,  -1080,   6157,   6678,   4099,  -1074,
-     2348,  -2314,  -2722,  -1025,    -70,   -336,  -2509,  -1540,
-    -1670,    403,    437,    268,   -882,   -957,   -587,    153,
-     1079,  16099,    242,   -881,   1690,    -71, -15820,     -3,
-      -47,   -174,  -1060,    -16,   -238,     58,    865,     13,
-     -111,  -1661,    -25,     90,   -278,    227,  -1039,   1636,
-    16945,     -4,     -3,    -65,   -163, -17526,      3,    -17,
-       14,     27,    -22,    103,    287,   -234,   1074,  -1693,
-    15778,  -1454,    574,   -603,   -107, -15195,   -129,    -20,
-      -22,      0,   1400,   -553,     51,    581,    -53,     21,
-      103,     -9,      3,     -3,   2406,   -836,  13224,   7993,
-    -4266,   -353,    -42, -10673,  -3899,  -1111,    122,  -1942,
-      674,  -1174,    407,  -6451,    626,   -217,   3443,   2081,
-     3184,  14368,  -3336,   2255,  -1801,   -619, -12600,   -679,
-     -310,   -198,  -2793,    648,   2926,   -438,  -1977,    459,
-      350,   1580,   -366,    247,  -1698,  17076,   2504,   -539,
-     -646,   -176, -17798,   -382,    -17,    -25,   1770,    259,
-    -2610,    -55,    561,     82,    -67,    673,     98,    -21,
-     2375,   -797,  -2696,  14483,   5383,   -344,    -38,   -443,
-   -12803,  -1769,    115,    391,   -131,  -2100,    705,   2384,
-     -780,    262,    886,  -4759,  -2691,   2554,  -4520,   9573,
-    10655,   -442,   -398,  -1247,  -5594,  -6930,    419,   -742,
-      704,   1572,  -1492,   2641,   1750,  -1661,   2939,  -6226,
-    -4332,  -4399,  -1657,   4880,   7375,  -1145,  -1181,   -167,
-    -1453,  -3319,  -1163,   -438,   -444,   1290,   1310,    493,
-     1950,   1980,    745,  -2196,  -3498,   7405,   9955,   2693,
-    -2971,   -746,  -3347,  -6049,   -442,   -538,   1581,   2125,
-    -4499,    575,  -1217,  -1636,   -634,   1342,   1805,    488,
-     6717,  -3792,   7739,   2798,   3489,  -2754,   -877,  -3655,
-     -477,   -743,   1554,  -3173,   1791,  -1147,    647,  -1321,
-    -1430,    807,  -1648,   -595,   5263,   9770,   3463,   1069,
-    -3971,  -1690,  -5826,   -732,    -69,   -962,  -3138,  -1112,
-    -2065,   -343,   -637,   -226,   1275,   2368,    839,    259,
-     1243,  -2634,  16772,   1871,    332,    -94,   -423, -17169,
-     -213,     -6,    199,  -1273,   2696,   -142,    300,  -1915,
-      -25,     53,   -339,    -37,   2691,   2836,   3105,   5711,
-     4817,   -442,   -491,   -588,  -1991,  -1416,   -465,   -510,
-     -537,   -938,   -988,  -1082,   -791,   -834,   -913,  -1679,
-     4366,   2944,   7210,   3627,   1161,  -1163,   -529,  -3172,
-     -803,    -82,   -784,  -1921,  -1295,   -966,   -651,  -1596,
-     -309,   -208,   -511,   -257,  13888,   3951,   -671,  -2305,
-     3354, -11773,   -953,    -27,   -324,   -686,  -3349,    569,
-      161,   1954,    556,    -94,  -2843,   -809,    137,    472,
-     7053,   5847,   2929,   8378,  -4794,  -3036,  -2086,   -523,
-    -4284,  -1403,  -2517,  -1261,  -1045,  -3607,  -2990,  -1498,
-     2064,   1711,    857,   2451,  -2191,  12838,   9182,  -3915,
-     1617,   -293, -10059,  -5146,   -935,   -159,   1717,   1228,
-    -7195,   -523,   3068,   2194,    216,  -1267,   -906,    386,
-    -4881,  13114,   5767,   -435,   4155,  -1454, -10498,  -2030,
-      -11,  -1054,   3907,   1718,  -4616,   -129,    348,    153,
-     1238,  -3326,  -1462,    110,   7843,  -1250,    210,   7106,
-    -5203,  -3754,    -95,     -2,  -3082,  -1652,    598,   -100,
-       16,  -3402,    542,    -91,   2491,   -397,     66,   2257,
-    -2463,   8168,  14551,  -3908,   1828,   -370,  -4072, -12923,
-     -932,   -204,   1228,   2188,  -7254,   -587,   1948,   3471,
-      274,   -911,  -1623,    436,  -1579,    347,   -272,  -2735,
-    16031,   -152,     -7,     -4,   -456, -15686,     33,    -26,
-        5,   -263,     58,    -45,   1545,   -340,    266,   2676,
-    -6327,   1328,   5093,  -5079,   7617,  -2443,   -107,  -1583,
-    -1574,  -3541,    513,   1967,   -413,  -1961,    411,   1578,
-     2941,   -617,  -2367,   2361,   3286,  -4509,  11306,  11025,
-    -2623,   -659,  -1241,  -7802,  -7419,   -420,    904,  -2267,
-     3112,  -2211,   3034,  -7608,    526,   -722,   1810,   1765,
-     5567,  17853,  -3754,   1166,   -519,  -1892, -19455,   -860,
-      -83,    -16,  -6067,   1275,   4090,   -396,  -1271,    267,
-      176,    566,   -119,     37,  -2136,   -424,  15292,   5108,
-    -1648,   -278,    -10, -14273,  -1593,   -165,    -55,   1993,
-      396,    666,    132,  -4768,   -214,    -42,   1538,    514,
-     2267,  -3297,   2549,  16563,   -791,   -313,   -663,   -396,
-   -16745,    -38,    456,   -352,    513,  -2291,   3333,  -2576,
-      109,   -159,    123,    799,   3655,   1899,  -3364,   6279,
-    12510,   -815,   -220,   -690,  -2406,  -9552,   -423,    750,
-      390,  -1400,   -728,   1289,  -2791,  -1450,   2568,  -4794,
-     8052,   2285,  -6193,   5138,   6003,  -3957,   -318,  -2341,
-    -1611,  -2199,  -1123,   3044,    864,  -2525,   -716,   1942,
-    -2950,   -837,   2269,  -1882,   -386,  -2291,   7679,  15387,
-    -2723,     -9,   -320,  -3599, -14452,   -452,    -54,    181,
-     1074,    362,   2152,  -7212,    -64,   -380,   1276,   2557,
-     2777,  -1173,   3984,  13079,   2508,   -470,    -84,   -969,
-   -10440,   -384,    198,   -675,    285,  -2217,    936,  -3180,
-     -425,    179,   -610,  -2002,  -1879,   1771,  -2684,  16705,
-     1833,   -215,   -191,   -439, -17032,   -205,    203,   -308,
-      290,   1916,  -1805,   2736,    210,   -198,    300,  -1869,
-     1052,   4495,  15519,   1467,  -4032,    -67,  -1233, -14700,
-     -131,   -992,   -288,   -997,  -4257,    -94,   -402,  -1389,
-      259,   1106,   3819,    361,   3010,   2544,   6969,   7559,
-     1996,   -553,   -395,  -2964,  -3487,   -243,   -467,  -1280,
-    -1082,  -1388,  -1174,  -3215,   -366,   -310,   -849,   -921,
-    -5209,  -1867,   8713,  10351,   1549,  -1656,   -212,  -4634,
-    -6540,   -146,   -593,   2770,    993,   3291,   1180,  -5505,
-      492,    176,   -824,   -979,  -4314,   8513,    913,   7547,
-    -2723,  -1135,  -4423,    -50,  -3476,   -452,   2241,    240,
-     -474,   1987,  -3921,   -420,   -717,   1415,    151,   1254,
-    12929,  -1219,   2448,   1757,   6303, -10204,    -90,   -365,
-     -188,  -2425,    962,  -1932,    182,  -1386,    130,   -262,
-    -4974,    469,   -941,   -676,   6465,   4132,   3167,   3160,
-     5697,  -2551,  -1042,   -612,   -609,  -1981,  -1630,  -1249,
-     -798,  -1247,   -797,   -611,  -2248,  -1437,  -1101,  -1099,
-    -3636,   4859,  18914,  -1335,    810,   -807,  -1441, -21836,
-     -108,    -40,   1078,   4198,  -5609,   -296,    396,   1541,
-      179,   -240,   -936,     66,   8844,   7864,    654,  -4063,
-    -5680,  -4774,  -3774,    -26,  -1007,  -1969,  -4245,   -353,
-     -314,   2193,   1950,    162,   3066,   2726,    226,  -1408,
-     1859,   2634,   9228,    996,   9464,   -211,   -423,  -5197,
-      -60,  -5467,   -299,  -1047,  -1483,   -113,   -160,   -561,
-    -1074,  -1521,  -5330,   -575,   2949,  12260,  10290,   -497,
-    -3943,   -530,  -9174,  -6463,    -15,   -949,  -2206,  -1852,
-    -7700,     89,    372,    312,    709,   2950,   2476,   -119,
-    -2903,   1552,  14867,   9970,   -496,   -514,   -147, -13491,
-    -6068,    -15,    275,   2634,  -1408,   1766,   -944,  -9047,
-      -87,     47,    450,    302,   3243,   8234,   7586,   3373,
-     2151,   -642,  -4138,  -3512,   -694,   -282,  -1630,  -1501,
-    -3812,   -667,  -1695,  -1561,   -425,  -1081,   -996,   -442,
-    -9631,     60,   3501,   5359,  10150,  -5662,      0,   -748,
-    -1752,  -6288,     35,   2058,    -12,   3150,    -19,  -1145,
-     5967,    -37,  -2169,  -3320,  -6874,  -2553,  -5446,  -2195,
-    -7841,  -2884,   -397,  -1810,   -294,  -3753,  -1071,  -2285,
-     -848,   -921,   -342,   -729,  -3290,  -1221,  -2606,  -1050,
-    -3413,  -1141,   4630,  13612,   7897,   -711,    -79,  -1308,
-   -11310,  -3806,   -237,    964,    322,   2836,    948,  -3847,
-     1645,    550,  -2231,  -6561,   4410,  -5678,   8006,  -3992,
-     3811,  -1187,  -1968,  -3912,   -973,   -886,   1528,  -2155,
-     2775,   1074,  -1383,   1951,  -1025,   1321,  -1862,    928,
-     5659,  11535,   2203,   -452,   7169,  -1954,  -8121,   -296,
-      -12,  -3137,  -3984,   -761,  -1551,    156,    318,     60,
-    -2476,  -5048,   -964,    197,   2914,  -2914,   3485,  -3965,
-    13675,   -518,   -518,   -741,   -959, -11414,    518,   -620,
-      620,    705,   -705,    843,  -2433,   2432,  -2909,   3310,
-     7843,   1907,   1022,   8882,   7972,  -3755,   -222,    -63,
-    -4815,  -3879,   -913,   -489,   -119,  -4252,  -1034,   -554,
-    -3816,   -928,   -497,  -4322,  13807,   9531,   1436,   1612,
-     1779, -11636,  -5544,   -125,   -158,   -193,  -8032,  -1210,
-     -835,  -1358,   -938,   -141,  -1499,  -1035,   -156,   -175,
-    13620,  -5337,   5450,  -2263,   1723, -11322,  -1738,  -1813,
-     -312,   -181,   4436,  -4531,   1775,   1881,   -737,    752,
-    -1432,    561,   -573,    238,   5297,   8374,   8872,   7694,
-     6538,  -1712,  -4280,  -4804,  -3613,  -2609,  -2707,  -2868,
-    -4534,  -2487,  -3932,  -4166,  -2113,  -3341,  -3540,  -3070
-};
-
 int ff_g723_1_scale_vector(int16_t *dst, const int16_t *vector, int length)
 {
     int bits, max = 0;
@@ -1169,9 +98,9 @@
 
     /* Select quantization table */
     if (cur_rate == RATE_6300 && pitch_lag < SUBFRAME_LEN - 2) {
-        cb_ptr = ff_g723_1_adaptive_cb_gain85;
+        cb_ptr = adaptive_cb_gain85;
     } else
-        cb_ptr = ff_g723_1_adaptive_cb_gain170;
+        cb_ptr = adaptive_cb_gain170;
 
     /* Calculate adaptive vector */
     cb_ptr += subfrm->ad_cb_gain * 20;
@@ -1196,8 +125,8 @@
     for (j = 0; j < LPC_ORDER; j++) {
         int index     = (lpc[j] >> 7) & 0x1FF;
         int offset    = lpc[j] & 0x7f;
-        int temp1  =  ff_g723_1_cos_tab[index] * (1 << 16);
-        int temp2  = (ff_g723_1_cos_tab[index + 1] - ff_g723_1_cos_tab[index]) *
+        int temp1     = cos_tab[index] * (1 << 16);
+        int temp2     = (cos_tab[index + 1] - cos_tab[index]) *
                           (((offset << 8) + 0x80) << 1);
 
         lpc[j] = -(av_sat_dadd32(1 << 15, temp1 + temp2) >> 16);
@@ -1286,16 +215,16 @@
     }
 
     /* Get the VQ table entry corresponding to the transmitted index */
-    cur_lsp[0] = ff_g723_1_lsp_band0[lsp_index[0]][0];
-    cur_lsp[1] = ff_g723_1_lsp_band0[lsp_index[0]][1];
-    cur_lsp[2] = ff_g723_1_lsp_band0[lsp_index[0]][2];
-    cur_lsp[3] = ff_g723_1_lsp_band1[lsp_index[1]][0];
-    cur_lsp[4] = ff_g723_1_lsp_band1[lsp_index[1]][1];
-    cur_lsp[5] = ff_g723_1_lsp_band1[lsp_index[1]][2];
-    cur_lsp[6] = ff_g723_1_lsp_band2[lsp_index[2]][0];
-    cur_lsp[7] = ff_g723_1_lsp_band2[lsp_index[2]][1];
-    cur_lsp[8] = ff_g723_1_lsp_band2[lsp_index[2]][2];
-    cur_lsp[9] = ff_g723_1_lsp_band2[lsp_index[2]][3];
+    cur_lsp[0] = lsp_band0[lsp_index[0]][0];
+    cur_lsp[1] = lsp_band0[lsp_index[0]][1];
+    cur_lsp[2] = lsp_band0[lsp_index[0]][2];
+    cur_lsp[3] = lsp_band1[lsp_index[1]][0];
+    cur_lsp[4] = lsp_band1[lsp_index[1]][1];
+    cur_lsp[5] = lsp_band1[lsp_index[1]][2];
+    cur_lsp[6] = lsp_band2[lsp_index[2]][0];
+    cur_lsp[7] = lsp_band2[lsp_index[2]][1];
+    cur_lsp[8] = lsp_band2[lsp_index[2]][2];
+    cur_lsp[9] = lsp_band2[lsp_index[2]][3];
 
     /* Add predicted vector & DC component to the previously quantized vector */
     for (i = 0; i < LPC_ORDER; i++) {
diff --git a/libavcodec/g723_1.h b/libavcodec/g723_1.h
index 521f220..d60d481 100644
--- a/libavcodec/g723_1.h
+++ b/libavcodec/g723_1.h
@@ -222,6 +222,11 @@
 static const uint8_t frame_size[4] = { 24, 20, 4, 1 };
 
 /**
+ * Postfilter gain weighting factors scaled by 2^15
+ */
+static const int16_t ppf_gain_weight[2] = {0x1800, 0x2000};
+
+/**
  * LSP DC component
  */
 static const int16_t dc_lsp[LPC_ORDER] = {
@@ -238,30 +243,1202 @@
 };
 
 /* Cosine table scaled by 2^14 */
-extern const int16_t ff_g723_1_cos_tab[COS_TBL_SIZE + 1];
-#define G723_1_COS_TAB_FIRST_ELEMENT 16384
+static const int16_t cos_tab[COS_TBL_SIZE + 1] = {
+    16384,  16383,  16379,  16373,  16364,  16353,  16340,  16324,
+    16305,  16284,  16261,  16235,  16207,  16176,  16143,  16107,
+    16069,  16029,  15986,  15941,  15893,  15843,  15791,  15736,
+    15679,  15619,  15557,  15493,  15426,  15357,  15286,  15213,
+    15137,  15059,  14978,  14896,  14811,  14724,  14635,  14543,
+    14449,  14354,  14256,  14155,  14053,  13949,  13842,  13733,
+    13623,  13510,  13395,  13279,  13160,  13039,  12916,  12792,
+    12665,  12537,  12406,  12274,  12140,  12004,  11866,  11727,
+    11585,  11442,  11297,  11151,  11003,  10853,  10702,  10549,
+    10394,  10238,  10080,   9921,   9760,   9598,   9434,   9269,
+     9102,   8935,   8765,   8595,   8423,   8250,   8076,   7900,
+     7723,   7545,   7366,   7186,   7005,   6823,   6639,   6455,
+     6270,   6084,   5897,   5708,   5520,   5330,   5139,   4948,
+     4756,   4563,   4370,   4176,   3981,   3786,   3590,   3393,
+     3196,   2999,   2801,   2603,   2404,   2205,   2006,   1806,
+     1606,   1406,   1205,   1005,    804,    603,    402,    201,
+        0,   -201,   -402,   -603,   -804,  -1005,  -1205,  -1406,
+    -1606,  -1806,  -2006,  -2205,  -2404,  -2603,  -2801,  -2999,
+    -3196,  -3393,  -3590,  -3786,  -3981,  -4176,  -4370,  -4563,
+    -4756,  -4948,  -5139,  -5330,  -5520,  -5708,  -5897,  -6084,
+    -6270,  -6455,  -6639,  -6823,  -7005,  -7186,  -7366,  -7545,
+    -7723,  -7900,  -8076,  -8250,  -8423,  -8595,  -8765,  -8935,
+    -9102,  -9269,  -9434,  -9598,  -9760,  -9921, -10080, -10238,
+   -10394, -10549, -10702, -10853, -11003, -11151, -11297, -11442,
+   -11585, -11727, -11866, -12004, -12140, -12274, -12406, -12537,
+   -12665, -12792, -12916, -13039, -13160, -13279, -13395, -13510,
+   -13623, -13733, -13842, -13949, -14053, -14155, -14256, -14354,
+   -14449, -14543, -14635, -14724, -14811, -14896, -14978, -15059,
+   -15137, -15213, -15286, -15357, -15426, -15493, -15557, -15619,
+   -15679, -15736, -15791, -15843, -15893, -15941, -15986, -16029,
+   -16069, -16107, -16143, -16176, -16207, -16235, -16261, -16284,
+   -16305, -16324, -16340, -16353, -16364, -16373, -16379, -16383,
+   -16384, -16383, -16379, -16373, -16364, -16353, -16340, -16324,
+   -16305, -16284, -16261, -16235, -16207, -16176, -16143, -16107,
+   -16069, -16029, -15986, -15941, -15893, -15843, -15791, -15736,
+   -15679, -15619, -15557, -15493, -15426, -15357, -15286, -15213,
+   -15137, -15059, -14978, -14896, -14811, -14724, -14635, -14543,
+   -14449, -14354, -14256, -14155, -14053, -13949, -13842, -13733,
+   -13623, -13510, -13395, -13279, -13160, -13039, -12916, -12792,
+   -12665, -12537, -12406, -12274, -12140, -12004, -11866, -11727,
+   -11585, -11442, -11297, -11151, -11003, -10853, -10702, -10549,
+   -10394, -10238, -10080,  -9921,  -9760,  -9598,  -9434,  -9269,
+    -9102,  -8935,  -8765,  -8595,  -8423,  -8250,  -8076,  -7900,
+    -7723,  -7545,  -7366,  -7186,  -7005,  -6823,  -6639,  -6455,
+    -6270,  -6084,  -5897,  -5708,  -5520,  -5330,  -5139,  -4948,
+    -4756,  -4563,  -4370,  -4176,  -3981,  -3786,  -3590,  -3393,
+    -3196,  -2999,  -2801,  -2603,  -2404,  -2205,  -2006,  -1806,
+    -1606,  -1406,  -1205,  -1005,   -804,   -603,   -402,   -201,
+        0,    201,    402,    603,    804,   1005,   1205,   1406,
+     1606,   1806,   2006,   2205,   2404,   2603,   2801,   2999,
+     3196,   3393,   3590,   3786,   3981,   4176,   4370,   4563,
+     4756,   4948,   5139,   5330,   5520,   5708,   5897,   6084,
+     6270,   6455,   6639,   6823,   7005,   7186,   7366,   7545,
+     7723,   7900,   8076,   8250,   8423,   8595,   8765,   8935,
+     9102,   9269,   9434,   9598,   9760,   9921,  10080,  10238,
+    10394,  10549,  10702,  10853,  11003,  11151,  11297,  11442,
+    11585,  11727,  11866,  12004,  12140,  12274,  12406,  12537,
+    12665,  12792,  12916,  13039,  13160,  13279,  13395,  13510,
+    13623,  13733,  13842,  13949,  14053,  14155,  14256,  14354,
+    14449,  14543,  14635,  14724,  14811,  14896,  14978,  15059,
+    15137,  15213,  15286,  15357,  15426,  15493,  15557,  15619,
+    15679,  15736,  15791,  15843,  15893,  15941,  15986,  16029,
+    16069,  16107,  16143,  16176,  16207,  16235,  16261,  16284,
+    16305,  16324,  16340,  16353,  16364,  16373,  16379,  16383,
+    16384
+};
 
 /**
  *  LSP VQ tables
  */
-extern const int16_t ff_g723_1_lsp_band0[LSP_CB_SIZE][3];
-extern const int16_t ff_g723_1_lsp_band1[LSP_CB_SIZE][3];
-extern const int16_t ff_g723_1_lsp_band2[LSP_CB_SIZE][4];
+static const int16_t lsp_band0[LSP_CB_SIZE][3] = {
+    {    0,      0,      0}, { -270,  -1372,  -1032}, { -541,  -1650,  -1382},
+    { -723,  -2011,  -2213}, { -941,  -1122,  -1942}, { -780,  -1145,  -2454},
+    { -884,  -1309,  -1373}, {-1051,  -1523,  -1766}, {-1083,  -1622,  -2300},
+    { -777,  -1377,  -2147}, { -935,  -1467,  -2763}, { -802,  -1327,  -3471},
+    { -935,  -1959,  -3999}, { -240,    -89,    222}, { -661,   -257,   -160},
+    { -994,   -466,   -419}, { -188,   -164,   -278}, { -342,   -512,   -415},
+    { -607,   -511,   -797}, {   16,     19,   -716}, {  374,    425,   -972},
+    { -346,    245,   -282}, { -265,    506,   -754}, { -620,   -147,   1955},
+    { -742,   -860,   2597}, { -150,   -352,   2704}, {  305,    880,   1954},
+    {  123,    731,   2766}, { -348,    765,   3327}, {  618,    221,   3258},
+    { -178,    -47,   4219}, {  393,   1304,   3842}, {  698,   1702,   4801},
+    {   63,   -584,   1229}, { -215,   -732,   1704}, {  172,   -335,   1909},
+    {   -2,    216,   1797}, {  353,    127,   2205}, {-1208,    188,     11},
+    { -513,    -75,   -683}, { -973,    222,   -646}, { -616,   -843,   -388},
+    { -950,  -1113,   -359}, {-1431,   -623,   -705}, {-1398,  -1063,   -178},
+    {  -45,   -461,     35}, {   -9,   -657,   -216}, {  127,  -1078,     95},
+    { -950,  -1156,    584}, {-1480,  -1494,    449}, { -120,   -705,    516},
+    { -368,   -961,    727}, { -378,   -526,    973}, { -793,   -614,    676},
+    { -801,   -755,   1287}, {-1476,   -340,   1636}, { -505,  -1254,   1543},
+    {-1243,  -1622,   1532}, { -776,  -1477,   -655}, {-1151,  -1296,   -823},
+    {-1153,  -1672,  -1124}, {-1291,  -2003,  -1702}, { -622,  -1283,     57},
+    { -471,  -1611,    509}, {-1060,  -1570,   -139}, { -873,  -2156,   -536},
+    {-1716,  -2021,   -364}, {-2150,  -3218,  -1291}, {-1248,  -1945,  -2904},
+    {-1215,  -2633,  -2855}, {  167,   -244,     84}, {  349,   -412,   -217},
+    {  -40,   -352,    632}, {  227,   -529,    405}, {   68,   -383,   -443},
+    {  167,   -558,   -706}, { -275,   -854,    -14}, { -351,  -1089,   -449},
+    {  341,    -72,   -289}, {  603,   -106,   -474}, {  322,   -219,   -649},
+    {  179,   -317,   -998}, {  450,   -291,   -996}, {  555,    195,   -525},
+    {  784,    272,   -831}, { -148,   -384,   -849}, {   82,   -536,  -1357},
+    {  238,   -172,  -1354}, {  422,   -268,  -1841}, {  297,   -737,  -2079},
+    { -111,   -801,   -598}, {    1,   -668,   -984}, { -131,   -818,  -1299},
+    { -329,   -521,  -1310}, { -151,   -778,  -1834}, {  -93,   -352,  -1746},
+    { -568,   -640,  -1821}, { -509,   -941,  -2183}, {  464,   -815,  -1250},
+    {   79,  -1133,  -1597}, { -184,  -1353,  -2123}, { -196,   -410,  -2427},
+    { -192,   -833,  -2810}, { -259,  -1382,  -3045}, { -217,      4,  -1166},
+    { -800,   -325,  -1219}, { -363,   -830,   -898}, { -661,  -1134,   -960},
+    { -386,   -980,  -1501}, { -627,  -1159,  -1722}, { -903,   -829,   -855},
+    { -685,   -829,  -1313}, {-1065,   -959,  -1405}, {  441,     25,   -847},
+    {  655,    -27,  -1181}, { 1159,   -110,   -705}, {  856,    253,  -1671},
+    {  415,    404,     -1}, {  322,    903,   -398}, {  670,    499,   -292},
+    {  803,    591,   -610}, { 1144,    591,   -814}, {  717,    183,    393},
+    {  857,    381,    106}, {  609,     62,    -27}, {  792,    198,   -325},
+    {  735,    805,     88}, { 1142,    812,     78}, { 1028,    366,   -292},
+    { 1309,    743,   -237}, { 1615,    589,    -79}, { 1010,    639,   -243},
+    {  999,    964,   -311}, { 1500,   1137,   -615}, {  988,    357,    646},
+    { 1227,    667,    683}, { 1164,   1565,    894}, { 1392,   2015,    477},
+    { 1138,    533,    250}, { 1437,    896,    391}, { 1765,   1118,     99},
+    { 1112,   1090,    802}, { 1596,    846,   1134}, {  937,   1161,    279},
+    { 1719,   1254,    683}, { 1338,   1086,     35}, { 1419,   1324,    428},
+    { 1428,   1524,     40}, { 2108,   1594,     89}, { 1015,    544,   1222},
+    { 1121,    925,   1263}, { 1030,   1318,   1485}, { 1295,    789,   1817},
+    { 1323,   1272,   1909}, { 1724,   1237,   1803}, { 1797,   1689,    858},
+    { 2149,   1367,   1301}, { 2302,   1867,    761}, { 2863,   2351,   1053},
+    {   52,    163,    -76}, {  230,    309,   -492}, {  -71,    619,     39},
+    { -218,    856,    499}, { -654,    736,   -207}, { -535,   1259,    155},
+    { -480,   1476,    643}, {  262,   1081,    102}, {  309,   1592,   -182},
+    {  627,   1629,    534}, {  337,    643,    456}, {  758,    670,    713},
+    {  202,   1126,    658}, {  612,   1131,    666}, {  686,   1223,   1136},
+    { -131,    377,    525}, {   42,    708,    907}, {   87,   1488,   1035},
+    {  432,   2117,    904}, {  137,    981,   1332}, { -447,   1014,   1136},
+    { -839,   1793,   1246}, { -559,    297,    198}, { -850,    685,    446},
+    {-1273,    632,    826}, { -401,   -544,    173}, { -753,   -793,    144},
+    { -436,     -9,    772}, { -115,   -243,   1310}, { -670,   -269,    374},
+    {-1027,    -13,    639}, { -887,    -81,   1137}, {-1277,   -455,    158},
+    {-1411,   -720,    736}, {  172,     88,    403}, {  386,    255,    756},
+    { -500,    522,    910}, { -958,    659,   1388}, { -395,    301,   1344},
+    { -356,    768,   1813}, { -613,    841,   2419}, {  445,   -122,    252},
+    {  629,    -87,    723}, {  283,   -253,    870}, {  456,   -116,   1381},
+    {  757,    180,   1059}, {  532,    408,   1509}, {  947,    288,   1806},
+    { 1325,    994,   2524}, {  892,   1219,   3023}, { 1397,   1596,   3406},
+    { 1143,   1552,   2546}, { 1850,   1433,   2710}, {  -10,    134,   1002},
+    {  154,    499,   1323}, {  508,    792,   1117}, {  509,   1340,   1616},
+    {  762,    862,   1608}, {  787,    740,   2320}, {  794,   1727,   1283},
+    {  465,   2108,   1660}, { -120,   1451,   1613}, { -386,   2016,   2169},
+    {  891,   1225,   2050}, {  456,   1480,   2185}, { 1493,   1283,   1209},
+    { 1397,   1636,   1518}, { 1776,   1738,   1552}, { 1572,   1698,   2141},
+    { 1389,   2126,   1271}, { 1959,   2413,   1119}, { 1365,   2892,   1505},
+    { 2206,   1971,   1623}, { 2076,   1950,   2280}, { 1717,   2291,   1867},
+    { 2366,   2515,   1953}, { 2865,   2838,   2522}, { 2535,   3465,   2011},
+    { 3381,   4127,   2638}, {  836,   2667,   2289}, { 1761,   2773,   2337},
+    { 1415,   3325,   2911}, { 2354,   3138,   3126}, { 2659,   4192,   4010},
+    { 1048,   1786,   1818}, { 1242,   2111,   2240}, { 1512,   2079,   2780},
+    { 1573,   2491,   3138}, { 2230,   2377,   2782}, {  416,   1773,   2704},
+    {  725,   2336,   3297}, { 1252,   2373,   3978}, { 2094,   2268,   3568},
+    { 2011,   2712,   4528}, { 1341,   3507,   3876}, { 1216,   3919,   4922},
+    { 1693,   4793,   6012}
+};
+
+static const int16_t lsp_band1[LSP_CB_SIZE][3] = {
+    {    0,      0,      0}, {-2114,  -1302,     76}, {-2652,  -1278,  -1368},
+    {-2847,   -828,   -349}, {-3812,  -2190,   -349}, {-3946,   -364,   -449},
+    {-2725,  -4492,  -3607}, {-3495,  -4764,  -1744}, {  -51,   -756,     84},
+    { -153,  -1191,    504}, {  108,  -1418,   1167}, { -835,   -896,    390},
+    { -569,  -1702,     87}, {-1151,  -1818,    933}, {-1826,  -2547,    411},
+    {-1842,  -1818,   1451}, {-2438,  -1611,    781}, {-2747,  -2477,   1311},
+    { -940,   1252,    477}, {-1629,   1688,    602}, {-1202,    617,    280},
+    {-1737,    393,    580}, {-1528,   1077,   1199}, {-2165,   -161,   1408},
+    {-2504,  -1087,   2371}, {-3458,   -175,   1395}, {-1397,    -98,   -843},
+    {-2252,   -177,  -1149}, {-1489,   -726,  -1283}, {-1558,   -265,  -1744},
+    {-1867,   -821,  -1897}, {-2062,  -1516,  -2340}, {-2595,  -1142,  -2861},
+    {  170,     46,   -819}, { -193,   -204,  -1151}, {  326,   -196,  -1532},
+    {  780,    329,   -816}, {  201,    369,  -1243}, {  650,   -209,  -1060},
+    { 1144,    -15,  -1216}, { 1203,   -259,  -1867}, { -890,   -564,  -1430},
+    { -638,   -852,  -1921}, {  177,   -739,  -1358}, { -261,   -526,  -1666},
+    {  206,   -407,  -2255}, {  338,   -526,   -822}, {  421,  -1095,  -1009},
+    {  765,   -607,  -1408}, {  825,  -1295,  -2004}, {  357,   -905,  -1815},
+    {  -58,  -1248,  -1588}, { -596,  -1436,  -2046}, {  -73,  -1159,  -2116},
+    { -115,  -1382,  -2581}, { -160,  -1723,  -1952}, {   -6,  -2196,  -2954},
+    { -649,  -1705,  -2603}, { -617,  -1453,  -3282}, { -949,  -2019,  -3102},
+    { -812,   1544,   1937}, {-1854,    574,   2000}, {-1463,   1140,   2649},
+    {-2683,   1748,   1452}, {-2486,   2241,   2523}, {  783,   1910,   1435},
+    {  581,   2682,   1376}, {  236,   2197,   1885}, { -453,   2943,   2057},
+    { -682,   2178,   2565}, {-1342,   3201,   3328}, { -288,   -184,    262},
+    {  121,   -149,   -183}, {  758,   -412,    206}, { 1038,   -204,    853},
+    { 1577,   -457,    700}, {  937,   -640,   -567}, { 1508,   -528,  -1024},
+    { -225,   -527,   -427}, { -564,  -1095,   -332}, { -742,   -353,   -186},
+    {-1288,   -459,     84}, {-1853,   -484,   -274}, {-1554,   -731,    825},
+    {-2425,   -234,    382}, {-1722,    293,   -271}, {-2515,    425,   -564},
+    {-2599,    818,    464}, { -358,    118,   -375}, { -613,    198,   -874},
+    { -690,    683,   -324}, {-1352,   1155,   -168}, {-1093,    129,   -324},
+    {-1184,    611,   -858}, {  433,    386,   -372}, { -120,    486,   -634},
+    {  234,    851,   -631}, {  602,    128,     46}, { 1099,    410,    159},
+    {  715,   -145,   -424}, { 1198,    -85,   -593}, { 1390,    367,   -358},
+    { 1683,    362,   -964}, { 1711,    622,     45}, { 2033,    833,   -383},
+    { 2890,    549,   -506}, {    7,    401,     52}, {   72,    811,    415},
+    {  566,    668,     41}, {  467,   1218,    130}, {   68,    957,   -187},
+    {  -25,   1649,   -103}, { -661,    260,    214}, { -925,    -94,    612},
+    { -321,   -422,    965}, { -788,   -672,   1783}, {  400,   -673,    779},
+    {  741,   -595,   1635}, { -161,    307,    657}, { -382,    836,    871},
+    { -814,    400,   1223}, {  364,    606,   1247}, {   57,     75,   1571},
+    {  151,    471,   2287}, {  -81,   1021,   1502}, {  227,   1470,   1097},
+    {  658,   1275,   1653}, {  664,   1478,   2377}, {  263,   -127,    444},
+    {  264,     89,    969}, {  794,    171,    576}, {  821,    186,   1226},
+    {  404,    462,    517}, {  339,    918,    794}, { 1280,   1423,    196},
+    { 1453,   2019,    365}, { 1615,   1481,    672}, { 2394,   1708,    508},
+    {  806,   1238,    573}, {  713,   1158,   1078}, { 1285,   1436,   1232},
+    { 1790,   1188,   1141}, {  765,    643,    864}, { 1032,    797,   1279},
+    {  900,    563,   1827}, { 1514,    673,   2312}, { 1544,   1129,   3240},
+    { 1469,   1050,   1594}, { 1945,   1318,   1988}, { 2397,   2026,   2060},
+    { 3538,   2057,   2620}, { 1249,   -118,     74}, { 1727,    194,    421},
+    { 2078,    -50,   -463}, {  970,    688,   -432}, { 1149,    952,   -110},
+    { 1254,   1275,   -651}, { 1386,    929,    401}, { 1960,   1167,    232},
+    {  407,   -752,   -243}, {  859,  -1118,    172}, { -227,   -860,   -992},
+    { -796,  -1175,  -1380}, {    8,  -1282,   -388}, {  353,  -1781,  -1037},
+    { -732,   -397,   -807}, { -853,    -28,  -1342}, {-1229,  -1207,  -1959},
+    {-1015,  -1125,  -2543}, {-1452,  -1791,  -2725}, {-1891,  -2416,  -3269},
+    { -918,  -1629,   -783}, { -580,  -2155,   -698}, {-1097,  -2364,    -96},
+    {-1387,  -1513,      7}, {-1588,  -2076,   -664}, {-1473,  -2740,   -784},
+    {-2378,  -3149,    -56}, {-2856,  -2092,   -169}, {-3391,  -3708,    316},
+    {-1176,   -890,   -614}, {-1944,  -1061,   -800}, { -299,  -1517,  -1000},
+    { -640,  -1850,  -1526}, {-1454,  -1536,  -1233}, {-1890,  -1955,  -1756},
+    {-1086,  -1921,  -2122}, { -750,  -2325,  -2260}, {-1325,  -2413,  -2673},
+    {-1114,  -2542,  -3459}, {-1341,  -2901,  -3963}, {-1160,  -2226,  -1393},
+    {-1001,  -2772,  -1573}, {-1594,  -2641,  -1978}, {-1534,  -3046,  -2624},
+    {-2224,  -2196,   -675}, {-2807,  -3054,  -1102}, {-2008,  -2840,  -1186},
+    {-1980,  -3332,  -1695}, {-1715,  -3562,   -505}, {-2527,  -4000,  -1887},
+    {-2333,  -2734,  -2296}, {-3440,  -2401,  -3211}, {-2008,  -3528,  -3337},
+    {-2247,  -3291,  -4510}, { -475,    949,    155}, { -149,   1365,    545},
+    { -757,   1644,   1083}, { -217,   2053,   1353}, {-1433,   2301,   1462},
+    {  495,   1661,    529}, {   10,   2037,    740}, { 2082,   1898,    978},
+    { 2831,   2294,    911}, {  842,    793,    420}, { 1223,   1023,    863},
+    { 1237,    451,    780}, { 1744,    708,    822}, { 1533,    284,   1384},
+    { 2135,    609,   1538}, { 2305,    626,    540}, { 2368,   1187,    955},
+    { 2586,   1255,     -7}, { 3116,   1131,    726}, { 3431,   1730,    428},
+    { 2734,   1648,   1307}, { 2988,   1231,   2010}, { 3523,   2024,   1488},
+    { 1034,   1657,    871}, { 1206,   2163,   1036}, { 1807,   2372,   1233},
+    { 1808,   1769,   1493}, { 1573,   2332,   1779}, { 1216,   1609,   1866},
+    { 1480,   1898,   2513}, {  465,   2708,   2776}, {  771,   3638,   3338},
+    { 1869,   2599,   2623}, { 2825,   2745,   2468}, { 2638,   2439,   1585},
+    { 2094,   2970,   1308}, { 2022,   3057,   1999}, { 3428,   2912,   1816},
+    { 4536,   2974,   2129}, { 1046,   2563,   2086}, { 1363,   3562,   2318},
+    { 2511,   1891,   2984}, { 1866,   2306,   3986}, { 3272,   2924,   3682},
+    { 3146,   3564,   2272}, { 3592,   3968,   2822}, { 2431,   3369,   3069},
+    { 1931,   4709,   3090}, { 2629,   4220,   3986}, { 4639,   4056,   3664},
+    { 4035,   5334,   4912}
+};
+
+static const int16_t lsp_band2[LSP_CB_SIZE][4] = {
+    {    0,      0,      0,      0}, {  601,    512,   -542,    334},
+    {  428,   1087,   -484,   -132}, {  652,    622,   -391,   -572},
+    {  378,    799,    141,   -860}, { 1040,    409,    112,   -554},
+    { 1123,    670,    -75,   -847}, { 1421,    494,   -315,  -1095},
+    {  787,   1001,    114,   -460}, {  988,   1672,    216,   -681},
+    { 1007,   1241,   -132,  -1247}, { 1073,    399,    186,     -5},
+    { 1262,    193,   -694,   -129}, {  325,    196,     51,   -641},
+    {  861,    -59,    350,   -458}, { 1261,    567,    586,   -346},
+    { 1532,    885,    210,   -517}, { 2027,    937,    113,   -792},
+    { 1383,   1064,    334,     38}, { 1964,   1468,    459,    133},
+    { 2062,   1186,    -98,   -121}, { 2577,   1445,    506,   -373},
+    { 2310,   1682,     -2,   -960}, { 2876,   1939,    765,    138},
+    { 3581,   2360,    649,   -414}, {  219,    176,   -398,   -309},
+    {  434,    -78,   -435,   -880}, { -344,    301,    265,   -552},
+    { -915,    470,    657,   -380}, {  419,   -432,   -163,   -453},
+    {  351,   -953,      8,   -562}, {  789,    -43,     20,   -958},
+    {  302,   -594,   -352,  -1159}, { 1040,    108,   -668,   -924},
+    { 1333,    210,  -1217,  -1663}, {  483,    589,   -350,  -1140},
+    { 1003,    824,   -802,  -1184}, {  745,     58,   -589,  -1443},
+    {  346,    247,   -915,  -1683}, {  270,    796,   -720,  -2043},
+    { 1208,    722,   -222,   -193}, { 1486,   1180,   -412,   -672},
+    { 1722,    179,    -69,   -521}, { 2047,    860,   -666,  -1410},
+    { -146,    222,   -281,   -805}, { -189,     90,   -114,  -1307},
+    { -152,   1086,   -241,   -764}, { -439,    733,   -601,  -1302},
+    { -833,   -167,   -351,   -601}, { -856,   -422,   -411,  -1059},
+    { -747,   -355,   -582,  -1644}, { -837,    210,   -916,  -1144},
+    {-1800,     32,   -878,  -1687}, {  -48,    -23,  -1146,     52},
+    { -350,   -409,  -1656,   -364}, {  265,   -728,   -858,   -577},
+    {  458,   -247,  -1141,   -997}, {  691,   -407,  -1988,  -1161},
+    {  -66,   -104,   -705,  -1249}, { -431,    -93,  -1191,  -1844},
+    {  203,   -732,  -1000,  -1693}, {   10,   -832,  -1846,  -1819},
+    {  493,   -128,  -1436,  -1768}, {  488,   -311,  -1730,  -2540},
+    { -653,   -532,  -1150,  -1172}, {-1086,   -289,  -1706,  -1533},
+    { -699,  -1205,  -1216,  -1766}, {-1032,  -1481,  -2074,  -1523},
+    { -721,  -1220,  -2277,  -2600}, {   12,   -539,  -1484,  -1131},
+    {  -40,   -911,  -2106,   -441}, { -471,   -484,  -2267,  -1549},
+    { -141,   -988,  -3006,  -1721}, {-1545,  -2102,   -583,    342},
+    {-1383,  -2772,   -386,    -13}, {-2118,  -2589,  -1205,     72},
+    {-2147,  -3231,   -965,    390}, {-2949,  -3300,   -621,    637},
+    {-3907,  -4138,   -865,    803}, {-1287,   -845,   -375,   -548},
+    {-1416,  -1169,   -487,  -1277}, {-1400,  -1690,  -1027,   -418},
+    {-2018,  -1909,  -1188,  -1260}, {-1418,  -2222,  -2029,   -128},
+    {-2067,  -2998,  -2693,   -310}, { -950,  -1028,  -1538,    185},
+    {-1616,   -915,  -2205,   -549}, {   19,   -821,  -1145,    352},
+    {  184,  -1175,  -1356,   -627}, { -547,  -1088,  -1661,   -911},
+    { -216,  -1502,  -2197,   -948}, { -795,  -1306,  -2374,   -451},
+    { -924,  -1889,  -2796,   -680}, { -600,  -1614,  -3609,   -885},
+    {-2392,  -2528,    319,    303}, {-2908,  -2095,   -310,    573},
+    {-3460,  -2141,     49,   -113}, {-2231,   -448,    675,   -146},
+    {-2805,   -532,   1231,    479}, {-2684,   -486,   -200,    611},
+    {-3525,   -971,   -198,    704}, {-3707,    173,    349,    254},
+    {-4734,  -1447,    -34,    880}, {  777,   -512,    114,    -10},
+    { 1250,    -66,    442,     -5}, {  604,    613,    452,   -352},
+    { 1224,    777,    675,  -1014}, {-1372,    -79,  -1208,   -238},
+    {-2389,    -17,  -1157,   -818}, {-1504,   -673,  -1133,  -1060},
+    {-1984,   -799,  -2005,  -1973}, {-2037,   -798,  -1068,   -105},
+    {-3190,   -899,  -1817,   -194}, { -156,   -886,    394,   -318},
+    { -258,  -1283,    551,    202}, { -536,  -1729,    910,    331},
+    { -847,  -1109,    795,   -163}, {-1171,  -1128,    715,    519},
+    {-1080,  -1319,   1685,    668}, {-1000,  -1921,     96,    211},
+    {-1487,  -2148,    831,    174}, {-1139,   -374,    414,     -4},
+    {-1517,  -1383,    396,   -352}, {-1012,    439,    -59,   -967},
+    {-1812,    706,   -440,  -1030}, {-1971,   -329,    -34,   -827},
+    {-2472,  -1588,   -151,   -606}, {-2161,    374,   -281,     76},
+    {-3012,    231,    -15,   -690}, { 1104,    566,    721,    209},
+    { 1685,    564,    383,     98}, { 1898,    750,    792,    -97},
+    {  556,    -64,    561,    -93}, {  876,    162,    913,    -22},
+    {  961,    675,   1296,    140}, {  756,   -396,    851,    544},
+    {  360,   -303,   1341,    396}, {  878,    -22,   1464,    863},
+    { -309,   -273,    642,   -129}, { -686,    -82,    842,    454},
+    {   -5,    -47,   1069,    998}, {  -94,    967,   1277,    298},
+    { -489,    385,   1473,    746}, { -369,   -717,   1333,    242},
+    {  281,   -993,   1726,    924}, {  464,    601,   1575,   1376},
+    { -250,    206,   2339,   1175}, { -438,    377,   -597,   -285},
+    {-1020,    787,   -790,   -287}, { -458,   -410,    215,    295},
+    { -589,   -860,   -121,    797}, {-1175,    122,   -437,    466},
+    {-1480,   -121,    367,    924}, {  234,    323,    770,   -555},
+    {  145,     30,    996,     26}, {   66,    849,     93,   -145},
+    { -117,   1261,    474,   -399}, {-1495,   1051,    218,   -506},
+    {-1390,    694,    994,     88}, {  616,      7,     78,    304},
+    { 1060,     52,    -62,    835}, {  833,    454,    649,   1359},
+    { -770,    464,     47,     93}, { -574,   1199,    -39,    379},
+    {  114,    -98,    488,    485}, {  727,    244,    606,    696},
+    {  -76,    455,    671,    546}, { -565,    -13,    145,    819},
+    { -376,    569,    448,   1128}, {  218,    122,    265,   1167},
+    {  230,    738,    932,   1003}, {  138,    477,     36,    450},
+    {  404,    787,    -73,   1000}, {  497,   1259,    387,   1231},
+    {   17,    207,    195,    -79}, {  562,    358,     53,   -158},
+    {  493,    387,    478,    189}, {  678,    831,    640,    558},
+    { -197,    523,    613,     57}, {  429,    894,    769,    111},
+    {   67,   1174,    568,    511}, { 1242,    824,    251,    840},
+    { 1419,   1074,    864,    481}, {  924,   1474,    669,    724},
+    { 1539,   1879,    654,   1590}, {  445,    337,   1111,    541},
+    {  472,   1421,   1264,   1094}, {  794,    735,   1103,    668},
+    { 1055,    863,   1192,   1020}, {  778,   1105,    806,   1798},
+    { 1052,   1527,   1587,   2151}, {  881,   1552,   1265,    391},
+    {  726,    872,   1812,    601}, { 1469,    280,   1008,    616},
+    { 1403,    577,   1803,   1244}, { 1650,   1314,   1148,   1072},
+    { 1297,   1669,   1911,   1026}, { 2093,   1044,   2115,   1189},
+    { 1644,   1961,   2587,   1512}, {   25,   -315,     -9,   -106},
+    {  290,   -339,    428,   -444}, {  -68,   -783,    735,    772},
+    {  245,   -555,    468,     47}, {  334,   -895,    814,    146},
+    {  235,    368,   -964,   -959}, { -203,    315,  -1566,  -1217},
+    {  801,     17,   -276,   -354}, {  894,   -495,   -789,   -635},
+    {  716,    291,  -1189,   -357}, {  560,   -260,   -733,     -2},
+    {  679,   -508,  -1429,    211}, {  -51,    -62,   -428,    557},
+    {  322,   -638,   -211,    614}, { -878,  -1057,    -84,    -71},
+    { -388,  -1415,   -167,   -318}, { -754,  -1574,    214,   -539},
+    {-1419,  -2004,    -92,   -787}, {  -47,   -856,   -347,   -255},
+    {   23,  -1211,   -173,    320}, { -658,   -487,   -893,    353},
+    { -783,  -1587,   -584,    507}, {-1420,   -859,   -378,    441},
+    {-2095,  -1491,   -137,    439}, { -321,  -1450,  -1288,    -12},
+    { -359,  -2113,   -553,     -8}, { -831,  -1918,  -1561,     32},
+    {-1014,  -2487,  -1359,   -939}, { -475,   -311,   -169,   -236},
+    { -907,   -426,    276,   -611}, {  -96,   -400,     50,   -710},
+    { -426,  -1022,    -10,   -985}, { -197,   -258,   -744,   -575},
+    { -611,   -930,   -771,   -394}, { -267,   -776,   -612,   -939},
+    { -256,  -1346,   -802,  -1122}, { -796,  -1570,   -825,   -754},
+    {  712,    876,    141,    227}, {  981,   1509,     85,    124},
+    { 1462,   1228,    979,    -39}, { 1734,    999,   1481,    440},
+    { 2293,   1116,    769,    440}, { 2504,   1480,   1241,    356},
+    { 2474,   1909,   1558,    810}, {  917,   1134,    607,   -134},
+    {  509,   1809,    781,   -123}, { 1712,   1506,    559,   -423},
+    { 2037,   2317,    726,   -155}, { 3031,   2676,   1203,    331},
+    { 3664,   3274,   1768,    531}, { 1610,   1839,    867,    183},
+    { 1774,   1972,   1538,     97}, { 1822,   2158,   1282,    659},
+    { 2222,   2758,   1818,    900}, { 3251,   2124,   1723,    996},
+    { 3633,   2336,   2408,   1453}, { 2923,   3517,   2567,   1318},
+};
 
 /**
  * Used for the coding/decoding of the pulses positions
  * for the MP-MLQ codebook
  */
-extern const int32_t ff_g723_1_combinatorial_table[PULSE_MAX][SUBFRAME_LEN/GRID_SIZE];
+static const int32_t combinatorial_table[PULSE_MAX][SUBFRAME_LEN/GRID_SIZE] = {
+    {118755, 98280, 80730,  65780, 53130,
+      42504, 33649, 26334,  20349, 15504,
+      11628,  8568,  6188,   4368,  3003,
+       2002,  1287,   792,    462,   252,
+        126,    56,    21,      6,     1,
+          0,     0,     0,      0,     0},
+
+    { 23751, 20475, 17550,  14950, 12650,
+      10626,  8855,  7315,   5985,  4845,
+       3876,  3060,  2380,   1820,  1365,
+       1001,   715,   495,    330,   210,
+        126,    70,    35,     15,     5,
+          1,     0,     0,      0,     0},
+
+    {  3654,  3276,  2925,   2600,  2300,
+       2024,  1771,  1540,   1330,  1140,
+        969,   816,   680,    560,   455,
+        364,   286,   220,    165,   120,
+         84,    56,    35,     20,    10,
+          4,     1,     0,      0,     0},
+
+    {   406,   378,   351,    325,   300,
+        276,   253,   231,    210,   190,
+        171,   153,   136,    120,   105,
+         91,    78,    66,     55,    45,
+         36,    28,    21,     15,    10,
+          6,     3,     1,      0,     0},
+
+    {    29,    28,    27,     26,    25,
+         24,    23,    22,     21,    20,
+         19,    18,    17,     16,    15,
+         14,    13,    12,     11,    10,
+          9,     8,     7,      6,     5,
+          4,     3,     2,      1,     0},
+
+    {     1,     1,     1,      1,     1,
+          1,     1,     1,      1,     1,
+          1,     1,     1,      1,     1,
+          1,     1,     1,      1,     1,
+          1,     1,     1,      1,     1,
+          1,     1,     1,      1,     1},
+};
+
+static const int16_t pitch_contrib[340] = {
+    60,     0,  0,  2489, 60,     0,  0,  5217,
+     1,  6171,  0,  3953,  0, 10364,  1,  9357,
+    -1,  8843,  1,  9396,  0,  5794, -1, 10816,
+     2, 11606, -2, 12072,  0,  8616,  1, 12170,
+     0, 14440,  0,  7787, -1, 13721,  0, 18205,
+     0, 14471,  0, 15807,  1, 15275,  0, 13480,
+    -1, 18375, -1,     0,  1, 11194, -1, 13010,
+     1, 18836, -2, 20354,  1, 16233, -1,     0,
+    60,     0,  0, 12130,  0, 13385,  1, 17834,
+     1, 20875,  0, 21996,  1,     0,  1, 18277,
+    -1, 21321,  1, 13738, -1, 19094, -1, 20387,
+    -1,     0,  0, 21008, 60,     0, -2, 22807,
+     0, 15900,  1,     0,  0, 17989, -1, 22259,
+     1, 24395,  1, 23138,  0, 23948,  1, 22997,
+     2, 22604, -1, 25942,  0, 26246,  1, 25321,
+     0, 26423,  0, 24061,  0, 27247, 60,     0,
+    -1, 25572,  1, 23918,  1, 25930,  2, 26408,
+    -1, 19049,  1, 27357, -1, 24538, 60,     0,
+    -1, 25093,  0, 28549,  1,     0,  0, 22793,
+    -1, 25659,  0, 29377,  0, 30276,  0, 26198,
+     1, 22521, -1, 28919,  0, 27384,  1, 30162,
+    -1,     0,  0, 24237, -1, 30062,  0, 21763,
+     1, 30917, 60,     0,  0, 31284,  0, 29433,
+     1, 26821,  1, 28655,  0, 31327,  2, 30799,
+     1, 31389,  0, 32322,  1, 31760, -2, 31830,
+     0, 26936, -1, 31180,  1, 30875,  0, 27873,
+    -1, 30429,  1, 31050,  0,     0,  0, 31912,
+     1, 31611,  0, 31565,  0, 25557,  0, 31357,
+    60,     0,  1, 29536,  1, 28985, -1, 26984,
+    -1, 31587,  2, 30836, -2, 31133,  0, 30243,
+    -1, 30742, -1, 32090, 60,     0,  2, 30902,
+    60,     0,  0, 30027,  0, 29042, 60,     0,
+     0, 31756,  0, 24553,  0, 25636, -2, 30501,
+    60,     0, -1, 29617,  0, 30649, 60,     0,
+     0, 29274,  2, 30415,  0, 27480,  0, 31213,
+    -1, 28147,  0, 30600,  1, 31652,  2, 29068,
+    60,     0,  1, 28571,  1, 28730,  1, 31422,
+     0, 28257,  0, 24797, 60,     0,  0,     0,
+    60,     0,  0, 22105,  0, 27852, 60,     0,
+    60,     0, -1, 24214,  0, 24642,  0, 23305,
+    60,     0, 60,     0,  1, 22883,  0, 21601,
+    60,     0,  2, 25650, 60,     0, -2, 31253,
+    -2, 25144,  0, 17998
+};
 
 /**
  * Number of non-zero pulses in the MP-MLQ excitation
  */
 static const int8_t pulses[4] = {6, 5, 6, 5};
 
-extern const int16_t ff_g723_1_fixed_cb_gain[GAIN_LEVELS];
+/**
+ * Size of the MP-MLQ fixed excitation codebooks
+ */
+static const int32_t max_pos[4] = {593775, 142506, 593775, 142506};
 
-extern const int16_t ff_g723_1_adaptive_cb_gain85 [ 85 * 20];
-extern const int16_t ff_g723_1_adaptive_cb_gain170[170 * 20];
+static const int16_t fixed_cb_gain[GAIN_LEVELS] = {
+      1,    2,    3,    4,    6,    9,   13,   18,
+     26,   38,   55,   80,  115,  166,  240,  348,
+    502,  726, 1050, 1517, 2193, 3170, 4582, 6623,
+};
+
+static const int16_t adaptive_cb_gain85[85 * 20] = {
+        0,      0,      0,      0,      0,      0,      0,      0,
+        0,      0,      0,      0,      0,      0,      0,      0,
+        0,      0,      0,      0,    800,   1496,    167,   -256,
+     -338,    -39,   -136,     -1,     -4,     -6,    -73,     -8,
+      -15,     12,     23,      2,     16,     30,      3,     -5,
+     -462,   -686,    493,   2575,    311,    -13,    -28,    -14,
+     -404,     -5,    -19,     13,     20,     72,    107,    -77,
+        8,     13,     -9,    -48,   1483,    144,    784,    928,
+     1243,   -134,     -1,    -37,    -52,    -94,    -13,    -71,
+       -6,    -84,     -8,    -44,   -112,    -10,    -59,    -70,
+      -77,    275,   3522,   1056,  -1254,      0,     -4,   -757,
+      -68,    -95,      1,     16,    -59,      4,    -17,   -227,
+       -5,     21,    269,     80,   -125,    -40,   -264,    381,
+     5027,      0,      0,     -4,     -8,  -1542,      0,     -2,
+        0,      2,      0,      6,     38,     12,     81,   -117,
+      138,    332,   2215,   2574,   1339,     -1,     -6,   -299,
+     -404,   -109,     -2,    -18,    -44,    -21,    -52,   -348,
+      -11,    -27,   -181,   -210,   3685,   2883,   -887,    866,
+    -1639,   -828,   -507,    -48,    -45,   -164,   -648,    199,
+      156,   -194,   -152,     46,    368,    288,    -88,     86,
+     1396,   2146,   2235,    345,    942,   -118,   -281,   -305,
+       -7,    -54,   -182,   -190,   -292,    -29,    -45,    -47,
+      -80,   -123,   -128,    -19,     13,   4475,   3549,   -804,
+     -655,      0,  -1222,   -768,    -39,    -26,     -3,     -2,
+     -969,      0,    219,    174,      0,    179,    141,    -32,
+     -724,    254,    242,   6049,   2462,    -32,     -3,     -3,
+    -2233,   -370,     11,     10,     -3,    267,    -94,    -89,
+      108,    -38,    -36,   -909,    626,  -1713,   6121,   4561,
+    -1061,    -23,   -179,  -2287,  -1270,    -68,     65,   -233,
+      640,   -174,    477,  -1704,     40,   -111,    396,    295,
+     -350,   1391,   7985,    511,   -405,     -7,   -118,  -3892,
+      -15,    -10,     29,    170,   -678,     10,    -43,   -249,
+       -8,     34,    197,     12,   3144,   -529,    608,   2530,
+     3878,   -603,    -17,    -22,   -390,   -918,    101,   -116,
+       19,   -485,     81,    -93,   -744,    125,   -144,   -599,
+     2589,   -689,   3045,   5603,   -404,   -409,    -29,   -566,
+    -1916,    -10,    108,   -481,    128,   -885,    235,  -1041,
+       63,    -17,     75,    138,   3107,    513,   1374,  -3594,
+    -4922,   -589,    -16,   -115,   -788,  -1478,    -97,   -260,
+      -43,    681,    112,    301,    933,    154,    413,  -1079,
+     2468,   6010,   1107,   -390,   1961,   -372,  -2204,    -74,
+       -9,   -234,   -905,   -166,   -406,     58,    143,     26,
+     -295,   -719,   -132,     46,   4773,   2766,   2368,   4862,
+    -4044,  -1390,   -467,   -342,  -1443,   -998,   -806,   -690,
+     -399,  -1416,   -821,   -702,   1178,    682,    584,   1200,
+     1665,  -1879,   1443,   1701,   8562,   -169,   -215,   -127,
+     -176,  -4475,    190,   -146,    165,   -172,    195,   -149,
+     -870,    982,   -754,   -889,   2716,   9011,  -1007,    755,
+    -1785,   -450,  -4956,    -61,    -34,   -194,  -1493,    167,
+      554,   -125,   -415,     46,    296,    982,   -109,     82,
+    -2727,   7548,   1285,    938,   3420,   -453,  -3478,   -100,
+      -53,   -714,   1256,    213,   -592,    156,   -432,    -73,
+      569,  -1576,   -268,   -196,   3677,    882,   4050,   1202,
+     2323,   -825,    -47,  -1001,    -88,   -329,   -198,   -909,
+     -218,   -269,    -64,   -297,   -521,   -125,   -574,   -170,
+     2046,   -753,    122,  10102,    603,   -255,    -34,      0,
+    -6229,    -22,     94,    -15,      5,  -1261,    464,    -75,
+      -75,     27,     -4,   -372,    449,  -1815,  10690,   3870,
+     -527,    -12,   -201,  -6976,   -914,    -16,     49,   -293,
+     1184,   -106,    428,  -2525,     14,    -58,    344,    124,
+     -941,   2352,   5049,   3650,   2637,    -54,   -337,  -1556,
+     -813,   -424,    135,    290,   -725,    209,   -524,  -1125,
+      151,   -378,   -812,   -587,  -1879,    796,   3117,   9569,
+     -404,   -215,    -38,   -593,  -5589,     -9,     91,    357,
+     -151,   1097,   -464,  -1821,    -46,     19,     76,    236,
+    -1715,   2043,  -2096,   9946,   4001,   -179,   -254,   -268,
+    -6038,   -977,    213,   -219,    261,   1041,  -1240,   1272,
+      418,   -498,    511,  -2429,  -5772,   -618,  -3921,    284,
+    -3155,  -2033,    -23,   -938,     -4,   -607,   -218,  -1381,
+     -148,    100,     10,     68,  -1111,   -119,   -755,     54,
+      382,   4748,   8003,  -2064,   2198,     -8,  -1376,  -3909,
+     -260,   -294,   -110,   -186,  -2319,     48,    598,   1008,
+      -51,   -637,  -1073,    277,   -867,   3015,  11926,  -1675,
+      947,    -45,   -555,  -8681,   -171,    -54,    159,    631,
+    -2195,    -88,    308,   1219,     50,   -174,   -690,     96,
+    -4933,   -432,   6757,   3771,   1352,  -1485,    -11,  -2786,
+     -867,   -111,   -130,   2034,    178,   1135,     99,  -1555,
+      407,     35,   -557,   -311,    152,   9726,   4231,  -1928,
+     1490,     -1,  -5774,  -1092,   -226,   -135,    -90,    -39,
+    -2511,     17,   1144,    498,    -13,   -884,   -384,    175,
+     2512,    193,   9033,   5361,  -3148,   -385,     -2,  -4980,
+    -1754,   -605,    -29,  -1385,   -106,   -822,    -63,  -2956,
+      482,     37,   1735,   1030,   8464,   2844,     12,    549,
+     2132,  -4373,   -493,      0,    -18,   -277,  -1469,     -6,
+       -2,   -284,    -95,      0,  -1101,   -370,     -1,    -71,
+     2141,  -2602,   7166,   9046,  -1350,   -279,   -413,  -3134,
+    -4994,   -111,    340,   -936,   1138,  -1182,   1436,  -3957,
+      176,   -214,    590,    745,   -244,    278,  13307,   1227,
+     -161,     -3,     -4, -10808,    -91,     -1,      4,    198,
+     -226,     18,    -20,   -997,     -2,      2,    131,     12,
+    -1947,   8217,   6269,    917,  -2559,   -231,  -4121,  -2399,
+      -51,   -399,    976,    745,  -3144,    108,   -460,   -350,
+     -304,   1283,    979,    143,  -1810,   2061,  -2781,   6056,
+    10058,   -200,   -259,   -472,  -2238,  -6174,    227,   -307,
+      349,    669,   -761,   1028,   1111,  -1265,   1707,  -3717,
+     7827,   9161,  -3409,   2473,  -1510,  -3739,  -5122,   -709,
+     -373,   -139,  -4376,   1628,   1906,  -1181,  -1382,    514,
+      721,    844,   -314,    228,  -1430,   8313,   9541,  -2955,
+     1626,   -124,  -4218,  -5556,   -533,   -161,    725,    832,
+    -4841,   -257,   1499,   1721,    142,   -825,   -947,    293,
+     2819,  -4247,   5391,   8673,   2756,   -485,  -1101,  -1774,
+    -4591,   -463,    730,   -927,   1397,  -1492,   2248,  -2854,
+     -474,    714,   -907,  -1459,    141,  14552,    690,    257,
+     -112,     -1, -12926,    -29,     -4,      0,   -125,     -5,
+     -613,     -2,   -228,    -10,      0,     99,      4,      1,
+    11938,  -1859,   1806,   -962,   -884,  -8699,   -211,   -199,
+      -56,    -47,   1355,  -1316,    205,    701,   -109,    106,
+      644,   -100,     97,    -51,   3728,   1982,   2264,   4584,
+     3131,   -848,   -239,   -312,  -1282,   -598,   -451,   -515,
+     -273,  -1043,   -554,   -633,   -712,   -378,   -432,   -876,
+    -1181,    766,    720,  14303,   -216,    -85,    -35,    -31,
+   -12486,     -2,     55,     51,    -33,   1031,   -668,   -628,
+      -15,     10,      9,    189,  -4385,   4826,  10112,   1569,
+     3388,  -1173,  -1421,  -6242,   -150,   -700,   1291,   2706,
+    -2979,    420,   -462,   -969,    906,   -998,  -2091,   -324,
+     -448,   1932,  15591,  -1842,    657,    -12,   -227, -14837,
+     -207,    -26,     52,    427,  -1838,    -50,    217,   1753,
+       18,    -77,   -626,     74,  -4141,   1844,   3962,   5517,
+     6220,  -1046,   -207,   -958,  -1858,  -2361,    466,   1001,
+     -446,   1394,   -621,  -1334,   1572,   -700,  -1504,  -2094,
+      729,  -2299,  14755,   3657,   -952,    -32,   -322, -13288,
+     -816,    -55,    102,   -656,   2071,   -162,    513,  -3294,
+       42,   -133,    857,    212,  -1385,   5801,  13339,  -3137,
+     1344,   -117,  -2054, -10861,   -600,   -110,    490,   1127,
+    -4723,   -265,   1111,   2554,    113,   -476,  -1094,    257,
+     4710,   9661,   1073,  -2467,   3274,  -1354,  -5697,    -70,
+     -371,   -654,  -2777,   -308,   -633,    709,   1455,    161,
+     -941,  -1930,   -214,    493,   1843,  -3624,  12422,   6898,
+    -1559,   -207,   -802,  -9419,  -2904,   -148,    407,  -1397,
+     2748,   -775,   1526,  -5230,    175,   -344,   1182,    656,
+     1433,   2394,   2507,   1380,   8780,   -125,   -349,   -383,
+     -116,  -4705,   -209,   -219,   -366,   -120,   -201,   -211,
+     -768,  -1283,  -1343,   -740,  -1712,  12915,   5883,  -2197,
+      991,   -179, -10181,  -2112,   -294,    -60,   1350,    615,
+    -4638,   -229,   1732,    789,    103,   -781,   -356,    133,
+    15072,   2158,  -1245,    910,   -496, -13865,   -284,    -94,
+      -50,    -15,  -1986,   1145,    164,   -837,   -119,     69,
+      456,     65,    -37,     27,   4655,   7319,   4916,    586,
+    -3381,  -1322,  -3270,  -1475,    -20,   -697,  -2079,  -1396,
+    -2196,   -166,   -261,   -175,    960,   1510,   1014,    120,
+     1191,  -2140,   5120,  13498,  -1418,    -86,   -279,  -1600,
+   -11121,   -122,    155,   -372,    669,   -981,   1763,  -4218,
+      103,   -185,    443,   1168,  -1530,   -817,   8191,   9632,
+    -1452,   -143,    -40,  -4095,  -5663,   -128,    -76,    765,
+      408,    900,    480,  -4815,   -135,    -72,    726,    854,
+    -3236,    607,   1696,  -2106,  11485,   -639,    -22,   -175,
+     -270,  -8051,    119,    335,    -62,   -416,     78,    218,
+     2268,   -425,  -1189,   1476,   3203,  -1903,   -837,   9679,
+     7057,   -626,   -221,    -42,  -5718,  -3039,    372,    163,
+      -97,  -1892,   1124,    494,  -1380,    819,    360,  -4169,
+      213,   -655,  17015,    620,   -384,     -2,    -26, -17671,
+      -23,     -9,      8,   -221,    681,     -8,     24,   -644,
+        5,    -15,    399,     14,   5088,     35,  -3339,   3726,
+     8488,  -1580,      0,   -680,   -847,  -4397,    -10,   1037,
+        7,  -1157,     -8,    759,  -2636,    -18,   1730,  -1930,
+     -988,   1454,  -2688,  15039,   2682,    -59,   -129,   -441,
+   -13805,   -439,     87,   -162,    238,    907,  -1335,   2467,
+      161,   -238,    440,  -2462,  -4865,  -2842,    -53,   5495,
+     6523,  -1445,   -493,      0,  -1843,  -2597,   -844,    -16,
+       -9,   1632,    953,     18,   1937,   1131,     21,  -2188,
+     3076,  15069,  -2914,   1810,   -971,   -577, -13860,   -518,
+     -200,    -57,  -2829,    547,   2680,   -339,  -1665,    322,
+      182,    893,   -172,    107,   1311,   5355,  11054,   2299,
+    -3654,   -105,  -1750,  -7458,   -322,   -814,   -428,   -885,
+    -3613,   -184,   -751,  -1551,    292,   1194,   2465,    512,
+     4035,   5619,   4618,   1815,   1912,   -994,  -1927,  -1301,
+     -201,   -223,  -1384,  -1137,  -1583,   -447,   -622,   -511,
+     -471,   -656,   -539,   -211,  -2131,   2754,  -4501,  12879,
+     7432,   -277,   -463,  -1236, -10124,  -3371,    358,   -585,
+      756,   1675,  -2165,   3538,    967,  -1249,   2042,  -5842,
+     5618,   -515,   3219,  -4149,   4857,  -1926,    -16,   -632,
+    -1050,  -1440,    176,  -1104,    101,   1422,   -130,    815,
+    -1666,    152,   -954,   1230,   1838,  -1709,   1139,  16867,
+      716,   -206,   -178,    -79, -17366,    -31,    191,   -127,
+      118,  -1892,   1759,  -1173,    -80,     74,    -49,   -737,
+     1978,  -3845,  10050,  11854,  -2492,   -238,   -902,  -6164,
+    -8576,   -379,    464,  -1213,   2358,  -1431,   2782,  -7271,
+      301,   -585,   1529,   1803,  -2600,  11246,  11289,  -3647,
+     1463,   -412,  -7720,  -7778,   -812,   -130,   1784,   1791,
+    -7749,   -578,   2504,   2513,    232,  -1004,  -1008,    325,
+     3442,    907,   2725,   8970,   3638,   -723,    -50,   -453,
+    -4911,   -808,   -190,   -572,   -150,  -1884,   -496,  -1492,
+     -764,   -201,   -605,  -1992,   -126,  17498,   3481,  -2003,
+     1090,      0, -18689,   -739,   -244,    -72,    135,     26,
+    -3717,    -15,   2139,    425,      8,  -1165,   -231,    133,
+    -1814,   1048,  -2164,   4070,  16272,   -200,    -67,   -285,
+    -1011, -16160,    116,   -239,    138,    450,   -260,    537,
+     1801,  -1041,   2149,  -4042,   9354,  12580,  -1883,    962,
+     -617,  -5341,  -9660,   -216,    -56,    -23,  -7183,   1075,
+     1446,   -549,   -738,    110,    352,    474,    -71,     36,
+     1708,   4199,   7387,   6335,   1003,   -178,  -1076,  -3330,
+    -2449,    -61,   -437,   -770,  -1893,   -660,  -1623,  -2856,
+     -104,   -257,   -452,   -388,  -2624,   5623,  17310,  -2353,
+      592,   -420,  -1930, -18288,   -338,    -21,    900,   2772,
+    -5941,   -376,    807,   2486,     94,   -203,   -625,     85,
+     1211,   -850,   1193,  -1926,  15992,    -89,    -44,    -86,
+     -226, -15609,     62,    -88,     61,    142,   -100,    140,
+    -1182,    830,  -1165,   1880,   3983,  -2054,  11506,    -19,
+     3622,   -968,   -257,  -8080,      0,   -801,    499,  -2797,
+     1442,      4,     -2,     13,   -880,    454,  -2544,      4,
+     -786,  -1354,  16092,   7246,  -1665,    -37,   -111, -15805,
+    -3205,   -169,    -65,    772,   1330,    348,    599,  -7117,
+      -80,   -137,   1636,    736,  -4316,   -511,   6674,  11665,
+     4633,  -1137,    -15,  -2719,  -8305,  -1310,   -134,   1758,
+      208,   3073,    364,  -4752,   1220,    144,  -1887,  -3299,
+     7912,   4557,   1937,   1885,   7037,  -3821,  -1267,   -229,
+     -216,  -3022,  -2200,   -935,   -538,   -910,   -524,   -222,
+    -3398,  -1957,   -832,   -809,   3434,   2967,   5867,   8196,
+     8766,   -720,   -537,  -2101,  -4100,  -4690,   -622,  -1230,
+    -1062,  -1718,  -1484,  -2935,  -1837,  -1588,  -3139,  -4385,
+     5881,   9176,   8119,   3934,   3355,  -2111,  -5139,  -4023,
+     -944,   -687,  -3294,  -2914,  -4547,  -1412,  -2203,  -1949,
+    -1204,  -1879,  -1662,   -805
+};
+
+static const int16_t adaptive_cb_gain170[170 * 20] = {
+        0,      0,      0,      0,      0,      0,      0,      0,
+        0,      0,      0,      0,      0,      0,      0,      0,
+        0,      0,      0,      0,    776,    212,    715,    670,
+      809,    -36,     -2,    -31,    -27,    -39,    -10,    -33,
+       -9,    -31,     -8,    -29,    -38,    -10,    -35,    -33,
+     1296,   1316,   -168,   -320,   -815,   -102,   -105,     -1,
+       -6,    -40,   -104,     13,     13,     25,     25,     -3,
+       64,     65,     -8,    -15,   -589,    680,   2478,    308,
+     -596,    -21,    -28,   -375,     -5,    -21,     24,     89,
+     -102,     11,    -12,    -46,    -21,     24,     90,     11,
+     -735,   -487,     -5,   2948,    468,    -33,    -14,      0,
+     -530,    -13,    -21,      0,      0,    132,     87,      0,
+       21,     13,      0,    -84,   1042,   1730,   1068,    333,
+      626,    -66,   -182,    -69,     -6,    -23,   -110,    -67,
+     -112,    -21,    -35,    -21,    -39,    -66,    -40,    -12,
+      486,   -769,   4074,   2825,  -1107,    -14,    -36,  -1013,
+     -487,    -74,     22,   -120,    191,    -83,    132,   -702,
+       32,    -52,    275,    191,   1521,   -767,   -124,   4320,
+     1026,   -141,    -35,      0,  -1139,    -64,     71,     11,
+       -5,   -401,    202,     32,    -95,     48,      7,   -270,
+     2425,   1267,   3439,    -91,  -1166,   -359,    -98,   -722,
+        0,    -83,   -187,   -509,   -266,     13,      7,     19,
+      172,     90,    244,     -6,  -1251,    975,    173,   4039,
+     2005,    -95,    -58,     -1,   -996,   -245,     74,     13,
+      -10,    308,   -240,    -42,    153,   -119,    -21,   -494,
+     1820,    632,   1322,   2062,   1031,   -202,    -24,   -106,
+     -259,    -64,    -70,   -146,    -51,   -229,    -79,   -166,
+     -114,    -39,    -83,   -129,   -447,   4904,    244,   -315,
+    -2038,    -12,  -1467,     -3,     -6,   -253,    134,      6,
+      -73,     -8,     94,      4,    -55,    610,     30,    -39,
+     -208,  -1102,    463,   -448,   5653,     -2,    -74,    -13,
+      -12,  -1950,    -14,      5,     31,     -5,    -30,     12,
+       71,    380,   -159,    154,   4739,   2600,  -1864,    856,
+    -1554,  -1371,   -412,   -212,    -44,   -147,   -752,    539,
+      295,   -247,   -135,     97,    449,    246,   -176,     81,
+     1894,   3533,     35,    -26,   2145,   -219,   -762,      0,
+        0,   -280,   -408,     -4,     -7,      3,      5,      0,
+     -248,   -462,     -4,      3,  -2699,   1841,   4072,   2443,
+     1582,   -444,   -207,  -1012,   -364,   -152,    303,    670,
+     -457,    402,   -274,   -607,    260,   -177,   -393,   -236,
+     -844,   3358,   6106,  -1059,   -537,    -43,   -688,  -2275,
+      -68,    -17,    173,    314,  -1251,    -54,    217,    395,
+      -27,    110,    200,    -34,   1251,   1016,   3020,   2210,
+     1445,    -95,    -63,   -556,   -298,   -127,    -77,   -230,
+     -187,   -168,   -137,   -407,   -110,    -89,   -266,   -194,
+     2099,   2277,   4038,   3533,  -2870,   -269,   -316,   -995,
+     -762,   -503,   -291,   -517,   -561,   -452,   -491,   -871,
+      367,    399,    707,    619,    400,  -1114,   8516,   2422,
+    -1117,     -9,    -75,  -4426,   -358,    -76,     27,   -208,
+      579,    -59,    164,  -1259,     27,    -75,    580,    165,
+    -4398,  -2011,   3912,  -2407,   2258,  -1180,   -247,   -934,
+     -353,   -311,   -540,   1050,    480,   -646,   -295,    575,
+      606,    277,   -539,    331,   1767,  -1447,   4240,   6160,
+     -757,   -190,   -127,  -1097,  -2316,    -35,    156,   -457,
+      374,   -664,    544,  -1594,     81,    -66,    195,    284,
+     1594,  -1463,   1035,   6938,   1920,   -155,   -130,    -65,
+    -2938,   -225,    142,   -100,     92,   -675,    619,   -438,
+     -186,    171,   -121,   -813,   -562,   4716,   4085,   -591,
+     2421,    -19,  -1357,  -1018,    -21,   -357,    162,    140,
+    -1175,    -20,    170,    147,     83,   -696,   -603,     87,
+     1552,   8778,   -935,    354,  -1424,   -147,  -4703,    -53,
+       -7,   -123,   -831,     88,    501,    -33,   -189,     20,
+      134,    763,    -81,     30,   4831,  -4431,     41,  -1479,
+    -2976,  -1424,  -1198,      0,   -133,   -540,   1306,    -12,
+       11,    436,   -400,      3,    877,   -804,      7,   -268,
+     2090,   1192,   1006,   1645,   4853,   -266,    -86,    -61,
+     -165,  -1437,   -152,   -128,    -73,   -210,   -119,   -101,
+     -619,   -353,   -298,   -487,   2386,   5712,   1426,    -94,
+     1350,   -347,  -1991,   -124,      0,   -111,   -832,   -207,
+     -497,     13,     32,      8,   -196,   -470,   -117,      7,
+    -1349,   1091,   1659,   8891,    313,   -111,    -72,   -168,
+    -4825,     -5,     89,    136,   -110,    732,   -592,   -900,
+       25,    -20,    -31,   -170,   9980,    916,   -381,   -808,
+       88,  -6080,    -51,     -8,    -39,      0,   -558,    232,
+       21,    492,     45,    -18,    -53,     -4,      2,      4,
+     2338,  -1031,   -248,   3928,   6484,   -333,    -64,     -3,
+     -942,  -2566,    147,     35,    -15,   -560,    247,     59,
+     -925,    408,     98,  -1555,   6166,  -1240,   -337,   3672,
+    -1277,  -2320,    -93,     -6,   -823,    -99,    466,    126,
+      -25,  -1382,    278,     75,    480,    -96,    -26,    286,
+     4377,   -132,  -2588,   1701,   4865,  -1169,     -1,   -409,
+     -176,  -1444,     35,    691,    -20,   -454,     13,    268,
+    -1299,     39,    768,   -505,   2594,   3295,   3944,   1481,
+      682,   -410,   -662,   -949,   -133,    -28,   -521,   -624,
+     -793,   -234,   -297,   -356,   -108,   -137,   -164,    -61,
+     4151,    624,    815,   4485,   2229,  -1052,    -23,    -40,
+    -1228,   -303,   -158,   -206,    -31,  -1136,   -170,   -223,
+     -565,    -84,   -111,   -610,  -3575,   -361,   4924,   2791,
+     4698,   -780,     -7,  -1480,   -475,  -1347,    -78,   1074,
+      108,    609,     61,   -839,   1025,    103,  -1412,   -800,
+    -2518,   3791,   8623,    315,   2465,   -387,   -877,  -4538,
+       -6,   -370,    582,   1325,  -1995,     48,    -73,   -166,
+      378,   -570,  -1297,    -47,   -691,   2989,   9957,   -421,
+    -1142,    -29,   -545,  -6051,    -10,    -79,    126,    420,
+    -1817,    -17,     76,    256,    -48,    208,    694,    -29,
+    -1918,    104,  -3190,  -3410,  -4440,   -224,      0,   -621,
+     -709,  -1203,     12,   -373,     20,   -399,     21,   -664,
+     -519,     28,   -864,   -924,  -3359,  -1668,   1854,   6939,
+     1430,   -688,   -169,   -209,  -2939,   -124,   -341,    380,
+      188,   1422,    706,   -785,    293,    145,   -161,   -606,
+       42,   9706,   3164,   -952,    907,      0,  -5750,   -611,
+      -55,    -50,    -25,     -8,  -1874,      2,    564,    183,
+       -2,   -537,   -175,     52,   1607,    785,   2862,   4327,
+     3307,   -157,    -37,   -500,  -1143,   -667,    -77,   -280,
+     -137,   -424,   -207,   -756,   -324,   -158,   -577,   -873,
+     6801,   3416,   2227,   1682,  -3217,  -2823,   -712,   -302,
+     -172,   -631,  -1418,   -924,   -464,   -698,   -350,   -228,
+     1335,    670,    437,    330,   3459,   3898,    364,   7841,
+    -2640,   -730,   -927,     -8,  -3753,   -425,   -823,    -76,
+      -86,  -1655,  -1865,   -174,    557,    628,     58,   1263,
+    -5902,  -3458,  -2465,  -1886,   4334,  -2126,   -730,   -371,
+     -217,  -1146,  -1245,   -888,   -520,   -679,   -398,   -283,
+     1561,    915,    652,    499,  -3710,   1133,   7849,   3443,
+     -215,   -840,    -78,  -3760,   -723,     -2,    256,   1777,
+     -543,    779,   -238,  -1649,    -48,     14,    103,     45,
+     4132,   2828,      2,  -4212,  -4116,  -1042,   -488,      0,
+    -1083,  -1034,   -713,      0,      0,   1062,    727,      0,
+     1038,    710,      0,  -1058,   5875,   8496,  -1796,   1376,
+    -1786,  -2107,  -4406,   -197,   -115,   -194,  -3047,    644,
+      931,   -493,   -713,    150,    640,    926,   -195,    150,
+     3143,   3483,   3546,   -793,   4489,   -603,   -740,   -767,
+      -38,  -1230,   -668,   -680,   -754,    152,    168,    171,
+     -861,   -954,   -971,    217,   2845,   7965,   3695,  -5432,
+     3978,   -494,  -3873,   -833,  -1801,   -966,  -1383,   -641,
+    -1796,    943,   2641,   1225,   -691,  -1934,   -897,   1319,
+     1538,    150,   7139,   2049,   3097,   -144,     -1,  -3110,
+     -256,   -585,    -14,   -670,    -65,   -192,    -18,   -892,
+     -290,    -28,  -1349,   -387,    618,   7520,   4729,   -238,
+    -3373,    -23,  -3452,  -1365,     -3,   -694,   -283,   -178,
+    -2170,      8,    109,     68,    127,   1548,    973,    -49,
+     2965,  -3013,   7912,   7076,  -1997,   -536,   -554,  -3821,
+    -3056,   -243,    545,  -1431,   1455,  -1280,   1301,  -3417,
+      361,   -367,    964,    862,   2443,   -929,  -1113,   9677,
+     4138,   -364,    -52,    -75,  -5716,  -1045,    138,    166,
+      -63,  -1443,    549,    657,   -617,    234,    281,  -2444,
+     1966,   3309,  10085,  -3399,   2105,   -236,   -668,  -6207,
+     -705,   -270,   -397,  -1210,  -2037,    408,    686,   2092,
+     -252,   -425,  -1295,    436,   -112,  -1368,   8868,   4822,
+     2048,      0,   -114,  -4800,  -1419,   -256,     -9,     61,
+      740,     33,    402,  -2610,     14,    171,  -1108,   -602,
+    -2597,    438,  -1839,   6229,   7266,   -411,    -11,   -206,
+    -2368,  -3223,     69,   -291,     49,    987,   -166,    699,
+     1152,   -194,    816,  -2763,   3454,    553,   9127,   4946,
+    -5596,   -728,    -18,  -5084,  -1493,  -1911,   -116,  -1924,
+     -308,  -1042,   -166,  -2755,   1179,    188,   3117,   1689,
+     -532,   -663,  12262,   2495,  -1004,    -17,    -26,  -9177,
+     -380,    -61,    -21,    398,    496,     81,    101,  -1867,
+      -32,    -40,    751,    152,  -2100,   1317,  -1509,  11425,
+     2997,   -269,   -105,   -139,  -7967,   -548,    168,   -193,
+      121,   1464,   -918,   1052,    384,   -240,    276,  -2090,
+     1193,  -2697,  11259,   5373,   -763,    -86,   -444,  -7737,
+    -1762,    -35,    196,   -819,   1853,   -391,    884,  -3692,
+       55,   -125,    525,    250,   2405,   -471,  11079,    203,
+      782,   -353,    -13,  -7491,     -2,    -37,     69,  -1626,
+      318,    -29,      5,   -137,   -114,     22,   -529,     -9,
+    -1871,   5685,  11290,  -2662,   1353,   -213,  -1972,  -7780,
+     -432,   -111,    649,   1289,  -3917,   -304,    923,   1834,
+      154,   -469,   -932,    220,  -3768,   5927,  -3093,   5041,
+     5212,   -866,  -2144,   -584,  -1551,  -1658,   1363,   -711,
+     1119,   1159,  -1824,    951,   1198,  -1885,    984,  -1603,
+    -2546,   9502,   5969,  -2440,   1928,   -395,  -5511,  -2175,
+     -363,   -226,   1477,    927,  -3462,   -379,   1415,    889,
+      299,  -1118,   -702,    287,  -4963,   3568,   4592,   5508,
+     3451,  -1503,   -777,  -1287,  -1851,   -727,   1080,   1391,
+    -1000,   1668,  -1199,  -1543,   1045,   -751,   -967,  -1160,
+     1745,  -2586,   3983,  10899,  -1551,   -186,   -408,   -968,
+    -7250,   -146,    275,   -424,    628,  -1161,   1720,  -2649,
+      165,   -244,    377,   1032,    867,   -456,   -727,   3369,
+    11822,    -45,    -12,    -32,   -692,  -8531,     24,     38,
+      -20,   -178,     93,    149,   -625,    329,    525,  -2431,
+     7535,   2422,   1926,   1405,   1599,  -3466,   -358,   -226,
+     -120,   -156,  -1114,   -886,   -284,   -646,   -207,   -165,
+     -735,   -236,   -188,   -137,   1041,   -735,   -142,  13209,
+     1515,    -66,    -33,     -1, -10649,   -140,     46,      9,
+       -6,   -839,    593,    114,    -96,     68,     13,  -1222,
+     7950,   6745,  -1444,  -1008,   2721,  -3857,  -2777,   -127,
+      -62,   -452,  -3273,    700,    594,    489,    415,    -88,
+    -1320,  -1120,    239,    167,  -4754,  -1379,   4522,   -578,
+    -5733,  -1379,   -116,  -1248,    -20,  -2006,   -400,   1312,
+      380,   -167,    -48,    159,  -1663,   -482,   1582,   -202,
+     3220,   5978,   5923,   2430,  -2689,   -633,  -2181,  -2141,
+     -360,   -441,  -1175,  -1164,  -2161,   -477,   -886,   -878,
+      528,    981,    972,    398,    377,   1312,  13978,  -1470,
+      677,     -8,   -105, -11925,   -132,    -28,    -30,   -321,
+    -1119,     33,    117,   1254,    -15,    -54,   -577,     60,
+    -3435,   6770,    314,   -885,   5686,   -720,  -2797,     -6,
+      -47,  -1973,   1419,     65,   -129,   -185,    366,     16,
+     1192,  -2349,   -109,    307,   3171,   8774,  -2260,   2679,
+     3069,   -613,  -4699,   -312,   -438,   -575,  -1698,    437,
+     1210,   -518,  -1435,    369,   -594,  -1643,    423,   -501,
+     5557,   1509,   5407,   -125,  -7386,  -1884,   -139,  -1784,
+        0,  -3330,   -511,  -1834,   -498,     42,     11,     41,
+     2505,    680,   2438,    -56,  -2838,   2595,  13228,    271,
+     1793,   -491,   -411, -10680,     -4,   -196,    449,   2291,
+    -2095,     47,    -42,   -219,    310,   -284,  -1447,    -29,
+      664,   -278,  14966,    951,   -711,    -26,     -4, -13672,
+      -55,    -30,     11,   -606,    253,    -38,     16,   -869,
+       28,    -12,    650,     41,    808,   1770,   8658,   5863,
+    -1486,    -39,   -191,  -4576,  -2098,   -134,    -87,   -427,
+     -935,   -289,   -633,  -3098,     73,    160,    785,    531,
+     3063,   1539,   2000,   -542,   9576,   -572,   -144,   -244,
+      -17,  -5597,   -287,   -374,   -188,    101,     51,     66,
+    -1790,   -900,  -1169,    317,    514,  14083,   -323,    896,
+     -891,    -16, -12106,     -6,    -49,    -48,   -442,     10,
+      277,    -28,   -770,     17,     27,    766,    -17,     48,
+      892,    158,   5237,  11057,  -1603,    -48,     -1,  -1674,
+    -7462,   -156,     -8,   -285,    -50,   -602,   -106,  -3534,
+       87,     15,    512,   1082,  -1612,   2564,  -4296,  12526,
+     5710,   -158,   -401,  -1126,  -9576,  -1990,    252,   -422,
+      672,   1232,  -1960,   3284,    561,   -893,   1497,  -4365,
+     4889,  -6878,    612,   6109,   4753,  -1459,  -2887,    -22,
+    -2277,  -1379,   2052,   -182,    257,  -1823,   2564,   -228,
+    -1418,   1995,   -177,  -1772,   3053,   -506,   2403,   9625,
+     1322,   -569,    -15,   -352,  -5655,   -106,     94,   -448,
+       74,  -1794,    297,  -1412,   -246,     40,   -194,   -777,
+     -754,  12904,   4480,  -2113,   1471,    -34, -10163,  -1225,
+     -272,   -132,    594,    206,  -3529,    -97,   1664,    577,
+       67,  -1159,   -402,    189,   4255,   1476,   5055,   2393,
+     2912,  -1105,   -132,  -1559,   -349,   -517,   -383,  -1313,
+     -455,   -621,   -215,   -738,   -756,   -262,   -898,   -425,
+    -1371,    535,   1417,  14604,   -997,   -114,    -17,   -122,
+   -13017,    -60,     44,    118,    -46,   1222,   -477,  -1263,
+      -83,     32,     86,    888,   5368,  -1744,   4083,  -1236,
+     3753,  -1758,   -185,  -1017,    -93,   -860,    571,  -1338,
+      434,    405,   -131,    308,  -1229,    399,   -935,    283,
+     1588,  -3097,  14415,   3699,  -1171,   -154,   -585, -12683,
+     -835,    -83,    300,  -1397,   2725,   -358,    699,  -3255,
+      113,   -221,   1030,    264,    212,   7989,   9471,  -3344,
+     2009,     -2,  -3895,  -5475,   -682,   -246,   -103,   -123,
+    -4618,     43,   1630,   1933,    -26,   -979,  -1161,    410,
+      856,   2294,   -627,   6930,   6929,    -44,   -321,    -24,
+    -2931,  -2930,   -119,     32,     87,   -362,   -970,    265,
+     -362,   -970,    265,  -2931,   2357,  -4187,   7162,   7683,
+     3371,   -339,  -1070,  -3131,  -3603,   -693,    602,  -1030,
+     1830,  -1105,   1963,  -3359,   -485,    861,  -1474,  -1581,
+      350,   4585,  14053,  -3819,   1218,     -7,  -1283, -12054,
+     -890,    -90,    -97,   -300,  -3933,     81,   1068,   3275,
+      -26,   -341,  -1045,    284,  -3248,   3531,    475,   2137,
+    11711,   -644,   -761,    -13,   -278,  -8372,    700,     94,
+     -102,    423,   -460,    -62,   2322,  -2524,   -340,  -1528,
+    -3017,   3852,   1725,   8440,   5257,   -555,   -905,   -181,
+    -4348,  -1686,    709,    317,   -405,   1554,  -1984,   -889,
+      968,  -1236,   -553,  -2708,   -909,   3196,  15512,  -2528,
+     1066,    -50,   -623, -14686,   -390,    -69,    177,    861,
+    -3026,   -140,    493,   2393,     59,   -208,  -1009,    164,
+      959,  -3370,   9617,   9545,  -1761,    -56,   -693,  -5645,
+    -5561,   -189,    197,   -563,   1978,   -558,   1963,  -5603,
+      103,   -362,   1034,   1026,   7575,  11796,  -4845,   3252,
+    -1703,  -3502,  -8493,  -1433,   -645,   -177,  -5454,   2240,
+     3488,  -1503,  -2341,    961,    787,   1226,   -503,    338,
+     6409,   1722,   1764,  -4191,   6015,  -2507,   -181,   -189,
+    -1072,  -2208,   -673,   -690,   -185,   1639,    440,    451,
+    -2353,   -632,   -647,   1538,  -2420,  12161,   5038,   1286,
+    -2098,   -357,  -9027,  -1549,   -100,   -268,   1796,    744,
+    -3740,    190,   -954,   -395,   -310,   1557,    645,    164,
+    -2232,  -1341,   7246,   9470,  -1977,   -304,   -109,  -3204,
+    -5474,   -238,   -182,    987,    593,   1290,    775,  -4188,
+     -269,   -161,    874,   1143,   1030,   7034,   4231,   1551,
+     3077,    -64,  -3019,  -1093,   -146,   -577,   -442,   -266,
+    -1816,    -97,   -666,   -400,   -193,  -1321,   -794,   -291,
+     5121,  11835,   -477,  -1749,   2298,  -1601,  -8549,    -13,
+     -186,   -322,  -3699,    149,    344,    546,   1264,    -50,
+     -718,  -1660,     66,    245,  -3328,   3827,   5921,   9976,
+    -1045,   -676,   -894,  -2140,  -6075,    -66,    777,   1203,
+    -1383,   2027,  -2330,  -3605,   -212,    244,    377,    636,
+     3813,   5718,  -4666,  -3412,   5674,   -887,  -1995,  -1329,
+     -710,  -1965,  -1331,   1086,   1628,    794,   1191,   -972,
+    -1320,  -1980,   1616,   1181,   1348,  -3672,  13154,   6938,
+    -1690,   -110,   -823, -10561,  -2938,   -174,    302,  -1082,
+     2948,   -570,   1555,  -5570,    139,   -379,   1357,    716,
+     2151,  -3586,   6949,  12131,  -1224,   -282,   -785,  -2947,
+    -8982,    -91,    470,   -912,   1521,  -1592,   2655,  -5145,
+      160,   -268,    519,    906,  -2889,   9647,  10276,  -2728,
+      995,   -509,  -5680,  -6445,   -454,    -60,   1701,   1812,
+    -6051,   -481,   1606,   1711,    175,   -586,   -624,    165,
+     6177,   2184,    555,   1985,   6589,  -2329,   -291,    -18,
+     -240,  -2650,   -823,   -209,    -74,   -748,   -264,    -67,
+    -2484,   -878,   -223,   -798,   -492,    391,  17166,   -681,
+      240,    -14,     -9, -17987,    -28,     -3,     11,    515,
+     -410,    -20,     16,    713,      7,     -5,   -252,     10,
+    12628,   5448,  -2630,   3011,  -2695,  -9733,  -1811,   -422,
+     -553,   -443,  -4199,   2027,    874,  -2321,  -1001,    483,
+     2077,    896,   -432,    495,  -3628,   -534,   3447,   7002,
+     6751,   -803,    -17,   -725,  -2992,  -2782,   -118,    763,
+      112,   1550,    228,  -1473,   1495,    220,  -1420,  -2885,
+    -5239,   5901,   8107,   3650,   4846,  -1675,  -2125,  -4012,
+     -813,  -1433,   1887,   2592,  -2920,   1167,  -1315,  -1806,
+     1550,  -1745,  -2398,  -1080,   6157,   6678,   4099,  -1074,
+     2348,  -2314,  -2722,  -1025,    -70,   -336,  -2509,  -1540,
+    -1670,    403,    437,    268,   -882,   -957,   -587,    153,
+     1079,  16099,    242,   -881,   1690,    -71, -15820,     -3,
+      -47,   -174,  -1060,    -16,   -238,     58,    865,     13,
+     -111,  -1661,    -25,     90,   -278,    227,  -1039,   1636,
+    16945,     -4,     -3,    -65,   -163, -17526,      3,    -17,
+       14,     27,    -22,    103,    287,   -234,   1074,  -1693,
+    15778,  -1454,    574,   -603,   -107, -15195,   -129,    -20,
+      -22,      0,   1400,   -553,     51,    581,    -53,     21,
+      103,     -9,      3,     -3,   2406,   -836,  13224,   7993,
+    -4266,   -353,    -42, -10673,  -3899,  -1111,    122,  -1942,
+      674,  -1174,    407,  -6451,    626,   -217,   3443,   2081,
+     3184,  14368,  -3336,   2255,  -1801,   -619, -12600,   -679,
+     -310,   -198,  -2793,    648,   2926,   -438,  -1977,    459,
+      350,   1580,   -366,    247,  -1698,  17076,   2504,   -539,
+     -646,   -176, -17798,   -382,    -17,    -25,   1770,    259,
+    -2610,    -55,    561,     82,    -67,    673,     98,    -21,
+     2375,   -797,  -2696,  14483,   5383,   -344,    -38,   -443,
+   -12803,  -1769,    115,    391,   -131,  -2100,    705,   2384,
+     -780,    262,    886,  -4759,  -2691,   2554,  -4520,   9573,
+    10655,   -442,   -398,  -1247,  -5594,  -6930,    419,   -742,
+      704,   1572,  -1492,   2641,   1750,  -1661,   2939,  -6226,
+    -4332,  -4399,  -1657,   4880,   7375,  -1145,  -1181,   -167,
+    -1453,  -3319,  -1163,   -438,   -444,   1290,   1310,    493,
+     1950,   1980,    745,  -2196,  -3498,   7405,   9955,   2693,
+    -2971,   -746,  -3347,  -6049,   -442,   -538,   1581,   2125,
+    -4499,    575,  -1217,  -1636,   -634,   1342,   1805,    488,
+     6717,  -3792,   7739,   2798,   3489,  -2754,   -877,  -3655,
+     -477,   -743,   1554,  -3173,   1791,  -1147,    647,  -1321,
+    -1430,    807,  -1648,   -595,   5263,   9770,   3463,   1069,
+    -3971,  -1690,  -5826,   -732,    -69,   -962,  -3138,  -1112,
+    -2065,   -343,   -637,   -226,   1275,   2368,    839,    259,
+     1243,  -2634,  16772,   1871,    332,    -94,   -423, -17169,
+     -213,     -6,    199,  -1273,   2696,   -142,    300,  -1915,
+      -25,     53,   -339,    -37,   2691,   2836,   3105,   5711,
+     4817,   -442,   -491,   -588,  -1991,  -1416,   -465,   -510,
+     -537,   -938,   -988,  -1082,   -791,   -834,   -913,  -1679,
+     4366,   2944,   7210,   3627,   1161,  -1163,   -529,  -3172,
+     -803,    -82,   -784,  -1921,  -1295,   -966,   -651,  -1596,
+     -309,   -208,   -511,   -257,  13888,   3951,   -671,  -2305,
+     3354, -11773,   -953,    -27,   -324,   -686,  -3349,    569,
+      161,   1954,    556,    -94,  -2843,   -809,    137,    472,
+     7053,   5847,   2929,   8378,  -4794,  -3036,  -2086,   -523,
+    -4284,  -1403,  -2517,  -1261,  -1045,  -3607,  -2990,  -1498,
+     2064,   1711,    857,   2451,  -2191,  12838,   9182,  -3915,
+     1617,   -293, -10059,  -5146,   -935,   -159,   1717,   1228,
+    -7195,   -523,   3068,   2194,    216,  -1267,   -906,    386,
+    -4881,  13114,   5767,   -435,   4155,  -1454, -10498,  -2030,
+      -11,  -1054,   3907,   1718,  -4616,   -129,    348,    153,
+     1238,  -3326,  -1462,    110,   7843,  -1250,    210,   7106,
+    -5203,  -3754,    -95,     -2,  -3082,  -1652,    598,   -100,
+       16,  -3402,    542,    -91,   2491,   -397,     66,   2257,
+    -2463,   8168,  14551,  -3908,   1828,   -370,  -4072, -12923,
+     -932,   -204,   1228,   2188,  -7254,   -587,   1948,   3471,
+      274,   -911,  -1623,    436,  -1579,    347,   -272,  -2735,
+    16031,   -152,     -7,     -4,   -456, -15686,     33,    -26,
+        5,   -263,     58,    -45,   1545,   -340,    266,   2676,
+    -6327,   1328,   5093,  -5079,   7617,  -2443,   -107,  -1583,
+    -1574,  -3541,    513,   1967,   -413,  -1961,    411,   1578,
+     2941,   -617,  -2367,   2361,   3286,  -4509,  11306,  11025,
+    -2623,   -659,  -1241,  -7802,  -7419,   -420,    904,  -2267,
+     3112,  -2211,   3034,  -7608,    526,   -722,   1810,   1765,
+     5567,  17853,  -3754,   1166,   -519,  -1892, -19455,   -860,
+      -83,    -16,  -6067,   1275,   4090,   -396,  -1271,    267,
+      176,    566,   -119,     37,  -2136,   -424,  15292,   5108,
+    -1648,   -278,    -10, -14273,  -1593,   -165,    -55,   1993,
+      396,    666,    132,  -4768,   -214,    -42,   1538,    514,
+     2267,  -3297,   2549,  16563,   -791,   -313,   -663,   -396,
+   -16745,    -38,    456,   -352,    513,  -2291,   3333,  -2576,
+      109,   -159,    123,    799,   3655,   1899,  -3364,   6279,
+    12510,   -815,   -220,   -690,  -2406,  -9552,   -423,    750,
+      390,  -1400,   -728,   1289,  -2791,  -1450,   2568,  -4794,
+     8052,   2285,  -6193,   5138,   6003,  -3957,   -318,  -2341,
+    -1611,  -2199,  -1123,   3044,    864,  -2525,   -716,   1942,
+    -2950,   -837,   2269,  -1882,   -386,  -2291,   7679,  15387,
+    -2723,     -9,   -320,  -3599, -14452,   -452,    -54,    181,
+     1074,    362,   2152,  -7212,    -64,   -380,   1276,   2557,
+     2777,  -1173,   3984,  13079,   2508,   -470,    -84,   -969,
+   -10440,   -384,    198,   -675,    285,  -2217,    936,  -3180,
+     -425,    179,   -610,  -2002,  -1879,   1771,  -2684,  16705,
+     1833,   -215,   -191,   -439, -17032,   -205,    203,   -308,
+      290,   1916,  -1805,   2736,    210,   -198,    300,  -1869,
+     1052,   4495,  15519,   1467,  -4032,    -67,  -1233, -14700,
+     -131,   -992,   -288,   -997,  -4257,    -94,   -402,  -1389,
+      259,   1106,   3819,    361,   3010,   2544,   6969,   7559,
+     1996,   -553,   -395,  -2964,  -3487,   -243,   -467,  -1280,
+    -1082,  -1388,  -1174,  -3215,   -366,   -310,   -849,   -921,
+    -5209,  -1867,   8713,  10351,   1549,  -1656,   -212,  -4634,
+    -6540,   -146,   -593,   2770,    993,   3291,   1180,  -5505,
+      492,    176,   -824,   -979,  -4314,   8513,    913,   7547,
+    -2723,  -1135,  -4423,    -50,  -3476,   -452,   2241,    240,
+     -474,   1987,  -3921,   -420,   -717,   1415,    151,   1254,
+    12929,  -1219,   2448,   1757,   6303, -10204,    -90,   -365,
+     -188,  -2425,    962,  -1932,    182,  -1386,    130,   -262,
+    -4974,    469,   -941,   -676,   6465,   4132,   3167,   3160,
+     5697,  -2551,  -1042,   -612,   -609,  -1981,  -1630,  -1249,
+     -798,  -1247,   -797,   -611,  -2248,  -1437,  -1101,  -1099,
+    -3636,   4859,  18914,  -1335,    810,   -807,  -1441, -21836,
+     -108,    -40,   1078,   4198,  -5609,   -296,    396,   1541,
+      179,   -240,   -936,     66,   8844,   7864,    654,  -4063,
+    -5680,  -4774,  -3774,    -26,  -1007,  -1969,  -4245,   -353,
+     -314,   2193,   1950,    162,   3066,   2726,    226,  -1408,
+     1859,   2634,   9228,    996,   9464,   -211,   -423,  -5197,
+      -60,  -5467,   -299,  -1047,  -1483,   -113,   -160,   -561,
+    -1074,  -1521,  -5330,   -575,   2949,  12260,  10290,   -497,
+    -3943,   -530,  -9174,  -6463,    -15,   -949,  -2206,  -1852,
+    -7700,     89,    372,    312,    709,   2950,   2476,   -119,
+    -2903,   1552,  14867,   9970,   -496,   -514,   -147, -13491,
+    -6068,    -15,    275,   2634,  -1408,   1766,   -944,  -9047,
+      -87,     47,    450,    302,   3243,   8234,   7586,   3373,
+     2151,   -642,  -4138,  -3512,   -694,   -282,  -1630,  -1501,
+    -3812,   -667,  -1695,  -1561,   -425,  -1081,   -996,   -442,
+    -9631,     60,   3501,   5359,  10150,  -5662,      0,   -748,
+    -1752,  -6288,     35,   2058,    -12,   3150,    -19,  -1145,
+     5967,    -37,  -2169,  -3320,  -6874,  -2553,  -5446,  -2195,
+    -7841,  -2884,   -397,  -1810,   -294,  -3753,  -1071,  -2285,
+     -848,   -921,   -342,   -729,  -3290,  -1221,  -2606,  -1050,
+    -3413,  -1141,   4630,  13612,   7897,   -711,    -79,  -1308,
+   -11310,  -3806,   -237,    964,    322,   2836,    948,  -3847,
+     1645,    550,  -2231,  -6561,   4410,  -5678,   8006,  -3992,
+     3811,  -1187,  -1968,  -3912,   -973,   -886,   1528,  -2155,
+     2775,   1074,  -1383,   1951,  -1025,   1321,  -1862,    928,
+     5659,  11535,   2203,   -452,   7169,  -1954,  -8121,   -296,
+      -12,  -3137,  -3984,   -761,  -1551,    156,    318,     60,
+    -2476,  -5048,   -964,    197,   2914,  -2914,   3485,  -3965,
+    13675,   -518,   -518,   -741,   -959, -11414,    518,   -620,
+      620,    705,   -705,    843,  -2433,   2432,  -2909,   3310,
+     7843,   1907,   1022,   8882,   7972,  -3755,   -222,    -63,
+    -4815,  -3879,   -913,   -489,   -119,  -4252,  -1034,   -554,
+    -3816,   -928,   -497,  -4322,  13807,   9531,   1436,   1612,
+     1779, -11636,  -5544,   -125,   -158,   -193,  -8032,  -1210,
+     -835,  -1358,   -938,   -141,  -1499,  -1035,   -156,   -175,
+    13620,  -5337,   5450,  -2263,   1723, -11322,  -1738,  -1813,
+     -312,   -181,   4436,  -4531,   1775,   1881,   -737,    752,
+    -1432,    561,   -573,    238,   5297,   8374,   8872,   7694,
+     6538,  -1712,  -4280,  -4804,  -3613,  -2609,  -2707,  -2868,
+    -4534,  -2487,  -3932,  -4166,  -2113,  -3341,  -3540,  -3070
+};
+
+/**
+ * 0.65^i (Zero part) and 0.75^i (Pole part) scaled by 2^15
+ */
+static const int16_t postfilter_tbl[2][LPC_ORDER] = {
+    /* Zero */
+    {21299, 13844,  8999,  5849, 3802, 2471, 1606, 1044,  679,  441},
+    /* Pole */
+    {24576, 18432, 13824, 10368, 7776, 5832, 4374, 3281, 2460, 1845}
+};
+
+/**
+ * Hamming window coefficients scaled by 2^15
+ */
+static const int16_t hamming_window[LPC_FRAME] = {
+     2621,  2631,  2659,  2705,  2770,  2853,  2955,  3074,  3212,  3367,
+     3541,  3731,  3939,  4164,  4405,  4663,  4937,  5226,  5531,  5851,
+     6186,  6534,  6897,  7273,  7661,  8062,  8475,  8899,  9334,  9780,
+    10235, 10699, 11172, 11653, 12141, 12636, 13138, 13645, 14157, 14673,
+    15193, 15716, 16242, 16769, 17298, 17827, 18356, 18884, 19411, 19935,
+    20457, 20975, 21489, 21999, 22503, 23002, 23494, 23978, 24455, 24924,
+    25384, 25834, 26274, 26704, 27122, 27529, 27924, 28306, 28675, 29031,
+    29373, 29700, 30012, 30310, 30592, 30857, 31107, 31340, 31557, 31756,
+    31938, 32102, 32249, 32377, 32488, 32580, 32654, 32710, 32747, 32766,
+    32766, 32747, 32710, 32654, 32580, 32488, 32377, 32249, 32102, 31938,
+    31756, 31557, 31340, 31107, 30857, 30592, 30310, 30012, 29700, 29373,
+    29031, 28675, 28306, 27924, 27529, 27122, 26704, 26274, 25834, 25384,
+    24924, 24455, 23978, 23494, 23002, 22503, 21999, 21489, 20975, 20457,
+    19935, 19411, 18884, 18356, 17827, 17298, 16769, 16242, 15716, 15193,
+    14673, 14157, 13645, 13138, 12636, 12141, 11653, 11172, 10699, 10235,
+     9780, 9334,   8899,  8475,  8062,  7661,  7273,  6897,  6534,  6186,
+     5851, 5531,   5226,  4937,  4663,  4405,  4164,  3939,  3731,  3541,
+     3367, 3212,   3074,  2955,  2853,  2770,  2705,  2659,  2631,  2621
+};
+
+/**
+ * Binomial window coefficients scaled by 2^15
+ */
+static const int16_t binomial_window[LPC_ORDER] = {
+    32749, 32695, 32604, 32477, 32315, 32118, 31887, 31622, 31324, 30995
+};
+
+/**
+ * 0.994^i scaled by 2^15
+ */
+static const int16_t bandwidth_expand[LPC_ORDER] = {
+    32571, 32376, 32182, 31989, 31797, 31606, 31416, 31228, 31040, 30854
+};
+
+/**
+ * 0.5^i scaled by 2^15
+ */
+static const int16_t percept_flt_tbl[2][LPC_ORDER] = {
+    /* Zero part */
+    {29491, 26542, 23888, 21499, 19349, 17414, 15673, 14106, 12695, 11425},
+    /* Pole part */
+    {16384,  8192,  4096,  2048,  1024,   512,   256,   128,    64,    32}
+};
+
+static const int cng_adaptive_cb_lag[4] = { 1, 0, 1, 3 };
+
+static const int cng_filt[4] = { 273, 998, 499, 333 };
+
+static const int cng_bseg[3] = { 2048, 18432, 231233 };
 
 #endif /* AVCODEC_G723_1_H */
diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c
index fddd4b0..f601d31 100644
--- a/libavcodec/g723_1dec.c
+++ b/libavcodec/g723_1dec.c
@@ -40,78 +40,6 @@
 
 #define CNG_RANDOM_SEED 12345
 
-/**
- * Postfilter gain weighting factors scaled by 2^15
- */
-static const int16_t ppf_gain_weight[2] = {0x1800, 0x2000};
-
-static const int16_t pitch_contrib[340] = {
-    60,     0,  0,  2489, 60,     0,  0,  5217,
-     1,  6171,  0,  3953,  0, 10364,  1,  9357,
-    -1,  8843,  1,  9396,  0,  5794, -1, 10816,
-     2, 11606, -2, 12072,  0,  8616,  1, 12170,
-     0, 14440,  0,  7787, -1, 13721,  0, 18205,
-     0, 14471,  0, 15807,  1, 15275,  0, 13480,
-    -1, 18375, -1,     0,  1, 11194, -1, 13010,
-     1, 18836, -2, 20354,  1, 16233, -1,     0,
-    60,     0,  0, 12130,  0, 13385,  1, 17834,
-     1, 20875,  0, 21996,  1,     0,  1, 18277,
-    -1, 21321,  1, 13738, -1, 19094, -1, 20387,
-    -1,     0,  0, 21008, 60,     0, -2, 22807,
-     0, 15900,  1,     0,  0, 17989, -1, 22259,
-     1, 24395,  1, 23138,  0, 23948,  1, 22997,
-     2, 22604, -1, 25942,  0, 26246,  1, 25321,
-     0, 26423,  0, 24061,  0, 27247, 60,     0,
-    -1, 25572,  1, 23918,  1, 25930,  2, 26408,
-    -1, 19049,  1, 27357, -1, 24538, 60,     0,
-    -1, 25093,  0, 28549,  1,     0,  0, 22793,
-    -1, 25659,  0, 29377,  0, 30276,  0, 26198,
-     1, 22521, -1, 28919,  0, 27384,  1, 30162,
-    -1,     0,  0, 24237, -1, 30062,  0, 21763,
-     1, 30917, 60,     0,  0, 31284,  0, 29433,
-     1, 26821,  1, 28655,  0, 31327,  2, 30799,
-     1, 31389,  0, 32322,  1, 31760, -2, 31830,
-     0, 26936, -1, 31180,  1, 30875,  0, 27873,
-    -1, 30429,  1, 31050,  0,     0,  0, 31912,
-     1, 31611,  0, 31565,  0, 25557,  0, 31357,
-    60,     0,  1, 29536,  1, 28985, -1, 26984,
-    -1, 31587,  2, 30836, -2, 31133,  0, 30243,
-    -1, 30742, -1, 32090, 60,     0,  2, 30902,
-    60,     0,  0, 30027,  0, 29042, 60,     0,
-     0, 31756,  0, 24553,  0, 25636, -2, 30501,
-    60,     0, -1, 29617,  0, 30649, 60,     0,
-     0, 29274,  2, 30415,  0, 27480,  0, 31213,
-    -1, 28147,  0, 30600,  1, 31652,  2, 29068,
-    60,     0,  1, 28571,  1, 28730,  1, 31422,
-     0, 28257,  0, 24797, 60,     0,  0,     0,
-    60,     0,  0, 22105,  0, 27852, 60,     0,
-    60,     0, -1, 24214,  0, 24642,  0, 23305,
-    60,     0, 60,     0,  1, 22883,  0, 21601,
-    60,     0,  2, 25650, 60,     0, -2, 31253,
-    -2, 25144,  0, 17998
-};
-
-/**
- * Size of the MP-MLQ fixed excitation codebooks
- */
-static const int32_t max_pos[4] = {593775, 142506, 593775, 142506};
-
-/**
- * 0.65^i (Zero part) and 0.75^i (Pole part) scaled by 2^15
- */
-static const int16_t postfilter_tbl[2][LPC_ORDER] = {
-    /* Zero */
-    {21299, 13844,  8999,  5849, 3802, 2471, 1606, 1044,  679,  441},
-    /* Pole */
-    {24576, 18432, 13824, 10368, 7776, 5832, 4374, 3281, 2460, 1845}
-};
-
-static const int cng_adaptive_cb_lag[4] = { 1, 0, 1, 3 };
-
-static const int cng_filt[4] = { 273, 998, 499, 333 };
-
-static const int cng_bseg[3] = { 2048, 18432, 231233 };
-
 static av_cold int g723_1_decode_init(AVCodecContext *avctx)
 {
     G723_1_Context *s = avctx->priv_data;
@@ -293,16 +221,16 @@
         j = PULSE_MAX - pulses[index];
         temp = subfrm->pulse_pos;
         for (i = 0; i < SUBFRAME_LEN / GRID_SIZE; i++) {
-            temp -= ff_g723_1_combinatorial_table[j][i];
+            temp -= combinatorial_table[j][i];
             if (temp >= 0)
                 continue;
-            temp += ff_g723_1_combinatorial_table[j++][i];
+            temp += combinatorial_table[j++][i];
             if (subfrm->pulse_sign & (1 << (PULSE_MAX - j))) {
                 vector[subfrm->grid_index + GRID_SIZE * i] =
-                                        -ff_g723_1_fixed_cb_gain[subfrm->amp_index];
+                                        -fixed_cb_gain[subfrm->amp_index];
             } else {
                 vector[subfrm->grid_index + GRID_SIZE * i] =
-                                         ff_g723_1_fixed_cb_gain[subfrm->amp_index];
+                                         fixed_cb_gain[subfrm->amp_index];
             }
             if (j == PULSE_MAX)
                 break;
@@ -310,7 +238,7 @@
         if (subfrm->dirac_train == 1)
             ff_g723_1_gen_dirac_train(vector, pitch_lag);
     } else { /* 5300 bps */
-        int cb_gain  = ff_g723_1_fixed_cb_gain[subfrm->amp_index];
+        int cb_gain  = fixed_cb_gain[subfrm->amp_index];
         int cb_shift = subfrm->grid_index;
         int cb_sign  = subfrm->pulse_sign;
         int cb_pos   = subfrm->pulse_pos;
@@ -987,7 +915,7 @@
                 int16_t *vector_ptr = p->excitation + PITCH_MAX;
 
                 /* Update interpolation gain memory */
-                p->interp_gain = ff_g723_1_fixed_cb_gain[(p->subframe[2].amp_index +
+                p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index +
                                                 p->subframe[3].amp_index) >> 1];
                 for (i = 0; i < SUBFRAMES; i++) {
                     gen_fcb_excitation(vector_ptr, &p->subframe[i], p->cur_rate,
diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c
index 11b0c7f..b2ba3c2 100644
--- a/libavcodec/g723_1enc.c
+++ b/libavcodec/g723_1enc.c
@@ -40,54 +40,6 @@
 #define BITSTREAM_WRITER_LE
 #include "put_bits.h"
 
-/**
- * Hamming window coefficients scaled by 2^15
- */
-static const int16_t hamming_window[LPC_FRAME] = {
-     2621,  2631,  2659,  2705,  2770,  2853,  2955,  3074,  3212,  3367,
-     3541,  3731,  3939,  4164,  4405,  4663,  4937,  5226,  5531,  5851,
-     6186,  6534,  6897,  7273,  7661,  8062,  8475,  8899,  9334,  9780,
-    10235, 10699, 11172, 11653, 12141, 12636, 13138, 13645, 14157, 14673,
-    15193, 15716, 16242, 16769, 17298, 17827, 18356, 18884, 19411, 19935,
-    20457, 20975, 21489, 21999, 22503, 23002, 23494, 23978, 24455, 24924,
-    25384, 25834, 26274, 26704, 27122, 27529, 27924, 28306, 28675, 29031,
-    29373, 29700, 30012, 30310, 30592, 30857, 31107, 31340, 31557, 31756,
-    31938, 32102, 32249, 32377, 32488, 32580, 32654, 32710, 32747, 32766,
-    32766, 32747, 32710, 32654, 32580, 32488, 32377, 32249, 32102, 31938,
-    31756, 31557, 31340, 31107, 30857, 30592, 30310, 30012, 29700, 29373,
-    29031, 28675, 28306, 27924, 27529, 27122, 26704, 26274, 25834, 25384,
-    24924, 24455, 23978, 23494, 23002, 22503, 21999, 21489, 20975, 20457,
-    19935, 19411, 18884, 18356, 17827, 17298, 16769, 16242, 15716, 15193,
-    14673, 14157, 13645, 13138, 12636, 12141, 11653, 11172, 10699, 10235,
-     9780, 9334,   8899,  8475,  8062,  7661,  7273,  6897,  6534,  6186,
-     5851, 5531,   5226,  4937,  4663,  4405,  4164,  3939,  3731,  3541,
-     3367, 3212,   3074,  2955,  2853,  2770,  2705,  2659,  2631,  2621
-};
-
-/**
- * Binomial window coefficients scaled by 2^15
- */
-static const int16_t binomial_window[LPC_ORDER] = {
-    32749, 32695, 32604, 32477, 32315, 32118, 31887, 31622, 31324, 30995
-};
-
-/**
- * 0.994^i scaled by 2^15
- */
-static const int16_t bandwidth_expand[LPC_ORDER] = {
-    32571, 32376, 32182, 31989, 31797, 31606, 31416, 31228, 31040, 30854
-};
-
-/**
- * 0.5^i scaled by 2^15
- */
-static const int16_t percept_flt_tbl[2][LPC_ORDER] = {
-    /* Zero part */
-    {29491, 26542, 23888, 21499, 19349, 17414, 15673, 14106, 12695, 11425},
-    /* Pole part */
-    {16384,  8192,  4096,  2048,  1024,   512,   256,   128,    64,    32}
-};
-
 static av_cold int g723_1_encode_init(AVCodecContext *avctx)
 {
     G723_1_Context *s = avctx->priv_data;
@@ -290,14 +242,14 @@
     p    = 0;
     temp = 0;
     for (i = 0; i <= LPC_ORDER / 2; i++)
-        temp += f[2 * i] * G723_1_COS_TAB_FIRST_ELEMENT;
+        temp += f[2 * i] * cos_tab[0];
     prev_val = av_clipl_int32(temp << 1);
     count    = 0;
     for (i = 1; i < COS_TBL_SIZE / 2; i++) {
         /* Evaluate */
         temp = 0;
         for (j = 0; j <= LPC_ORDER / 2; j++)
-            temp += f[LPC_ORDER - 2 * j + p] * ff_g723_1_cos_tab[i * j % COS_TBL_SIZE];
+            temp += f[LPC_ORDER - 2 * j + p] * cos_tab[i * j % COS_TBL_SIZE];
         cur_val = av_clipl_int32(temp << 1);
 
         /* Check for sign change, indicating a zero crossing */
@@ -321,7 +273,7 @@
             temp = 0;
             for (j = 0; j <= LPC_ORDER / 2; j++)
                 temp += f[LPC_ORDER - 2 * j + p] *
-                        ff_g723_1_cos_tab[i * j % COS_TBL_SIZE];
+                        cos_tab[i * j % COS_TBL_SIZE];
             cur_val = av_clipl_int32(temp << 1);
         }
         prev_val = cur_val;
@@ -346,11 +298,11 @@
                                                                               \
     for (i = 0; i < LSP_CB_SIZE; i++) {                                       \
         for (j = 0; j < size; j++){                                           \
-            temp[j] = (weight[j + (offset)] * ff_g723_1_lsp_band##num[i][j] + \
+            temp[j] = (weight[j + (offset)] * lsp_band##num[i][j] +           \
                       (1 << 14)) >> 15;                                       \
         }                                                                     \
         error  = ff_g723_1_dot_product(lsp + (offset), temp, size) << 1;      \
-        error -= ff_g723_1_dot_product(ff_g723_1_lsp_band##num[i], temp, size); \
+        error -= ff_g723_1_dot_product(lsp_band##num[i], temp, size);         \
         if (error > max) {                                                    \
             max = error;                                                      \
             lsp_index[num] = i;                                               \
@@ -690,7 +642,7 @@
 {
     int16_t flt_buf[PITCH_ORDER][SUBFRAME_LEN];
 
-    const int16_t *cb_tbl = ff_g723_1_adaptive_cb_gain85;
+    const int16_t *cb_tbl = adaptive_cb_gain85;
 
     int ccr_buf[PITCH_ORDER * SUBFRAMES << 2];
 
@@ -768,7 +720,7 @@
         /* Select quantization table */
         if (!odd_frame && pitch_lag + i - 1 >= SUBFRAME_LEN - 2 ||
             odd_frame && pitch_lag >= SUBFRAME_LEN - 2) {
-            cb_tbl   = ff_g723_1_adaptive_cb_gain170;
+            cb_tbl   = adaptive_cb_gain170;
             tbl_size = 170;
         }
 
@@ -886,7 +838,7 @@
         min           = 1 << 30;
         max_amp_index = GAIN_LEVELS - 2;
         for (j = max_amp_index; j >= 2; j--) {
-            temp = av_clipl_int32((int64_t) ff_g723_1_fixed_cb_gain[j] *
+            temp = av_clipl_int32((int64_t) fixed_cb_gain[j] *
                                   impulse_corr[0] << 1);
             temp = FFABS(temp - amp);
             if (temp < min) {
@@ -903,7 +855,7 @@
                 ccr2[k]      = ccr1[k];
             }
             param.amp_index = max_amp_index + j - 2;
-            amp             = ff_g723_1_fixed_cb_gain[param.amp_index];
+            amp             = fixed_cb_gain[param.amp_index];
 
             param.pulse_sign[0] = (ccr2[param.pulse_pos[0]] < 0) ? -amp : amp;
             temp_corr[param.pulse_pos[0]] = 1;
@@ -990,7 +942,7 @@
     for (i = 0; i < SUBFRAME_LEN >> 1; i++) {
         int val = buf[optim->grid_index + (i << 1)];
         if (!val) {
-            subfrm->pulse_pos += ff_g723_1_combinatorial_table[j][i];
+            subfrm->pulse_pos += combinatorial_table[j][i];
         } else {
             subfrm->pulse_sign <<= 1;
             if (val < 0)
diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c
index 860634c..2be1e2e 100644
--- a/libavcodec/gdv.c
+++ b/libavcodec/gdv.c
@@ -461,8 +461,7 @@
     GetByteContext *gb = &gdv->gb;
     PutByteContext *pb = &gdv->pb;
     AVFrame *frame = data;
-    int ret, i;
-    buffer_size_t pal_size;
+    int ret, i, pal_size;
     const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
     int compression;
     unsigned flags;
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index 938bc0e..de41992 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -47,12 +47,10 @@
     const AVClass *class;
     LZWState *lzw;
     uint8_t *buf;
-    uint8_t *shrunk_buf;
     int buf_size;
     AVFrame *last_frame;
     int flags;
     int image;
-    int use_global_palette;
     uint32_t palette[AVPALETTE_COUNT];  ///< local reference palette for !pal8
     int palette_loaded;
     int transparent_index;
@@ -64,38 +62,6 @@
     GF_TRANSDIFF  = 1<<1,
 };
 
-static void shrink_palette(const uint32_t *src, uint8_t *map,
-                           uint32_t *dst, size_t *palette_count)
-{
-    size_t colors_seen = 0;
-
-    for (size_t i = 0; i < AVPALETTE_COUNT; i++) {
-        int seen = 0;
-        for (size_t c = 0; c < colors_seen; c++) {
-            if (src[i] == dst[c]) {
-                seen = 1;
-                break;
-            }
-        }
-        if (!seen) {
-            dst[colors_seen] = src[i];
-            map[i] = colors_seen;
-            colors_seen++;
-        }
-    }
-
-    *palette_count = colors_seen;
-}
-
-static void remap_frame_to_palette(const uint8_t *src, int src_linesize,
-                                   uint8_t *dst, int dst_linesize,
-                                   int w, int h, uint8_t *map)
-{
-    for (int i = 0; i < h; i++)
-        for (int j = 0; j < w; j++)
-            dst[i * dst_linesize + j] = map[src[i * src_linesize + j]];
-}
-
 static int is_image_translucent(AVCodecContext *avctx,
                                 const uint8_t *buf, const int linesize)
 {
@@ -300,17 +266,6 @@
     int x_start = 0, y_start = 0, trans = s->transparent_index;
     int bcid = -1, honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame && !palette;
     const uint8_t *ptr;
-    uint32_t shrunk_palette[AVPALETTE_COUNT];
-    uint8_t map[AVPALETTE_COUNT] = { 0 };
-    size_t shrunk_palette_count = 0;
-
-    /*
-     * We memset to 0xff instead of 0x00 so that the transparency detection
-     * doesn't pick anything after the palette entries as the transparency
-     * index, and because GIF89a requires us to always write a power-of-2
-     * number of palette entries.
-     */
-    memset(shrunk_palette, 0xff, AVPALETTE_SIZE);
 
     if (!s->image && is_image_translucent(avctx, buf, linesize)) {
         gif_crop_translucent(avctx, buf, linesize, &width, &height, &x_start, &y_start);
@@ -338,14 +293,12 @@
 
         bcid = get_palette_transparency_index(global_palette);
 
-        bytestream_put_byte(bytestream, ((uint8_t) s->use_global_palette << 7) | 0x70 | (s->use_global_palette ? 7 : 0)); /* flags: global clut, 256 entries */
+        bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */
         bytestream_put_byte(bytestream, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : bcid); /* background color index */
         bytestream_put_byte(bytestream, aspect);
-        if (s->use_global_palette) {
-            for (int i = 0; i < 256; i++) {
-                const uint32_t v = global_palette[i] & 0xffffff;
-                bytestream_put_be24(bytestream, v);
-            }
+        for (int i = 0; i < 256; i++) {
+            const uint32_t v = global_palette[i] & 0xffffff;
+            bytestream_put_be24(bytestream, v);
         }
     }
 
@@ -359,11 +312,6 @@
     if (trans < 0)
         honor_transparency = 0;
 
-    if (palette || !s->use_global_palette) {
-        const uint32_t *pal = palette ? palette : s->palette;
-        shrink_palette(pal, map, shrunk_palette, &shrunk_palette_count);
-    }
-
     bcid = honor_transparency || disposal == GCE_DISPOSAL_BACKGROUND ? trans : get_palette_transparency_index(palette);
 
     /* graphic control extension */
@@ -372,7 +320,7 @@
     bytestream_put_byte(bytestream, 0x04); /* block size */
     bytestream_put_byte(bytestream, disposal<<2 | (bcid >= 0));
     bytestream_put_le16(bytestream, 5); // default delay
-    bytestream_put_byte(bytestream, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : (shrunk_palette_count ? map[bcid] : bcid));
+    bytestream_put_byte(bytestream, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : bcid);
     bytestream_put_byte(bytestream, 0x00);
 
     /* image block */
@@ -382,18 +330,15 @@
     bytestream_put_le16(bytestream, width);
     bytestream_put_le16(bytestream, height);
 
-    if (palette || !s->use_global_palette) {
-        const uint32_t *pal = palette ? palette : s->palette;
-        unsigned pow2_count = av_log2(shrunk_palette_count - 1);
+    if (!palette) {
+        bytestream_put_byte(bytestream, 0x00); /* flags */
+    } else {
         unsigned i;
-
-        bytestream_put_byte(bytestream, 1<<7 | pow2_count); /* flags */
-        for (i = 0; i < 1 << (pow2_count + 1); i++) {
-            const uint32_t v = pal[i];
+        bytestream_put_byte(bytestream, 1<<7 | 0x7); /* flags */
+        for (i = 0; i < AVPALETTE_COUNT; i++) {
+            const uint32_t v = palette[i];
             bytestream_put_be24(bytestream, v);
         }
-    } else {
-        bytestream_put_byte(bytestream, 0x00); /* flags */
     }
 
     bytestream_put_byte(bytestream, 0x08);
@@ -401,19 +346,7 @@
     ff_lzw_encode_init(s->lzw, s->buf, s->buf_size,
                        12, FF_LZW_GIF, 1);
 
-    if (shrunk_palette_count) {
-        if (!s->shrunk_buf) {
-            s->shrunk_buf = av_malloc(avctx->height * linesize);
-            if (!s->shrunk_buf) {
-                av_log(avctx, AV_LOG_ERROR, "Could not allocated remapped frame buffer.\n");
-                return AVERROR(ENOMEM);
-            }
-        }
-        remap_frame_to_palette(buf, linesize, s->shrunk_buf, linesize, avctx->width, avctx->height, map);
-        ptr = s->shrunk_buf + y_start*linesize + x_start;
-    } else {
-        ptr = buf + y_start*linesize + x_start;
-    }
+    ptr = buf + y_start*linesize + x_start;
     if (honor_transparency) {
         const int ref_linesize = s->last_frame->linesize[0];
         const uint8_t *ref = s->last_frame->data[0] + y_start*ref_linesize + x_start;
@@ -527,7 +460,6 @@
 
     av_freep(&s->lzw);
     av_freep(&s->buf);
-    av_freep(&s->shrunk_buf);
     s->buf_size = 0;
     av_frame_free(&s->last_frame);
     av_freep(&s->tmpl);
@@ -541,7 +473,6 @@
         { "offsetting", "enable picture offsetting", 0, AV_OPT_TYPE_CONST, {.i64=GF_OFFSETTING}, INT_MIN, INT_MAX, FLAGS, "flags" },
         { "transdiff", "enable transparency detection between frames", 0, AV_OPT_TYPE_CONST, {.i64=GF_TRANSDIFF}, INT_MIN, INT_MAX, FLAGS, "flags" },
     { "gifimage", "enable encoding only images per frame", OFFSET(image), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
-    { "global_palette", "write a palette to the global gif header where feasible", OFFSET(use_global_palette), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
     { NULL }
 };
 
diff --git a/libavcodec/h261.c b/libavcodec/h261.c
index 01abfad..47bad4e 100644
--- a/libavcodec/h261.c
+++ b/libavcodec/h261.c
@@ -30,6 +30,8 @@
 
 #define IS_FIL(a)    ((a) & MB_TYPE_H261_FIL)
 
+uint8_t ff_h261_rl_table_store[2][2 * MAX_RUN + MAX_LEVEL + 3];
+
 static void h261_loop_filter(uint8_t *src, int stride)
 {
     int x, y, xy, yz;
@@ -77,3 +79,14 @@
     h261_loop_filter(dest_cb, uvlinesize);
     h261_loop_filter(dest_cr, uvlinesize);
 }
+
+av_cold void ff_h261_common_init(void)
+{
+    static int done = 0;
+
+    if (done)
+        return;
+
+    ff_rl_init(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
+    done = 1;
+}
diff --git a/libavcodec/h261.h b/libavcodec/h261.h
index 25728a2..399a404 100644
--- a/libavcodec/h261.h
+++ b/libavcodec/h261.h
@@ -48,6 +48,8 @@
 
 #define MB_TYPE_H261_FIL 0x800000
 
+extern uint8_t ff_h261_rl_table_store[2][2 * MAX_RUN + MAX_LEVEL + 3];
+
 extern const uint8_t ff_h261_mba_code[35];
 extern const uint8_t ff_h261_mba_bits[35];
 extern const uint8_t ff_h261_mtype_code[10];
@@ -58,6 +60,7 @@
 extern RLTable ff_h261_rl_tcoeff;
 
 void ff_h261_loop_filter(MpegEncContext *s);
+void ff_h261_common_init(void);
 
 int ff_h261_get_picture_format(int width, int height);
 void ff_h261_reorder_mb_index(MpegEncContext *s);
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 5c25aa9..8a49e7d 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -26,7 +26,6 @@
  */
 
 #include "libavutil/avassert.h"
-#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "mpeg_er.h"
 #include "mpegutils.h"
@@ -35,7 +34,7 @@
 #include "h261.h"
 #include "internal.h"
 
-#define H261_MBA_VLC_BITS 8
+#define H261_MBA_VLC_BITS 9
 #define H261_MTYPE_VLC_BITS 6
 #define H261_MV_VLC_BITS 7
 #define H261_CBP_VLC_BITS 9
@@ -48,39 +47,45 @@
 static VLC h261_mv_vlc;
 static VLC h261_cbp_vlc;
 
-static av_cold void h261_decode_init_static(void)
+static av_cold void h261_decode_init_vlc(H261Context *h)
 {
-    INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
-                    ff_h261_mba_bits, 1, 1,
-                    ff_h261_mba_code, 1, 1, 540);
-    INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
-                    ff_h261_mtype_bits, 1, 1,
-                    ff_h261_mtype_code, 1, 1, 80);
-    INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
-                    &ff_h261_mv_tab[0][1], 2, 1,
-                    &ff_h261_mv_tab[0][0], 2, 1, 144);
-    INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
-                    &ff_h261_cbp_tab[0][1], 2, 1,
-                    &ff_h261_cbp_tab[0][0], 2, 1, 512);
-    INIT_FIRST_VLC_RL(ff_h261_rl_tcoeff, 552);
+    static int done = 0;
+
+    if (!done) {
+        done = 1;
+        INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
+                        ff_h261_mba_bits, 1, 1,
+                        ff_h261_mba_code, 1, 1, 662);
+        INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
+                        ff_h261_mtype_bits, 1, 1,
+                        ff_h261_mtype_code, 1, 1, 80);
+        INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
+                        &ff_h261_mv_tab[0][1], 2, 1,
+                        &ff_h261_mv_tab[0][0], 2, 1, 144);
+        INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
+                        &ff_h261_cbp_tab[0][1], 2, 1,
+                        &ff_h261_cbp_tab[0][0], 2, 1, 512);
+        INIT_VLC_RL(ff_h261_rl_tcoeff, 552);
+    }
 }
 
 static av_cold int h261_decode_init(AVCodecContext *avctx)
 {
-    static AVOnce init_static_once = AV_ONCE_INIT;
     H261Context *h          = avctx->priv_data;
     MpegEncContext *const s = &h->s;
 
     // set defaults
+    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
 
     s->out_format  = FMT_H261;
     s->low_delay   = 1;
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
-    h->gob_start_code_skipped = 0;
+    ff_h261_common_init();
+    h261_decode_init_vlc(h);
 
-    ff_thread_once(&init_static_once, h261_decode_init_static);
+    h->gob_start_code_skipped = 0;
 
     return 0;
 }
@@ -426,7 +431,7 @@
 
     // Read cbp
     if (HAS_CBP(h->mtype))
-        cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 1) + 1;
+        cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1;
 
     if (s->mb_intra) {
         s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
@@ -608,7 +613,10 @@
     }
 
     if (s->width != avctx->coded_width || s->height != avctx->coded_height) {
+        ParseContext pc = s->parse_context; // FIXME move this demuxing hack to libavformat
+        s->parse_context.buffer = 0;
         ff_mpv_common_end(s);
+        s->parse_context = pc;
     }
 
     if (!s->context_initialized) {
@@ -678,6 +686,6 @@
     .close          = h261_decode_end,
     .decode         = h261_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .max_lowres     = 3,
 };
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index eec526c..8d5d62b 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -27,7 +27,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
-#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "mpegutils.h"
 #include "mpegvideo.h"
@@ -362,17 +361,9 @@
     }
 }
 
-static av_cold void h261_encode_init_static(void)
-{
-    static uint8_t h261_rl_table_store[2][2 * MAX_RUN + MAX_LEVEL + 3];
-
-    ff_rl_init(&ff_h261_rl_tcoeff, h261_rl_table_store);
-    init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len);
-}
-
 av_cold void ff_h261_encode_init(MpegEncContext *s)
 {
-    static AVOnce init_static_once = AV_ONCE_INIT;
+    ff_h261_common_init();
 
     s->min_qcoeff       = -127;
     s->max_qcoeff       = 127;
@@ -380,9 +371,10 @@
     s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
     s->ac_esc_length    = 6+6+8;
 
+    init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len);
+
     s->intra_ac_vlc_length      = s->inter_ac_vlc_length      = uni_h261_rl_len;
     s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len + 128*64;
-    ff_thread_once(&init_static_once, h261_encode_init_static);
 }
 
 static const AVClass h261_class = {
@@ -401,7 +393,7 @@
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE },
     .priv_class     = &h261_class,
diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 998f7d0..f891f72 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -34,7 +34,6 @@
 // reading vlc values. Changing these may improve speed and data cache needs
 // be aware though that decreasing them may need the number of stages that is
 // passed to get_vlc* to be increased.
-#define H263_MV_VLC_BITS     9
 #define INTRA_MCBPC_VLC_BITS 6
 #define INTER_MCBPC_VLC_BITS 7
 #define CBPY_VLC_BITS 6
@@ -45,7 +44,6 @@
 extern VLC ff_h263_intra_MCBPC_vlc;
 extern VLC ff_h263_inter_MCBPC_vlc;
 extern VLC ff_h263_cbpy_vlc;
-extern VLC ff_h263_mv_vlc;
 
 extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[];
 
diff --git a/libavcodec/h263data.c b/libavcodec/h263data.c
index 604a042..f649d58 100644
--- a/libavcodec/h263data.c
+++ b/libavcodec/h263data.c
@@ -25,11 +25,11 @@
 
 #include <stdint.h>
 
-#include "libavutil/thread.h"
-
 #include "h263data.h"
 #include "mpegvideo.h"
 
+uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3];
+
 /* intra MCBPC, mb_type = (intra), then (intraq) */
 const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 };
 const uint8_t ff_h263_intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 };
@@ -290,15 +290,3 @@
     {  0,  1 },
     {  0,  1 },
 };
-
-static av_cold void h263_init_rl_inter(void)
-{
-    static uint8_t h263_rl_inter_table[2][2 * MAX_RUN + MAX_LEVEL + 3];
-    ff_rl_init(&ff_h263_rl_inter, h263_rl_inter_table);
-}
-
-av_cold void ff_h263_init_rl_inter(void)
-{
-    static AVOnce init_static_once = AV_ONCE_INIT;
-    ff_thread_once(&init_static_once, h263_init_rl_inter);
-}
diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h
index 144704d..3da0e37 100644
--- a/libavcodec/h263data.h
+++ b/libavcodec/h263data.h
@@ -61,7 +61,7 @@
 
 extern RLTable ff_h263_rl_inter;
 extern RLTable ff_rl_intra_aic;
-void ff_h263_init_rl_inter(void);
+extern uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3];
 
 extern const uint16_t ff_h263_format[8][2];
 
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 6943899..89052e8 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -26,8 +26,6 @@
  */
 
 #include "libavutil/cpu.h"
-#include "libavutil/video_enc_params.h"
-
 #include "avcodec.h"
 #include "error_resilience.h"
 #include "flv.h"
@@ -73,6 +71,7 @@
     s->out_format      = FMT_H263;
 
     // set defaults
+    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
 
     s->quant_precision = 5;
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 1e31bd1..0f98b49 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -146,7 +146,7 @@
     return si;
 }
 
-static const char *const hevc_nal_type_name[64] = {
+static const char *hevc_nal_type_name[64] = {
     "TRAIL_N", // HEVC_NAL_TRAIL_N
     "TRAIL_R", // HEVC_NAL_TRAIL_R
     "TSA_N", // HEVC_NAL_TSA_N
@@ -219,7 +219,7 @@
     return hevc_nal_type_name[nal_type];
 }
 
-static const char *const h264_nal_type_name[32] = {
+static const char *h264_nal_type_name[32] = {
     "Unspecified 0", //H264_NAL_UNSPECIFIED
     "Coded slice of a non-IDR picture", // H264_NAL_SLICE
     "Coded slice data partition A", // H264_NAL_DPA
@@ -467,12 +467,8 @@
             memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
 
             nal = &pkt->nals[pkt->nb_nals];
-            nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); // initial buffer size
-#if 0  // Chromium: Always use av_realloc() for |nal->skipped_bytes_pos|. https://crbug.com/1193797
+            nal->skipped_bytes_pos_size = 1024; // initial buffer size
             nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
-#else
-            nal->skipped_bytes_pos = av_realloc_array(NULL, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
-#endif
             if (!nal->skipped_bytes_pos)
                 return AVERROR(ENOMEM);
 
diff --git a/libavcodec/h264_levels.c b/libavcodec/h264_levels.c
index 801b27f..dd517f1 100644
--- a/libavcodec/h264_levels.c
+++ b/libavcodec/h264_levels.c
@@ -75,6 +75,18 @@
     return 1200;
 }
 
+const H264LevelDescriptor *ff_h264_get_level(int level_idc,
+                                             int constraint_set3_flag)
+{
+    int i;
+    for (i = 0; i < FF_ARRAY_ELEMS(h264_levels); i++) {
+        if (h264_levels[i].level_idc            == level_idc &&
+            h264_levels[i].constraint_set3_flag == constraint_set3_flag)
+            return &h264_levels[i];
+    }
+    return NULL;
+}
+
 const H264LevelDescriptor *ff_h264_guess_level(int profile_idc,
                                                int64_t bitrate,
                                                int framerate,
diff --git a/libavcodec/h264_levels.h b/libavcodec/h264_levels.h
index 6bba2e8..0a0f410 100644
--- a/libavcodec/h264_levels.h
+++ b/libavcodec/h264_levels.h
@@ -36,6 +36,9 @@
     uint8_t     max_mvs_per_2mb;
 } H264LevelDescriptor;
 
+const H264LevelDescriptor *ff_h264_get_level(int level_idc,
+                                             int constraint_set3_flag);
+
 /**
  * Guess the level of a stream from some parameters.
  *
diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index 558ec6c..0924f32 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -27,7 +27,6 @@
 
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "internal.h"
 #include "avcodec.h"
 #include "h264dec.h"
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index c3a63f3..eb15031 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -22,14 +22,21 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
-#include "cbs_bsf.h"
 #include "cbs_h264.h"
 #include "h264.h"
 #include "h264_levels.h"
 #include "h264_sei.h"
 
 enum {
+    PASS,
+    INSERT,
+    REMOVE,
+    EXTRACT,
+};
+
+enum {
     FLIP_HORIZONTAL = 1,
     FLIP_VERTICAL   = 2,
 };
@@ -40,12 +47,15 @@
 };
 
 typedef struct H264MetadataContext {
-    CBSBSFContext common;
+    const AVClass *class;
+
+    CodedBitstreamContext *input;
+    CodedBitstreamContext *output;
+    CodedBitstreamFragment access_unit;
 
     int done_first_au;
 
     int aud;
-    H264RawAUD aud_nal;
 
     AVRational sample_aspect_ratio;
 
@@ -68,72 +78,17 @@
     int crop_bottom;
 
     const char *sei_user_data;
-    SEIRawUserDataUnregistered sei_user_data_payload;
 
     int delete_filler;
 
     int display_orientation;
     double rotate;
     int flip;
-    H264RawSEIDisplayOrientation display_orientation_payload;
 
     int level;
 } H264MetadataContext;
 
 
-static int h264_metadata_insert_aud(AVBSFContext *bsf,
-                                    CodedBitstreamFragment *au)
-{
-    H264MetadataContext *ctx = bsf->priv_data;
-    int primary_pic_type_mask = 0xff;
-    int err, i, j;
-
-    static const int primary_pic_type_table[] = {
-        0x084, // 2, 7
-        0x0a5, // 0, 2, 5, 7
-        0x0e7, // 0, 1, 2, 5, 6, 7
-        0x210, // 4, 9
-        0x318, // 3, 4, 8, 9
-        0x294, // 2, 4, 7, 9
-        0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9
-        0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
-    };
-
-    for (i = 0; i < au->nb_units; i++) {
-        if (au->units[i].type == H264_NAL_SLICE ||
-            au->units[i].type == H264_NAL_IDR_SLICE) {
-            H264RawSlice *slice = au->units[i].content;
-            for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) {
-                if (!(primary_pic_type_table[j] &
-                      (1 << slice->header.slice_type)))
-                    primary_pic_type_mask &= ~(1 << j);
-            }
-        }
-    }
-    for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++)
-        if (primary_pic_type_mask & (1 << j))
-            break;
-    if (j >= FF_ARRAY_ELEMS(primary_pic_type_table)) {
-        av_log(bsf, AV_LOG_ERROR, "No usable primary_pic_type: "
-               "invalid slice types?\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    ctx->aud_nal = (H264RawAUD) {
-        .nal_unit_header.nal_unit_type = H264_NAL_AUD,
-        .primary_pic_type = j,
-    };
-
-    err = ff_cbs_insert_unit_content(au, 0, H264_NAL_AUD,
-                                     &ctx->aud_nal, NULL);
-    if (err < 0) {
-        av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
-        return err;
-    }
-
-    return 0;
-}
-
 static int h264_metadata_update_sps(AVBSFContext *bsf,
                                     H264RawSPS *sps)
 {
@@ -322,94 +277,292 @@
     return 0;
 }
 
-static int h264_metadata_handle_display_orientation(AVBSFContext *bsf,
-                                                    AVPacket *pkt,
-                                                    CodedBitstreamFragment *au,
-                                                    int seek_point)
+static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
 {
     H264MetadataContext *ctx = bsf->priv_data;
-    SEIRawMessage *message;
-    int err;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    uint8_t *side_data;
+    int side_data_size;
+    int err, i;
 
-    message = NULL;
-    while (ff_cbs_sei_find_message(ctx->common.output, au,
-                                   SEI_TYPE_DISPLAY_ORIENTATION,
-                                   &message) == 0) {
-        H264RawSEIDisplayOrientation *disp = message->payload;
-        int32_t *matrix;
+    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+                                        &side_data_size);
+    if (!side_data_size)
+        return 0;
 
-        matrix = av_malloc(9 * sizeof(int32_t));
-        if (!matrix)
-            return AVERROR(ENOMEM);
+    err = ff_cbs_read(ctx->input, au, side_data, side_data_size);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n");
+        return err;
+    }
 
-        av_display_rotation_set(matrix,
-                                disp->anticlockwise_rotation *
-                                180.0 / 65536.0);
-        av_display_matrix_flip(matrix, disp->hor_flip, disp->ver_flip);
-
-        // If there are multiple display orientation messages in an
-        // access unit, then the last one added to the packet (i.e.
-        // the first one in the access unit) will prevail.
-        err = av_packet_add_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX,
-                                      (uint8_t*)matrix,
-                                      9 * sizeof(int32_t));
-        if (err < 0) {
-            av_log(bsf, AV_LOG_ERROR, "Failed to attach extracted "
-                   "displaymatrix side data to packet.\n");
-            av_free(matrix);
-            return AVERROR(ENOMEM);
+    for (i = 0; i < au->nb_units; i++) {
+        if (au->units[i].type == H264_NAL_SPS) {
+            err = h264_metadata_update_sps(bsf, au->units[i].content);
+            if (err < 0)
+                return err;
         }
     }
 
-    if (ctx->display_orientation == BSF_ELEMENT_REMOVE ||
-        ctx->display_orientation == BSF_ELEMENT_INSERT) {
-        ff_cbs_sei_delete_message_type(ctx->common.output, au,
-                                       SEI_TYPE_DISPLAY_ORIENTATION);
+    err = ff_cbs_write_fragment_data(ctx->output, au);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n");
+        return err;
     }
 
-    if (ctx->display_orientation == BSF_ELEMENT_INSERT) {
+    side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size);
+    if (!side_data)
+        return AVERROR(ENOMEM);
+    memcpy(side_data, au->data, au->data_size);
+
+    ff_cbs_fragment_reset(au);
+
+    return 0;
+}
+
+static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+{
+    H264MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    int err, i, j, has_sps;
+    H264RawAUD aud;
+
+    err = ff_bsf_get_packet_ref(bsf, pkt);
+    if (err < 0)
+        return err;
+
+    err = h264_metadata_update_side_data(bsf, pkt);
+    if (err < 0)
+        goto fail;
+
+    err = ff_cbs_read_packet(ctx->input, au, pkt);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+        goto fail;
+    }
+
+    if (au->nb_units == 0) {
+        av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n");
+        err = AVERROR_INVALIDDATA;
+        goto fail;
+    }
+
+    // If an AUD is present, it must be the first NAL unit.
+    if (au->units[0].type == H264_NAL_AUD) {
+        if (ctx->aud == REMOVE)
+            ff_cbs_delete_unit(au, 0);
+    } else {
+        if (ctx->aud == INSERT) {
+            static const int primary_pic_type_table[] = {
+                0x084, // 2, 7
+                0x0a5, // 0, 2, 5, 7
+                0x0e7, // 0, 1, 2, 5, 6, 7
+                0x210, // 4, 9
+                0x318, // 3, 4, 8, 9
+                0x294, // 2, 4, 7, 9
+                0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9
+                0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+            };
+            int primary_pic_type_mask = 0xff;
+
+            for (i = 0; i < au->nb_units; i++) {
+                if (au->units[i].type == H264_NAL_SLICE ||
+                    au->units[i].type == H264_NAL_IDR_SLICE) {
+                    H264RawSlice *slice = au->units[i].content;
+                    for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) {
+                         if (!(primary_pic_type_table[j] &
+                               (1 << slice->header.slice_type)))
+                             primary_pic_type_mask &= ~(1 << j);
+                    }
+                }
+            }
+            for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++)
+                if (primary_pic_type_mask & (1 << j))
+                    break;
+            if (j >= FF_ARRAY_ELEMS(primary_pic_type_table)) {
+                av_log(bsf, AV_LOG_ERROR, "No usable primary_pic_type: "
+                       "invalid slice types?\n");
+                err = AVERROR_INVALIDDATA;
+                goto fail;
+            }
+
+            aud = (H264RawAUD) {
+                .nal_unit_header.nal_unit_type = H264_NAL_AUD,
+                .primary_pic_type = j,
+            };
+
+            err = ff_cbs_insert_unit_content(au,
+                                             0, H264_NAL_AUD, &aud, NULL);
+            if (err < 0) {
+                av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
+                goto fail;
+            }
+        }
+    }
+
+    has_sps = 0;
+    for (i = 0; i < au->nb_units; i++) {
+        if (au->units[i].type == H264_NAL_SPS) {
+            err = h264_metadata_update_sps(bsf, au->units[i].content);
+            if (err < 0)
+                goto fail;
+            has_sps = 1;
+        }
+    }
+
+    // Only insert the SEI in access units containing SPSs, and also
+    // unconditionally in the first access unit we ever see.
+    if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
+        H264RawSEIPayload payload = {
+            .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
+        };
+        H264RawSEIUserDataUnregistered *udu =
+            &payload.payload.user_data_unregistered;
+
+        for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) {
+            int c, v;
+            c = ctx->sei_user_data[i];
+            if (c == '-') {
+                continue;
+            } else if (av_isxdigit(c)) {
+                c = av_tolower(c);
+                v = (c <= '9' ? c - '0' : c - 'a' + 10);
+            } else {
+                goto invalid_user_data;
+            }
+            if (j & 1)
+                udu->uuid_iso_iec_11578[j / 2] |= v;
+            else
+                udu->uuid_iso_iec_11578[j / 2] = v << 4;
+            ++j;
+        }
+        if (j == 32 && ctx->sei_user_data[i] == '+') {
+            size_t len = strlen(ctx->sei_user_data + i + 1);
+
+            udu->data_ref = av_buffer_alloc(len + 1);
+            if (!udu->data_ref) {
+                err = AVERROR(ENOMEM);
+                goto fail;
+            }
+
+            udu->data        = udu->data_ref->data;
+            udu->data_length = len + 1;
+            memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1);
+
+            err = ff_cbs_h264_add_sei_message(au, &payload);
+            if (err < 0) {
+                av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
+                       "message to access unit.\n");
+                goto fail;
+            }
+
+        } else {
+        invalid_user_data:
+            av_log(bsf, AV_LOG_ERROR, "Invalid user data: "
+                   "must be \"UUID+string\".\n");
+            err = AVERROR(EINVAL);
+            goto fail;
+        }
+    }
+
+    if (ctx->delete_filler) {
+        for (i = au->nb_units - 1; i >= 0; i--) {
+            if (au->units[i].type == H264_NAL_FILLER_DATA) {
+                ff_cbs_delete_unit(au, i);
+                continue;
+            }
+
+            if (au->units[i].type == H264_NAL_SEI) {
+                // Filler SEI messages.
+                H264RawSEI *sei = au->units[i].content;
+
+                for (j = sei->payload_count - 1; j >= 0; j--) {
+                    if (sei->payload[j].payload_type ==
+                        H264_SEI_TYPE_FILLER_PAYLOAD)
+                        ff_cbs_h264_delete_sei_message(au, &au->units[i], j);
+                }
+            }
+        }
+    }
+
+    if (ctx->display_orientation != PASS) {
+        for (i = au->nb_units - 1; i >= 0; i--) {
+            H264RawSEI *sei;
+            if (au->units[i].type != H264_NAL_SEI)
+                continue;
+            sei = au->units[i].content;
+
+            for (j = sei->payload_count - 1; j >= 0; j--) {
+                H264RawSEIDisplayOrientation *disp;
+                int32_t *matrix;
+
+                if (sei->payload[j].payload_type !=
+                    H264_SEI_TYPE_DISPLAY_ORIENTATION)
+                    continue;
+                disp = &sei->payload[j].payload.display_orientation;
+
+                if (ctx->display_orientation == REMOVE ||
+                    ctx->display_orientation == INSERT) {
+                    ff_cbs_h264_delete_sei_message(au, &au->units[i], j);
+                    continue;
+                }
+
+                matrix = av_malloc(9 * sizeof(int32_t));
+                if (!matrix) {
+                    err = AVERROR(ENOMEM);
+                    goto fail;
+                }
+
+                av_display_rotation_set(matrix,
+                                        disp->anticlockwise_rotation *
+                                        180.0 / 65536.0);
+                av_display_matrix_flip(matrix, disp->hor_flip, disp->ver_flip);
+
+                // If there are multiple display orientation messages in an
+                // access unit, then the last one added to the packet (i.e.
+                // the first one in the access unit) will prevail.
+                err = av_packet_add_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX,
+                                              (uint8_t*)matrix,
+                                              9 * sizeof(int32_t));
+                if (err < 0) {
+                    av_log(bsf, AV_LOG_ERROR, "Failed to attach extracted "
+                           "displaymatrix side data to packet.\n");
+                    av_free(matrix);
+                    goto fail;
+                }
+            }
+        }
+    }
+    if (ctx->display_orientation == INSERT) {
+        H264RawSEIPayload payload = {
+            .payload_type = H264_SEI_TYPE_DISPLAY_ORIENTATION,
+        };
         H264RawSEIDisplayOrientation *disp =
-            &ctx->display_orientation_payload;
+            &payload.payload.display_orientation;
         uint8_t *data;
-        buffer_size_t size;
+        int size;
         int write = 0;
 
         data = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size);
         if (data && size >= 9 * sizeof(int32_t)) {
             int32_t matrix[9];
-            double dmatrix[9];
-            int hflip, vflip, i;
-            double scale_x, scale_y, angle;
+            int hflip, vflip;
+            double angle;
 
             memcpy(matrix, data, sizeof(matrix));
 
-            for (i = 0; i < 9; i++)
-                dmatrix[i] = matrix[i] / 65536.0;
+            hflip = vflip = 0;
+            if (matrix[0] < 0 && matrix[4] > 0)
+                hflip = 1;
+            else if (matrix[0] > 0 && matrix[4] < 0)
+                vflip = 1;
+            av_display_matrix_flip(matrix, hflip, vflip);
 
-            // Extract scale factors.
-            scale_x = hypot(dmatrix[0], dmatrix[3]);
-            scale_y = hypot(dmatrix[1], dmatrix[4]);
+            angle = av_display_rotation_get(matrix);
 
-            // Select flips to make the main diagonal positive.
-            hflip = dmatrix[0] < 0.0;
-            vflip = dmatrix[4] < 0.0;
-            if (hflip)
-                scale_x = -scale_x;
-            if (vflip)
-                scale_y = -scale_y;
-
-            // Rescale.
-            for (i = 0; i < 9; i += 3) {
-                dmatrix[i]     /= scale_x;
-                dmatrix[i + 1] /= scale_y;
-            }
-
-            // Extract rotation.
-            angle = atan2(dmatrix[3], dmatrix[0]);
-
-            if (!(angle >= -M_PI && angle <= M_PI) ||
-                matrix[2] != 0.0 || matrix[5] != 0.0 ||
-                matrix[6] != 0.0 || matrix[7] != 0.0) {
+            if (!(angle >= -180.0 && angle <= 180.0 /* also excludes NaN */) ||
+                matrix[2] != 0 || matrix[5] != 0 ||
+                matrix[6] != 0 || matrix[7] != 0) {
                 av_log(bsf, AV_LOG_WARNING, "Input display matrix is not "
                        "representable in H.264 parameters.\n");
             } else {
@@ -417,13 +570,13 @@
                 disp->ver_flip = vflip;
                 disp->anticlockwise_rotation =
                     (uint16_t)rint((angle >= 0.0 ? angle
-                                                 : angle + 2 * M_PI) *
-                                   32768.0 / M_PI);
+                                                 : angle + 360.0) *
+                                   65536.0 / 360.0);
                 write = 1;
             }
         }
 
-        if (seek_point) {
+        if (has_sps || !ctx->done_first_au) {
             if (!isnan(ctx->rotate)) {
                 disp->anticlockwise_rotation =
                     (uint16_t)rint((ctx->rotate >= 0.0 ? ctx->rotate
@@ -441,148 +594,95 @@
         if (write) {
             disp->display_orientation_repetition_period = 1;
 
-            err = ff_cbs_sei_add_message(ctx->common.output, au, 1,
-                                         SEI_TYPE_DISPLAY_ORIENTATION,
-                                         disp, NULL);
+            err = ff_cbs_h264_add_sei_message(au, &payload);
             if (err < 0) {
                 av_log(bsf, AV_LOG_ERROR, "Failed to add display orientation "
                        "SEI message to access unit.\n");
-                return err;
+                goto fail;
             }
         }
     }
 
-    return 0;
+    err = ff_cbs_write_packet(ctx->output, pkt, au);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+        goto fail;
+    }
+
+    ctx->done_first_au = 1;
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(au);
+
+    if (err < 0)
+        av_packet_unref(pkt);
+
+    return err;
 }
 
-static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
-                                         CodedBitstreamFragment *au)
-{
-    H264MetadataContext *ctx = bsf->priv_data;
-    int err, i, has_sps, seek_point;
-
-    // If an AUD is present, it must be the first NAL unit.
-    if (au->units[0].type == H264_NAL_AUD) {
-        if (ctx->aud == BSF_ELEMENT_REMOVE)
-            ff_cbs_delete_unit(au, 0);
-    } else {
-        if (ctx->aud == BSF_ELEMENT_INSERT) {
-            err = h264_metadata_insert_aud(bsf, au);
-            if (err < 0)
-                return err;
-        }
-    }
-
-    has_sps = 0;
-    for (i = 0; i < au->nb_units; i++) {
-        if (au->units[i].type == H264_NAL_SPS) {
-            err = h264_metadata_update_sps(bsf, au->units[i].content);
-            if (err < 0)
-                return err;
-            has_sps = 1;
-        }
-    }
-
-    if (pkt) {
-        // The current packet should be treated as a seek point for metadata
-        // insertion if any of:
-        // - It is the first packet in the stream.
-        // - It contains an SPS, indicating that a sequence might start here.
-        // - It is marked as containing a key frame.
-        seek_point = !ctx->done_first_au || has_sps ||
-            (pkt->flags & AV_PKT_FLAG_KEY);
-    } else {
-        seek_point = 0;
-    }
-
-    if (ctx->sei_user_data && seek_point) {
-        err = ff_cbs_sei_add_message(ctx->common.output, au, 1,
-                                     SEI_TYPE_USER_DATA_UNREGISTERED,
-                                     &ctx->sei_user_data_payload, NULL);
-        if (err < 0) {
-            av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
-                   "message to access unit.\n");
-            return err;
-        }
-    }
-
-    if (ctx->delete_filler) {
-        for (i = au->nb_units - 1; i >= 0; i--) {
-            if (au->units[i].type == H264_NAL_FILLER_DATA) {
-                ff_cbs_delete_unit(au, i);
-                continue;
-            }
-        }
-
-        ff_cbs_sei_delete_message_type(ctx->common.output, au,
-                                       SEI_TYPE_FILLER_PAYLOAD);
-    }
-
-    if (pkt && ctx->display_orientation != BSF_ELEMENT_PASS) {
-        err = h264_metadata_handle_display_orientation(bsf, pkt, au,
-                                                       seek_point);
-        if (err < 0)
-            return err;
-    }
-
-    if (pkt)
-        ctx->done_first_au = 1;
-
-    return 0;
-}
-
-static const CBSBSFType h264_metadata_type = {
-    .codec_id        = AV_CODEC_ID_H264,
-    .fragment_name   = "access unit",
-    .unit_name       = "NAL unit",
-    .update_fragment = &h264_metadata_update_fragment,
-};
-
 static int h264_metadata_init(AVBSFContext *bsf)
 {
     H264MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    int err, i;
 
-    if (ctx->sei_user_data) {
-        SEIRawUserDataUnregistered *udu = &ctx->sei_user_data_payload;
-        int i, j;
+    err = ff_cbs_init(&ctx->input,  AV_CODEC_ID_H264, bsf);
+    if (err < 0)
+        return err;
+    err = ff_cbs_init(&ctx->output, AV_CODEC_ID_H264, bsf);
+    if (err < 0)
+        return err;
 
-        // Parse UUID.  It must be a hex string of length 32, possibly
-        // containing '-'s between hex digits (which we ignore).
-        for (i = j = 0; j < 32 && i < 64 && ctx->sei_user_data[i]; i++) {
-            int c, v;
-            c = ctx->sei_user_data[i];
-            if (c == '-') {
-                continue;
-            } else if (av_isxdigit(c)) {
-                c = av_tolower(c);
-                v = (c <= '9' ? c - '0' : c - 'a' + 10);
-            } else {
-                break;
-            }
-            if (j & 1)
-                udu->uuid_iso_iec_11578[j / 2] |= v;
-            else
-                udu->uuid_iso_iec_11578[j / 2] = v << 4;
-            ++j;
+    if (bsf->par_in->extradata) {
+        err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
+            goto fail;
         }
-        if (j == 32 && ctx->sei_user_data[i] == '+') {
-            udu->data = (uint8_t*)ctx->sei_user_data + i + 1;
-            udu->data_length = strlen(udu->data) + 1;
-        } else {
-            av_log(bsf, AV_LOG_ERROR, "Invalid user data: "
-                   "must be \"UUID+string\".\n");
-            return AVERROR(EINVAL);
+
+        for (i = 0; i < au->nb_units; i++) {
+            if (au->units[i].type == H264_NAL_SPS) {
+                err = h264_metadata_update_sps(bsf, au->units[i].content);
+                if (err < 0)
+                    goto fail;
+            }
+        }
+
+        err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
+            goto fail;
         }
     }
 
-    return ff_cbs_bsf_generic_init(bsf, &h264_metadata_type);
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(au);
+    return err;
+}
+
+static void h264_metadata_close(AVBSFContext *bsf)
+{
+    H264MetadataContext *ctx = bsf->priv_data;
+
+    ff_cbs_fragment_free(&ctx->access_unit);
+    ff_cbs_close(&ctx->input);
+    ff_cbs_close(&ctx->output);
 }
 
 #define OFFSET(x) offsetof(H264MetadataContext, x)
 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption h264_metadata_options[] = {
-    BSF_ELEMENT_OPTIONS_PIR("aud", "Access Unit Delimiter NAL units",
-                            aud, FLAGS),
+    { "aud", "Access Unit Delimiter NAL units",
+        OFFSET(aud), AV_OPT_TYPE_INT,
+        { .i64 = PASS }, PASS, REMOVE, FLAGS, "aud" },
+    { "pass",   NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = PASS   }, .flags = FLAGS, .unit = "aud" },
+    { "insert", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = INSERT }, .flags = FLAGS, .unit = "aud" },
+    { "remove", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = REMOVE }, .flags = FLAGS, .unit = "aud" },
 
     { "sample_aspect_ratio", "Set sample aspect ratio (table E-1)",
         OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL,
@@ -638,9 +738,17 @@
     { "delete_filler", "Delete all filler (both NAL and SEI)",
         OFFSET(delete_filler), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS},
 
-    BSF_ELEMENT_OPTIONS_PIRE("display_orientation",
-                             "Display orientation SEI",
-                             display_orientation, FLAGS),
+    { "display_orientation", "Display orientation SEI",
+        OFFSET(display_orientation), AV_OPT_TYPE_INT,
+        { .i64 = PASS }, PASS, EXTRACT, FLAGS, "disp_or" },
+    { "pass",    NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = PASS    }, .flags = FLAGS, .unit = "disp_or" },
+    { "insert",  NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = INSERT  }, .flags = FLAGS, .unit = "disp_or" },
+    { "remove",  NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = REMOVE  }, .flags = FLAGS, .unit = "disp_or" },
+    { "extract", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = EXTRACT }, .flags = FLAGS, .unit = "disp_or" },
 
     { "rotate", "Set rotation in display orientation SEI (anticlockwise angle in degrees)",
         OFFSET(rotate), AV_OPT_TYPE_DOUBLE,
@@ -704,7 +812,7 @@
     .priv_data_size = sizeof(H264MetadataContext),
     .priv_class     = &h264_metadata_class,
     .init           = &h264_metadata_init,
-    .close          = &ff_cbs_bsf_generic_close,
-    .filter         = &ff_cbs_bsf_generic_filter,
+    .close          = &h264_metadata_close,
+    .filter         = &h264_metadata_filter,
     .codec_ids      = h264_metadata_codec_ids,
 };
diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
index 19d9ee4..bf395e3 100644
--- a/libavcodec/h264_mvpred.h
+++ b/libavcodec/h264_mvpred.h
@@ -33,7 +33,6 @@
 #include "h264dec.h"
 #include "mpegutils.h"
 #include "libavutil/avassert.h"
-#include "libavutil/mem_internal.h"
 
 
 static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl,
diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c
index 6ba4029..cf41abe 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -24,13 +24,15 @@
 #include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
-#include "cbs_bsf.h"
 #include "cbs_h264.h"
 #include "h264.h"
 
 
 typedef struct H264RedundantPPSContext {
-    CBSBSFContext common;
+    CodedBitstreamContext *input;
+    CodedBitstreamContext *output;
+
+    CodedBitstreamFragment access_unit;
 
     int global_pic_init_qp;
     int current_pic_init_qp;
@@ -47,7 +49,7 @@
     // The changes we are about to perform affect the parsing process,
     // so we must make sure that the PPS is writable, otherwise the
     // parsing of future slices will be incorrect and even raise errors.
-    err = ff_cbs_make_unit_writable(ctx->common.input, unit);
+    err = ff_cbs_make_unit_writable(ctx->input, unit);
     if (err < 0)
         return err;
     pps = unit->content;
@@ -76,14 +78,21 @@
     return 0;
 }
 
-static int h264_redundant_pps_update_fragment(AVBSFContext *bsf,
-                                              AVPacket *pkt,
-                                              CodedBitstreamFragment *au)
+static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt)
 {
     H264RedundantPPSContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
     int au_has_sps;
     int err, i;
 
+    err = ff_bsf_get_packet_ref(bsf, pkt);
+    if (err < 0)
+        return err;
+
+    err = ff_cbs_read_packet(ctx->input, au, pkt);
+    if (err < 0)
+        goto fail;
+
     au_has_sps = 0;
     for (i = 0; i < au->nb_units; i++) {
         CodedBitstreamUnit *nal = &au->units[i];
@@ -93,7 +102,7 @@
         if (nal->type == H264_NAL_PPS) {
             err = h264_redundant_pps_fixup_pps(ctx, nal);
             if (err < 0)
-                return err;
+                goto fail;
             if (!au_has_sps) {
                 av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
                        "at %"PRId64".\n", pkt->pts);
@@ -109,7 +118,62 @@
         }
     }
 
-    return 0;
+    err = ff_cbs_write_packet(ctx->output, pkt, au);
+    if (err < 0)
+        goto fail;
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(au);
+    if (err < 0)
+        av_packet_unref(pkt);
+
+    return err;
+}
+
+static int h264_redundant_pps_init(AVBSFContext *bsf)
+{
+    H264RedundantPPSContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    int err, i;
+
+    err = ff_cbs_init(&ctx->input, AV_CODEC_ID_H264, bsf);
+    if (err < 0)
+        return err;
+
+    err = ff_cbs_init(&ctx->output, AV_CODEC_ID_H264, bsf);
+    if (err < 0)
+        return err;
+
+    ctx->global_pic_init_qp = 26;
+
+    if (bsf->par_in->extradata) {
+        err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
+            goto fail;
+        }
+
+        for (i = 0; i < au->nb_units; i++) {
+            if (au->units[i].type == H264_NAL_PPS) {
+                err = h264_redundant_pps_fixup_pps(ctx, &au->units[i]);
+                if (err < 0)
+                    goto fail;
+            }
+        }
+
+        ctx->extradata_pic_init_qp = ctx->current_pic_init_qp;
+        err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
+            goto fail;
+        }
+    }
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(au);
+    return err;
 }
 
 static void h264_redundant_pps_flush(AVBSFContext *bsf)
@@ -118,20 +182,13 @@
     ctx->current_pic_init_qp = ctx->extradata_pic_init_qp;
 }
 
-static const CBSBSFType h264_redundant_pps_type = {
-    .codec_id        = AV_CODEC_ID_H264,
-    .fragment_name   = "access unit",
-    .unit_name       = "NAL unit",
-    .update_fragment = &h264_redundant_pps_update_fragment,
-};
-
-static int h264_redundant_pps_init(AVBSFContext *bsf)
+static void h264_redundant_pps_close(AVBSFContext *bsf)
 {
     H264RedundantPPSContext *ctx = bsf->priv_data;
 
-    ctx->global_pic_init_qp = 26;
-
-    return ff_cbs_bsf_generic_init(bsf, &h264_redundant_pps_type);
+    ff_cbs_fragment_free(&ctx->access_unit);
+    ff_cbs_close(&ctx->input);
+    ff_cbs_close(&ctx->output);
 }
 
 static const enum AVCodecID h264_redundant_pps_codec_ids[] = {
@@ -143,7 +200,7 @@
     .priv_data_size = sizeof(H264RedundantPPSContext),
     .init           = &h264_redundant_pps_init,
     .flush          = &h264_redundant_pps_flush,
-    .close          = &ff_cbs_bsf_generic_close,
-    .filter         = &ff_cbs_bsf_generic_filter,
+    .close          = &h264_redundant_pps_close,
+    .filter         = &h264_redundant_pps_filter,
     .codec_ids      = h264_redundant_pps_codec_ids,
 };
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index ca2ca59..669560a 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -183,59 +183,33 @@
 static int decode_registered_user_data(H264SEIContext *h, GetBitContext *gb,
                                        void *logctx, int size)
 {
-    int country_code, provider_code;
+    uint32_t country_code;
+    uint32_t user_identifier;
 
-    if (size < 3)
+    if (size < 7)
         return AVERROR_INVALIDDATA;
-    size -= 3;
+    size -= 7;
 
     country_code = get_bits(gb, 8); // itu_t_t35_country_code
     if (country_code == 0xFF) {
-        if (size < 1)
-            return AVERROR_INVALIDDATA;
-
         skip_bits(gb, 8);           // itu_t_t35_country_code_extension_byte
         size--;
     }
 
-    if (country_code != 0xB5) { // usa_country_code
-        av_log(logctx, AV_LOG_VERBOSE,
-               "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n",
-               country_code);
-        return 0;
-    }
-
     /* itu_t_t35_payload_byte follows */
-    provider_code = get_bits(gb, 16);
+    skip_bits(gb, 8);              // terminal provider code
+    skip_bits(gb, 8);              // terminal provider oriented code
+    user_identifier = get_bits_long(gb, 32);
 
-    switch (provider_code) {
-    case 0x31: { // atsc_provider_code
-        uint32_t user_identifier;
-
-        if (size < 4)
-            return AVERROR_INVALIDDATA;
-        size -= 4;
-
-        user_identifier = get_bits_long(gb, 32);
-        switch (user_identifier) {
+    switch (user_identifier) {
         case MKBETAG('D', 'T', 'G', '1'):       // afd_data
             return decode_registered_user_data_afd(&h->afd, gb, size);
         case MKBETAG('G', 'A', '9', '4'):       // closed captions
             return decode_registered_user_data_closed_caption(&h->a53_caption, gb,
                                                               logctx, size);
         default:
-            av_log(logctx, AV_LOG_VERBOSE,
-                   "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
-                   user_identifier);
+            skip_bits(gb, size * 8);
             break;
-        }
-        break;
-    }
-    default:
-        av_log(logctx, AV_LOG_VERBOSE,
-               "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
-               provider_code);
-        break;
     }
 
     return 0;
@@ -444,31 +418,31 @@
             return ret;
 
         switch (type) {
-        case SEI_TYPE_PIC_TIMING: // Picture timing SEI
+        case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI
             ret = decode_picture_timing(&h->picture_timing, &gb_payload, logctx);
             break;
-        case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+        case H264_SEI_TYPE_USER_DATA_REGISTERED:
             ret = decode_registered_user_data(h, &gb_payload, logctx, size);
             break;
-        case SEI_TYPE_USER_DATA_UNREGISTERED:
+        case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
             ret = decode_unregistered_user_data(&h->unregistered, &gb_payload, logctx, size);
             break;
-        case SEI_TYPE_RECOVERY_POINT:
+        case H264_SEI_TYPE_RECOVERY_POINT:
             ret = decode_recovery_point(&h->recovery_point, &gb_payload, logctx);
             break;
-        case SEI_TYPE_BUFFERING_PERIOD:
+        case H264_SEI_TYPE_BUFFERING_PERIOD:
             ret = decode_buffering_period(&h->buffering_period, &gb_payload, ps, logctx);
             break;
-        case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
+        case H264_SEI_TYPE_FRAME_PACKING:
             ret = decode_frame_packing_arrangement(&h->frame_packing, &gb_payload);
             break;
-        case SEI_TYPE_DISPLAY_ORIENTATION:
+        case H264_SEI_TYPE_DISPLAY_ORIENTATION:
             ret = decode_display_orientation(&h->display_orientation, &gb_payload);
             break;
-        case SEI_TYPE_GREEN_METADATA:
+        case H264_SEI_TYPE_GREEN_METADATA:
             ret = decode_green_metadata(&h->green_metadata, &gb_payload);
             break;
-        case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
+        case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
             ret = decode_alternative_transfer(&h->alternative_transfer, &gb_payload);
             break;
         default:
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index 14cc559..4fdcf4e 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -21,8 +21,24 @@
 
 #include "get_bits.h"
 #include "h264_ps.h"
-#include "sei.h"
 
+/**
+ * SEI message types
+ */
+typedef enum {
+    H264_SEI_TYPE_BUFFERING_PERIOD       = 0,   ///< buffering period (H.264, D.1.1)
+    H264_SEI_TYPE_PIC_TIMING             = 1,   ///< picture timing
+    H264_SEI_TYPE_PAN_SCAN_RECT          = 2,   ///< pan-scan rectangle
+    H264_SEI_TYPE_FILLER_PAYLOAD         = 3,   ///< filler data
+    H264_SEI_TYPE_USER_DATA_REGISTERED   = 4,   ///< registered user data as specified by Rec. ITU-T T.35
+    H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user data
+    H264_SEI_TYPE_RECOVERY_POINT         = 6,   ///< recovery point (frame # to decoder sync)
+    H264_SEI_TYPE_FRAME_PACKING          = 45,  ///< frame packing arrangement
+    H264_SEI_TYPE_DISPLAY_ORIENTATION    = 47,  ///< display orientation
+    H264_SEI_TYPE_GREEN_METADATA         = 56,  ///< GreenMPEG information
+    H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME = 137,  ///< mastering display properties
+    H264_SEI_TYPE_ALTERNATIVE_TRANSFER   = 147, ///< alternative transfer
+} H264_SEI_Type;
 
 /**
  * pic_struct in picture timing SEI message
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 8ba6cc6..6a33dde 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -977,7 +977,7 @@
         return send_next_delayed_frame(h, pict, got_frame, 0);
 
     if (av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
-        buffer_size_t side_size;
+        int side_size;
         uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
         ff_h264_decode_extradata(side, side_size,
                                  &h->ps, &h->is_avc, &h->nal_length_size,
@@ -1056,7 +1056,7 @@
     .capabilities          = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 |
                              AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
                              AV_CODEC_CAP_FRAME_THREADS,
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_H264_DXVA2_HWACCEL
                                HWACCEL_DXVA2(h264),
 #endif
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index b3677cd..29c4d4e 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -30,7 +30,6 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "cabac.h"
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index 59325c0..504a75d 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -20,19 +20,29 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
-#include "cbs_bsf.h"
 #include "cbs_h265.h"
 #include "hevc.h"
 #include "h265_profile_level.h"
 
 enum {
+    PASS,
+    INSERT,
+    REMOVE,
+};
+
+enum {
     LEVEL_UNSET = -2,
     LEVEL_AUTO  = -1,
 };
 
 typedef struct H265MetadataContext {
-    CBSBSFContext common;
+    const AVClass *class;
+
+    CodedBitstreamContext *input;
+    CodedBitstreamContext *output;
+    CodedBitstreamFragment access_unit;
 
     H265RawAUD aud_nal;
 
@@ -328,18 +338,89 @@
     return 0;
 }
 
-static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
-                                         CodedBitstreamFragment *au)
+static int h265_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
 {
     H265MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    uint8_t *side_data;
+    int side_data_size;
     int err, i;
 
+    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+                                        &side_data_size);
+    if (!side_data_size)
+        return 0;
+
+    err = ff_cbs_read(ctx->input, au, side_data, side_data_size);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n");
+        return err;
+    }
+
+    if (ctx->level == LEVEL_AUTO && !ctx->level_guess)
+        h265_metadata_guess_level(bsf, au);
+
+    for (i = 0; i < au->nb_units; i++) {
+        if (au->units[i].type == HEVC_NAL_VPS) {
+            err = h265_metadata_update_vps(bsf, au->units[i].content);
+            if (err < 0)
+                return err;
+        }
+        if (au->units[i].type == HEVC_NAL_SPS) {
+            err = h265_metadata_update_sps(bsf, au->units[i].content);
+            if (err < 0)
+                return err;
+        }
+    }
+
+    err = ff_cbs_write_fragment_data(ctx->output, au);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n");
+        return err;
+    }
+
+    side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size);
+    if (!side_data)
+        return AVERROR(ENOMEM);
+    memcpy(side_data, au->data, au->data_size);
+
+    ff_cbs_fragment_reset(au);
+
+    return 0;
+}
+
+static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+{
+    H265MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    int err, i;
+
+    err = ff_bsf_get_packet_ref(bsf, pkt);
+    if (err < 0)
+        return err;
+
+    err = h265_metadata_update_side_data(bsf, pkt);
+    if (err < 0)
+        goto fail;
+
+    err = ff_cbs_read_packet(ctx->input, au, pkt);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+        goto fail;
+    }
+
+    if (au->nb_units == 0) {
+        av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n");
+        err = AVERROR_INVALIDDATA;
+        goto fail;
+    }
+
     // If an AUD is present, it must be the first NAL unit.
     if (au->units[0].type == HEVC_NAL_AUD) {
-        if (ctx->aud == BSF_ELEMENT_REMOVE)
+        if (ctx->aud == REMOVE)
             ff_cbs_delete_unit(au, 0);
     } else {
-        if (pkt && ctx->aud == BSF_ELEMENT_INSERT) {
+        if (ctx->aud == INSERT) {
             H265RawAUD *aud = &ctx->aud_nal;
             int pic_type = 0, temporal_id = 8, layer_id = 0;
 
@@ -372,7 +453,7 @@
             err = ff_cbs_insert_unit_content(au, 0, HEVC_NAL_AUD, aud, NULL);
             if (err < 0) {
                 av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
-                return err;
+                goto fail;
             }
         }
     }
@@ -384,35 +465,101 @@
         if (au->units[i].type == HEVC_NAL_VPS) {
             err = h265_metadata_update_vps(bsf, au->units[i].content);
             if (err < 0)
-                return err;
+                goto fail;
         }
         if (au->units[i].type == HEVC_NAL_SPS) {
             err = h265_metadata_update_sps(bsf, au->units[i].content);
             if (err < 0)
-                return err;
+                goto fail;
         }
     }
 
-    return 0;
-}
+    err = ff_cbs_write_packet(ctx->output, pkt, au);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+        goto fail;
+    }
 
-static const CBSBSFType h265_metadata_type = {
-    .codec_id        = AV_CODEC_ID_HEVC,
-    .fragment_name   = "access unit",
-    .unit_name       = "NAL unit",
-    .update_fragment = &h265_metadata_update_fragment,
-};
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(au);
+
+    if (err < 0)
+        av_packet_unref(pkt);
+
+    return err;
+}
 
 static int h265_metadata_init(AVBSFContext *bsf)
 {
-    return ff_cbs_bsf_generic_init(bsf, &h265_metadata_type);
+    H265MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *au = &ctx->access_unit;
+    int err, i;
+
+    err = ff_cbs_init(&ctx->input,  AV_CODEC_ID_HEVC, bsf);
+    if (err < 0)
+        return err;
+    err = ff_cbs_init(&ctx->output, AV_CODEC_ID_HEVC, bsf);
+    if (err < 0)
+        return err;
+
+    if (bsf->par_in->extradata) {
+        err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
+            goto fail;
+        }
+
+        if (ctx->level == LEVEL_AUTO)
+            h265_metadata_guess_level(bsf, au);
+
+        for (i = 0; i < au->nb_units; i++) {
+            if (au->units[i].type == HEVC_NAL_VPS) {
+                err = h265_metadata_update_vps(bsf, au->units[i].content);
+                if (err < 0)
+                    goto fail;
+            }
+            if (au->units[i].type == HEVC_NAL_SPS) {
+                err = h265_metadata_update_sps(bsf, au->units[i].content);
+                if (err < 0)
+                    goto fail;
+            }
+        }
+
+        err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
+            goto fail;
+        }
+    }
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(au);
+    return err;
+}
+
+static void h265_metadata_close(AVBSFContext *bsf)
+{
+    H265MetadataContext *ctx = bsf->priv_data;
+
+    ff_cbs_fragment_free(&ctx->access_unit);
+    ff_cbs_close(&ctx->input);
+    ff_cbs_close(&ctx->output);
 }
 
 #define OFFSET(x) offsetof(H265MetadataContext, x)
 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption h265_metadata_options[] = {
-    BSF_ELEMENT_OPTIONS_PIR("aud", "Access Unit Delimiter NAL units",
-                            aud, FLAGS),
+    { "aud", "Access Unit Delimiter NAL units",
+        OFFSET(aud), AV_OPT_TYPE_INT,
+        { .i64 = PASS }, PASS, REMOVE, FLAGS, "aud" },
+    { "pass",   NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = PASS   }, .flags = FLAGS, .unit = "aud" },
+    { "insert", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = INSERT }, .flags = FLAGS, .unit = "aud" },
+    { "remove", NULL, 0, AV_OPT_TYPE_CONST,
+        { .i64 = REMOVE }, .flags = FLAGS, .unit = "aud" },
 
     { "sample_aspect_ratio", "Set sample aspect ratio (table E-1)",
         OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL,
@@ -503,7 +650,7 @@
     .priv_data_size = sizeof(H265MetadataContext),
     .priv_class     = &h265_metadata_class,
     .init           = &h265_metadata_init,
-    .close          = &ff_cbs_bsf_generic_close,
-    .filter         = &ff_cbs_bsf_generic_filter,
+    .close          = &h265_metadata_close,
+    .filter         = &h265_metadata_filter,
     .codec_ids      = h265_metadata_codec_ids,
 };
diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
index 7ff9681..d79c1ab 100644
--- a/libavcodec/h265_profile_level.c
+++ b/libavcodec/h265_profile_level.c
@@ -120,6 +120,18 @@
 };
 
 
+const H265LevelDescriptor *ff_h265_get_level(int level_idc)
+{
+    int i;
+
+    for (i = 0; i < FF_ARRAY_ELEMS(h265_levels); i++) {
+        if (h265_levels[i].level_idc == level_idc)
+            return &h265_levels[i];
+    }
+
+    return NULL;
+}
+
 const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel *ptl)
 {
     int i;
diff --git a/libavcodec/h265_profile_level.h b/libavcodec/h265_profile_level.h
index f1a11f5..2d5beba 100644
--- a/libavcodec/h265_profile_level.h
+++ b/libavcodec/h265_profile_level.h
@@ -70,6 +70,8 @@
 } H265ProfileDescriptor;
 
 
+const H265LevelDescriptor *ff_h265_get_level(int level_idc);
+
 const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel *ptl);
 
 
diff --git a/libavcodec/half2float.h b/libavcodec/half2float.h
deleted file mode 100644
index fd11caf..0000000
--- a/libavcodec/half2float.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_HALF2FLOAT_H
-#define AVCODEC_HALF2FLOAT_H
-
-#include <stdint.h>
-
-static uint32_t convertmantissa(uint32_t i)
-{
-    int32_t m = i << 13; // Zero pad mantissa bits
-    int32_t e = 0; // Zero exponent
-
-    while (!(m & 0x00800000)) { // While not normalized
-        e -= 0x00800000; // Decrement exponent (1<<23)
-        m <<= 1; // Shift mantissa
-    }
-
-    m &= ~0x00800000; // Clear leading 1 bit
-    e +=  0x38800000; // Adjust bias ((127-14)<<23)
-
-    return m | e; // Return combined number
-}
-
-static void half2float_table(uint32_t *mantissatable, uint32_t *exponenttable,
-                             uint16_t *offsettable)
-{
-    mantissatable[0] = 0;
-    for (int i = 1; i < 1024; i++)
-        mantissatable[i] = convertmantissa(i);
-    for (int i = 1024; i < 2048; i++)
-        mantissatable[i] = 0x38000000UL + ((i - 1024) << 13UL);
-
-    exponenttable[0] = 0;
-    for (int i = 1; i < 31; i++)
-        exponenttable[i] = i << 23;
-    for (int i = 33; i < 63; i++)
-        exponenttable[i] = 0x80000000UL + ((i - 32) << 23UL);
-    exponenttable[31]= 0x47800000UL;
-    exponenttable[32]= 0x80000000UL;
-    exponenttable[63]= 0xC7800000UL;
-
-    offsettable[0] = 0;
-    for (int i = 1; i < 64; i++)
-        offsettable[i] = 1024;
-    offsettable[32] = 0;
-}
-
-static uint32_t half2float(uint16_t h, uint32_t *mantissatable, uint32_t *exponenttable,
-                           uint16_t *offsettable)
-{
-    uint32_t f;
-
-    f = mantissatable[offsettable[h >> 10] + (h & 0x3ff)] + exponenttable[h >> 10];
-
-    return f;
-}
-
-#endif /* AVCODEC_HALF2FLOAT_H */
diff --git a/libavcodec/hap.h b/libavcodec/hap.h
index 00c3dbb..bbeed11 100644
--- a/libavcodec/hap.h
+++ b/libavcodec/hap.h
@@ -52,7 +52,7 @@
 
 typedef struct HapChunk {
     enum HapCompressor compressor;
-    uint32_t compressed_offset;
+    int compressed_offset;
     size_t compressed_size;
     int uncompressed_offset;
     size_t uncompressed_size;
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 692bb6e..ab364aa 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -105,8 +105,6 @@
         size_t running_size = 0;
         for (i = 0; i < ctx->chunk_count; i++) {
             ctx->chunks[i].compressed_offset = running_size;
-            if (ctx->chunks[i].compressed_size > UINT32_MAX - running_size)
-                return AVERROR_INVALIDDATA;
             running_size += ctx->chunks[i].compressed_size;
         }
     }
@@ -188,7 +186,7 @@
         HapChunk *chunk = &ctx->chunks[i];
 
         /* Check the compressed buffer is valid */
-        if (chunk->compressed_offset + (uint64_t)chunk->compressed_size > bytestream2_get_bytes_left(gbc))
+        if (chunk->compressed_offset + chunk->compressed_size > bytestream2_get_bytes_left(gbc))
             return AVERROR_INVALIDDATA;
 
         /* Chunks are unpacked sequentially, ctx->tex_size is the uncompressed
diff --git a/libavcodec/hcadec.c b/libavcodec/hcadec.c
index 9c3eda2..11cb157 100644
--- a/libavcodec/hcadec.c
+++ b/libavcodec/hcadec.c
@@ -19,7 +19,6 @@
 #include "libavutil/crc.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/tx.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 9b8c8e3..3635b16 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -454,19 +454,12 @@
          (s->ps.sps->ctb_width == 2 &&
           ctb_addr_ts % s->ps.sps->ctb_width == 0))) {
         memcpy(s->cabac_state, s->HEVClc->cabac_state, HEVC_CONTEXTS);
-        if (s->ps.sps->persistent_rice_adaptation_enabled_flag) {
-            memcpy(s->stat_coeff, s->HEVClc->stat_coeff, HEVC_STAT_COEFFS);
-        }
     }
 }
 
-static void load_states(HEVCContext *s, int thread)
+static void load_states(HEVCContext *s)
 {
     memcpy(s->HEVClc->cabac_state, s->cabac_state, HEVC_CONTEXTS);
-    if (s->ps.sps->persistent_rice_adaptation_enabled_flag) {
-        const HEVCContext *prev = s->sList[(thread + s->threads_number - 1) % s->threads_number];
-        memcpy(s->HEVClc->stat_coeff, prev->stat_coeff, HEVC_STAT_COEFFS);
-    }
 }
 
 static int cabac_reinit(HEVCLocalContext *lc)
@@ -508,7 +501,7 @@
         s->HEVClc->stat_coeff[i] = 0;
 }
 
-int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts, int thread)
+int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
 {
     if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
         int ret = cabac_init_decoder(s);
@@ -525,7 +518,7 @@
                 if (s->ps.sps->ctb_width == 1)
                     cabac_init_state(s);
                 else if (s->sh.dependent_slice_segment_flag == 1)
-                    load_states(s, thread);
+                    load_states(s);
             }
         }
     } else {
@@ -556,7 +549,7 @@
                 if (s->ps.sps->ctb_width == 1)
                     cabac_init_state(s);
                 else
-                    load_states(s, thread);
+                    load_states(s);
             }
         }
     }
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 764c484..ea6fd53 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -783,7 +783,7 @@
 static int scaling_list_data(GetBitContext *gb, AVCodecContext *avctx, ScalingList *sl, HEVCSPS *sps)
 {
     uint8_t scaling_list_pred_mode_flag;
-    uint8_t scaling_list_dc_coef[2][6];
+    int32_t scaling_list_dc_coef[2][6];
     int size_id, matrix_id, pos;
     int i;
 
@@ -816,11 +816,7 @@
                 next_coef = 8;
                 coef_num  = FFMIN(64, 1 << (4 + (size_id << 1)));
                 if (size_id > 1) {
-                    int scaling_list_coeff_minus8 = get_se_golomb(gb);
-                    if (scaling_list_coeff_minus8 < -7 ||
-                        scaling_list_coeff_minus8 > 247)
-                        return AVERROR_INVALIDDATA;
-                    scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
+                    scaling_list_dc_coef[size_id - 2][matrix_id] = get_se_golomb(gb) + 8;
                     next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
                     sl->sl_dc[size_id - 2][matrix_id] = next_coef;
                 }
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index c881c43..3b0fa43 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -169,7 +169,7 @@
     int ret;
 
     if (size < 3)
-       return AVERROR_INVALIDDATA;
+       return AVERROR(EINVAL);
 
     ret = ff_parse_a53_cc(&s->buf_ref, gb->buffer + get_bits_count(gb) / 8, size);
 
@@ -236,34 +236,28 @@
 }
 
 static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitContext *gb,
-                                                         void *logctx, int size)
+                                                         int size)
 {
-    int country_code, provider_code;
+    const uint8_t usa_country_code = 0xB5;
+    const uint16_t smpte_provider_code = 0x003C;
+
+    uint8_t country_code = 0;
+    uint16_t provider_code = 0;
 
     if (size < 3)
-        return AVERROR_INVALIDDATA;
+        return AVERROR(EINVAL);
     size -= 3;
 
     country_code = get_bits(gb, 8);
     if (country_code == 0xFF) {
-        if (size < 1)
-            return AVERROR_INVALIDDATA;
-
         skip_bits(gb, 8);
         size--;
     }
 
-    if (country_code != 0xB5) { // usa_country_code
-        av_log(logctx, AV_LOG_VERBOSE,
-               "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n",
-               country_code);
-        goto end;
-    }
-
     provider_code = get_bits(gb, 16);
 
-    switch (provider_code) {
-    case 0x3C: { // smpte_provider_code
+    if (country_code == usa_country_code &&
+        provider_code == smpte_provider_code) {
         // A/341 Amendment - 2094-40
         const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
         const uint8_t smpte2094_40_application_identifier = 0x04;
@@ -271,7 +265,7 @@
         uint8_t application_identifier;
 
         if (size < 3)
-            return AVERROR_INVALIDDATA;
+            return AVERROR(EINVAL);
         size -= 3;
 
         provider_oriented_code = get_bits(gb, 16);
@@ -280,13 +274,11 @@
             application_identifier == smpte2094_40_application_identifier) {
             return decode_registered_user_data_dynamic_hdr_plus(&s->dynamic_hdr_plus, gb, size);
         }
-        break;
-    }
-    case 0x31: { // atsc_provider_code
+    } else {
         uint32_t user_identifier;
 
         if (size < 4)
-            return AVERROR_INVALIDDATA;
+            return AVERROR(EINVAL);
         size -= 4;
 
         user_identifier = get_bits_long(gb, 32);
@@ -294,21 +286,9 @@
         case MKBETAG('G', 'A', '9', '4'):
             return decode_registered_user_data_closed_caption(&s->a53_caption, gb, size);
         default:
-            av_log(logctx, AV_LOG_VERBOSE,
-                   "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
-                   user_identifier);
             break;
         }
-        break;
     }
-    default:
-        av_log(logctx, AV_LOG_VERBOSE,
-               "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
-               provider_code);
-        break;
-    }
-
-end:
     skip_bits_long(gb, size * 8);
     return 0;
 }
@@ -402,25 +382,25 @@
     switch (type) {
     case 256:  // Mismatched value from HM 8.1
         return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb);
-    case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
+    case HEVC_SEI_TYPE_FRAME_PACKING:
         return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb);
-    case SEI_TYPE_DISPLAY_ORIENTATION:
+    case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
         return decode_nal_sei_display_orientation(&s->display_orientation, gb);
-    case SEI_TYPE_PIC_TIMING:
+    case HEVC_SEI_TYPE_PICTURE_TIMING:
         return decode_nal_sei_pic_timing(s, gb, ps, logctx, size);
-    case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
+    case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
         return decode_nal_sei_mastering_display_info(&s->mastering_display, gb);
-    case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+    case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
         return decode_nal_sei_content_light_info(&s->content_light, gb);
-    case SEI_TYPE_ACTIVE_PARAMETER_SETS:
+    case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
         return decode_nal_sei_active_parameter_sets(s, gb, logctx);
-    case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
-        return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, logctx, size);
-    case SEI_TYPE_USER_DATA_UNREGISTERED:
+    case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+        return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size);
+    case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
         return decode_nal_sei_user_data_unregistered(&s->unregistered, gb, size);
-    case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
+    case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
         return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb);
-    case SEI_TYPE_TIME_CODE:
+    case HEVC_SEI_TYPE_TIME_CODE:
         return decode_nal_sei_timecode(&s->timecode, gb);
     default:
         av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
@@ -433,7 +413,7 @@
                                  int type, int size)
 {
     switch (type) {
-    case SEI_TYPE_DECODED_PICTURE_HASH:
+    case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
         return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb);
     default:
         av_log(logctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type);
@@ -463,8 +443,6 @@
         byte          = get_bits(gb, 8);
         payload_size += byte;
     }
-    if (get_bits_left(gb) < 8LL*payload_size)
-        return AVERROR_INVALIDDATA;
     if (nal_unit_type == HEVC_NAL_SEI_PREFIX) {
         return decode_nal_sei_prefix(gb, logctx, s, ps, payload_type, payload_size);
     } else { /* nal_unit_type == NAL_SEI_SUFFIX */
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index c67dbce..e9e2d46 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -24,8 +24,40 @@
 #include <stdint.h>
 
 #include "get_bits.h"
-#include "sei.h"
 
+/**
+ * SEI message types
+ */
+typedef enum {
+    HEVC_SEI_TYPE_BUFFERING_PERIOD                     = 0,
+    HEVC_SEI_TYPE_PICTURE_TIMING                       = 1,
+    HEVC_SEI_TYPE_PAN_SCAN_RECT                        = 2,
+    HEVC_SEI_TYPE_FILLER_PAYLOAD                       = 3,
+    HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35       = 4,
+    HEVC_SEI_TYPE_USER_DATA_UNREGISTERED               = 5,
+    HEVC_SEI_TYPE_RECOVERY_POINT                       = 6,
+    HEVC_SEI_TYPE_SCENE_INFO                           = 9,
+    HEVC_SEI_TYPE_FULL_FRAME_SNAPSHOT                  = 15,
+    HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
+    HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
+    HEVC_SEI_TYPE_FILM_GRAIN_CHARACTERISTICS           = 19,
+    HEVC_SEI_TYPE_POST_FILTER_HINT                     = 22,
+    HEVC_SEI_TYPE_TONE_MAPPING_INFO                    = 23,
+    HEVC_SEI_TYPE_FRAME_PACKING                        = 45,
+    HEVC_SEI_TYPE_DISPLAY_ORIENTATION                  = 47,
+    HEVC_SEI_TYPE_SOP_DESCRIPTION                      = 128,
+    HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS                = 129,
+    HEVC_SEI_TYPE_DECODING_UNIT_INFO                   = 130,
+    HEVC_SEI_TYPE_TEMPORAL_LEVEL0_INDEX                = 131,
+    HEVC_SEI_TYPE_DECODED_PICTURE_HASH                 = 132,
+    HEVC_SEI_TYPE_SCALABLE_NESTING                     = 133,
+    HEVC_SEI_TYPE_REGION_REFRESH_INFO                  = 134,
+    HEVC_SEI_TYPE_TIME_CODE                            = 136,
+    HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO               = 137,
+    HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO             = 144,
+    HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
+    HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO                   = 165,
+} HEVC_SEI_Type;
 
 typedef enum {
         HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING = 7,
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 2231aed..be814bb 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -515,9 +515,6 @@
             s->sao_pixel_buffer_v[c_idx] =
                 av_malloc((h * 2 * sps->ctb_width) <<
                           sps->pixel_shift);
-            if (!s->sao_pixel_buffer_h[c_idx] ||
-                !s->sao_pixel_buffer_v[c_idx])
-                goto fail;
         }
     }
 
@@ -528,10 +525,6 @@
 
 fail:
     pic_arrays_free(s);
-    for (i = 0; i < 3; i++) {
-        av_freep(&s->sao_pixel_buffer_h[i]);
-        av_freep(&s->sao_pixel_buffer_v[i]);
-    }
     s->ps.sps = NULL;
     return ret;
 }
@@ -2480,7 +2473,7 @@
         y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
         hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts);
 
-        ret = ff_hevc_cabac_init(s, ctb_addr_ts, 0);
+        ret = ff_hevc_cabac_init(s, ctb_addr_ts);
         if (ret < 0) {
             s->tab_slice_address[ctb_addr_rs] = -1;
             return ret;
@@ -2558,7 +2551,7 @@
             return 0;
         }
 
-        ret = ff_hevc_cabac_init(s, ctb_addr_ts, thread);
+        ret = ff_hevc_cabac_init(s, ctb_addr_ts);
         if (ret < 0)
             goto error;
         hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size);
@@ -2631,19 +2624,13 @@
 
     ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
 
-    for (i = 1; i < s->threads_number; i++) {
-        if (s->sList[i] && s->HEVClcList[i])
-            continue;
-        av_freep(&s->sList[i]);
-        av_freep(&s->HEVClcList[i]);
-        s->sList[i] = av_malloc(sizeof(HEVCContext));
-        s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));
-        if (!s->sList[i] || !s->HEVClcList[i]) {
-            res = AVERROR(ENOMEM);
-            goto error;
+    if (!s->sList[1]) {
+        for (i = 1; i < s->threads_number; i++) {
+            s->sList[i] = av_malloc(sizeof(HEVCContext));
+            memcpy(s->sList[i], s, sizeof(HEVCContext));
+            s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));
+            s->sList[i]->HEVClc = s->HEVClcList[i];
         }
-        memcpy(s->sList[i], s, sizeof(HEVCContext));
-        s->sList[i]->HEVClc = s->HEVClcList[i];
     }
 
     offset = (lc->gb.index >> 3);
@@ -3303,7 +3290,7 @@
                              AVPacket *avpkt)
 {
     int ret;
-    buffer_size_t new_extradata_size;
+    int new_extradata_size;
     uint8_t *new_extradata;
     HEVCContext *s = avctx->priv_data;
 
@@ -3430,13 +3417,16 @@
     av_freep(&s->sh.offset);
     av_freep(&s->sh.size);
 
-    if (s->HEVClcList && s->sList) {
-        for (i = 1; i < s->threads_number; i++) {
+    for (i = 1; i < s->threads_number; i++) {
+        HEVCLocalContext *lc = s->HEVClcList[i];
+        if (lc) {
             av_freep(&s->HEVClcList[i]);
             av_freep(&s->sList[i]);
         }
     }
-    av_freep(&s->HEVClc);
+    if (s->HEVClc == s->HEVClcList[0])
+        s->HEVClc = NULL;
+    av_freep(&s->HEVClcList[0]);
     av_freep(&s->HEVClcList);
     av_freep(&s->sList);
 
@@ -3632,6 +3622,7 @@
         if (avctx->extradata_size > 0 && avctx->extradata) {
             ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size, 1);
             if (ret < 0) {
+                hevc_decode_free(avctx);
                 return ret;
             }
         }
@@ -3682,9 +3673,9 @@
     .capabilities          = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
                              AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS,
     .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING |
-                             FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP,
+                             FF_CODEC_CAP_ALLOCATE_PROGRESS,
     .profiles              = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_HEVC_DXVA2_HWACCEL
                                HWACCEL_DXVA2(hevc),
 #endif
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 482638a..c0a138e 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -27,7 +27,6 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/md5.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "bswapdsp.h"
@@ -53,7 +52,6 @@
 #define DEFAULT_INTRA_TC_OFFSET 2
 
 #define HEVC_CONTEXTS 199
-#define HEVC_STAT_COEFFS 4
 
 #define MRG_MAX_NUM_CANDS     5
 
@@ -425,7 +423,7 @@
 typedef struct HEVCLocalContext {
     uint8_t cabac_state[HEVC_CONTEXTS];
 
-    uint8_t stat_coeff[HEVC_STAT_COEFFS];
+    uint8_t stat_coeff[4];
 
     uint8_t first_qp_group;
 
@@ -481,7 +479,6 @@
     int                 height;
 
     uint8_t *cabac_state;
-    uint8_t stat_coeff[HEVC_STAT_COEFFS];
 
     /** 1 if the independent slice segment header was successfully parsed */
     uint8_t slice_initialized;
@@ -596,7 +593,7 @@
 int ff_hevc_slice_rpl(HEVCContext *s);
 
 void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts);
-int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts, int thread);
+int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts);
 int ff_hevc_sao_merge_flag_decode(HEVCContext *s);
 int ff_hevc_sao_type_idx_decode(HEVCContext *s);
 int ff_hevc_sao_band_position_decode(HEVCContext *s);
diff --git a/libavcodec/hevcdsp.c b/libavcodec/hevcdsp.c
index fe272ac..957e40d 100644
--- a/libavcodec/hevcdsp.c
+++ b/libavcodec/hevcdsp.c
@@ -257,8 +257,6 @@
         break;
     }
 
-    if (ARCH_AARCH64)
-        ff_hevc_dsp_init_aarch64(hevcdsp, bit_depth);
     if (ARCH_ARM)
         ff_hevc_dsp_init_arm(hevcdsp, bit_depth);
     if (ARCH_PPC)
diff --git a/libavcodec/hevcdsp.h b/libavcodec/hevcdsp.h
index 0e013a8..0ae67cb 100644
--- a/libavcodec/hevcdsp.h
+++ b/libavcodec/hevcdsp.h
@@ -25,8 +25,6 @@
 #ifndef AVCODEC_HEVCDSP_H
 #define AVCODEC_HEVCDSP_H
 
-#include "libavutil/mem_internal.h"
-
 #include "get_bits.h"
 
 #define MAX_PB_SIZE 64
@@ -129,7 +127,6 @@
 extern const int8_t ff_hevc_epel_filters[7][4];
 extern const int8_t ff_hevc_qpel_filters[3][16];
 
-void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth);
 void ff_hevc_dsp_init_arm(HEVCDSPContext *c, const int bit_depth);
 void ff_hevc_dsp_init_ppc(HEVCDSPContext *c, const int bit_depth);
 void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth);
diff --git a/libavcodec/hq_hqa.h b/libavcodec/hq_hqa.h
index 08d79e7..608e2ca 100644
--- a/libavcodec/hq_hqa.h
+++ b/libavcodec/hq_hqa.h
@@ -23,8 +23,6 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "bytestream.h"
 #include "hq_hqadsp.h"
diff --git a/libavcodec/hqx.h b/libavcodec/hqx.h
index 3eddaaf..50d60f9 100644
--- a/libavcodec/hqx.h
+++ b/libavcodec/hqx.h
@@ -24,8 +24,7 @@
 #include <stdint.h>
 
 #include "libavutil/frame.h"
-#include "libavutil/mem_internal.h"
-
+#include "libavutil/mem.h"
 #include "get_bits.h"
 #include "hqxdsp.h"
 
diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c
index 5691915..941a89d 100644
--- a/libavcodec/idcinvideo.c
+++ b/libavcodec/idcinvideo.c
@@ -214,7 +214,7 @@
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     IdcinContext *s = avctx->priv_data;
-    buffer_size_t pal_size;
+    int pal_size;
     const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
     AVFrame *frame = data;
     int ret;
diff --git a/libavcodec/ilbcdata.h b/libavcodec/ilbcdata.h
index b17e24d..8d145bc 100644
--- a/libavcodec/ilbcdata.h
+++ b/libavcodec/ilbcdata.h
@@ -60,6 +60,10 @@
     32767, 29573, 26690, 24087, 21739, 19619, 17707, 15980, 14422, 13016, 11747
 };
 
+static const int16_t LpcChirpWeightDenum[] = {
+    32767, 13835, 5841, 2466, 1041, 440, 186, 78,  33,  14,  6
+};
+
 static const int16_t cos_tbl[64] = {
     32767,  32729,  32610,  32413,  32138,  31786,  31357,   30853,
     30274,  29622,  28899,  28106,  27246,  26320,  25330,   24279,
diff --git a/libavcodec/imc.c b/libavcodec/imc.c
index 51e7c1b..dbcb98a 100644
--- a/libavcodec/imc.c
+++ b/libavcodec/imc.c
@@ -38,9 +38,7 @@
 #include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
-
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "get_bits.h"
@@ -180,7 +178,7 @@
     for (int i = 0, offset = 0; i < 4 ; i++) {
         for (int j = 0; j < 4; j++) {
             huffman_vlc[i][j].table           = &vlc_tables[offset];
-            huffman_vlc[i][j].table_allocated = VLC_TABLES_SIZE - offset;
+            huffman_vlc[i][j].table_allocated = VLC_TABLES_SIZE - offset;;
             ff_init_vlc_from_lengths(&huffman_vlc[i][j], IMC_VLC_BITS, imc_huffman_sizes[i],
                                      imc_huffman_lens[i][j], 1,
                                      imc_huffman_syms[i][j], 1, 1,
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 8de1563..1fd636c 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -44,7 +44,6 @@
 }
 #endif
 
-#if FF_API_AVCODEC_PIX_FMT
 int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
                              enum AVPixelFormat src_pix_fmt,
                              int has_alpha)
@@ -61,10 +60,9 @@
 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
 {
-    return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr);
+    return avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr);
 }
 
-#endif
 enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,
                                             enum AVPixelFormat src_pix_fmt,
                                             int has_alpha, int *loss_ptr){
@@ -75,7 +73,7 @@
 
     for (i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++) {
         loss = loss_ptr ? *loss_ptr : 0;
-        best = av_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, &loss);
+        best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, &loss);
     }
 
     if (loss_ptr)
diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index 636130d..4cbafff 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -24,7 +24,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/imx.c b/libavcodec/imx.c
deleted file mode 100644
index 0d6c99e..0000000
--- a/libavcodec/imx.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/common.h"
-#include "avcodec.h"
-#include "bytestream.h"
-#include "internal.h"
-
-typedef struct SimbiosisIMXContext {
-    AVFrame *frame;
-    uint32_t pal[256];
-    uint8_t history[32768];
-    int pos;
-} SimbiosisIMXContext;
-
-static av_cold int imx_decode_init(AVCodecContext *avctx)
-{
-    SimbiosisIMXContext *imx = avctx->priv_data;
-
-    avctx->pix_fmt = AV_PIX_FMT_PAL8;
-    avctx->width   = 320;
-    avctx->height  = 160;
-
-    imx->frame = av_frame_alloc();
-    if (!imx->frame)
-        return AVERROR(ENOMEM);
-
-    return 0;
-}
-
-static int imx_decode_frame(AVCodecContext *avctx, void *data,
-                            int *got_frame, AVPacket *avpkt)
-{
-    SimbiosisIMXContext *imx = avctx->priv_data;
-    int ret, x, y;
-    buffer_size_t pal_size;
-    const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
-    AVFrame *frame = imx->frame;
-    GetByteContext gb;
-
-    if ((ret = ff_reget_buffer(avctx, frame, 0)) < 0)
-        return ret;
-
-    if (pal && pal_size == AVPALETTE_SIZE) {
-        memcpy(imx->pal, pal, pal_size);
-        frame->palette_has_changed = 1;
-        frame->key_frame = 1;
-    } else {
-        frame->key_frame = 0;
-        frame->palette_has_changed = 0;
-    }
-
-    bytestream2_init(&gb, avpkt->data, avpkt->size);
-
-    memcpy(frame->data[1], imx->pal, AVPALETTE_SIZE);
-
-    x = 0, y = 0;
-    while (bytestream2_get_bytes_left(&gb) > 0 &&
-           x < 320 && y < 160) {
-        int b = bytestream2_get_byte(&gb);
-        int len = b & 0x3f;
-        int op = b >> 6;
-        int fill;
-
-        switch (op) {
-        case 3:
-            len = len * 64 + bytestream2_get_byte(&gb);
-        case 0:
-            while (len > 0) {
-                x++;
-                len--;
-                if (x >= 320) {
-                    x = 0;
-                    y++;
-                }
-                if (y >= 160)
-                    break;
-            }
-
-            frame->key_frame = 0;
-            break;
-        case 1:
-            if (len == 0) {
-                int offset = bytestream2_get_le16(&gb);
-
-                if (offset < 0 || offset >= 32768)
-                    return AVERROR_INVALIDDATA;
-
-                len = bytestream2_get_byte(&gb);
-                while (len > 0 && offset < 32768) {
-                    frame->data[0][x + y * frame->linesize[0]] = imx->history[offset++];
-                    x++;
-                    len--;
-                    if (x >= 320) {
-                        x = 0;
-                        y++;
-                    }
-                    if (y >= 160)
-                        break;
-                }
-
-                frame->key_frame = 0;
-            } else {
-                while (len > 0) {
-                    fill = bytestream2_get_byte(&gb);
-                    frame->data[0][x + y * frame->linesize[0]] = fill;
-                    if (imx->pos < 32768)
-                        imx->history[imx->pos++] = fill;
-                    x++;
-                    len--;
-                    if (x >= 320) {
-                        x = 0;
-                        y++;
-                    }
-                    if (y >= 160)
-                        break;
-                }
-            }
-            break;
-        case 2:
-            fill = bytestream2_get_byte(&gb);
-
-            while (len > 0) {
-                frame->data[0][x + y * frame->linesize[0]] = fill;
-                x++;
-                len--;
-                if (x >= 320) {
-                    x = 0;
-                    y++;
-                }
-                if (y >= 160)
-                    break;
-            }
-            break;
-        }
-    }
-
-    frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
-
-    if ((ret = av_frame_ref(data, frame)) < 0)
-        return ret;
-
-    *got_frame = 1;
-
-    return avpkt->size;
-}
-
-static void imx_decode_flush(AVCodecContext *avctx)
-{
-    SimbiosisIMXContext *imx = avctx->priv_data;
-
-    av_frame_unref(imx->frame);
-    imx->pos = 0;
-    memset(imx->pal, 0, sizeof(imx->pal));
-    memset(imx->history, 0, sizeof(imx->history));
-}
-
-static int imx_decode_close(AVCodecContext *avctx)
-{
-    SimbiosisIMXContext *imx = avctx->priv_data;
-
-    av_frame_free(&imx->frame);
-
-    return 0;
-}
-
-AVCodec ff_simbiosis_imx_decoder = {
-    .name           = "simbiosis_imx",
-    .long_name      = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"),
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_SIMBIOSIS_IMX,
-    .priv_data_size = sizeof(SimbiosisIMXContext),
-    .init           = imx_decode_init,
-    .decode         = imx_decode_frame,
-    .close          = imx_decode_close,
-    .flush          = imx_decode_flush,
-    .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
-                      FF_CODEC_CAP_INIT_CLEANUP,
-};
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index 5257d98..75113a7 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -171,7 +171,7 @@
 
     if (luma_width  < 16 || luma_width  > 640 ||
         luma_height < 16 || luma_height > 480 ||
-        luma_width  &  1 || luma_height &   1) {
+        luma_width  &  3 || luma_height &   3) {
         av_log(avctx, AV_LOG_ERROR, "Invalid picture dimensions: %d x %d!\n",
                luma_width, luma_height);
         return AVERROR_INVALIDDATA;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 400ea50..141f3fb 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -28,7 +28,6 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/channel_layout.h"
-#include "libavutil/fifo.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/pixfmt.h"
 #include "avcodec.h"
@@ -132,9 +131,7 @@
      */
     int last_audio_frame;
 
-#if FF_API_OLD_ENCDEC
     AVFrame *to_free;
-#endif
 
     AVBufferRef *pool;
 
@@ -148,7 +145,8 @@
      * for decoding.
      */
     AVPacket *last_pkt_props;
-    AVFifoBuffer *pkt_props;
+    AVPacketList *pkt_props;
+    AVPacketList *pkt_props_tail;
 
     /**
      * temporary buffer used for encoders to store their bitstream
@@ -181,8 +179,6 @@
     AVPacket *buffer_pkt;
     AVFrame *buffer_frame;
     int draining_done;
-
-#if FF_API_OLD_ENCDEC
     int compat_decode_warned;
     /* this variable is set by the decoder internals to signal to the old
      * API compat wrappers the amount of data consumed from the last packet */
@@ -192,7 +188,6 @@
     size_t compat_decode_partial_size;
     AVFrame *compat_decode_frame;
     AVPacket *compat_encode_packet;
-#endif
 
     int showed_multi_packet_warning;
 
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index 4d16fdf..58400b6 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -1317,7 +1317,7 @@
         return ret;
 
     if (!s->is_16bpp) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
         if (pal && size == AVPALETTE_SIZE) {
             frame->palette_has_changed = 1;
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index d5fff54..fe77e6d 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -33,7 +33,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #include "mpegvideo.h"
 #include "h263.h"
@@ -51,6 +50,7 @@
 // reading vlc values. Changing these may improve speed and data cache needs
 // be aware though that decreasing them may need the number of stages that is
 // passed to get_vlc* to be increased.
+#define MV_VLC_BITS 9
 #define H263_MBTYPE_B_VLC_BITS 6
 #define CBPC_B_VLC_BITS 3
 
@@ -97,7 +97,7 @@
 VLC ff_h263_intra_MCBPC_vlc;
 VLC ff_h263_inter_MCBPC_vlc;
 VLC ff_h263_cbpy_vlc;
-VLC ff_h263_mv_vlc;
+static VLC mv_vlc;
 static VLC h263_mbtype_b_vlc;
 static VLC cbpc_b_vlc;
 
@@ -118,12 +118,13 @@
         INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
                  &ff_h263_cbpy_tab[0][1], 2, 1,
                  &ff_h263_cbpy_tab[0][0], 2, 1, 64);
-        INIT_VLC_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33,
+        INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 33,
                  &ff_mvtab[0][1], 2, 1,
                  &ff_mvtab[0][0], 2, 1, 538);
-        ff_h263_init_rl_inter();
+        ff_rl_init(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
+        ff_rl_init(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
         INIT_VLC_RL(ff_h263_rl_inter, 554);
-        INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554);
+        INIT_VLC_RL(ff_rl_intra_aic, 554);
         INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
                  &ff_h263_mbtype_b_tab[0][1], 2, 1,
                  &ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
@@ -268,7 +269,7 @@
 int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
 {
     int code, val, sign, shift;
-    code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2);
+    code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
 
     if (code == 0)
         return pred;
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 43260e6..b1b7821 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -713,7 +713,8 @@
     }
 }
 
-static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab)
+static av_cold void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab,
+                                         uint8_t *len_tab)
 {
     int slevel, run, last;
 
@@ -737,9 +738,10 @@
                 len=  rl->table_vlc[code][1];
                 bits=bits*2+sign; len++;
 
-                if (code != rl->n && len < len_tab[index])
+                if(code!=rl->n && len < len_tab[index]){
+                    if(bits_tab) bits_tab[index]= bits;
                     len_tab [index]= len;
-
+                }
                 /* ESC */
                 bits= rl->table_vlc[rl->n][0];
                 len = rl->table_vlc[rl->n][1];
@@ -747,8 +749,10 @@
                 bits=bits*64+run; len+=6;
                 bits=bits*256+(level&0xff); len+=8;
 
-                if (len < len_tab[index])
+                if(len < len_tab[index]){
+                    if(bits_tab) bits_tab[index]= bits;
                     len_tab [index]= len;
+                }
             }
         }
     }
@@ -759,14 +763,13 @@
     static int done = 0;
 
     if (!done) {
-        static uint8_t rl_intra_table[2][2 * MAX_RUN + MAX_LEVEL + 3];
         done = 1;
 
-        ff_rl_init(&ff_rl_intra_aic, rl_intra_table);
-        ff_h263_init_rl_inter();
+        ff_rl_init(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
+        ff_rl_init(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
 
-        init_uni_h263_rl_tab(&ff_rl_intra_aic,  uni_h263_intra_aic_rl_len);
-        init_uni_h263_rl_tab(&ff_h263_rl_inter, uni_h263_inter_rl_len);
+        init_uni_h263_rl_tab(&ff_rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
+        init_uni_h263_rl_tab(&ff_h263_rl_inter    , NULL, uni_h263_inter_rl_len);
 
         init_mv_penalty_and_fcode(s);
     }
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 63edbcd..624542c 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2342,12 +2342,8 @@
                 return 0;
             }
             atom_size = bytestream2_get_be32u(&s->g);
-            if (atom_size < 16 || (int64_t)bytestream2_tell(&s->g) + atom_size - 16 > INT_MAX)
-                return AVERROR_INVALIDDATA;
             atom_end  = bytestream2_tell(&s->g) + atom_size - 16;
         } else {
-            if (atom_size <  8 || (int64_t)bytestream2_tell(&s->g) + atom_size -  8 > INT_MAX)
-                return AVERROR_INVALIDDATA;
             atom_end  = bytestream2_tell(&s->g) + atom_size -  8;
         }
 
diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 69980ea..ef97bdb 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -149,7 +149,7 @@
 {
     int k, ret;
 
-    for (k = 0; ((unsigned)state->N[Q] << k) < state->A[Q]; k++)
+    for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
         ;
 
 #ifdef JLS_BROKEN
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 2bb6b14..10a3bd0 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -26,7 +26,6 @@
  */
 
 #include "avcodec.h"
-#include "bytestream.h"
 #include "get_bits.h"
 #include "put_bits.h"
 #include "golomb.h"
@@ -42,18 +41,6 @@
     int pred;
 } JPEGLSContext;
 
-static inline void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
-{
-    bytestream2_put_byteu(pb, 0xff);
-    bytestream2_put_byteu(pb, code);
-}
-
-static inline void put_marker_byte(PutByteContext *pb, enum JpegMarker code)
-{
-    bytestream2_put_byte(pb, 0xff);
-    bytestream2_put_byte(pb, code);
-}
-
 /**
  * Encode error from regular symbol
  */
@@ -141,19 +128,21 @@
  * Encode one line of image
  */
 static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
-                                  void *tmp, const void *in, int last2, int w,
+                                  void *last, void *cur, int last2, int w,
                                   int stride, int comp, int bits)
 {
     int x = 0;
-    int Ra = R(tmp, 0), Rb, Rc = last2, Rd;
+    int Ra, Rb, Rc, Rd;
     int D0, D1, D2;
 
     while (x < w) {
         int err, pred, sign;
 
         /* compute gradients */
-        Rb = R(tmp, x);
-        Rd = (x >= w - stride) ? R(tmp, x) : R(tmp, x + stride);
+        Ra = x ? R(cur, x - stride) : R(last, x);
+        Rb = R(last, x);
+        Rc = x ? R(last, x - stride) : last2;
+        Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
         D0 = Rd - Rb;
         D1 = Rb - Rc;
         D2 = Rc - Ra;
@@ -166,18 +155,18 @@
 
             run    = 0;
             RUNval = Ra;
-            while (x < w && (FFABS(R(in, x) - RUNval) <= state->near)) {
+            while (x < w && (FFABS(R(cur, x) - RUNval) <= state->near)) {
                 run++;
-                W(tmp, x, Ra);
+                W(cur, x, Ra);
                 x += stride;
             }
             ls_encode_run(state, pb, run, comp, x < w);
             if (x >= w)
                 return;
-            Rb     = R(tmp, x);
+            Rb     = R(last, x);
             RItype = FFABS(Ra - Rb) <= state->near;
             pred   = RItype ? Ra : Rb;
-            err    = R(in, x) - pred;
+            err    = R(cur, x) - pred;
 
             if (!RItype && Ra > Rb)
                 err = -err;
@@ -192,10 +181,8 @@
                     Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
                 else
                     Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
-            } else
-                Ra = R(in, x);
-            W(tmp, x, Ra);
-
+                W(cur, x, Ra);
+            }
             if (err < 0)
                 err += state->range;
             if (err >= state->range + 1 >> 1)
@@ -218,11 +205,11 @@
                 context = -context;
                 sign    = 1;
                 pred    = av_clip(pred - state->C[context], 0, state->maxval);
-                err     = pred - R(in, x);
+                err     = pred - R(cur, x);
             } else {
                 sign = 0;
                 pred = av_clip(pred + state->C[context], 0, state->maxval);
-                err  = R(in, x) - pred;
+                err  = R(cur, x) - pred;
             }
 
             if (state->near) {
@@ -234,18 +221,16 @@
                     Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
                 else
                     Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
-            } else
-                Ra = R(in, x);
-            W(tmp, x, Ra);
+                W(cur, x, Ra);
+            }
 
             ls_encode_regular(state, pb, context, err);
         }
-        Rc = Rb;
         x += stride;
     }
 }
 
-static void ls_store_lse(JLSState *state, PutByteContext *pb)
+static void ls_store_lse(JLSState *state, PutBitContext *pb)
 {
     /* Test if we have default params and don't need to store LSE */
     JLSState state2 = { 0 };
@@ -258,14 +243,14 @@
         state->reset == state2.reset)
         return;
     /* store LSE type 1 */
-    put_marker_byteu(pb, LSE);
-    bytestream2_put_be16u(pb, 13);
-    bytestream2_put_byteu(pb, 1);
-    bytestream2_put_be16u(pb, state->maxval);
-    bytestream2_put_be16u(pb, state->T1);
-    bytestream2_put_be16u(pb, state->T2);
-    bytestream2_put_be16u(pb, state->T3);
-    bytestream2_put_be16u(pb, state->reset);
+    put_marker(pb, LSE);
+    put_bits(pb, 16, 13);
+    put_bits(pb, 8, 1);
+    put_bits(pb, 16, state->maxval);
+    put_bits(pb, 16, state->T1);
+    put_bits(pb, 16, state->T2);
+    put_bits(pb, 16, state->T3);
+    put_bits(pb, 16, state->reset);
 }
 
 static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
@@ -273,12 +258,13 @@
 {
     JPEGLSContext *ctx = avctx->priv_data;
     const AVFrame *const p = pict;
-    PutByteContext pb;
-    PutBitContext pb2;
+    PutBitContext pb, pb2;
     GetBitContext gb;
-    const uint8_t *in;
+    uint8_t *buf2 = NULL;
+    uint8_t *zero = NULL;
+    uint8_t *cur  = NULL;
     uint8_t *last = NULL;
-    JLSState state = { 0 };
+    JLSState *state = NULL;
     int i, size, ret;
     int comps;
 
@@ -299,65 +285,72 @@
                                 AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0)
         return ret;
 
-    last = av_malloc((unsigned)pkt->size + FFABS(p->linesize[0]));
-    if (!last)
-        return AVERROR(ENOMEM);
-    memset(last, 0, FFABS(p->linesize[0]));
+    buf2 = av_malloc(pkt->size);
+    if (!buf2)
+        goto memfail;
 
-    bytestream2_init_writer(&pb, pkt->data, pkt->size);
-    init_put_bits(&pb2, last + FFABS(p->linesize[0]), pkt->size);
+    init_put_bits(&pb, pkt->data, pkt->size);
+    init_put_bits(&pb2, buf2, pkt->size);
 
     /* write our own JPEG header, can't use mjpeg_picture_header */
-    put_marker_byteu(&pb, SOI);
-    put_marker_byteu(&pb, SOF48);
-    bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on components
-    bytestream2_put_byteu(&pb, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8);  // bpp
-    bytestream2_put_be16u(&pb, avctx->height);
-    bytestream2_put_be16u(&pb, avctx->width);
-    bytestream2_put_byteu(&pb, comps);          // components
+    put_marker(&pb, SOI);
+    put_marker(&pb, SOF48);
+    put_bits(&pb, 16, 8 + comps * 3); // header size depends on components
+    put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8);  // bpp
+    put_bits(&pb, 16, avctx->height);
+    put_bits(&pb, 16, avctx->width);
+    put_bits(&pb, 8, comps);          // components
     for (i = 1; i <= comps; i++) {
-        bytestream2_put_byteu(&pb, i);     // component ID
-        bytestream2_put_byteu(&pb, 0x11);  // subsampling: none
-        bytestream2_put_byteu(&pb, 0);     // Tiq, used by JPEG-LS ext
+        put_bits(&pb, 8, i);     // component ID
+        put_bits(&pb, 8, 0x11);  // subsampling: none
+        put_bits(&pb, 8, 0);     // Tiq, used by JPEG-LS ext
     }
 
-    put_marker_byteu(&pb, SOS);
-    bytestream2_put_be16u(&pb, 6 + comps * 2);
-    bytestream2_put_byteu(&pb, comps);
+    put_marker(&pb, SOS);
+    put_bits(&pb, 16, 6 + comps * 2);
+    put_bits(&pb, 8, comps);
     for (i = 1; i <= comps; i++) {
-        bytestream2_put_byteu(&pb, i);   // component ID
-        bytestream2_put_byteu(&pb, 0);   // mapping index: none
+        put_bits(&pb, 8, i);   // component ID
+        put_bits(&pb, 8, 0);   // mapping index: none
     }
-    bytestream2_put_byteu(&pb, ctx->pred);
-    bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0);  // interleaving: 0 - plane, 1 - line
-    bytestream2_put_byteu(&pb, 0);  // point transform: none
+    put_bits(&pb, 8, ctx->pred);
+    put_bits(&pb, 8, (comps > 1) ? 1 : 0);  // interleaving: 0 - plane, 1 - line
+    put_bits(&pb, 8, 0);  // point transform: none
+
+    state = av_mallocz(sizeof(JLSState));
+    if (!state)
+        goto memfail;
 
     /* initialize JPEG-LS state from JPEG parameters */
-    state.near = ctx->pred;
-    state.bpp  = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
-    ff_jpegls_reset_coding_parameters(&state, 0);
-    ff_jpegls_init_state(&state);
+    state->near = ctx->pred;
+    state->bpp  = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
+    ff_jpegls_reset_coding_parameters(state, 0);
+    ff_jpegls_init_state(state);
 
-    ls_store_lse(&state, &pb);
+    ls_store_lse(state, &pb);
 
-    in = p->data[0];
+    zero = last = av_mallocz(FFABS(p->linesize[0]));
+    if (!zero)
+        goto memfail;
+
+    cur  = p->data[0];
     if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
         int t = 0;
 
         for (i = 0; i < avctx->height; i++) {
-            int last0 = last[0];
-            ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 8);
-            t   = last0;
-            in += p->linesize[0];
+            ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8);
+            t    = last[0];
+            last = cur;
+            cur += p->linesize[0];
         }
     } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
         int t = 0;
 
         for (i = 0; i < avctx->height; i++) {
-            int last0 = *((uint16_t *)last);
-            ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 16);
-            t   = last0;
-            in += p->linesize[0];
+            ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16);
+            t    = *((uint16_t *)last);
+            last = cur;
+            cur += p->linesize[0];
         }
     } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
         int j, width;
@@ -366,12 +359,12 @@
         width = avctx->width * 3;
         for (i = 0; i < avctx->height; i++) {
             for (j = 0; j < 3; j++) {
-                int last0 = last[j];
-                ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
+                ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
                                width, 3, j, 8);
-                Rc[j] = last0;
+                Rc[j] = last[j];
             }
-            in += p->linesize[0];
+            last = cur;
+            cur += p->linesize[0];
         }
     } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
         int j, width;
@@ -380,15 +373,18 @@
         width = avctx->width * 3;
         for (i = 0; i < avctx->height; i++) {
             for (j = 2; j >= 0; j--) {
-                int last0 = last[j];
-                ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
+                ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
                                width, 3, j, 8);
-                Rc[j] = last0;
+                Rc[j] = last[j];
             }
-            in += p->linesize[0];
+            last = cur;
+            cur += p->linesize[0];
         }
     }
 
+    av_freep(&zero);
+    av_freep(&state);
+
     /* the specification says that after doing 0xff escaping unused bits in
      * the last byte must be set to 0, so just append 7 "optional" zero bits
      * to avoid special-casing. */
@@ -396,28 +392,36 @@
     size = put_bits_count(&pb2);
     flush_put_bits(&pb2);
     /* do escape coding */
-    init_get_bits(&gb, pb2.buf, size);
+    init_get_bits(&gb, buf2, size);
     size -= 7;
     while (get_bits_count(&gb) < size) {
         int v;
         v = get_bits(&gb, 8);
-        bytestream2_put_byte(&pb, v);
+        put_bits(&pb, 8, v);
         if (v == 0xFF) {
             v = get_bits(&gb, 7);
-            bytestream2_put_byte(&pb, v);
+            put_bits(&pb, 8, v);
         }
     }
-    av_freep(&last);
+    align_put_bits(&pb);
+    av_freep(&buf2);
 
     /* End of image */
-    put_marker_byte(&pb, EOI);
+    put_marker(&pb, EOI);
+    flush_put_bits(&pb);
 
     emms_c();
 
-    pkt->size   = bytestream2_tell_p(&pb);
+    pkt->size   = put_bits_count(&pb) >> 3;
     pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
     return 0;
+
+memfail:
+    av_freep(&buf2);
+    av_freep(&state);
+    av_freep(&zero);
+    return AVERROR(ENOMEM);
 }
 
 static av_cold int encode_init_ls(AVCodecContext *ctx)
diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index ef3f8de..e44bc7a 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -122,3 +122,24 @@
   0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
   0xf9, 0xfa
 };
+
+/* isn't this function nicer than the one in the libjpeg ? */
+void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
+                                  const uint8_t *bits_table,
+                                  const uint8_t *val_table)
+{
+    int i, j, k,nb, code, sym;
+
+    k = 0;
+    code = 0;
+    for(i=1;i<=16;i++) {
+        nb = bits_table[i];
+        for(j=0;j<nb;j++) {
+            sym = val_table[k++];
+            huff_size[sym] = i;
+            huff_code[sym] = code;
+            code++;
+        }
+        code <<= 1;
+    }
+}
diff --git a/libavcodec/jpegtables.h b/libavcodec/jpegtables.h
index 0907280..aa38df4 100644
--- a/libavcodec/jpegtables.h
+++ b/libavcodec/jpegtables.h
@@ -36,4 +36,8 @@
 extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
 extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_chrominance[];
 
+void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
+                                  const uint8_t *bits_table,
+                                  const uint8_t *val_table);
+
 #endif /* AVCODEC_JPEGTABLES_H */
diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index 0d96139..ffe6a14 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -268,7 +268,7 @@
     int i, ret;
     int header;
     int blocksize;
-    buffer_size_t pal_size;
+    int pal_size;
     const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
 
     bytestream2_init(&ctx->g, avpkt->data, avpkt->size);
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 9a26b5f..342d088 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -124,7 +124,6 @@
     int enable_diff_wtd_comp;
     int enable_dist_wtd_comp;
     int enable_dual_filter;
-    AVDictionary *aom_params;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -875,20 +874,6 @@
         codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
 #endif
 
-#if AOM_ENCODER_ABI_VERSION >= 23
-    {
-        AVDictionaryEntry *en = NULL;
-
-        while ((en = av_dict_get(ctx->aom_params, "", en, AV_DICT_IGNORE_SUFFIX))) {
-            int ret = aom_codec_set_option(&ctx->encoder, en->key, en->value);
-            if (ret != AOM_CODEC_OK) {
-                log_encoder_error(avctx, en->key);
-                return AVERROR_EXTERNAL;
-            }
-        }
-    }
-#endif
-
     // provide dummy value to initialize wrapper, values will be updated each _encode()
     aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
                  (unsigned char*)1);
@@ -1314,9 +1299,6 @@
     { "enable-masked-comp",           "Enable masked compound",                            OFFSET(enable_masked_comp),           AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
     { "enable-interintra-comp",       "Enable interintra compound",                        OFFSET(enable_interintra_comp),       AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
     { "enable-smooth-interintra",     "Enable smooth interintra mode",                     OFFSET(enable_smooth_interintra),     AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
-#if AOM_ENCODER_ABI_VERSION >= 23
-    { "aom-params",                   "Set libaom options using a :-separated list of key=value pairs", OFFSET(aom_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
-#endif
     { NULL },
 };
 
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 383e455..de57bce 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -313,7 +313,7 @@
     }
 
     // match timestamps and packet size
-    frame->pts = p->m.timestamp;
+    frame->pts = frame->best_effort_timestamp = p->m.timestamp;
 #if FF_API_PKT_PTS
 FF_DISABLE_DEPRECATION_WARNINGS
     frame->pkt_pts = p->m.timestamp;
diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c
index 9c82589..08f951a 100644
--- a/libavcodec/libilbc.c
+++ b/libavcodec/libilbc.c
@@ -27,10 +27,6 @@
 #include "avcodec.h"
 #include "internal.h"
 
-#ifndef LIBILBC_VERSION_MAJOR
-#define LIBILBC_VERSION_MAJOR 2
-#endif
-
 static int get_mode(AVCodecContext *avctx)
 {
     if (avctx->block_align == 38)
@@ -45,11 +41,7 @@
 
 typedef struct ILBCDecContext {
     const AVClass *class;
-#if LIBILBC_VERSION_MAJOR < 3
     iLBC_Dec_Inst_t decoder;
-#else
-    IlbcDecoder decoder;
-#endif
     int enhance;
 } ILBCDecContext;
 
@@ -95,12 +87,7 @@
     int ret;
 
     if (s->decoder.no_of_bytes > buf_size) {
-#if LIBILBC_VERSION_MAJOR < 3
         av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be %u)\n",
-#else
-        av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be "
-                                    "%"SIZE_SPECIFIER")\n",
-#endif
                buf_size, s->decoder.no_of_bytes);
         return AVERROR_INVALIDDATA;
     }
@@ -130,11 +117,7 @@
 
 typedef struct ILBCEncContext {
     const AVClass *class;
-#if LIBILBC_VERSION_MAJOR < 3
     iLBC_Enc_Inst_t encoder;
-#else
-    IlbcEncoder encoder;
-#endif
     int mode;
 } ILBCEncContext;
 
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index d94cf99..9032547 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -95,9 +95,6 @@
     cfg->target_bitrate = avctx->bit_rate;
     cfg->vui.sar_width  = avctx->sample_aspect_ratio.num;
     cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
-    if (avctx->bit_rate) {
-        cfg->rc_algorithm = KVZ_LAMBDA;
-    }
 
     if (ctx->kvz_params) {
         AVDictionary *dict = NULL;
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 70d17f8..bf2d04b 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -94,7 +94,7 @@
     bytestream_put_buffer(&p, "OpusHead", 8);
     bytestream_put_byte(&p, 1); /* Version */
     bytestream_put_byte(&p, channels);
-    bytestream_put_le16(&p, avctx->initial_padding * 48000 / avctx->sample_rate); /* Lookahead samples at 48kHz */
+    bytestream_put_le16(&p, avctx->initial_padding); /* Lookahead samples at 48kHz */
     bytestream_put_le32(&p, avctx->sample_rate); /* Original sample rate */
     bytestream_put_le16(&p, 0); /* Gain of 0dB is recommended. */
 
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 2d5acc7..e9b82a7 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -443,32 +443,23 @@
             return ret;
 
         if (frame->buf[0]) {
-            const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
 
-            int64_t *pts = av_malloc(sizeof(int64_t));
-            if (!pts) {
-                av_log(avctx, AV_LOG_ERROR, "Could not allocate PTS buffer.\n");
-                return AVERROR(ENOMEM);
-            }
-            *pts = frame->pts;
-
-            rframe = rav1e_frame_new(ctx->ctx);
-            if (!rframe) {
-                av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e frame.\n");
-                av_frame_unref(frame);
-                av_freep(&pts);
-                return AVERROR(ENOMEM);
-            }
-
-            for (int i = 0; i < desc->nb_components; i++) {
-                int shift = i ? desc->log2_chroma_h : 0;
-                int bytes = desc->comp[0].depth == 8 ? 1 : 2;
-                rav1e_frame_fill_plane(rframe, i, frame->data[i],
-                                       (frame->height >> shift) * frame->linesize[i],
-                                       frame->linesize[i], bytes);
-            }
+        rframe = rav1e_frame_new(ctx->ctx);
+        if (!rframe) {
+            av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e frame.\n");
             av_frame_unref(frame);
-            rav1e_frame_set_opaque(rframe, pts, av_free);
+            return AVERROR(ENOMEM);
+        }
+
+        for (int i = 0; i < desc->nb_components; i++) {
+            int shift = i ? desc->log2_chroma_h : 0;
+            int bytes = desc->comp[0].depth == 8 ? 1 : 2;
+            rav1e_frame_fill_plane(rframe, i, frame->data[i],
+                                   (frame->height >> shift) * frame->linesize[i],
+                                   frame->linesize[i], bytes);
+        }
+        av_frame_unref(frame);
         }
     }
 
@@ -477,7 +468,7 @@
         if (ret == RA_ENCODER_STATUS_ENOUGH_DATA) {
             ctx->rframe = rframe; /* Queue is full. Store the RaFrame to retry next call */
         } else {
-            rav1e_frame_unref(rframe); /* No need to unref if flushing. */
+         rav1e_frame_unref(rframe); /* No need to unref if flushing. */
             ctx->rframe = NULL;
         }
 
@@ -544,8 +535,7 @@
     if (rpkt->frame_type == RA_FRAME_TYPE_KEY)
         pkt->flags |= AV_PKT_FLAG_KEY;
 
-    pkt->pts = pkt->dts = *((int64_t *) rpkt->opaque);
-    av_free(rpkt->opaque);
+    pkt->pts = pkt->dts = rpkt->input_frameno * avctx->ticks_per_frame;
     rav1e_packet_unref(rpkt);
 
     if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c
index bf94764..f78f872 100644
--- a/libavcodec/libvorbisenc.c
+++ b/libavcodec/libvorbisenc.c
@@ -70,17 +70,6 @@
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-static const uint8_t vorbis_encoding_channel_layout_offsets[8][8] = {
-    { 0 },
-    { 0, 1 },
-    { 0, 2, 1 },
-    { 0, 1, 2, 3 },
-    { 0, 2, 1, 3, 4 },
-    { 0, 2, 1, 4, 5, 3 },
-    { 0, 2, 1, 5, 6, 4, 3 },
-    { 0, 2, 1, 6, 7, 4, 5, 3 },
-};
-
 static int vorbis_error_to_averror(int ov_err)
 {
     switch (ov_err) {
@@ -298,7 +287,7 @@
         buffer = vorbis_analysis_buffer(&s->vd, samples);
         for (c = 0; c < channels; c++) {
             int co = (channels > 8) ? c :
-                     vorbis_encoding_channel_layout_offsets[channels - 1][c];
+                     ff_vorbis_encoding_channel_layout_offsets[channels - 1][c];
             memcpy(buffer[c], frame->extended_data[co],
                    samples * sizeof(*buffer[c]));
         }
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 8698232..3e32044 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -221,7 +221,7 @@
     struct vpx_image *img, *img_alpha;
     int ret;
     uint8_t *side_data = NULL;
-    buffer_size_t side_data_size;
+    int side_data_size;
 
     ret = decode_frame(avctx, &ctx->decoder, avpkt->data, avpkt->size);
     if (ret)
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 02df4fe..a7c76eb 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -125,9 +125,6 @@
      * encounter a frame with ROI side data.
      */
     int roi_warned;
-#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
-    vpx_svc_ref_frame_config_t ref_frame_config;
-#endif
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -155,7 +152,6 @@
     [VP9E_SET_SVC_LAYER_ID]            = "VP9E_SET_SVC_LAYER_ID",
 #if VPX_ENCODER_ABI_VERSION >= 12
     [VP9E_SET_SVC_PARAMETERS]          = "VP9E_SET_SVC_PARAMETERS",
-    [VP9E_SET_SVC_REF_FRAME_CONFIG]    = "VP9E_SET_SVC_REF_FRAME_CONFIG",
 #endif
     [VP9E_SET_SVC]                     = "VP9E_SET_SVC",
 #if VPX_ENCODER_ABI_VERSION >= 11
@@ -398,20 +394,6 @@
     }
 }
 
-#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
-static void vp8_ts_parse_int64_array(int64_t *dest, char *value, size_t value_len, int max_entries)
-{
-    int dest_idx = 0;
-    char *saveptr = NULL;
-    char *token = av_strtok(value, ",", &saveptr);
-
-    while (token && dest_idx < max_entries) {
-        dest[dest_idx++] = strtoull(token, NULL, 10);
-        token = av_strtok(NULL, ",", &saveptr);
-    }
-}
-#endif
-
 static void set_temporal_layer_pattern(int layering_mode, vpx_codec_enc_cfg_t *cfg,
                                        int *layer_flags, int *flag_periodicity)
 {
@@ -559,86 +541,6 @@
     return 0;
 }
 
-#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
-static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t *ref_frame_config,
-                                          int ss_number_layers, char *key, char *value)
-{
-    size_t value_len = strlen(value);
-
-    if (!value_len)
-        return AVERROR(EINVAL);
-
-    if (!strcmp(key, "rfc_update_buffer_slot")) {
-        vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_update_last")) {
-        vp8_ts_parse_int_array(ref_frame_config->update_last, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_update_golden")) {
-        vp8_ts_parse_int_array(ref_frame_config->update_golden, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_update_alt_ref")) {
-        vp8_ts_parse_int_array(ref_frame_config->update_alt_ref, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_lst_fb_idx")) {
-        vp8_ts_parse_int_array(ref_frame_config->lst_fb_idx, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_gld_fb_idx")) {
-        vp8_ts_parse_int_array(ref_frame_config->gld_fb_idx, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_alt_fb_idx")) {
-        vp8_ts_parse_int_array(ref_frame_config->alt_fb_idx, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_reference_last")) {
-        vp8_ts_parse_int_array(ref_frame_config->reference_last, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_reference_golden")) {
-        vp8_ts_parse_int_array(ref_frame_config->reference_golden, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_reference_alt_ref")) {
-        vp8_ts_parse_int_array(ref_frame_config->reference_alt_ref, value, value_len, ss_number_layers);
-    } else if (!strcmp(key, "rfc_reference_duration")) {
-        vp8_ts_parse_int64_array(ref_frame_config->duration, value, value_len, ss_number_layers);
-    }
-
-    return 0;
-}
-
-static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t *ref_frame_config,
-                                              int ss_number_layers, const char **buf)
-{
-    const char key_val_sep[] = "=";
-    const char pairs_sep[] = ":";
-    char *key = av_get_token(buf, key_val_sep);
-    char *val = NULL;
-    int ret;
-
-    if (key && *key && strspn(*buf, key_val_sep)) {
-        (*buf)++;
-        val = av_get_token(buf, pairs_sep);
-    }
-
-    if (key && *key && val && *val)
-        ret = vpx_ref_frame_config_set_value(ref_frame_config, ss_number_layers, key, val);
-    else
-        ret = AVERROR(EINVAL);
-
-    av_freep(&key);
-    av_freep(&val);
-
-    return ret;
-}
-
-static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t *ref_frame_config,
-                                      int ss_number_layers, const char *str)
-{
-    int ret = 0;
-
-    while (*str) {
-        ret =
-            vpx_parse_ref_frame_config_element(ref_frame_config, ss_number_layers, &str);
-        if (ret < 0)
-            return ret;
-
-        if (*str)
-            str++;
-    }
-
-    return ret;
-}
-#endif
-
 #if CONFIG_LIBVPX_VP9_ENCODER
 static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps,
                        struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *flags,
@@ -1626,26 +1528,6 @@
 #endif
                 layer_id_valid = 1;
             }
-#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
-            en = av_dict_get(frame->metadata, "ref-frame-config", NULL, 0);
-
-            if (en) {
-                if (avctx->codec_id == AV_CODEC_ID_VP9) {
-                    int ret = vpx_parse_ref_frame_config(&ctx->ref_frame_config,
-                                                         enccfg->ss_number_layers, en->value);
-                    if (ret < 0) {
-                        av_log(avctx, AV_LOG_WARNING,
-                               "Error parsing ref_frame_config option %s.\n", en->value);
-                        return ret;
-                    }
-
-                    codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int *)&ctx->ref_frame_config);
-                } else {
-                    av_log(avctx, AV_LOG_WARNING,
-                           "Ignoring ref-frame-config for a non-VP9 codec\n");
-                }
-            }
-#endif
         }
 
         if (sd) {
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 212ed7d..ca7cc3a 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -1051,17 +1051,19 @@
 };
 #endif
 
-#if X264_BUILD < 153
 static av_cold void X264_init_static(AVCodec *codec)
 {
+#if X264_BUILD < 153
     if (x264_bit_depth == 8)
         codec->pix_fmts = pix_fmts_8bit;
     else if (x264_bit_depth == 9)
         codec->pix_fmts = pix_fmts_9bit;
     else if (x264_bit_depth == 10)
         codec->pix_fmts = pix_fmts_10bit;
-}
+#else
+    codec->pix_fmts = pix_fmts_all;
 #endif
+}
 
 #define OFFSET(x) offsetof(X264Context, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
@@ -1206,11 +1208,7 @@
                         AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_class       = &x264_class,
     .defaults         = x264_defaults,
-#if X264_BUILD < 153
     .init_static_data = X264_init_static,
-#else
-    .pix_fmts         = pix_fmts_all,
-#endif
 #if X264_BUILD >= 158
     .caps_internal    = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
 #else
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index dda8b94..857077d 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -40,6 +40,7 @@
 
 #include "avcodec.h"
 #include "internal.h"
+#include "libxvid.h"
 #include "mpegutils.h"
 #include "packet_internal.h"
 
diff --git a/libavcodec/ttmlenc.h b/libavcodec/libxvid.h
similarity index 64%
copy from libavcodec/ttmlenc.h
copy to libavcodec/libxvid.h
index c1dd5ec..58bef61 100644
--- a/libavcodec/ttmlenc.h
+++ b/libavcodec/libxvid.h
@@ -1,6 +1,5 @@
 /*
- * TTML subtitle encoder shared functionality
- * Copyright (c) 2020 24i
+ * copyright (C) 2006 Corey Hickey
  *
  * This file is part of FFmpeg.
  *
@@ -19,10 +18,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_TTMLENC_H
-#define AVCODEC_TTMLENC_H
+#ifndef AVCODEC_LIBXVID_H
+#define AVCODEC_LIBXVID_H
 
-#define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc"
-#define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1)
+/**
+ * @file
+ * common functions for use with the Xvid wrappers
+ */
 
-#endif /* AVCODEC_TTMLENC_H */
+struct MpegEncContext;
+
+/* rate control */
+int ff_xvid_rate_control_init(struct MpegEncContext *s);
+void ff_xvid_rate_control_uninit(struct MpegEncContext *s);
+float ff_xvid_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
+
+#endif /* AVCODEC_LIBXVID_H */
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 3c68c08..39ce5a0 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -32,14 +32,12 @@
 
 #include "libavutil/frame.h"
 #include "libavutil/mem.h"
-#include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
 #include "idctdsp.h"
 #include "internal.h"
 #include "jpegtables.h"
-#include "mathops.h"
 #include "mjpegenc_common.h"
 #include "mjpeg.h"
 
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 1d1d04f..f8da1e1 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/lls.h"
-#include "libavutil/mem_internal.h"
 
 #define LPC_USE_DOUBLE
 #include "lpc.h"
diff --git a/libavcodec/lscrdec.c b/libavcodec/lscrdec.c
deleted file mode 100644
index f5cfe1f..0000000
--- a/libavcodec/lscrdec.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (c) 2019 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-#include <zlib.h>
-
-#include "libavutil/frame.h"
-#include "libavutil/error.h"
-#include "libavutil/log.h"
-
-#include "avcodec.h"
-#include "bytestream.h"
-#include "codec.h"
-#include "internal.h"
-#include "packet.h"
-#include "png.h"
-#include "pngdsp.h"
-
-typedef struct LSCRContext {
-    PNGDSPContext   dsp;
-    AVCodecContext *avctx;
-
-    AVFrame        *last_picture;
-    uint8_t        *buffer;
-    int             buffer_size;
-    uint8_t        *crow_buf;
-    int             crow_size;
-    uint8_t        *last_row;
-    unsigned int    last_row_size;
-
-    GetByteContext  gb;
-    uint8_t        *image_buf;
-    int             image_linesize;
-    int             row_size;
-    int             cur_h;
-    int             y;
-
-    z_stream        zstream;
-} LSCRContext;
-
-static void handle_row(LSCRContext *s)
-{
-    uint8_t *ptr, *last_row;
-
-    ptr = s->image_buf + s->image_linesize * s->y;
-    if (s->y == 0)
-        last_row = s->last_row;
-    else
-        last_row = ptr - s->image_linesize;
-
-    ff_png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1,
-                      last_row, s->row_size, 3);
-
-    s->y++;
-}
-
-static int decode_idat(LSCRContext *s, int length)
-{
-    int ret;
-    s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb));
-    s->zstream.next_in  = s->gb.buffer;
-    bytestream2_skip(&s->gb, length);
-
-    /* decode one line if possible */
-    while (s->zstream.avail_in > 0) {
-        ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
-        if (ret != Z_OK && ret != Z_STREAM_END) {
-            av_log(s->avctx, AV_LOG_ERROR, "inflate returned error %d\n", ret);
-            return AVERROR_EXTERNAL;
-        }
-        if (s->zstream.avail_out == 0) {
-            if (s->y < s->cur_h) {
-                handle_row(s);
-            }
-            s->zstream.avail_out = s->crow_size;
-            s->zstream.next_out  = s->crow_buf;
-        }
-        if (ret == Z_STREAM_END && s->zstream.avail_in > 0) {
-            av_log(s->avctx, AV_LOG_WARNING,
-                   "%d undecompressed bytes left in buffer\n", s->zstream.avail_in);
-            return 0;
-        }
-    }
-    return 0;
-}
-
-static int decode_frame_lscr(AVCodecContext *avctx,
-                             void *data, int *got_frame,
-                             AVPacket *avpkt)
-{
-    LSCRContext *const s = avctx->priv_data;
-    GetByteContext *gb = &s->gb;
-    AVFrame *frame = s->last_picture;
-    int ret, nb_blocks, offset = 0;
-
-    if (avpkt->size < 2)
-        return AVERROR_INVALIDDATA;
-    if (avpkt->size == 2)
-        return 0;
-
-    bytestream2_init(gb, avpkt->data, avpkt->size);
-
-    nb_blocks = bytestream2_get_le16(gb);
-    if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * (12 + 8))
-        return AVERROR_INVALIDDATA;
-
-    ret = ff_reget_buffer(avctx, frame,
-                          nb_blocks ? 0 : FF_REGET_BUFFER_FLAG_READONLY);
-    if (ret < 0)
-        return ret;
-
-    for (int b = 0; b < nb_blocks; b++) {
-        int x, y, x2, y2, w, h, left;
-        uint32_t csize, size;
-
-        s->zstream.zalloc = ff_png_zalloc;
-        s->zstream.zfree  = ff_png_zfree;
-        s->zstream.opaque = NULL;
-
-        if ((ret = inflateInit(&s->zstream)) != Z_OK) {
-            av_log(avctx, AV_LOG_ERROR, "inflateInit returned error %d\n", ret);
-            ret = AVERROR_EXTERNAL;
-            goto end;
-        }
-
-        bytestream2_seek(gb, 2 + b * 12, SEEK_SET);
-
-        x = bytestream2_get_le16(gb);
-        y = bytestream2_get_le16(gb);
-        x2 = bytestream2_get_le16(gb);
-        y2 = bytestream2_get_le16(gb);
-        w = x2-x;
-        s->cur_h = h = y2-y;
-
-        if (w <= 0 || x < 0 || x >= avctx->width || w + x > avctx->width ||
-            h <= 0 || y < 0 || y >= avctx->height || h + y > avctx->height) {
-            ret = AVERROR_INVALIDDATA;
-            goto end;
-        }
-
-        size = bytestream2_get_le32(gb);
-
-        frame->key_frame = (nb_blocks == 1) &&
-                           (w == avctx->width) &&
-                           (h == avctx->height) &&
-                           (x == 0) && (y == 0);
-
-        bytestream2_seek(gb, 2 + nb_blocks * 12 + offset, SEEK_SET);
-        csize = bytestream2_get_be32(gb);
-        if (bytestream2_get_le32(gb) != MKTAG('I', 'D', 'A', 'T')) {
-            ret = AVERROR_INVALIDDATA;
-            goto end;
-        }
-
-        offset += size;
-        left = size;
-
-        s->y                 = 0;
-        s->row_size          = w * 3;
-
-        av_fast_padded_malloc(&s->buffer, &s->buffer_size, s->row_size + 16);
-        if (!s->buffer) {
-            ret = AVERROR(ENOMEM);
-            goto end;
-        }
-
-        av_fast_padded_malloc(&s->last_row, &s->last_row_size, s->row_size);
-        if (!s->last_row) {
-            ret = AVERROR(ENOMEM);
-            goto end;
-        }
-
-        s->crow_size         = w * 3 + 1;
-        s->crow_buf          = s->buffer + 15;
-        s->zstream.avail_out = s->crow_size;
-        s->zstream.next_out  = s->crow_buf;
-        s->image_buf         = frame->data[0] + (avctx->height - y - 1) * frame->linesize[0] + x * 3;
-        s->image_linesize    =-frame->linesize[0];
-
-        while (left > 16) {
-            ret = decode_idat(s, csize);
-            if (ret < 0)
-                goto end;
-            left -= csize + 16;
-            if (left > 16) {
-                bytestream2_skip(gb, 4);
-                csize = bytestream2_get_be32(gb);
-                if (bytestream2_get_le32(gb) != MKTAG('I', 'D', 'A', 'T')) {
-                    ret = AVERROR_INVALIDDATA;
-                    goto end;
-                }
-            }
-        }
-
-        inflateEnd(&s->zstream);
-    }
-
-    frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
-
-    if ((ret = av_frame_ref(data, frame)) < 0)
-        return ret;
-
-    *got_frame = 1;
-end:
-    inflateEnd(&s->zstream);
-
-    if (ret < 0)
-        return ret;
-    return avpkt->size;
-}
-
-static int lscr_decode_close(AVCodecContext *avctx)
-{
-    LSCRContext *s = avctx->priv_data;
-
-    av_frame_free(&s->last_picture);
-    av_freep(&s->buffer);
-    av_freep(&s->last_row);
-
-    return 0;
-}
-
-static int lscr_decode_init(AVCodecContext *avctx)
-{
-    LSCRContext *s = avctx->priv_data;
-
-    avctx->color_range = AVCOL_RANGE_JPEG;
-    avctx->pix_fmt     = AV_PIX_FMT_BGR24;
-
-    s->avctx = avctx;
-    s->last_picture = av_frame_alloc();
-    if (!s->last_picture)
-        return AVERROR(ENOMEM);
-
-    ff_pngdsp_init(&s->dsp);
-
-    return 0;
-}
-
-static void lscr_decode_flush(AVCodecContext *avctx)
-{
-    LSCRContext *s = avctx->priv_data;
-    av_frame_unref(s->last_picture);
-}
-
-AVCodec ff_lscr_decoder = {
-    .name           = "lscr",
-    .long_name      = NULL_IF_CONFIG_SMALL("LEAD Screen Capture"),
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_LSCR,
-    .priv_data_size = sizeof(LSCRContext),
-    .init           = lscr_decode_init,
-    .close          = lscr_decode_close,
-    .decode         = decode_frame_lscr,
-    .flush          = lscr_decode_flush,
-    .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
-};
diff --git a/libavcodec/mdct15.h b/libavcodec/mdct15.h
index 035246f..42e60f3 100644
--- a/libavcodec/mdct15.h
+++ b/libavcodec/mdct15.h
@@ -23,8 +23,6 @@
 
 #include <stddef.h>
 
-#include "libavutil/mem_internal.h"
-
 #include "fft.h"
 
 typedef struct MDCT15Context {
diff --git a/libavcodec/mdct_fixed.c b/libavcodec/mdct_fixed.c
new file mode 100644
index 0000000..aabf0c8
--- /dev/null
+++ b/libavcodec/mdct_fixed.c
@@ -0,0 +1,65 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 0
+#include "mdct_template.c"
+
+/* same as ff_mdct_calcw_c with double-width unscaled output */
+void ff_mdct_calcw_c(FFTContext *s, FFTDouble *out, const FFTSample *input)
+{
+    int i, j, n, n8, n4, n2, n3;
+    FFTDouble re, im;
+    const uint16_t *revtab = s->revtab;
+    const FFTSample *tcos = s->tcos;
+    const FFTSample *tsin = s->tsin;
+    FFTComplex *x = s->tmp_buf;
+    FFTDComplex *o = (FFTDComplex *)out;
+
+    n = 1 << s->mdct_bits;
+    n2 = n >> 1;
+    n4 = n >> 2;
+    n8 = n >> 3;
+    n3 = 3 * n4;
+
+    /* pre rotation */
+    for(i=0;i<n8;i++) {
+        re = RSCALE(-input[2*i+n3], - input[n3-1-2*i]);
+        im = RSCALE(-input[n4+2*i], + input[n4-1-2*i]);
+        j = revtab[i];
+        CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
+
+        re = RSCALE( input[2*i]   , - input[n2-1-2*i]);
+        im = RSCALE(-input[n2+2*i], - input[ n-1-2*i]);
+        j = revtab[n8 + i];
+        CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
+    }
+
+    s->fft_calc(s, x);
+
+    /* post rotation */
+    for(i=0;i<n8;i++) {
+        FFTDouble r0, i0, r1, i1;
+        CMULL(i1, r0, x[n8-i-1].re, x[n8-i-1].im, -tsin[n8-i-1], -tcos[n8-i-1]);
+        CMULL(i0, r1, x[n8+i  ].re, x[n8+i  ].im, -tsin[n8+i  ], -tcos[n8+i  ]);
+        o[n8-i-1].re = r0;
+        o[n8-i-1].im = i0;
+        o[n8+i  ].re = r1;
+        o[n8+i  ].im = i1;
+    }
+}
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index 101e558..b16cbb6 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -27,8 +27,6 @@
  * This is very similar to intra-only MPEG-1.
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
@@ -260,5 +258,4 @@
     .close            = decode_end,
     .decode           = decode_frame,
     .capabilities     = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
-    .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 6054524..ae248c5 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #include "copy_block.h"
 #include "simple_idct.h"
@@ -1012,8 +1011,31 @@
 WRAPPER8_16_SQ(rd8x8_c, rd16_c)
 WRAPPER8_16_SQ(bit8x8_c, bit16_c)
 
+int ff_check_alignment(void)
+{
+    static int did_fail = 0;
+    LOCAL_ALIGNED_16(int, aligned, [4]);
+
+    if ((intptr_t)aligned & 15) {
+        if (!did_fail) {
+#if HAVE_MMX || HAVE_ALTIVEC
+            av_log(NULL, AV_LOG_ERROR,
+                "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
+                "and may be very slow or crash. This is not a bug in libavcodec,\n"
+                "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
+                "Do not report crashes to FFmpeg developers.\n");
+#endif
+            did_fail=1;
+        }
+        return -1;
+    }
+    return 0;
+}
+
 av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
 {
+    ff_check_alignment();
+
     c->sum_abs_dctelem = sum_abs_dctelem_c;
 
     /* TODO [0] 16  [1] 8 */
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index e9b5161..0a589e3 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -79,6 +79,8 @@
     me_cmp_func median_sad[6];
 } MECmpContext;
 
+int ff_check_alignment(void);
+
 void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx);
diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index c829941..79abc8b 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -45,7 +45,6 @@
     jmethodID get_codec_capabilities_id;
     jmethodID get_supported_types_id;
     jmethodID is_encoder_id;
-    jmethodID is_software_only_id;
 
     jclass codec_capabilities_class;
     jfieldID color_formats_id;
@@ -82,7 +81,6 @@
         { "android/media/MediaCodecInfo", "getCapabilitiesForType", "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_capabilities_id), 1 },
         { "android/media/MediaCodecInfo", "getSupportedTypes", "()[Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_supported_types_id), 1 },
         { "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_encoder_id), 1 },
-        { "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_software_only_id), 0 },
 
     { "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, codec_capabilities_class), 1 },
         { "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", "[I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, color_formats_id), 1 },
@@ -443,41 +441,6 @@
             goto done_with_info;
         }
 
-        if (jfields.is_software_only_id) {
-            int is_software_only = (*env)->CallBooleanMethod(env, info, jfields.is_software_only_id);
-            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-                goto done;
-            }
-
-            if (is_software_only) {
-                goto done_with_info;
-            }
-        }
-
-        codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id);
-        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-            goto done;
-        }
-
-        name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx);
-        if (!name) {
-            goto done;
-        }
-
-        if (codec_name) {
-            (*env)->DeleteLocalRef(env, codec_name);
-            codec_name = NULL;
-        }
-
-        /* Skip software decoders */
-        if (
-            strstr(name, "OMX.google") ||
-            strstr(name, "OMX.ffmpeg") ||
-            (strstr(name, "OMX.SEC") && strstr(name, ".sw.")) ||
-            !strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) {
-            goto done_with_info;
-        }
-
         type_count = (*env)->GetArrayLength(env, types);
         for (j = 0; j < type_count; j++) {
             int k;
@@ -493,51 +456,74 @@
                 goto done;
             }
 
-            if (av_strcasecmp(supported_type, mime)) {
-                goto done_with_type;
-            }
+            if (!av_strcasecmp(supported_type, mime)) {
+                codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id);
+                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+                    goto done;
+                }
 
-            capabilities = (*env)->CallObjectMethod(env, info, jfields.get_codec_capabilities_id, type);
-            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-                goto done;
-            }
+                name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx);
+                if (!name) {
+                    goto done;
+                }
 
-            profile_levels = (*env)->GetObjectField(env, capabilities, jfields.profile_levels_id);
-            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-                goto done;
-            }
+                if (codec_name) {
+                    (*env)->DeleteLocalRef(env, codec_name);
+                    codec_name = NULL;
+                }
 
-            profile_count = (*env)->GetArrayLength(env, profile_levels);
-            if (!profile_count) {
-                found_codec = 1;
-            }
-            for (k = 0; k < profile_count; k++) {
-                int supported_profile = 0;
+                /* Skip software decoders */
+                if (
+                    strstr(name, "OMX.google") ||
+                    strstr(name, "OMX.ffmpeg") ||
+                    (strstr(name, "OMX.SEC") && strstr(name, ".sw.")) ||
+                    !strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) {
+                    av_freep(&name);
+                    goto done_with_type;
+                }
 
-                if (profile < 0) {
+                capabilities = (*env)->CallObjectMethod(env, info, jfields.get_codec_capabilities_id, type);
+                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+                    goto done;
+                }
+
+                profile_levels = (*env)->GetObjectField(env, capabilities, jfields.profile_levels_id);
+                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+                    goto done;
+                }
+
+                profile_count = (*env)->GetArrayLength(env, profile_levels);
+                if (!profile_count) {
                     found_codec = 1;
-                    break;
                 }
+                for (k = 0; k < profile_count; k++) {
+                    int supported_profile = 0;
 
-                profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k);
-                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-                    goto done;
-                }
+                    if (profile < 0) {
+                        found_codec = 1;
+                        break;
+                    }
 
-                supported_profile = (*env)->GetIntField(env, profile_level, jfields.profile_id);
-                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-                    goto done;
-                }
+                    profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k);
+                    if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+                        goto done;
+                    }
 
-                found_codec = profile == supported_profile;
+                    supported_profile = (*env)->GetIntField(env, profile_level, jfields.profile_id);
+                    if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+                        goto done;
+                    }
 
-                if (profile_level) {
-                    (*env)->DeleteLocalRef(env, profile_level);
-                    profile_level = NULL;
-                }
+                    found_codec = profile == supported_profile;
 
-                if (found_codec) {
-                    break;
+                    if (profile_level) {
+                        (*env)->DeleteLocalRef(env, profile_level);
+                        profile_level = NULL;
+                    }
+
+                    if (found_codec) {
+                        break;
+                    }
                 }
             }
 
@@ -562,6 +548,8 @@
             if (found_codec) {
                 break;
             }
+
+            av_freep(&name);
         }
 
 done_with_info:
@@ -578,8 +566,6 @@
         if (found_codec) {
             break;
         }
-
-        av_freep(&name);
     }
 
 done:
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index ad592d1..ac1725e 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -167,11 +167,8 @@
         ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
         av_freep(&data);
     } else {
-        const int warn = is_avc && (avctx->codec_tag == MKTAG('a','v','c','1') ||
-                                    avctx->codec_tag == MKTAG('a','v','c','2'));
-        av_log(avctx, warn ? AV_LOG_WARNING : AV_LOG_DEBUG,
-               "Could not extract PPS/SPS from extradata\n");
-        ret = 0;
+        av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
+        ret = AVERROR_INVALIDDATA;
     }
 
 done:
@@ -257,10 +254,8 @@
 
         av_freep(&data);
     } else {
-        const int warn = is_nalff && avctx->codec_tag == MKTAG('h','v','c','1');
-        av_log(avctx, warn ? AV_LOG_WARNING : AV_LOG_DEBUG,
-               "Could not extract VPS/PPS/SPS from extradata\n");
-        ret = 0;
+        av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from extradata");
+        ret = AVERROR_INVALIDDATA;
     }
 
 done:
diff --git a/libavcodec/metasound.c b/libavcodec/metasound.c
index 27cf1dd..396310b 100644
--- a/libavcodec/metasound.c
+++ b/libavcodec/metasound.c
@@ -341,17 +341,23 @@
         tctx->mtab = &ff_metasound_mode2224s;
         break;
     case (1 << 16) + (44 << 8) + 32:
-    case (2 << 16) + (44 << 8) + 32:
         tctx->mtab = &ff_metasound_mode4432;
         break;
+    case (2 << 16) + (44 << 8) + 32:
+        tctx->mtab = &ff_metasound_mode4432s;
+        break;
     case (1 << 16) + (44 << 8) + 40:
-    case (2 << 16) + (44 << 8) + 40:
         tctx->mtab = &ff_metasound_mode4440;
         break;
+    case (2 << 16) + (44 << 8) + 40:
+        tctx->mtab = &ff_metasound_mode4440s;
+        break;
     case (1 << 16) + (44 << 8) + 48:
-    case (2 << 16) + (44 << 8) + 48:
         tctx->mtab = &ff_metasound_mode4448;
         break;
+    case (2 << 16) + (44 << 8) + 48:
+        tctx->mtab = &ff_metasound_mode4448s;
+        break;
     default:
         av_log(avctx, AV_LOG_ERROR,
                "This version does not support %d kHz - %d kbit/s/ch mode.\n",
diff --git a/libavcodec/metasound_data.c b/libavcodec/metasound_data.c
index 22b2730..da2548a 100644
--- a/libavcodec/metasound_data.c
+++ b/libavcodec/metasound_data.c
@@ -19,10 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
 #include "metasound_data.h"
 
-#if CONFIG_METASOUND_DECODER
 static const int16_t cb0806sl0[] = {
       -417,   -225,    -84,     16,   -106,    -34,   -246,   -164,
        112,     48,    -47,     36,    -65,    -68,   -172,  -1655,
@@ -12103,9 +12101,8 @@
       -623,   -588,     38,    -58,    975,   1529,   -986,   -891,
      -1121,   -619,   1967,   -463,     -7,    632,    768,    953,
 };
-#endif /* CONFIG_METASOUND_DECODER */
 
-const float ff_metasound_lsp8[] = {
+static const float lsp8[] = {
      0.2702,  0.5096,  0.6437,  0.7672,  0.9639,  1.0696,  1.2625,  1.5789,
      1.9285,  2.2383,  2.5129,  2.8470,  0.1740,  0.3677,  0.6082,  0.8387,
      1.1084,  1.3721,  1.6362,  1.8733,  2.0640,  2.3442,  2.6087,  2.8548,
@@ -12171,7 +12168,73 @@
      0.2217,  0.2632,  0.2706,  0.2624,  0.2162,  0.2453,  0.2460,  0.2531,
 };
 
-const float ff_metasound_lsp11[] = {
+static const float lsp8s[] = {
+     0.2702,  0.5096,  0.6437,  0.7672,  0.9639,  1.0696,  1.2625,  1.5789,
+     1.9285,  2.2383,  2.5129,  2.8470,  0.1740,  0.3677,  0.6082,  0.8387,
+     1.1084,  1.3721,  1.6362,  1.8733,  2.0640,  2.3442,  2.6087,  2.8548,
+     0.1536,  0.3279,  0.5143,  0.6859,  0.9763,  1.2744,  1.5605,  1.8566,
+     2.1007,  2.3450,  2.6075,  2.8850,  0.2075,  0.4533,  0.7709,  1.0377,
+     1.2953,  1.5132,  1.7826,  2.0351,  2.2590,  2.4996,  2.6795,  2.8748,
+     0.1393,  0.2453,  0.3754,  0.5453,  0.8148,  1.1289,  1.4389,  1.7592,
+     2.0353,  2.3215,  2.5934,  2.8588,  0.1250,  0.3627,  0.7613,  1.1380,
+     1.4163,  1.5565,  1.6920,  1.8130,  1.8678,  2.0427,  2.4318,  2.8544,
+     0.2256,  0.4223,  0.6452,  0.8599,  1.0673,  1.3118,  1.5486,  1.8366,
+     2.0759,  2.3026,  2.5284,  2.8030,  0.2304,  0.4404,  0.6891,  0.8964,
+     1.1510,  1.4202,  1.6483,  1.8580,  2.1181,  2.3686,  2.6078,  2.9128,
+     0.2230,  0.3816,  0.5520,  0.6062,  0.7909,  1.0988,  1.4330,  1.7846,
+     2.0713,  2.3457,  2.6048,  2.8708,  0.2447,  0.5800,  0.8249,  0.9905,
+     1.1721,  1.3990,  1.6694,  1.9064,  2.1307,  2.4255,  2.6815,  2.9117,
+     0.1974,  0.3812,  0.5802,  0.7759,  0.9280,  1.1547,  1.4170,  1.6369,
+     1.8890,  2.2587,  2.5626,  2.8239,  0.1209,  0.2510,  0.4841,  0.8048,
+     1.1197,  1.3563,  1.6073,  1.8926,  2.1350,  2.3669,  2.6291,  2.8985,
+     0.2352,  0.4347,  0.6582,  0.8178,  0.9548,  1.1654,  1.4942,  1.8812,
+     2.1703,  2.3779,  2.6412,  2.8871,  0.2091,  0.4084,  0.6730,  0.9151,
+     1.1259,  1.3262,  1.5937,  1.8129,  2.0237,  2.3317,  2.5778,  2.8620,
+     0.1167,  0.2406,  0.4520,  0.7298,  0.9848,  1.2448,  1.5137,  1.7874,
+     2.0280,  2.3020,  2.5914,  2.8794,  0.3003,  0.4966,  0.6520,  0.8505,
+     1.1600,  1.3981,  1.5805,  1.8346,  2.0757,  2.3102,  2.5760,  2.8499,
+     0.2451,  0.4163,  0.5960,  0.7805,  0.9507,  1.2438,  1.5587,  1.8581,
+     2.0735,  2.3198,  2.5704,  2.8220,  0.3112,  0.5517,  0.7032,  0.8528,
+     1.1489,  1.4257,  1.6848,  1.9388,  2.1577,  2.4265,  2.6678,  2.9051,
+     0.2249,  0.3897,  0.5559,  0.7473,  1.0158,  1.3581,  1.6914,  1.9930,
+     2.1843,  2.3534,  2.5512,  2.8065,  0.2600,  0.4574,  0.7349,  0.9691,
+     1.1696,  1.3848,  1.6335,  1.9021,  2.1174,  2.3481,  2.5902,  2.8390,
+     0.2246,  0.3372,  0.4560,  0.5249,  0.7056,  1.0273,  1.3810,  1.7132,
+     1.9819,  2.2574,  2.5410,  2.8491,  0.1419,  0.4834,  0.8835,  1.1453,
+     1.2839,  1.4224,  1.5593,  1.7877,  2.1285,  2.4070,  2.6043,  2.8511,
+     0.1886,  0.3677,  0.5617,  0.8099,  1.1277,  1.3841,  1.5804,  1.8136,
+     2.0307,  2.2805,  2.5399,  2.8322,  0.2351,  0.4151,  0.6675,  0.8713,
+     1.0464,  1.3292,  1.6586,  1.9281,  2.1355,  2.3495,  2.6222,  2.8782,
+     0.2700,  0.4489,  0.6206,  0.7121,  0.7737,  0.9848,  1.3658,  1.7433,
+     2.0139,  2.2243,  2.4806,  2.8175,  0.2479,  0.4425,  0.6490,  0.8745,
+     1.1161,  1.3849,  1.6773,  1.9566,  2.1491,  2.3624,  2.5685,  2.8114,
+     0.2035,  0.3701,  0.5567,  0.7953,  1.0082,  1.2758,  1.5373,  1.7822,
+     2.0175,  2.2601,  2.4759,  2.7771,  0.1856,  0.3461,  0.5998,  0.9041,
+     1.2383,  1.4612,  1.6667,  1.9305,  2.1617,  2.4107,  2.6477,  2.8656,
+     0.2107,  0.3715,  0.5289,  0.6651,  0.8420,  1.1168,  1.4401,  1.7230,
+     1.9901,  2.2687,  2.5452,  2.8655,  0.1218,  0.2999,  0.6348,  0.9482,
+     1.2745,  1.5876,  1.9129,  2.2348,  2.4020,  2.4922,  2.6351,  2.8357,
+     0.1617,  0.3483,  0.5869,  0.8163,  1.0366,  1.2344,  1.4609,  1.7029,
+     1.9476,  2.2337,  2.5258,  2.8442,  0.2505,  0.4894,  0.7510,  0.9152,
+     1.0845,  1.3657,  1.6528,  1.8346,  2.0160,  2.2811,  2.5338,  2.8136,
+     0.0947,  0.1158,  0.0578, -0.0337, -0.0066,  0.0104, -0.0447, -0.0505,
+    -0.0778, -0.0293,  0.0251, -0.0143,  0.0349, -0.0227, -0.0909,  0.0523,
+     0.0325, -0.0410, -0.1045, -0.0899, -0.0009,  0.0075, -0.0575, -0.0855,
+    -0.0129,  0.0575,  0.0597,  0.0391,  0.0371, -0.0184, -0.0083,  0.0287,
+     0.0143,  0.0167,  0.0120, -0.0168,  0.0452,  0.0223, -0.0352,  0.0119,
+    -0.0496, -0.0965, -0.0661, -0.0072,  0.1099,  0.0843, -0.0087, -0.0478,
+    -0.0128, -0.0120, -0.0004,  0.0731,  0.1047,  0.0630,  0.0196, -0.0103,
+    -0.0399, -0.0986, -0.0912, -0.0390, -0.0247, -0.0694, -0.0749, -0.0066,
+     0.0223,  0.0634,  0.0343, -0.0134,  0.0727,  0.0241,  0.0066,  0.0437,
+     0.0610,  0.0364,  0.0248, -0.0358, -0.0686, -0.0104,  0.0426,  0.0088,
+    -0.0137, -0.0165,  0.0671,  0.0815, -0.0863, -0.0644, -0.0088,  0.0023,
+     0.0482,  0.1174,  0.1270,  0.0594,  0.0165,  0.0949,  0.1098,  0.0137,
+     0.4951,  0.4999,  0.4958,  0.4907,  0.4984,  0.4965,  0.4958,  0.4996,
+     0.4987,  0.4958,  0.4986,  0.4977,  0.2841,  0.2186,  0.1474,  0.1687,
+     0.2217,  0.2632,  0.2706,  0.2624,  0.2162,  0.2453,  0.2460,  0.2531,
+};
+
+static const float lsp11[] = {
      0.1103,  0.3862,  0.6863,  0.8447,  0.9231,  1.0261,  1.1248,  1.4057,
      1.6621,  1.8010,  1.8692,  2.0704,  2.3490,  2.6060,  2.7539,  2.8977,
      0.1273,  0.2407,  0.3812,  0.6004,  0.7767,  0.9383,  1.1344,  1.3351,
@@ -12338,7 +12401,174 @@
      0.1486,  0.1342,  0.1215,  0.1423,  0.1634,  0.1588,  0.1539,  0.1857,
 };
 
-const float ff_metasound_lsp16[] = {
+static const float lsp11s[] = {
+     0.1103,  0.3862,  0.6863,  0.8447,  0.9231,  1.0261,  1.1248,  1.4057,
+     1.6621,  1.8010,  1.8692,  2.0704,  2.3490,  2.6060,  2.7539,  2.8977,
+     0.1273,  0.2407,  0.3812,  0.6004,  0.7767,  0.9383,  1.1344,  1.3351,
+     1.5233,  1.7262,  1.9466,  2.1739,  2.3495,  2.5162,  2.7164,  2.9202,
+     0.2010,  0.3330,  0.4488,  0.6465,  0.8046,  0.9889,  1.1479,  1.2964,
+     1.4770,  1.6606,  1.8789,  2.1155,  2.3287,  2.5199,  2.7101,  2.9119,
+     0.1168,  0.2197,  0.3279,  0.4691,  0.6268,  0.8251,  1.0533,  1.2714,
+     1.4712,  1.6762,  1.8831,  2.1114,  2.3230,  2.5297,  2.7365,  2.9270,
+     0.1405,  0.3109,  0.4986,  0.6891,  0.8634,  1.0583,  1.2594,  1.4349,
+     1.6232,  1.8116,  1.9905,  2.1935,  2.3799,  2.5656,  2.7661,  2.9486,
+     0.1703,  0.3057,  0.4403,  0.5225,  0.5969,  0.8110,  1.0729,  1.3215,
+     1.5407,  1.7381,  1.9477,  2.1680,  2.3586,  2.5612,  2.7630,  2.9410,
+     0.1128,  0.2628,  0.4523,  0.6495,  0.8176,  0.9816,  1.1746,  1.3710,
+     1.5568,  1.7518,  1.9497,  2.1452,  2.3346,  2.5389,  2.7362,  2.9264,
+     0.1809,  0.3287,  0.5205,  0.7264,  0.9298,  1.1217,  1.2970,  1.4894,
+     1.6874,  1.8493,  2.0576,  2.2382,  2.4097,  2.6041,  2.7796,  2.9389,
+     0.2502,  0.4709,  0.6892,  0.8346,  0.9209,  1.0455,  1.2399,  1.4616,
+     1.6463,  1.8380,  2.0475,  2.2397,  2.4665,  2.6550,  2.7701,  2.8895,
+     0.1040,  0.2340,  0.3964,  0.5740,  0.7764,  0.9941,  1.2000,  1.4014,
+     1.6024,  1.7974,  1.9939,  2.1959,  2.3783,  2.5663,  2.7613,  2.9484,
+     0.1912,  0.3393,  0.4743,  0.6313,  0.8014,  0.9879,  1.1855,  1.3922,
+     1.5678,  1.7289,  1.9271,  2.1165,  2.3089,  2.5414,  2.7448,  2.9269,
+     0.0965,  0.2025,  0.3398,  0.4990,  0.6934,  0.9386,  1.1730,  1.3766,
+     1.5783,  1.7783,  1.9790,  2.1831,  2.3670,  2.5578,  2.7641,  2.9516,
+     0.2126,  0.3652,  0.5545,  0.7170,  0.8674,  1.0640,  1.2558,  1.4061,
+     1.5904,  1.8095,  1.9760,  2.1505,  2.3549,  2.5575,  2.7023,  2.8877,
+     0.1827,  0.3426,  0.4894,  0.6488,  0.7960,  0.9535,  1.1217,  1.2798,
+     1.4566,  1.6453,  1.8044,  2.0042,  2.2379,  2.4611,  2.6697,  2.8966,
+     0.2034,  0.3822,  0.5231,  0.6960,  0.9200,  1.0394,  1.1616,  1.3772,
+     1.5493,  1.7330,  1.9646,  2.1233,  2.3334,  2.5361,  2.7087,  2.9470,
+     0.1050,  0.2060,  0.3705,  0.5998,  0.8337,  1.0577,  1.2559,  1.4327,
+     1.6334,  1.8165,  1.9853,  2.2058,  2.4063,  2.5818,  2.7625,  2.9458,
+     0.1419,  0.4053,  0.6660,  0.8911,  1.0405,  1.1547,  1.2506,  1.3926,
+     1.5669,  1.7527,  1.9694,  2.2054,  2.3889,  2.5743,  2.7586,  2.9174,
+     0.1514,  0.2825,  0.4309,  0.5772,  0.7470,  0.9703,  1.1462,  1.3316,
+     1.5321,  1.7259,  1.9282,  2.1266,  2.3106,  2.5064,  2.7067,  2.9094,
+     0.1693,  0.3156,  0.4878,  0.6635,  0.8206,  0.9569,  1.1154,  1.3064,
+     1.5109,  1.7184,  1.9179,  2.1036,  2.2763,  2.4820,  2.6949,  2.9105,
+     0.1432,  0.2718,  0.4241,  0.5564,  0.6939,  0.9011,  1.1582,  1.3948,
+     1.6181,  1.8024,  1.9814,  2.1740,  2.3459,  2.5456,  2.7491,  2.9307,
+     0.2294,  0.3857,  0.5590,  0.7434,  0.9189,  1.0941,  1.2740,  1.4456,
+     1.6178,  1.7994,  1.9689,  2.1644,  2.3525,  2.5385,  2.7468,  2.9405,
+     0.1667,  0.3109,  0.4612,  0.6032,  0.7375,  0.8866,  1.0840,  1.3053,
+     1.4982,  1.7044,  1.9146,  2.1117,  2.2942,  2.4983,  2.7084,  2.9132,
+     0.1810,  0.3205,  0.4696,  0.6231,  0.7641,  0.9959,  1.2427,  1.4361,
+     1.5889,  1.7544,  1.9083,  2.0733,  2.2457,  2.4461,  2.6793,  2.9098,
+     0.1164,  0.3753,  0.6068,  0.7503,  1.0100,  1.2131,  1.3793,  1.5302,
+     1.6300,  1.7950,  1.9057,  2.1031,  2.3830,  2.5745,  2.6949,  2.8779,
+     0.1571,  0.4378,  0.6735,  0.8312,  0.8944,  0.9818,  1.1622,  1.4094,
+     1.6423,  1.8066,  1.9258,  2.1838,  2.4363,  2.6279,  2.7358,  2.8790,
+     0.1398,  0.2686,  0.4248,  0.6156,  0.7870,  1.0035,  1.2012,  1.3689,
+     1.5363,  1.7398,  1.9604,  2.1619,  2.3345,  2.5097,  2.7271,  2.9368,
+     0.1913,  0.3338,  0.4987,  0.6446,  0.7852,  1.0163,  1.1886,  1.3610,
+     1.5379,  1.7230,  1.8880,  2.0862,  2.2960,  2.4928,  2.7122,  2.9151,
+     0.0908,  0.1752,  0.2899,  0.5365,  0.7761,  1.0100,  1.2124,  1.4060,
+     1.6019,  1.8010,  1.9774,  2.1905,  2.3733,  2.5623,  2.7660,  2.9565,
+     0.1773,  0.3179,  0.4925,  0.6864,  0.8452,  0.9897,  1.1860,  1.3722,
+     1.5515,  1.7658,  1.9802,  2.1819,  2.3620,  2.5442,  2.7250,  2.9220,
+     0.1286,  0.2341,  0.3689,  0.5364,  0.7176,  0.9350,  1.1083,  1.2943,
+     1.4974,  1.7059,  1.9047,  2.1145,  2.3242,  2.5361,  2.7453,  2.9329,
+     0.2273,  0.3834,  0.5565,  0.7192,  0.8431,  0.9962,  1.1763,  1.3571,
+     1.5774,  1.7419,  1.9202,  2.1131,  2.2919,  2.4898,  2.6895,  2.9180,
+     0.1775,  0.3058,  0.4274,  0.6023,  0.8151,  1.0734,  1.3211,  1.5178,
+     1.6706,  1.8154,  1.9686,  2.1537,  2.3461,  2.5276,  2.7181,  2.9121,
+     0.1653,  0.4304,  0.6361,  0.7824,  0.9183,  1.0452,  1.2071,  1.4077,
+     1.6206,  1.8299,  2.0089,  2.1948,  2.3900,  2.5982,  2.7844,  2.9487,
+     0.1492,  0.2609,  0.3820,  0.5485,  0.7243,  0.9319,  1.1538,  1.3579,
+     1.5266,  1.7002,  1.8873,  2.1016,  2.3175,  2.5221,  2.7241,  2.9243,
+     0.2074,  0.3781,  0.5209,  0.6869,  0.8577,  0.9875,  1.1849,  1.3568,
+     1.4907,  1.7335,  1.8902,  2.1224,  2.3099,  2.4918,  2.7023,  2.8765,
+     0.1359,  0.2254,  0.3286,  0.4432,  0.6586,  0.8964,  1.1125,  1.3523,
+     1.5626,  1.7579,  1.9846,  2.1905,  2.3548,  2.5542,  2.7663,  2.9346,
+     0.1430,  0.2966,  0.4685,  0.6493,  0.8315,  1.0304,  1.2220,  1.4082,
+     1.5995,  1.7888,  1.9774,  2.1737,  2.3607,  2.5577,  2.7558,  2.9405,
+     0.1477,  0.2694,  0.4056,  0.5626,  0.7051,  0.8647,  1.0491,  1.2488,
+     1.4814,  1.7072,  1.9150,  2.1147,  2.3038,  2.5144,  2.7184,  2.9202,
+     0.1690,  0.3033,  0.4580,  0.6686,  0.8536,  1.0293,  1.2124,  1.3998,
+     1.5718,  1.7607,  1.9580,  2.1245,  2.2971,  2.4762,  2.6896,  2.9177,
+     0.1092,  0.2779,  0.4853,  0.6880,  0.9011,  1.0953,  1.2752,  1.4618,
+     1.6623,  1.8484,  2.0264,  2.2152,  2.4017,  2.5835,  2.7671,  2.9436,
+     0.1497,  0.3637,  0.6014,  0.8032,  0.9963,  1.1835,  1.3741,  1.5698,
+     1.7382,  1.9094,  2.0710,  2.2392,  2.4082,  2.5926,  2.7762,  2.9536,
+     0.1434,  0.2492,  0.3966,  0.5934,  0.8033,  1.0657,  1.2796,  1.4276,
+     1.5745,  1.7833,  1.9288,  2.1247,  2.3543,  2.5412,  2.7049,  2.8872,
+     0.1612,  0.2926,  0.4574,  0.6387,  0.8265,  1.0180,  1.1808,  1.3526,
+     1.5564,  1.7536,  1.9187,  2.1192,  2.3149,  2.5006,  2.7101,  2.9217,
+     0.0828,  0.1863,  0.3235,  0.5050,  0.7250,  0.9867,  1.2093,  1.3941,
+     1.5980,  1.7932,  1.9809,  2.1894,  2.3918,  2.5773,  2.7540,  2.9329,
+     0.2001,  0.3655,  0.5290,  0.6761,  0.8027,  0.9972,  1.2090,  1.4255,
+     1.6085,  1.7825,  1.9804,  2.1681,  2.3457,  2.5325,  2.7319,  2.9196,
+     0.1505,  0.2767,  0.4254,  0.6054,  0.7821,  0.9567,  1.1294,  1.3080,
+     1.4984,  1.6954,  1.8666,  2.0736,  2.2875,  2.4969,  2.7072,  2.9163,
+     0.1589,  0.4151,  0.5749,  0.6651,  0.8061,  1.0470,  1.2616,  1.3690,
+     1.4985,  1.7808,  1.9825,  2.1068,  2.2751,  2.5448,  2.7133,  2.8689,
+     0.0916,  0.1846,  0.3788,  0.6329,  0.8774,  1.0687,  1.2653,  1.4561,
+     1.6573,  1.8449,  2.0402,  2.2254,  2.3968,  2.5861,  2.7792,  2.9508,
+     0.2282,  0.4159,  0.5834,  0.6899,  0.8108,  1.0321,  1.2795,  1.5262,
+     1.6936,  1.8469,  2.0922,  2.2607,  2.3795,  2.5301,  2.7386,  2.9530,
+     0.1651,  0.3004,  0.4555,  0.6179,  0.7891,  0.9584,  1.1372,  1.3707,
+     1.5951,  1.7880,  1.9434,  2.1465,  2.3311,  2.5081,  2.6977,  2.8970,
+     0.1279,  0.3828,  0.6330,  0.8323,  0.9652,  1.1175,  1.2319,  1.3511,
+     1.5115,  1.6392,  1.7835,  1.9558,  2.2008,  2.4635,  2.6910,  2.9058,
+     0.1193,  0.2185,  0.3521,  0.5311,  0.7378,  0.9239,  1.1105,  1.3217,
+     1.5362,  1.7504,  1.9536,  2.1627,  2.3560,  2.5506,  2.7548,  2.9453,
+     0.1806,  0.3432,  0.4981,  0.6948,  0.8928,  1.0527,  1.2467,  1.4140,
+     1.6326,  1.7950,  1.9935,  2.1969,  2.3512,  2.5682,  2.7445,  2.9277,
+     0.1846,  0.3112,  0.4568,  0.5891,  0.7317,  0.8493,  1.0204,  1.2022,
+     1.3688,  1.6020,  1.8428,  2.0710,  2.2725,  2.4879,  2.7057,  2.9160,
+     0.0880,  0.2514,  0.5332,  0.7272,  0.8906,  1.1354,  1.3199,  1.4941,
+     1.6010,  1.7151,  1.8712,  2.0643,  2.2755,  2.5375,  2.7054,  2.8891,
+     0.1382,  0.2833,  0.4658,  0.6897,  0.9071,  1.0716,  1.2469,  1.4143,
+     1.5910,  1.7947,  1.9805,  2.1581,  2.3338,  2.5215,  2.7292,  2.9211,
+     0.1061,  0.3494,  0.6327,  0.8570,  0.9748,  1.0560,  1.1529,  1.3250,
+     1.6032,  1.8340,  1.9711,  2.1157,  2.3011,  2.5464,  2.8078,  2.9803,
+     0.1603,  0.2839,  0.4307,  0.5980,  0.7980,  1.0399,  1.1971,  1.3524,
+     1.5715,  1.7838,  1.9468,  2.1498,  2.3627,  2.5514,  2.7327,  2.9148,
+     0.1691,  0.3117,  0.4796,  0.6895,  0.8732,  1.0164,  1.1916,  1.3707,
+     1.5384,  1.7202,  1.8857,  2.0672,  2.2487,  2.4593,  2.6789,  2.8940,
+     0.0965,  0.1702,  0.3191,  0.5721,  0.8100,  1.0241,  1.2272,  1.4196,
+     1.6093,  1.8057,  1.9884,  2.2037,  2.3925,  2.5805,  2.7578,  2.9366,
+     0.1950,  0.3519,  0.5272,  0.6973,  0.8732,  1.0656,  1.2112,  1.3959,
+     1.6116,  1.7821,  1.9445,  2.1592,  2.3348,  2.5142,  2.7440,  2.9297,
+     0.1388,  0.2557,  0.4120,  0.5727,  0.7354,  0.9196,  1.0985,  1.2805,
+     1.4643,  1.6535,  1.8340,  2.0546,  2.2758,  2.4778,  2.6921,  2.9122,
+     0.1823,  0.3336,  0.4957,  0.6771,  0.8563,  1.0137,  1.2299,  1.3849,
+     1.5718,  1.7667,  1.9193,  2.1326,  2.3135,  2.5268,  2.7133,  2.8998,
+     0.0790,  0.1901,  0.4083,  0.6456,  0.8463,  1.0285,  1.2297,  1.4181,
+     1.6159,  1.8056,  1.9971,  2.1912,  2.3816,  2.5746,  2.7692,  2.9497,
+     0.0049,  0.0116,  0.0045,  0.0039, -0.0010, -0.0122, -0.0205, -0.0034,
+    -0.0140, -0.0041,  0.0191, -0.0322,  0.0002, -0.0124, -0.0269,  0.0059,
+     0.0586,  0.0339, -0.0389, -0.0319, -0.0079, -0.0205, -0.0363, -0.0211,
+     0.0241,  0.0595,  0.0469,  0.0283,  0.0176, -0.0183, -0.0173, -0.0004,
+     0.0024,  0.0145,  0.0534,  0.0197, -0.0065, -0.0067,  0.0133,  0.0358,
+    -0.0104, -0.0386, -0.0109, -0.0078,  0.0275,  0.0565,  0.0251, -0.0027,
+    -0.0053,  0.0171,  0.0088,  0.0495,  0.0141,  0.0039, -0.0445, -0.0426,
+    -0.0184, -0.0280, -0.0223,  0.0039, -0.0171, -0.0606, -0.0786, -0.0430,
+     0.0544,  0.0595,  0.0320, -0.0012,  0.0108,  0.0185,  0.0066,  0.0408,
+     0.0552, -0.0073, -0.0247, -0.0480, -0.0288,  0.0186,  0.0212, -0.0013,
+     0.0403,  0.0598,  0.0690,  0.0516, -0.0298, -0.0177,  0.0278,  0.0168,
+    -0.0106,  0.0251,  0.0386,  0.0331, -0.0052,  0.0133,  0.0291, -0.0158,
+    -0.0329, -0.0367,  0.0287,  0.0462, -0.0176,  0.0049,  0.0242, -0.0034,
+     0.0135,  0.0086, -0.0149,  0.0241,  0.0504,  0.0246, -0.0273, -0.0369,
+    -0.0108, -0.0449, -0.0625, -0.0414, -0.0292, -0.0571, -0.0440, -0.0088,
+     0.0098,  0.0009, -0.0004,  0.0007, -0.0314, -0.0208, -0.0138, -0.0277,
+    -0.0044,  0.0522,  0.0315, -0.0270, -0.0277, -0.0256, -0.0103, -0.0201,
+    -0.0287, -0.0279, -0.0182,  0.0472,  0.0613,  0.0450,  0.0413,  0.0333,
+     0.0444,  0.0223,  0.0061,  0.0316,  0.0321,  0.0501,  0.0460,  0.0250,
+     0.0227,  0.0235,  0.0099,  0.0185, -0.0347, -0.0684, -0.0189,  0.0242,
+    -0.0190, -0.0273, -0.0012, -0.0253,  0.0293, -0.0231, -0.0219, -0.0010,
+     0.0153,  0.0128, -0.0166, -0.0435, -0.0417, -0.0121, -0.0351, -0.0390,
+     0.0077, -0.0278, -0.0355,  0.0092, -0.0063,  0.0005,  0.0216,  0.0461,
+     0.0538,  0.0451,  0.0298, -0.0130,  0.0058,  0.0206,  0.0471,  0.0499,
+     0.0280,  0.0086, -0.0007, -0.0317,  0.0259,  0.0176,  0.0043,  0.0212,
+     0.0138,  0.0106,  0.0220, -0.0025,  0.0050,  0.0122, -0.0051, -0.0086,
+    -0.0472, -0.0005,  0.0193,  0.0032,  0.0246,  0.0222,  0.0090, -0.0320,
+    -0.0713, -0.0526, -0.0151, -0.0440, -0.0648, -0.0466, -0.0092,  0.0115,
+    -0.0129,  0.0053, -0.0344, -0.0385,  0.0392,  0.0599,  0.0414,  0.0165,
+    -0.0098, -0.0320, -0.0261, -0.0055, -0.0139, -0.0110,  0.0084,  0.0172,
+    -0.0492, -0.0537, -0.0320, -0.0036,  0.0265,  0.0385,  0.0064, -0.0280,
+    -0.0230,  0.0134,  0.0241,  0.0106,  0.0387,  0.0105,  0.0068,  0.0260,
+     0.4940,  0.4911,  0.4849,  0.4820,  0.4837,  0.4839,  0.4824,  0.4799,
+     0.4812,  0.4782,  0.4788,  0.4711,  0.4706,  0.4671,  0.4601,  0.4578,
+     0.2954,  0.2121,  0.1859,  0.1958,  0.1474,  0.1086,  0.1351,  0.1362,
+     0.1486,  0.1342,  0.1215,  0.1423,  0.1634,  0.1588,  0.1539,  0.1857,
+};
+
+static const float lsp16[] = {
      0.1813,  0.3911,  0.6301,  0.8012,  1.0057,  1.2041,  1.4271,  1.6943,
      1.9402,  2.1733,  2.3521,  2.4989,  2.5839,  2.6846,  2.7634,  2.8950,
      0.1311,  0.3183,  0.4659,  0.5601,  0.6658,  0.7828,  1.0065,  1.2717,
@@ -12517,7 +12747,7 @@
     -0.0429, -0.0615, -0.0893, -0.0618, -0.0384, -0.0134, -0.0232, -0.0238,
 };
 
-const float ff_metasound_lsp22[] = {
+static const float lsp22[] = {
      0.0664,  0.1875,  0.4300,  0.6730,  0.8793,  1.0640,  1.2563,  1.4433,
      1.6394,  1.8176,  2.0029,  2.1921,  2.3796,  2.5671,  2.7595,  2.9536,
      0.2128,  0.4052,  0.5311,  0.6404,  0.7875,  0.8775,  1.0974,  1.3261,
@@ -12684,7 +12914,174 @@
      0.4239,  0.4331,  0.4522,  0.4423,  0.4475,  0.4387,  0.4525,  0.4446,
 };
 
-const float ff_metasound_lsp44[] = {
+static const float lsp22s[] = {
+     0.0664,  0.1875,  0.4300,  0.6730,  0.8793,  1.0640,  1.2563,  1.4433,
+     1.6394,  1.8176,  2.0029,  2.1921,  2.3796,  2.5671,  2.7595,  2.9536,
+     0.2128,  0.4052,  0.5311,  0.6404,  0.7875,  0.8775,  1.0974,  1.3261,
+     1.5563,  1.6790,  1.8339,  2.1195,  2.3226,  2.4609,  2.6440,  2.8947,
+     0.2024,  0.3362,  0.4834,  0.6784,  0.9088,  1.0850,  1.2188,  1.4054,
+     1.6102,  1.7767,  1.9679,  2.1436,  2.3445,  2.5467,  2.7429,  2.9320,
+     0.1181,  0.2279,  0.4413,  0.6114,  0.7710,  0.9427,  1.1142,  1.2707,
+     1.4892,  1.7416,  1.9526,  2.1466,  2.3629,  2.5445,  2.7293,  2.9205,
+     0.1155,  0.2720,  0.4886,  0.6812,  0.8594,  1.0422,  1.2315,  1.4116,
+     1.6137,  1.8020,  1.9758,  2.1743,  2.3602,  2.5568,  2.7472,  2.9374,
+     0.1110,  0.3312,  0.4735,  0.5612,  0.7129,  0.8146,  1.0233,  1.3155,
+     1.5765,  1.7746,  1.9574,  2.1416,  2.3220,  2.5384,  2.7334,  2.9318,
+     0.1656,  0.3350,  0.4215,  0.5609,  0.6759,  0.8503,  1.1405,  1.4094,
+     1.6057,  1.6860,  1.7639,  2.0031,  2.2680,  2.5076,  2.7263,  2.9368,
+     0.1466,  0.3638,  0.4587,  0.5674,  0.7381,  0.8669,  0.9619,  1.1658,
+     1.4667,  1.7440,  1.9335,  2.1018,  2.3022,  2.5281,  2.7359,  2.9261,
+     0.1061,  0.2566,  0.4739,  0.6751,  0.8711,  1.0704,  1.2720,  1.4655,
+     1.6605,  1.8494,  2.0290,  2.2197,  2.4008,  2.5912,  2.7772,  2.9513,
+     0.1116,  0.2364,  0.3971,  0.6316,  0.8583,  1.0335,  1.1686,  1.3302,
+     1.5612,  1.7877,  1.9829,  2.2052,  2.3596,  2.5460,  2.7341,  2.9290,
+     0.2661,  0.4186,  0.5126,  0.6477,  0.8818,  1.1045,  1.2852,  1.4128,
+     1.5851,  1.7593,  1.9399,  2.1757,  2.3684,  2.5136,  2.6927,  2.9064,
+     0.1495,  0.2749,  0.4391,  0.6304,  0.8239,  1.0181,  1.1995,  1.3759,
+     1.5669,  1.7722,  1.9671,  2.1635,  2.3586,  2.5528,  2.7445,  2.9311,
+     0.0912,  0.1759,  0.3066,  0.5660,  0.8005,  0.9568,  1.1832,  1.4504,
+     1.6259,  1.7948,  2.0113,  2.2002,  2.3654,  2.5583,  2.7929,  2.9735,
+     0.1353,  0.2747,  0.4078,  0.5977,  0.7658,  0.9124,  1.1081,  1.3630,
+     1.5875,  1.7847,  1.9323,  2.1181,  2.3321,  2.5046,  2.7183,  2.9225,
+     0.1938,  0.4063,  0.4982,  0.6002,  0.7702,  0.9071,  1.1631,  1.3885,
+     1.6043,  1.8118,  1.9306,  2.0893,  2.2724,  2.4609,  2.6283,  2.8802,
+     0.1857,  0.3351,  0.4381,  0.6101,  0.7561,  0.8555,  1.0384,  1.3171,
+     1.5667,  1.6904,  1.7552,  1.9689,  2.2597,  2.5260,  2.7272,  2.9337,
+     0.1037,  0.2159,  0.4188,  0.6174,  0.8035,  1.0285,  1.2256,  1.4230,
+     1.6400,  1.8322,  2.0144,  2.1988,  2.3810,  2.5682,  2.7613,  2.9438,
+     0.1625,  0.2776,  0.4225,  0.6001,  0.7879,  0.9087,  1.0801,  1.2759,
+     1.4899,  1.7448,  1.9911,  2.1770,  2.3723,  2.5777,  2.7971,  2.9444,
+     0.2111,  0.3640,  0.5839,  0.7290,  0.8051,  1.0023,  1.2315,  1.4143,
+     1.5878,  1.7755,  1.9804,  2.1498,  2.3312,  2.5350,  2.7613,  2.9472,
+     0.1423,  0.2646,  0.4136,  0.6350,  0.8070,  0.9514,  1.1168,  1.3213,
+     1.5776,  1.7721,  1.9404,  2.1545,  2.3385,  2.5137,  2.7396,  2.9553,
+     0.1132,  0.2386,  0.4103,  0.5931,  0.7808,  0.9881,  1.1840,  1.3860,
+     1.6021,  1.7990,  1.9922,  2.1885,  2.3852,  2.5717,  2.7640,  2.9510,
+     0.1267,  0.2602,  0.3913,  0.5944,  0.7598,  0.9198,  1.0781,  1.2715,
+     1.5299,  1.7573,  1.9308,  2.1346,  2.3267,  2.5419,  2.7466,  2.9320,
+     0.2023,  0.3417,  0.4392,  0.6141,  0.7439,  0.8593,  1.1096,  1.3543,
+     1.5185,  1.6553,  1.7862,  2.0341,  2.2718,  2.4834,  2.7103,  2.9466,
+     0.1113,  0.2470,  0.3677,  0.5686,  0.7700,  0.9356,  1.0806,  1.2452,
+     1.4830,  1.7344,  1.9268,  2.1404,  2.3371,  2.5169,  2.7329,  2.9012,
+     0.1664,  0.3554,  0.5573,  0.7471,  0.9245,  1.0998,  1.2787,  1.4655,
+     1.6654,  1.8346,  2.0179,  2.2159,  2.4096,  2.5946,  2.7790,  2.9530,
+     0.1313,  0.2625,  0.4731,  0.6444,  0.8110,  0.9878,  1.1493,  1.3212,
+     1.5719,  1.8138,  1.9861,  2.1943,  2.3714,  2.5578,  2.7346,  2.9296,
+     0.1186,  0.3035,  0.5049,  0.6860,  0.8670,  0.9975,  1.1364,  1.3471,
+     1.5695,  1.7412,  1.9346,  2.1506,  2.3413,  2.5531,  2.7794,  2.9627,
+     0.1108,  0.2697,  0.4787,  0.6344,  0.7909,  0.9586,  1.1440,  1.3511,
+     1.5686,  1.7601,  1.9246,  2.1241,  2.3293,  2.5390,  2.7315,  2.9333,
+     0.0985,  0.2302,  0.3544,  0.5759,  0.7620,  0.9651,  1.1497,  1.3080,
+     1.5500,  1.7845,  1.9518,  2.1734,  2.3565,  2.5665,  2.7605,  2.9102,
+     0.1208,  0.2727,  0.4381,  0.5736,  0.7382,  0.8390,  1.0102,  1.2648,
+     1.5100,  1.7440,  1.9619,  2.1430,  2.3307,  2.5159,  2.7264,  2.9211,
+     0.1582,  0.2777,  0.4475,  0.6551,  0.8591,  1.0084,  1.1414,  1.3291,
+     1.5902,  1.7826,  1.9543,  2.1659,  2.3233,  2.5044,  2.6935,  2.9199,
+     0.1360,  0.2873,  0.4585,  0.6295,  0.7592,  0.9089,  1.0492,  1.2733,
+     1.5391,  1.7768,  1.9372,  2.1329,  2.3168,  2.5015,  2.6857,  2.8837,
+     0.0886,  0.1829,  0.3696,  0.6126,  0.8334,  1.0135,  1.2303,  1.4674,
+     1.6743,  1.8564,  2.0530,  2.2370,  2.3960,  2.5787,  2.7756,  2.9377,
+     0.2005,  0.3537,  0.4700,  0.6249,  0.7385,  0.9097,  1.1759,  1.3811,
+     1.5314,  1.6705,  1.8546,  2.1229,  2.3292,  2.5251,  2.7951,  2.9646,
+     0.1999,  0.3112,  0.4722,  0.7146,  0.8908,  1.0028,  1.1831,  1.3903,
+     1.6125,  1.7514,  1.9083,  2.1248,  2.3271,  2.5339,  2.6945,  2.8918,
+     0.1243,  0.2606,  0.4382,  0.5850,  0.7705,  0.9727,  1.1214,  1.3059,
+     1.5218,  1.7406,  1.9137,  2.1353,  2.3354,  2.5299,  2.7287,  2.9068,
+     0.1039,  0.2426,  0.4265,  0.6284,  0.8152,  0.9941,  1.2004,  1.4038,
+     1.5912,  1.7763,  1.9650,  2.1598,  2.3474,  2.5488,  2.7419,  2.9322,
+     0.1364,  0.2420,  0.3886,  0.5864,  0.7663,  0.8844,  1.0860,  1.3242,
+     1.5518,  1.7893,  2.0004,  2.1562,  2.3619,  2.5516,  2.7687,  2.9181,
+     0.1483,  0.2851,  0.4479,  0.6312,  0.7924,  0.9821,  1.1705,  1.3386,
+     1.5375,  1.7226,  1.9053,  2.0991,  2.2898,  2.4953,  2.7000,  2.9146,
+     0.2332,  0.4561,  0.5407,  0.6212,  0.7524,  0.8215,  0.9522,  1.1685,
+     1.5216,  1.7132,  1.8291,  2.0647,  2.2811,  2.4857,  2.7071,  2.9281,
+     0.1348,  0.3126,  0.5179,  0.7192,  0.9227,  1.1363,  1.3223,  1.4756,
+     1.6509,  1.8191,  1.9991,  2.1976,  2.3877,  2.5768,  2.7590,  2.9386,
+     0.1093,  0.2211,  0.4763,  0.6703,  0.8282,  0.9536,  1.1202,  1.3796,
+     1.6043,  1.8031,  1.9832,  2.1604,  2.3578,  2.5856,  2.7650,  2.9291,
+     0.1865,  0.3027,  0.4580,  0.6719,  0.8400,  1.0082,  1.1901,  1.3782,
+     1.5448,  1.6885,  1.9477,  2.1381,  2.2797,  2.5113,  2.7465,  2.9414,
+     0.1575,  0.3124,  0.4649,  0.6262,  0.8095,  0.9858,  1.1676,  1.3602,
+     1.5646,  1.7582,  1.9550,  2.1671,  2.3628,  2.5734,  2.7670,  2.9519,
+     0.1174,  0.2777,  0.4663,  0.6333,  0.8169,  1.0096,  1.1885,  1.3847,
+     1.5803,  1.7571,  1.9380,  2.1398,  2.3414,  2.5407,  2.7360,  2.9375,
+     0.1073,  0.2264,  0.4083,  0.5973,  0.7474,  0.9514,  1.1349,  1.3337,
+     1.5433,  1.7348,  1.9380,  2.1436,  2.3441,  2.5438,  2.7457,  2.9383,
+     0.1472,  0.2880,  0.4793,  0.6268,  0.8015,  1.0063,  1.1715,  1.3644,
+     1.5525,  1.7410,  1.9258,  2.1227,  2.3214,  2.5149,  2.7148,  2.9196,
+     0.1414,  0.2565,  0.4349,  0.6111,  0.7695,  0.9496,  1.1212,  1.3265,
+     1.5218,  1.7209,  1.9015,  2.0887,  2.3158,  2.5077,  2.7233,  2.9421,
+     0.1252,  0.2667,  0.4454,  0.6431,  0.8371,  1.0124,  1.2110,  1.4160,
+     1.6240,  1.8242,  2.0047,  2.1974,  2.3902,  2.5778,  2.7637,  2.9481,
+     0.1321,  0.2565,  0.3846,  0.5847,  0.7578,  0.9259,  1.0637,  1.2239,
+     1.4690,  1.7346,  1.9750,  2.1882,  2.3712,  2.5509,  2.7280,  2.8885,
+     0.1437,  0.2930,  0.4428,  0.6156,  0.8045,  0.9638,  1.1450,  1.3138,
+     1.5144,  1.7355,  1.9469,  2.1534,  2.3414,  2.5452,  2.7353,  2.9334,
+     0.1692,  0.2770,  0.3831,  0.6100,  0.7825,  0.9302,  1.0690,  1.2481,
+     1.4615,  1.6799,  1.9165,  2.1739,  2.3435,  2.5349,  2.7520,  2.9163,
+     0.1235,  0.2489,  0.4354,  0.6343,  0.8236,  1.0066,  1.1908,  1.3474,
+     1.5656,  1.8275,  2.0620,  2.2548,  2.4135,  2.5913,  2.7639,  2.9334,
+     0.1090,  0.1961,  0.3854,  0.5701,  0.7024,  0.8843,  1.1393,  1.3785,
+     1.5940,  1.7797,  1.9442,  2.1740,  2.3853,  2.5773,  2.7727,  2.9406,
+     0.1560,  0.3477,  0.5011,  0.6287,  0.7612,  0.9896,  1.1510,  1.3420,
+     1.5435,  1.6816,  1.8731,  2.0651,  2.2613,  2.4999,  2.7027,  2.8971,
+     0.1459,  0.2416,  0.3833,  0.5450,  0.7916,  0.9223,  1.0662,  1.1953,
+     1.4029,  1.6616,  1.9320,  2.1459,  2.3386,  2.5081,  2.6799,  2.9195,
+     0.1546,  0.3854,  0.6184,  0.8460,  1.0599,  1.2428,  1.3906,  1.5550,
+     1.7388,  1.8945,  2.0757,  2.2386,  2.4014,  2.5705,  2.7574,  2.9400,
+     0.1080,  0.2307,  0.4112,  0.6067,  0.7725,  0.9467,  1.1285,  1.3205,
+     1.5348,  1.7609,  1.9937,  2.1878,  2.3583,  2.5515,  2.7199,  2.9049,
+     0.1482,  0.3178,  0.4983,  0.6342,  0.7783,  0.9880,  1.2019,  1.3404,
+     1.5223,  1.7296,  1.9211,  2.0943,  2.2928,  2.5008,  2.7136,  2.9224,
+     0.1145,  0.2910,  0.4891,  0.6492,  0.8126,  0.9530,  1.1180,  1.3155,
+     1.5054,  1.6893,  1.8899,  2.1188,  2.3389,  2.5512,  2.7313,  2.9224,
+     0.0939,  0.1689,  0.3250,  0.5792,  0.7698,  0.9245,  1.1574,  1.3865,
+     1.5959,  1.7977,  1.9821,  2.1528,  2.3326,  2.5540,  2.7553,  2.9179,
+     0.1243,  0.2474,  0.3923,  0.6199,  0.7908,  0.9379,  1.1497,  1.3734,
+     1.5582,  1.7420,  1.9539,  2.1385,  2.3240,  2.5277,  2.7311,  2.9178,
+     0.1961,  0.3748,  0.5176,  0.6387,  0.8169,  1.0477,  1.2124,  1.3869,
+     1.5604,  1.7225,  1.8770,  2.0837,  2.2960,  2.5103,  2.6945,  2.8862,
+     0.1295,  0.2403,  0.4149,  0.6189,  0.7913,  0.9130,  1.0832,  1.2787,
+     1.4860,  1.7112,  1.9502,  2.1348,  2.2776,  2.4982,  2.7431,  2.9522,
+     0.0160,  0.0362,  0.0097,  0.0057, -0.0014, -0.0073, -0.0046, -0.0064,
+    -0.0121,  0.0019,  0.0149, -0.0440, -0.0479, -0.0382, -0.0480, -0.0182,
+     0.0170,  0.0114, -0.0298, -0.0175, -0.0033, -0.0354, -0.0510, -0.0025,
+     0.0307,  0.0351,  0.0338,  0.0420,  0.0138, -0.0175, -0.0102,  0.0053,
+     0.0084, -0.0003,  0.0412, -0.0027,  0.0145, -0.0039,  0.0083,  0.0400,
+     0.0001, -0.0262,  0.0055, -0.0082,  0.0348,  0.0433,  0.0137, -0.0024,
+    -0.0055,  0.0262,  0.0521,  0.0349,  0.0185,  0.0076, -0.0319, -0.0561,
+    -0.0460, -0.0253, -0.0097,  0.0163,  0.0184, -0.0037, -0.0480, -0.0371,
+     0.0628,  0.0665,  0.0296, -0.0057,  0.0253,  0.0227,  0.0350,  0.0692,
+     0.0545,  0.0218,  0.0094, -0.0449, -0.0372,  0.0005,  0.0258,  0.0118,
+     0.0285,  0.0760,  0.0822,  0.0527, -0.0299, -0.0049,  0.0170,  0.0195,
+     0.0136,  0.0286,  0.0289,  0.0139,  0.0054,  0.0152,  0.0244,  0.0028,
+    -0.0056, -0.0260,  0.0307,  0.0572, -0.0087,  0.0088,  0.0062,  0.0000,
+     0.0125,  0.0000, -0.0292,  0.0820,  0.0872,  0.0646,  0.0346,  0.0076,
+    -0.0022, -0.0253, -0.0567, -0.0188, -0.0336, -0.0673, -0.0549, -0.0166,
+    -0.0259, -0.0140,  0.0040, -0.0029, -0.0430, -0.0531, -0.0253, -0.0019,
+    -0.0071,  0.0393,  0.0072, -0.0327, -0.0236, -0.0235, -0.0177, -0.0186,
+    -0.0280, -0.0201, -0.0077,  0.0383,  0.0418,  0.0321,  0.0294,  0.0169,
+     0.0468,  0.0301,  0.0133,  0.0363,  0.0516,  0.0937,  0.1240,  0.1404,
+     0.1325,  0.1178,  0.0999,  0.0251, -0.0037, -0.0495, -0.0703, -0.0219,
+    -0.0261, -0.0304, -0.0204, -0.0372,  0.0355,  0.0131, -0.0093, -0.0099,
+    -0.0069, -0.0034, -0.0065, -0.0208, -0.0231, -0.0117, -0.0211, -0.0243,
+     0.0046, -0.0107, -0.0070,  0.0123,  0.0230,  0.0152,  0.0164,  0.0412,
+     0.0619,  0.0858,  0.0862, -0.0056,  0.0125,  0.0182,  0.0347,  0.0388,
+     0.0456,  0.0407, -0.0249, -0.0460,  0.0206,  0.0299,  0.0253,  0.0207,
+     0.0177,  0.0238,  0.0253,  0.0030,  0.0042,  0.0020, -0.0081, -0.0136,
+    -0.0290, -0.0042,  0.0122,  0.0051,  0.0107,  0.0228,  0.0211, -0.0068,
+    -0.0436, -0.0299, -0.0078, -0.0779, -0.1157, -0.0679,  0.0172,  0.0150,
+    -0.0051,  0.0081, -0.0512, -0.0616,  0.0576,  0.0799,  0.0803,  0.0336,
+     0.0001, -0.0298, -0.0747, -0.0115, -0.0101, -0.0170, -0.0050,  0.0174,
+    -0.0290, -0.0601, -0.0150,  0.0121,  0.0165,  0.0230,  0.0028, -0.0317,
+    -0.0165,  0.0356,  0.0451,  0.0120,  0.0321,  0.0084, -0.0058,  0.0122,
+     0.1935,  0.1802,  0.2195,  0.2410,  0.2201,  0.1915,  0.1840,  0.1935,
+     0.2213,  0.2079,  0.1858,  0.1974,  0.2239,  0.2173,  0.1840,  0.2120,
+     0.4912,  0.4777,  0.4607,  0.4395,  0.4426,  0.4388,  0.4416,  0.4345,
+     0.4239,  0.4331,  0.4522,  0.4423,  0.4475,  0.4387,  0.4525,  0.4446,
+};
+
+static const float lsp44s[] = {
      0.0927,  0.2291,  0.4059,  0.5779,  0.7288,  0.8821,  1.0377,  1.1915,
      1.3433,  1.4931,  1.6475,  1.7989,  1.9381,  2.0858,  2.2321,  2.3765,
      2.5187,  2.6530,  2.7895,  2.9354,  0.0944,  0.1974,  0.3046,  0.4714,
@@ -12892,7 +13289,6 @@
      0.1897,  0.1772,  0.1651,  0.1247,  0.1041,  0.1231,  0.1809,  0.2234,
 };
 
-#if CONFIG_METASOUND_DECODER
 static const int16_t shape8[] = {
       2765,   1262,   6624,    867,    688,   1884,   3245,   1248,
      -2160,    593,    182,  -1004,  -1067,    687,   1021,   -920,
@@ -14575,6 +14971,17 @@
      29,  36,  45,  60,  80, 113, 173, 302,
 };
 
+static const uint16_t bark_tab_s22_128[] = {
+      1,   2,   1,   2,   3,   4,   6,  10,
+     23,  76,
+};
+
+static const uint16_t bark_tab_m22_512[] = {
+      3,   2,   3,   3,   3,   4,   3,   5,
+      4,   6,   7,   8,  10,  14,  18,  25,
+     36,  55,  95, 208,
+};
+
 static const uint16_t bark_tab_l22s_1024[] = {
       6,   7,   6,   6,   7,   7,   7,   7,
       7,   8,   9,   8,  10,  10,  11,  12,
@@ -14599,13 +15006,11 @@
     64, 79, 98, 123, 161, 220, 320, 512,
 };
 
-#define bark_tab_m22_512 bark_tab_m44_512 /* Both tables are identical */
 static const uint16_t bark_tab_m44_512[] = {
      3,  2,  3,   3,  3,  4,  3,  5,  4,  6,  7,  8, 10, 14, 18, 25,
     36, 55, 95, 208,
 };
 
-#define bark_tab_s22_128 bark_tab_s44_128 /* Both tables are identical */
 static const uint16_t bark_tab_s44_128[] = {
     1, 2, 1, 2, 3, 4, 6, 10, 23, 76
 };
@@ -14616,7 +15021,7 @@
         {  2, bark_tab_m8_256, 20, fcb8m, 2, 5, cb0806sm0, cb0806sm1, 22 },
         {  1, bark_tab_l8_512, 30, fcb8l, 3, 6, cb0806sl0, cb0806sl1, 24 }
     },
-    512, 12, ff_metasound_lsp8, 1, 5, 3, 3, shape8, 8, 28, 20, 6, 200
+    512, 12, lsp8, 1, 5, 3, 3, shape8, 8, 28, 20, 6, 200
 };
 
 const TwinVQModeTab ff_metasound_mode0806s = {
@@ -14625,7 +15030,7 @@
         {  2, bark_tab_m8s_256, 20, fcb8sm, 2, 5, cb0806sm0, cb0806sm1, 22 },
         {  1, bark_tab_l8s_512, 30, fcb8sl, 3, 6, cb0806sl0, cb0806sl1, 24 }
     },
-    512, 12, ff_metasound_lsp8, 1, 5, 3, 3, shape8s, 8, 28, 20, 6, 200
+    512, 12, lsp8s, 1, 5, 3, 3, shape8s, 8, 28, 20, 6, 200
 };
 
 const TwinVQModeTab ff_metasound_mode0808 = {
@@ -14634,7 +15039,7 @@
         { 2, bark_tab_m8_256, 20, fcb8m, 2, 5, cb0808m0, cb0808m1, 16 },
         { 1, bark_tab_l8_512, 30, fcb8l, 3, 6, cb0808l0, cb0808l1, 17 }
     },
-    512, 12, ff_metasound_lsp8, 1, 5, 3, 3, shape8, 8, 28, 20, 6, 200
+    512, 12, lsp8, 1, 5, 3, 3, shape8, 8, 28, 20, 6, 200
 };
 
 const TwinVQModeTab ff_metasound_mode0808s = {
@@ -14643,7 +15048,7 @@
         {  2, bark_tab_m8s_256, 20, fcb8sm, 2, 5, cb0808sm0, cb0808sm1, 16 },
         {  1, bark_tab_l8s_512, 30, fcb8sl, 3, 6, cb0808sl0, cb0808sl1, 17 }
     },
-    512, 12, ff_metasound_lsp8, 1, 5, 3, 3, shape8s, 8, 28, 20, 6, 200
+    512, 12, lsp8s, 1, 5, 3, 3, shape8s, 8, 28, 20, 6, 200
 };
 
 const TwinVQModeTab ff_metasound_mode1110 = {
@@ -14652,7 +15057,7 @@
         {  2, bark_tab_m11_256, 16, fcb11m, 2, 5, cb1110m0, cb1110m1, 18 },
         {  1, bark_tab_l11_512, 24, fcb11l, 3, 6, cb1110l0, cb1110l1, 19 }
     },
-    512, 16, ff_metasound_lsp11, 1, 6, 4, 3, shape11, 9, 28, 20, 7, 200
+    512, 16, lsp11, 1, 6, 4, 3, shape11, 9, 28, 20, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode1110s = {
@@ -14661,7 +15066,7 @@
         {  2, bark_tab_m11s_256, 20, fcb11sm, 2, 5, cb1110sm0, cb1110sm1, 18 },
         {  1, bark_tab_l11s_512, 30, fcb11sl, 3, 6, cb1110sl0, cb1110sl1, 20 }
     },
-    512, 16, ff_metasound_lsp11, 1, 6, 4, 3, shape11s, 9, 36, 30, 7, 200
+    512, 16, lsp11s, 1, 6, 4, 3, shape11s, 9, 36, 30, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode1616 = {
@@ -14670,7 +15075,7 @@
         { 2, bark_tab_m16_512,  24, fcb16m, 2, 5, cb1616m0, cb1616m1, 15 },
         { 1, bark_tab_l16_1024, 30, fcb16l, 3, 6, cb1616l0, cb1616l1, 16 }
     },
-    1024, 16, ff_metasound_lsp16, 1, 6, 4, 3, shape16, 9, 28, 30, 7, 200
+    1024, 16, lsp16, 1, 6, 4, 3, shape16, 9, 28, 30, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode1616s = {
@@ -14679,7 +15084,7 @@
         { 2, bark_tab_m16s_512,  20, fcb16sm, 2, 5, cb1616sm0, cb1616sm1, 15 },
         { 1, bark_tab_l16s_1024, 30, fcb16sl, 3, 6, cb1616sl0, cb1616sl1, 16 }
     },
-    1024, 16, ff_metasound_lsp16, 1, 6, 4, 3, shape16s, 9, 56, 60, 7, 200
+    1024, 16, lsp16, 1, 6, 4, 3, shape16s, 9, 56, 60, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode2224 = {
@@ -14688,7 +15093,7 @@
         { 2, bark_tab_m22_512,  20, fcb22m, 2, 6, cb2224m0, cb2224m1, 14 },
         { 1, bark_tab_l22_1024, 32, fcb22l, 4, 6, cb2224l0, cb2224l1, 15 }
     },
-    1024, 16, ff_metasound_lsp22, 1, 6, 4, 3, shape22, 9, 56, 36, 7, 200
+    1024, 16, lsp22, 1, 6, 4, 3, shape22, 9, 56, 36, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode2224s = {
@@ -14697,7 +15102,7 @@
         { 2, bark_tab_m22s_512,  20, fcb22sm, 2, 6, cb2224sm0, cb2224sm1, 14 },
         { 1, bark_tab_l22s_1024, 32, fcb22sl, 4, 6, cb2224sl0, cb2224sl1, 15 }
     },
-    1024, 16, ff_metasound_lsp22, 1, 6, 4, 3, shape22s, 9, 56, 36, 7, 200
+    1024, 16, lsp22s, 1, 6, 4, 3, shape22s, 9, 56, 36, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode4432 = {
@@ -14706,7 +15111,16 @@
         {  4, bark_tab_m44_512,  20, fcb44sm, 2, 6, cb4432m0, cb4432m1, 21 },
         {  1, bark_tab_l44_2048, 40, fcb44sl, 4, 6, cb4432l0, cb4432l1, 22 }
     },
-    2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200,
+    2048, 20, lsp44s, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200,
+};
+
+const TwinVQModeTab ff_metasound_mode4432s = {
+    {
+        { 16, bark_tab_s44_128,  10, fcb44ss, 1, 6, cb4432s0, cb4432s1, 23 },
+        {  4, bark_tab_m44_512,  20, fcb44sm, 2, 6, cb4432m0, cb4432m1, 21 },
+        {  1, bark_tab_l44_2048, 40, fcb44sl, 4, 6, cb4432l0, cb4432l1, 22 }
+    },
+    2048, 20, lsp44s, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200,
 };
 
 const TwinVQModeTab ff_metasound_mode4440 = {
@@ -14715,7 +15129,16 @@
         {  4, bark_tab_m44_512,  20, fcb44sm, 2, 6, cb4440sm0, cb4440sm1, 17 },
         {  1, bark_tab_l44_2048, 40, fcb44sl, 4, 6, cb4440sl0, cb4440sl1, 17 }
     },
-    2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200
+    2048, 20, lsp44s, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200
+};
+
+const TwinVQModeTab ff_metasound_mode4440s = {
+    {
+        { 16, bark_tab_s44_128,  10, fcb44ss, 1, 6, cb4440ss0, cb4440ss1, 18 },
+        {  4, bark_tab_m44_512,  20, fcb44sm, 2, 6, cb4440sm0, cb4440sm1, 17 },
+        {  1, bark_tab_l44_2048, 40, fcb44sl, 4, 6, cb4440sl0, cb4440sl1, 17 }
+    },
+    2048, 20, lsp44s, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200
 };
 
 const TwinVQModeTab ff_metasound_mode4448 = {
@@ -14724,6 +15147,14 @@
         {  4, bark_tab_m44_512,  20, fcb44sm, 2, 6, cb4448sm0, cb4448sm1, 14 },
         {  1, bark_tab_l44_2048, 40, fcb44sl, 4, 6, cb4448sl0, cb4448sl1, 14 }
     },
-    2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200
+    2048, 20, lsp44s, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200
 };
-#endif /* CONFIG_METASOUND_DECODER */
+
+const TwinVQModeTab ff_metasound_mode4448s = {
+    {
+        { 16, bark_tab_s44_128,  10, fcb44ss, 1, 6, cb4448ss0, cb4448ss1, 15 },
+        {  4, bark_tab_m44_512,  20, fcb44sm, 2, 6, cb4448sm0, cb4448sm1, 14 },
+        {  1, bark_tab_l44_2048, 40, fcb44sl, 4, 6, cb4448sl0, cb4448sl1, 14 }
+    },
+    2048, 20, lsp44s, 1, 6, 4, 4, shape44s, 9, 84, 54, 7, 200
+};
diff --git a/libavcodec/metasound_data.h b/libavcodec/metasound_data.h
index 24c77c3..5c33411 100644
--- a/libavcodec/metasound_data.h
+++ b/libavcodec/metasound_data.h
@@ -27,12 +27,6 @@
 
 #include "twinvq.h"
 
-extern const float ff_metasound_lsp8[];
-extern const float ff_metasound_lsp11[];
-extern const float ff_metasound_lsp16[];
-extern const float ff_metasound_lsp22[];
-extern const float ff_metasound_lsp44[];
-
 extern const TwinVQModeTab ff_metasound_mode0806;
 extern const TwinVQModeTab ff_metasound_mode0806s;
 extern const TwinVQModeTab ff_metasound_mode0808;
@@ -46,7 +40,10 @@
 extern const TwinVQModeTab ff_metasound_mode2232;
 extern const TwinVQModeTab ff_metasound_mode2232s;
 extern const TwinVQModeTab ff_metasound_mode4432;
+extern const TwinVQModeTab ff_metasound_mode4432s;
 extern const TwinVQModeTab ff_metasound_mode4440;
+extern const TwinVQModeTab ff_metasound_mode4440s;
 extern const TwinVQModeTab ff_metasound_mode4448;
+extern const TwinVQModeTab ff_metasound_mode4448s;
 
 #endif /* AVCODEC_METASOUND_DATA_H */
diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index 407faa0..ea6a7ef 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/mips/aacsbr_mips.c b/libavcodec/mips/aacsbr_mips.c
index 33fd9b2..5ef5e68 100644
--- a/libavcodec/mips/aacsbr_mips.c
+++ b/libavcodec/mips/aacsbr_mips.c
@@ -53,7 +53,6 @@
 
 #include "libavcodec/aac.h"
 #include "libavcodec/aacsbr.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/mips/asmdefs.h"
 
 #define ENVELOPE_ADJUSTMENT_OFFSET 2
diff --git a/libavcodec/mips/constants.c b/libavcodec/mips/constants.c
index 8c990b6..a7c4a5c 100644
--- a/libavcodec/mips/constants.c
+++ b/libavcodec/mips/constants.c
@@ -20,7 +20,7 @@
  */
 
 #include "config.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "constants.h"
 
 DECLARE_ALIGNED(8, const uint64_t, ff_pw_1) =       {0x0001000100010001ULL};
diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c
index d4fcef0..173e191 100644
--- a/libavcodec/mips/h264dsp_mmi.c
+++ b/libavcodec/mips/h264dsp_mmi.c
@@ -26,7 +26,6 @@
 #include "libavcodec/bit_depth_template.c"
 #include "h264dsp_mips.h"
 #include "libavutil/mips/mmiutils.h"
-#include "libavutil/mem_internal.h"
 
 void ff_h264_add_pixels4_8_mmi(uint8_t *dst, int16_t *src, int stride)
 {
diff --git a/libavcodec/mips/simple_idct_mmi.c b/libavcodec/mips/simple_idct_mmi.c
index e4b58dc..73d797f 100644
--- a/libavcodec/mips/simple_idct_mmi.c
+++ b/libavcodec/mips/simple_idct_mmi.c
@@ -26,7 +26,6 @@
 #include "constants.h"
 #include "libavutil/mips/asmdefs.h"
 #include "libavutil/mips/mmiutils.h"
-#include "libavutil/mem_internal.h"
 
 #define W1  22725  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
 #define W2  21407  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
diff --git a/libavcodec/mips/vc1dsp_mmi.c b/libavcodec/mips/vc1dsp_mmi.c
index 8355cd1..9837868 100644
--- a/libavcodec/mips/vc1dsp_mmi.c
+++ b/libavcodec/mips/vc1dsp_mmi.c
@@ -21,13 +21,10 @@
  */
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/vc1dsp.h"
 #include "constants.h"
 #include "vc1dsp_mips.h"
 #include "hpeldsp_mips.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/mips/mmiutils.h"
 
 #define VC1_INV_TRANCS_8_TYPE1(o1, o2, r1, r2, r3, r4, c0)                  \
diff --git a/libavcodec/mips/vp8dsp_mmi.c b/libavcodec/mips/vp8dsp_mmi.c
index aa6e856..bd80aa1 100644
--- a/libavcodec/mips/vp8dsp_mmi.c
+++ b/libavcodec/mips/vp8dsp_mmi.c
@@ -24,7 +24,6 @@
 #include "vp8dsp_mips.h"
 #include "constants.h"
 #include "libavutil/mips/mmiutils.h"
-#include "libavutil/mem_internal.h"
 
 #define DECLARE_DOUBLE_1            double db_1
 #define DECLARE_DOUBLE_2            double db_2
diff --git a/libavcodec/mips/xvid_idct_mmi.c b/libavcodec/mips/xvid_idct_mmi.c
index 034a48d..b822b8a 100644
--- a/libavcodec/mips/xvid_idct_mmi.c
+++ b/libavcodec/mips/xvid_idct_mmi.c
@@ -21,8 +21,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "idctdsp_mips.h"
 #include "xvididct_mips.h"
 
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 20f310f..82098e4 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -51,6 +51,40 @@
 #include "bytestream.h"
 
 
+static void build_huffman_codes(uint8_t *huff_size, const uint8_t *bits_table)
+{
+    for (int i = 1, k = 0; i <= 16; i++) {
+        int nb = bits_table[i];
+        for (int j = 0; j < nb;j++) {
+            huff_size[k] = i;
+            k++;
+        }
+    }
+}
+
+static int build_vlc(VLC *vlc, const uint8_t *bits_table,
+                     const uint8_t *val_table, int nb_codes,
+                     int is_ac, void *logctx)
+{
+    uint8_t huff_size[256];
+    uint16_t huff_sym[256];
+    int i;
+
+    av_assert0(nb_codes <= 256);
+
+    build_huffman_codes(huff_size, bits_table);
+
+    for (i = 0; i < nb_codes; i++) {
+        huff_sym[i] = val_table[i] + 16 * is_ac;
+
+        if (is_ac && !val_table[i])
+            huff_sym[i] = 16 * 256;
+    }
+
+    return ff_init_vlc_from_lengths(vlc, 9, nb_codes, huff_size, 1,
+                                    huff_sym, 2, 2, 0, 0, logctx);
+}
+
 static int init_default_huffman_tables(MJpegDecodeContext *s)
 {
     static const struct {
@@ -76,9 +110,9 @@
     int i, ret;
 
     for (i = 0; i < FF_ARRAY_ELEMS(ht); i++) {
-        ret = ff_mjpeg_build_vlc(&s->vlcs[ht[i].class][ht[i].index],
-                                 ht[i].bits, ht[i].values,
-                                 ht[i].class == 1, s->avctx);
+        ret = build_vlc(&s->vlcs[ht[i].class][ht[i].index],
+                        ht[i].bits, ht[i].values, ht[i].length,
+                        ht[i].class == 1, s->avctx);
         if (ret < 0)
             return ret;
 
@@ -138,7 +172,7 @@
     s->start_code    = -1;
     s->first_picture = 1;
     s->got_picture   = 0;
-    s->orig_height    = avctx->coded_height;
+    s->org_height    = avctx->coded_height;
     avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
     avctx->colorspace = AVCOL_SPC_BT470BG;
     s->hwaccel_pix_fmt = s->hwaccel_sw_pix_fmt = AV_PIX_FMT_NONE;
@@ -273,14 +307,14 @@
         ff_free_vlc(&s->vlcs[class][index]);
         av_log(s->avctx, AV_LOG_DEBUG, "class=%d index=%d nb_codes=%d\n",
                class, index, n);
-        if ((ret = ff_mjpeg_build_vlc(&s->vlcs[class][index], bits_table,
-                                      val_table, class > 0, s->avctx)) < 0)
+        if ((ret = build_vlc(&s->vlcs[class][index], bits_table, val_table,
+                             n, class > 0, s->avctx)) < 0)
             return ret;
 
         if (class > 0) {
             ff_free_vlc(&s->vlcs[2][index]);
-            if ((ret = ff_mjpeg_build_vlc(&s->vlcs[2][index], bits_table,
-                                          val_table, 0, s->avctx)) < 0)
+            if ((ret = build_vlc(&s->vlcs[2][index], bits_table, val_table,
+                                 n, 0, s->avctx)) < 0)
                 return ret;
         }
 
@@ -432,8 +466,8 @@
         /* test interlaced mode */
         if (s->first_picture   &&
             (s->multiscope != 2 || s->avctx->time_base.den >= 25 * s->avctx->time_base.num) &&
-            s->orig_height != 0 &&
-            s->height < ((s->orig_height * 3) / 4)) {
+            s->org_height != 0 &&
+            s->height < ((s->org_height * 3) / 4)) {
             s->interlaced                    = 1;
             s->bottom_field                  = s->interlace_polarity;
             s->picture_ptr->interlaced_frame = 1;
@@ -445,11 +479,6 @@
         if (ret < 0)
             return ret;
 
-        if ((s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') ||
-             s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) &&
-            s->orig_height < height)
-            s->avctx->height = AV_CEIL_RSHIFT(s->orig_height, s->avctx->lowres);
-
         s->first_picture = 0;
     } else {
         size_change = 0;
@@ -2576,13 +2605,21 @@
             s->got_picture = 0;
 
             frame->pkt_dts = s->pkt->dts;
+            frame->best_effort_timestamp = s->pkt->pts;
 
-            if (!s->lossless && avctx->debug & FF_DEBUG_QP) {
+            if (!s->lossless) {
                 int qp = FFMAX3(s->qscale[0],
                                 s->qscale[1],
                                 s->qscale[2]);
+                int qpw = (s->width + 15) / 16;
+                AVBufferRef *qp_table_buf = av_buffer_alloc(qpw);
+                if (qp_table_buf) {
+                    memset(qp_table_buf->data, qp, qpw);
+                    av_frame_set_qp_table(frame, qp_table_buf, 0, FF_QSCALE_TYPE_MPEG1);
+                }
 
-                av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", qp);
+                if(avctx->debug & FF_DEBUG_QP)
+                    av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", qp);
             }
 
             goto the_end;
@@ -2860,12 +2897,6 @@
             return ret;
         }
     }
-    if ((avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') ||
-         avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) &&
-        avctx->coded_height > s->orig_height) {
-        frame->height   = AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres);
-        frame->crop_top = frame->height - avctx->height;
-    }
 
     ret = 0;
 
@@ -2960,7 +2991,7 @@
     .profiles       = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles),
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
                       FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS,
-    .hw_configs     = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs     = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_MJPEG_NVDEC_HWACCEL
                         HWACCEL_NVDEC(mjpeg),
 #endif
@@ -3002,6 +3033,6 @@
     .flush          = decode_flush,
     .capabilities   = AV_CODEC_CAP_DR1,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING |
-                      FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP,
+                      FF_CODEC_CAP_SETS_PKT_DTS,
 };
 #endif
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h
index 732aeab..d9844ad 100644
--- a/libavcodec/mjpegdec.h
+++ b/libavcodec/mjpegdec.h
@@ -30,7 +30,6 @@
 #define AVCODEC_MJPEGDEC_H
 
 #include "libavutil/log.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/stereo3d.h"
 
@@ -60,7 +59,7 @@
     VLC vlcs[3][4];
     int qscale[4];      ///< quantizer scale calculated from quant_matrixes
 
-    int orig_height;  /* size given at codec init */
+    int org_height;  /* size given at codec init */
     int first_picture;    /* true if decoding first picture */
     int interlaced;     /* true if interlaced */
     int bottom_field;   /* true if bottom field */
@@ -161,8 +160,6 @@
     void *hwaccel_picture_private;
 } MJpegDecodeContext;
 
-int ff_mjpeg_build_vlc(VLC *vlc, const uint8_t *bits_table,
-                       const uint8_t *val_table, int is_ac, void *logctx);
 int ff_mjpeg_decode_init(AVCodecContext *avctx);
 int ff_mjpeg_decode_end(AVCodecContext *avctx);
 int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame);
diff --git a/libavcodec/mjpegdec_common.c b/libavcodec/mjpegdec_common.c
deleted file mode 100644
index 701ddfe..0000000
--- a/libavcodec/mjpegdec_common.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * MJPEG decoder VLC code
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 Michael Niedermayer
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-#include "libavutil/avassert.h"
-#include "mjpegdec.h"
-#include "vlc.h"
-
-static int build_huffman_codes(uint8_t *huff_size, const uint8_t *bits_table)
-{
-    int nb_codes = 0;
-    for (int i = 1, j = 0; i <= 16; i++) {
-        nb_codes += bits_table[i];
-        av_assert1(nb_codes <= 256);
-        for (; j < nb_codes; j++)
-            huff_size[j] = i;
-    }
-    return nb_codes;
-}
-
-int ff_mjpeg_build_vlc(VLC *vlc, const uint8_t *bits_table,
-                       const uint8_t *val_table, int is_ac, void *logctx)
-{
-    uint8_t huff_size[256];
-    uint16_t huff_sym[256];
-    int nb_codes = build_huffman_codes(huff_size, bits_table);
-
-    for (int i = 0; i < nb_codes; i++) {
-        huff_sym[i] = val_table[i] + 16 * is_ac;
-
-        if (is_ac && !val_table[i])
-            huff_sym[i] = 16 * 256;
-    }
-
-    return ff_init_vlc_from_lengths(vlc, 9, nb_codes, huff_size, 1,
-                                    huff_sym, 2, 2, 0, 0, logctx);
-}
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 22af094..56ccbc5 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -35,198 +35,11 @@
 #include "avcodec.h"
 #include "jpegtables.h"
 #include "mjpegenc_common.h"
-#include "mjpegenc_huffman.h"
 #include "mpegvideo.h"
 #include "mjpeg.h"
 #include "mjpegenc.h"
 #include "profiles.h"
 
-static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256],
-                                    uint8_t *uni_ac_vlc_len)
-{
-    for (int i = 0; i < 128; i++) {
-        int level = i - 64;
-        if (!level)
-            continue;
-        for (int run = 0; run < 64; run++) {
-            int len, code, nbits;
-            int alevel = FFABS(level);
-
-            len = (run >> 4) * huff_size_ac[0xf0];
-
-            nbits= av_log2_16bit(alevel) + 1;
-            code = ((15&run) << 4) | nbits;
-
-            len += huff_size_ac[code] + nbits;
-
-            uni_ac_vlc_len[UNI_AC_ENC_INDEX(run, i)] = len;
-            // We ignore EOB as its just a constant which does not change generally
-        }
-    }
-}
-
-/**
- * Encodes and outputs the entire frame in the JPEG format.
- *
- * @param s The MpegEncContext.
- */
-static void mjpeg_encode_picture_frame(MpegEncContext *s)
-{
-    int nbits, code, table_id;
-    MJpegContext *m = s->mjpeg_ctx;
-    uint8_t  *huff_size[4] = { m->huff_size_dc_luminance,
-                               m->huff_size_dc_chrominance,
-                               m->huff_size_ac_luminance,
-                               m->huff_size_ac_chrominance };
-    uint16_t *huff_code[4] = { m->huff_code_dc_luminance,
-                               m->huff_code_dc_chrominance,
-                               m->huff_code_ac_luminance,
-                               m->huff_code_ac_chrominance };
-    size_t total_bits = 0;
-    size_t bytes_needed;
-
-    s->header_bits = get_bits_diff(s);
-    // Estimate the total size first
-    for (int i = 0; i < m->huff_ncode; i++) {
-        table_id = m->huff_buffer[i].table_id;
-        code = m->huff_buffer[i].code;
-        nbits = code & 0xf;
-
-        total_bits += huff_size[table_id][code] + nbits;
-    }
-
-    bytes_needed = (total_bits + 7) / 8;
-    ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
-
-    for (int i = 0; i < m->huff_ncode; i++) {
-        table_id = m->huff_buffer[i].table_id;
-        code = m->huff_buffer[i].code;
-        nbits = code & 0xf;
-
-        put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
-        if (nbits != 0) {
-            put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
-        }
-    }
-
-    m->huff_ncode = 0;
-    s->i_tex_bits = get_bits_diff(s);
-}
-
-/**
- * Builds all 4 optimal Huffman tables.
- *
- * Uses the data stored in the JPEG buffer to compute the tables.
- * Stores the Huffman tables in the bits_* and val_* arrays in the MJpegContext.
- *
- * @param m MJpegContext containing the JPEG buffer.
- */
-static void mjpeg_build_optimal_huffman(MJpegContext *m)
-{
-    MJpegEncHuffmanContext dc_luminance_ctx;
-    MJpegEncHuffmanContext dc_chrominance_ctx;
-    MJpegEncHuffmanContext ac_luminance_ctx;
-    MJpegEncHuffmanContext ac_chrominance_ctx;
-    MJpegEncHuffmanContext *ctx[4] = { &dc_luminance_ctx,
-                                       &dc_chrominance_ctx,
-                                       &ac_luminance_ctx,
-                                       &ac_chrominance_ctx };
-    for (int i = 0; i < 4; i++)
-        ff_mjpeg_encode_huffman_init(ctx[i]);
-
-    for (int i = 0; i < m->huff_ncode; i++) {
-        int table_id = m->huff_buffer[i].table_id;
-        int code     = m->huff_buffer[i].code;
-
-        ff_mjpeg_encode_huffman_increment(ctx[table_id], code);
-    }
-
-    ff_mjpeg_encode_huffman_close(&dc_luminance_ctx,
-                                  m->bits_dc_luminance,
-                                  m->val_dc_luminance, 12);
-    ff_mjpeg_encode_huffman_close(&dc_chrominance_ctx,
-                                  m->bits_dc_chrominance,
-                                  m->val_dc_chrominance, 12);
-    ff_mjpeg_encode_huffman_close(&ac_luminance_ctx,
-                                  m->bits_ac_luminance,
-                                  m->val_ac_luminance, 256);
-    ff_mjpeg_encode_huffman_close(&ac_chrominance_ctx,
-                                  m->bits_ac_chrominance,
-                                  m->val_ac_chrominance, 256);
-
-    ff_mjpeg_build_huffman_codes(m->huff_size_dc_luminance,
-                                 m->huff_code_dc_luminance,
-                                 m->bits_dc_luminance,
-                                 m->val_dc_luminance);
-    ff_mjpeg_build_huffman_codes(m->huff_size_dc_chrominance,
-                                 m->huff_code_dc_chrominance,
-                                 m->bits_dc_chrominance,
-                                 m->val_dc_chrominance);
-    ff_mjpeg_build_huffman_codes(m->huff_size_ac_luminance,
-                                 m->huff_code_ac_luminance,
-                                 m->bits_ac_luminance,
-                                 m->val_ac_luminance);
-    ff_mjpeg_build_huffman_codes(m->huff_size_ac_chrominance,
-                                 m->huff_code_ac_chrominance,
-                                 m->bits_ac_chrominance,
-                                 m->val_ac_chrominance);
-}
-
-/**
- * Writes the complete JPEG frame when optimal huffman tables are enabled,
- * otherwise writes the stuffing.
- *
- * Header + values + stuffing.
- *
- * @param s The MpegEncContext.
- * @return int Error code, 0 if successful.
- */
-int ff_mjpeg_encode_stuffing(MpegEncContext *s)
-{
-    PutBitContext *pbc = &s->pb;
-    int mb_y = s->mb_y - !s->mb_x;
-    int ret;
-    MJpegContext *m;
-
-    m = s->mjpeg_ctx;
-
-    if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {
-        mjpeg_build_optimal_huffman(m);
-
-        // Replace the VLCs with the optimal ones.
-        // The default ones may be used for trellis during quantization.
-        init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
-        init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
-        s->intra_ac_vlc_length      =
-        s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
-        s->intra_chroma_ac_vlc_length      =
-        s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len;
-
-        ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
-                                       s->pred, s->intra_matrix, s->chroma_intra_matrix);
-        mjpeg_encode_picture_frame(s);
-    }
-
-    ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,
-                                            put_bits_count(&s->pb) / 4 + 1000);
-    if (ret < 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "Buffer reallocation failed\n");
-        goto fail;
-    }
-
-    ff_mjpeg_escape_FF(pbc, s->esc_pos);
-
-    if ((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height - 1)
-        put_marker(pbc, RST0 + (mb_y&7));
-    s->esc_pos = put_bits_count(pbc) >> 3;
-
-fail:
-    for (int i = 0; i < 3; i++)
-        s->last_dc[i] = 128 << s->intra_dc_precision;
-
-    return ret;
-}
-
 static int alloc_huffman(MpegEncContext *s)
 {
     MJpegContext *m = s->mjpeg_ctx;
@@ -293,8 +106,8 @@
                                  avpriv_mjpeg_bits_ac_chrominance,
                                  avpriv_mjpeg_val_ac_chrominance);
 
-    init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
-    init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
+    ff_init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
+    ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
     s->intra_ac_vlc_length      =
     s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
     s->intra_chroma_ac_vlc_length      =
@@ -602,7 +415,7 @@
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
     .capabilities   = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE
     },
@@ -628,7 +441,7 @@
     .init           = ff_mpv_encode_init,
     .encode2        = amv_encode_picture,
     .close          = ff_mpv_encode_end,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE
     },
diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h
index 2e92511..d7ddc35 100644
--- a/libavcodec/mjpegenc.h
+++ b/libavcodec/mjpegenc.h
@@ -107,6 +107,5 @@
 int  ff_mjpeg_encode_init(MpegEncContext *s);
 void ff_mjpeg_encode_close(MpegEncContext *s);
 void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
-int  ff_mjpeg_encode_stuffing(MpegEncContext *s);
 
 #endif /* AVCODEC_MJPEGENC_H */
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 12dd7be..0b82777 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <string.h>
 
+#include "libavutil/common.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 
@@ -32,8 +33,35 @@
 #include "put_bits.h"
 #include "mjpegenc.h"
 #include "mjpegenc_common.h"
+#include "mjpegenc_huffman.h"
 #include "mjpeg.h"
 
+av_cold void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len)
+{
+    int i;
+
+    for (i = 0; i < 128; i++) {
+        int level = i - 64;
+        int run;
+        if (!level)
+            continue;
+        for (run = 0; run < 64; run++) {
+            int len, code, nbits;
+            int alevel = FFABS(level);
+
+            len = (run >> 4) * huff_size_ac[0xf0];
+
+            nbits= av_log2_16bit(alevel) + 1;
+            code = ((15&run) << 4) | nbits;
+
+            len += huff_size_ac[code] + nbits;
+
+            uni_ac_vlc_len[UNI_AC_ENC_INDEX(run, i)] = len;
+            // We ignore EOB as its just a constant which does not change generally
+        }
+    }
+}
+
 /* table_class: 0 = DC coef, 1 = AC coefs */
 static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
                              const uint8_t *bits_table, const uint8_t *value_table)
@@ -331,6 +359,54 @@
     }
 }
 
+/**
+ * Encodes and outputs the entire frame in the JPEG format.
+ *
+ * @param s The MpegEncContext.
+ */
+void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
+{
+    int i, nbits, code, table_id;
+    MJpegContext *m = s->mjpeg_ctx;
+    uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
+                             m->huff_size_dc_chrominance,
+                             m->huff_size_ac_luminance,
+                             m->huff_size_ac_chrominance};
+    uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
+                              m->huff_code_dc_chrominance,
+                              m->huff_code_ac_luminance,
+                              m->huff_code_ac_chrominance};
+    size_t total_bits = 0;
+    size_t bytes_needed;
+
+    s->header_bits = get_bits_diff(s);
+    // Estimate the total size first
+    for (i = 0; i < m->huff_ncode; i++) {
+        table_id = m->huff_buffer[i].table_id;
+        code = m->huff_buffer[i].code;
+        nbits = code & 0xf;
+
+        total_bits += huff_size[table_id][code] + nbits;
+    }
+
+    bytes_needed = (total_bits + 7) / 8;
+    ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
+
+    for (i = 0; i < m->huff_ncode; i++) {
+        table_id = m->huff_buffer[i].table_id;
+        code = m->huff_buffer[i].code;
+        nbits = code & 0xf;
+
+        put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
+        if (nbits != 0) {
+            put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
+        }
+    }
+
+    m->huff_ncode = 0;
+    s->i_tex_bits = get_bits_diff(s);
+}
+
 void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
 {
     int size;
@@ -390,25 +466,122 @@
     }
 }
 
-/* isn't this function nicer than the one in the libjpeg ? */
-void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
-                                  const uint8_t *bits_table,
-                                  const uint8_t *val_table)
+/**
+ * Builds all 4 optimal Huffman tables.
+ *
+ * Uses the data stored in the JPEG buffer to compute the tables.
+ * Stores the Huffman tables in the bits_* and val_* arrays in the MJpegContext.
+ *
+ * @param m MJpegContext containing the JPEG buffer.
+ */
+static void ff_mjpeg_build_optimal_huffman(MJpegContext *m)
 {
-    int k, code;
+    int i, table_id, code;
 
-    k = 0;
-    code = 0;
-    for (int i = 1; i <= 16; i++) {
-        int nb = bits_table[i];
-        for (int j = 0; j < nb; j++) {
-            int sym = val_table[k++];
-            huff_size[sym] = i;
-            huff_code[sym] = code;
-            code++;
-        }
-        code <<= 1;
+    MJpegEncHuffmanContext dc_luminance_ctx;
+    MJpegEncHuffmanContext dc_chrominance_ctx;
+    MJpegEncHuffmanContext ac_luminance_ctx;
+    MJpegEncHuffmanContext ac_chrominance_ctx;
+    MJpegEncHuffmanContext *ctx[4] = {&dc_luminance_ctx,
+                                      &dc_chrominance_ctx,
+                                      &ac_luminance_ctx,
+                                      &ac_chrominance_ctx};
+    for (i = 0; i < 4; i++) {
+        ff_mjpeg_encode_huffman_init(ctx[i]);
     }
+    for (i = 0; i < m->huff_ncode; i++) {
+        table_id = m->huff_buffer[i].table_id;
+        code = m->huff_buffer[i].code;
+
+        ff_mjpeg_encode_huffman_increment(ctx[table_id], code);
+    }
+
+    ff_mjpeg_encode_huffman_close(&dc_luminance_ctx,
+                                  m->bits_dc_luminance,
+                                  m->val_dc_luminance, 12);
+    ff_mjpeg_encode_huffman_close(&dc_chrominance_ctx,
+                                  m->bits_dc_chrominance,
+                                  m->val_dc_chrominance, 12);
+    ff_mjpeg_encode_huffman_close(&ac_luminance_ctx,
+                                  m->bits_ac_luminance,
+                                  m->val_ac_luminance, 256);
+    ff_mjpeg_encode_huffman_close(&ac_chrominance_ctx,
+                                  m->bits_ac_chrominance,
+                                  m->val_ac_chrominance, 256);
+
+    ff_mjpeg_build_huffman_codes(m->huff_size_dc_luminance,
+                                 m->huff_code_dc_luminance,
+                                 m->bits_dc_luminance,
+                                 m->val_dc_luminance);
+    ff_mjpeg_build_huffman_codes(m->huff_size_dc_chrominance,
+                                 m->huff_code_dc_chrominance,
+                                 m->bits_dc_chrominance,
+                                 m->val_dc_chrominance);
+    ff_mjpeg_build_huffman_codes(m->huff_size_ac_luminance,
+                                 m->huff_code_ac_luminance,
+                                 m->bits_ac_luminance,
+                                 m->val_ac_luminance);
+    ff_mjpeg_build_huffman_codes(m->huff_size_ac_chrominance,
+                                 m->huff_code_ac_chrominance,
+                                 m->bits_ac_chrominance,
+                                 m->val_ac_chrominance);
+}
+
+/**
+ * Writes the complete JPEG frame when optimal huffman tables are enabled,
+ * otherwise writes the stuffing.
+ *
+ * Header + values + stuffing.
+ *
+ * @param s The MpegEncContext.
+ * @return int Error code, 0 if successful.
+ */
+int ff_mjpeg_encode_stuffing(MpegEncContext *s)
+{
+    int i;
+    PutBitContext *pbc = &s->pb;
+    int mb_y = s->mb_y - !s->mb_x;
+    int ret;
+    MJpegContext *m;
+
+    m = s->mjpeg_ctx;
+
+    if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {
+        ff_mjpeg_build_optimal_huffman(m);
+
+        // Replace the VLCs with the optimal ones.
+        // The default ones may be used for trellis during quantization.
+        ff_init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
+        ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
+        s->intra_ac_vlc_length      =
+        s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
+        s->intra_chroma_ac_vlc_length      =
+        s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len;
+
+        ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
+                                       s->pred, s->intra_matrix, s->chroma_intra_matrix);
+        ff_mjpeg_encode_picture_frame(s);
+    }
+
+    ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,
+                                            put_bits_count(&s->pb) / 4 + 1000);
+
+    if (ret < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "Buffer reallocation failed\n");
+        goto fail;
+    }
+
+    ff_mjpeg_escape_FF(pbc, s->esc_pos);
+
+    if((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height - 1)
+        put_marker(pbc, RST0 + (mb_y&7));
+    s->esc_pos = put_bits_count(pbc) >> 3;
+fail:
+
+    for(i=0; i<3; i++)
+        s->last_dc[i] = 128 << s->intra_dc_precision;
+
+    return ret;
 }
 
 void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index b4f8a08..e8698d1 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -25,20 +25,22 @@
 
 #include "avcodec.h"
 #include "idctdsp.h"
+#include "mpegvideo.h"
 #include "put_bits.h"
 
 void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
                                     ScanTable *intra_scantable, int pred,
                                     uint16_t luma_intra_matrix[64],
                                     uint16_t chroma_intra_matrix[64]);
+void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
 void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
 void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
-void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
-                                  const uint8_t *bits_table,
-                                  const uint8_t *val_table);
+int ff_mjpeg_encode_stuffing(MpegEncContext *s);
 void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4]);
 
 void ff_mjpeg_encode_dc(PutBitContext *pb, int val,
                         uint8_t *huff_size, uint16_t *huff_code);
 
+av_cold void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len);
+
 #endif /* AVCODEC_MJPEGENC_COMMON_H */
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0c30034..3b1608b 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -30,7 +30,6 @@
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "get_bits.h"
 #include "internal.h"
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 9782cb8..f6159d3 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1947,16 +1947,24 @@
  ****************************************************************************/
 
 typedef struct {
-    char    path[MAJOR_HEADER_INTERVAL + 2];
-    int     cur_idx;
+    char    path[MAJOR_HEADER_INTERVAL + 3];
     int     bitcount;
 } PathCounter;
 
+static const char *path_counter_codebook[] = { "0", "1", "2", "3", };
+
+#define ZERO_PATH               '0'
 #define CODEBOOK_CHANGE_BITS    21
 
 static void clear_path_counter(PathCounter *path_counter)
 {
-    memset(path_counter, 0, (NUM_CODEBOOKS + 1) * sizeof(*path_counter));
+    unsigned int i;
+
+    for (i = 0; i < NUM_CODEBOOKS + 1; i++) {
+        path_counter[i].path[0]  = ZERO_PATH;
+        path_counter[i].path[1]  =      0x00;
+        path_counter[i].bitcount =         0;
+    }
 }
 
 static int compare_best_offset(BestOffset *prev, BestOffset *cur)
@@ -1970,11 +1978,18 @@
 static int best_codebook_path_cost(MLPEncodeContext *ctx, unsigned int channel,
                                    PathCounter *src, int cur_codebook)
 {
-    int idx = src->cur_idx;
-    BestOffset *cur_bo = ctx->best_offset[idx][channel],
-              *prev_bo = idx ? ctx->best_offset[idx - 1][channel] : restart_best_offset;
+    BestOffset *cur_bo, *prev_bo = restart_best_offset;
     int bitcount = src->bitcount;
-    int prev_codebook = src->path[idx];
+    char *path = src->path + 1;
+    int prev_codebook;
+    int i;
+
+    for (i = 0; path[i]; i++)
+        prev_bo = ctx->best_offset[i][channel];
+
+    prev_codebook = path[i - 1] - ZERO_PATH;
+
+    cur_bo = ctx->best_offset[i][channel];
 
     bitcount += cur_bo[cur_codebook].bitcount;
 
@@ -2037,8 +2052,7 @@
                         prev_best_bitcount = temp_bitcount;
                         if (src_path != dst_path)
                             memcpy(dst_path, src_path, sizeof(PathCounter));
-                        if (dst_path->cur_idx < FF_ARRAY_ELEMS(dst_path->path) - 1)
-                            dst_path->path[++dst_path->cur_idx] = codebook;
+                        av_strlcat(dst_path->path, path_counter_codebook[codebook], sizeof(dst_path->path));
                         dst_path->bitcount = temp_bitcount;
                     }
                 }
@@ -2055,7 +2069,7 @@
         for (index = 0; index < ctx->number_of_subblocks; index++) {
             ChannelParams *cp = ctx->seq_channel_params + index*(ctx->avctx->channels) + channel;
 
-            best_codebook = *best_path++;
+            best_codebook = *best_path++ - ZERO_PATH;
             cur_bo = &ctx->best_offset[index][channel][best_codebook];
 
             cp->huff_offset      = cur_bo->offset;
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index cb15ac0..172fb61 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -1,6 +1,6 @@
 /*
  * MMAL Video Decoder
- * Copyright (c) 2015 rcombs
+ * Copyright (c) 2015 Rodger Combs
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
index bf47a5b..94368c2 100644
--- a/libavcodec/mobiclip.c
+++ b/libavcodec/mobiclip.c
@@ -1,6 +1,5 @@
 /*
  * MobiClip Video decoder
- * Copyright (c) 2015-2016 Florian Nouwt
  * Copyright (c) 2017 Adib Surani
  * Copyright (c) 2020 Paul B Mahol
  *
@@ -545,7 +544,7 @@
 
 static uint8_t half3(int a, int b, int c)
 {
-    return ((a + b + b + c) * 2 / 4 + 1) / 2;
+    return ((a + b + b + c) * 2 / 4 + 1) / 2;;
 }
 
 static uint8_t pick_above(BlockXY bxy)
@@ -849,7 +848,7 @@
             uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] + FFMAX(ax - 1, 0);
             int bottommost = frame->data[plane][(ay + size - 1) * frame->linesize[plane] + FFMAX(ax - 1, 0)];
             int rightmost = frame->data[plane][FFMAX(ay - 1, 0) * frame->linesize[plane] + ax + size - 1];
-            int avg = (bottommost + rightmost + 1) / 2 + 2 * av_clip(get_se_golomb(gb), -(1<<16), 1<<16);
+            int avg = (bottommost + rightmost + 1) / 2 + 2 * get_se_golomb(gb);
             int r6 = adjust(avg - bottommost, size);
             int r9 = adjust(avg - rightmost, size);
             int shift = adjust(size, size) == 8 ? 3 : 2;
@@ -1092,8 +1091,8 @@
             sidx += 6;
 
         if (index > 0) {
-            mv.x = mv.x + (unsigned)get_se_golomb(gb);
-            mv.y = mv.y + (unsigned)get_se_golomb(gb);
+            mv.x = mv.x + get_se_golomb(gb);
+            mv.y = mv.y + get_se_golomb(gb);
         }
         if (mv.x >= INT_MAX || mv.y >= INT_MAX)
             return AVERROR_INVALIDDATA;
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 5a339fc..02c75fd 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -578,7 +578,7 @@
     int dmin_sum=0, mx4_sum=0, my4_sum=0, i;
     int same=1;
     const int stride= c->stride;
-    const uint8_t *mv_penalty = c->current_mv_penalty;
+    uint8_t *mv_penalty= c->current_mv_penalty;
     int safety_clipping= s->unrestricted_mv && (s->width&15) && (s->height&15);
 
     init_mv4_ref(c);
@@ -743,7 +743,7 @@
     const int h=8;
     int block;
     int P[10][2];
-    const uint8_t * const mv_penalty = c->current_mv_penalty;
+    uint8_t * const mv_penalty= c->current_mv_penalty;
     int same=1;
     const int stride= 2*s->linesize;
     int dmin_sum= 0;
@@ -1120,7 +1120,7 @@
     const int shift= 1+s->quarter_sample;
     const int mot_stride = s->mb_stride;
     const int mot_xy = mb_y*mot_stride + mb_x;
-    const uint8_t * const mv_penalty = c->mv_penalty[f_code] + MAX_DMV;
+    uint8_t * const mv_penalty= c->mv_penalty[f_code] + MAX_DMV;
     int mv_scale;
 
     c->penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
@@ -1184,8 +1184,8 @@
     //FIXME better f_code prediction (max mv & distance)
     //FIXME pointers
     MotionEstContext * const c= &s->me;
-    const uint8_t * const mv_penalty_f = c->mv_penalty[s->f_code] + MAX_DMV; // f_code of the prev frame
-    const uint8_t * const mv_penalty_b = c->mv_penalty[s->b_code] + MAX_DMV; // f_code of the prev frame
+    uint8_t * const mv_penalty_f= c->mv_penalty[s->f_code] + MAX_DMV; // f_code of the prev frame
+    uint8_t * const mv_penalty_b= c->mv_penalty[s->b_code] + MAX_DMV; // f_code of the prev frame
     int stride= c->stride;
     uint8_t *dest_y = c->scratchpad;
     uint8_t *ptr;
@@ -1600,7 +1600,7 @@
     if (s->motion_est != FF_ME_ZERO) {
         int score[8];
         int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
-        const uint8_t * fcode_tab = s->fcode_tab;
+        uint8_t * fcode_tab= s->fcode_tab;
         int best_fcode=-1;
         int best_score=-10000000;
 
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index 5742e51..817220f 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -90,8 +90,8 @@
     op_pixels_func(*hpel_avg)[4];
     qpel_mc_func(*qpel_put)[16];
     qpel_mc_func(*qpel_avg)[16];
-    const uint8_t (*mv_penalty)[MAX_DMV * 2 + 1]; ///< bit amount needed to encode a MV
-    const uint8_t *current_mv_penalty;
+    uint8_t (*mv_penalty)[MAX_DMV * 2 + 1]; ///< bit amount needed to encode a MV
+    uint8_t *current_mv_penalty;
     int (*sub_motion_search)(struct MpegEncContext *s,
                              int *mx_ptr, int *my_ptr, int dmin,
                              int src_index, int ref_index,
diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c
index d3b2f97..13e73f2 100644
--- a/libavcodec/motion_est_template.c
+++ b/libavcodec/motion_est_template.c
@@ -34,7 +34,7 @@
     const int av_unused ymin= c->ymin;\
     const int av_unused xmax= c->xmax;\
     const int av_unused ymax= c->ymax;\
-    const uint8_t *mv_penalty = c->current_mv_penalty; \
+    uint8_t *mv_penalty= c->current_mv_penalty;\
     const int pred_x= c->pred_x;\
     const int pred_y= c->pred_y;\
 
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 7adc16d..ad790bf 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -117,7 +117,7 @@
 typedef struct {
     uint32_t type;
     size_t base_size;
-    int (*decode)(const uint8_t *tsmb, MovTextContext *m, const AVPacket *avpkt);
+    int (*decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt);
 } Box;
 
 static void mov_text_cleanup(MovTextContext *m)
@@ -240,14 +240,14 @@
     return 0;
 }
 
-static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, const AVPacket *avpkt)
+static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
 {
     m->box_flags |= TWRP_BOX;
     m->w.wrap_flag = bytestream_get_byte(&tsmb);
     return 0;
 }
 
-static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, const AVPacket *avpkt)
+static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
 {
     m->box_flags |= HLIT_BOX;
     m->h.hlit_start = bytestream_get_be16(&tsmb);
@@ -255,14 +255,14 @@
     return 0;
 }
 
-static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, const AVPacket *avpkt)
+static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
 {
     m->box_flags |= HCLR_BOX;
     bytestream_get_buffer(&tsmb, m->c.hlit_color, 4);
     return 0;
 }
 
-static int decode_styl(const uint8_t *tsmb, MovTextContext *m, const AVPacket *avpkt)
+static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
 {
     int i;
     int style_entries = bytestream_get_be16(&tsmb);
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index cf30adb..1bef21e 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -355,7 +355,7 @@
         StyleBox *tmp;
 
         // last style != defaults, end the style entry and start a new one
-        if (s->count + 1 > FFMIN(SIZE_MAX / sizeof(*s->style_attributes), UINT16_MAX) ||
+        if (s->count + 1 > SIZE_MAX / sizeof(*s->style_attributes) ||
             !(tmp = av_fast_realloc(s->style_attributes,
                                     &s->style_attributes_bytes_allocated,
                                     (s->count + 1) * sizeof(*s->style_attributes)))) {
diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h
index f809379..704edc9 100644
--- a/libavcodec/mpc.h
+++ b/libavcodec/mpc.h
@@ -30,7 +30,6 @@
 #define AVCODEC_MPC_H
 
 #include "libavutil/lfg.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index af12a6f..720d676 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -28,9 +28,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
 #include "libavutil/lfg.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
-
 #include "avcodec.h"
 #include "get_bits.h"
 #include "internal.h"
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 88dd87c..599dfa9 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -28,7 +28,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
 #include "libavutil/timecode.h"
-#include "libavutil/thread.h"
 
 #include "internal.h"
 #include "avcodec.h"
@@ -40,6 +39,8 @@
 #include "bytestream.h"
 #include "thread.h"
 
+uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
+
 static const uint8_t table_mb_ptype[7][2] = {
     { 3, 5 }, // 0x01 MB_INTRA
     { 1, 2 }, // 0x02 MB_PAT
@@ -131,39 +132,41 @@
 VLC ff_mb_btype_vlc;
 VLC ff_mb_pat_vlc;
 
-static av_cold void mpeg12_init_vlcs(void)
-{
-    INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
-                    ff_mpeg12_vlc_dc_lum_bits, 1, 1,
-                    ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
-    INIT_VLC_STATIC(&ff_dc_chroma_vlc,  DC_VLC_BITS, 12,
-                    ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
-                    ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
-    INIT_VLC_STATIC(&ff_mv_vlc, MV_VLC_BITS, 17,
-                    &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1,
-                    &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 266);
-    INIT_VLC_STATIC(&ff_mbincr_vlc, MBINCR_VLC_BITS, 36,
-                    &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1,
-                    &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 538);
-    INIT_VLC_STATIC(&ff_mb_pat_vlc, MB_PAT_VLC_BITS, 64,
-                    &ff_mpeg12_mbPatTable[0][1], 2, 1,
-                    &ff_mpeg12_mbPatTable[0][0], 2, 1, 512);
-
-    INIT_VLC_STATIC(&ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
-                    &table_mb_ptype[0][1], 2, 1,
-                    &table_mb_ptype[0][0], 2, 1, 64);
-    INIT_VLC_STATIC(&ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
-                    &table_mb_btype[0][1], 2, 1,
-                    &table_mb_btype[0][0], 2, 1, 64);
-
-    INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0);
-    INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0);
-}
-
 av_cold void ff_mpeg12_init_vlcs(void)
 {
-    static AVOnce init_static_once = AV_ONCE_INIT;
-    ff_thread_once(&init_static_once, mpeg12_init_vlcs);
+    static int done = 0;
+
+    if (!done) {
+        done = 1;
+
+        INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
+                        ff_mpeg12_vlc_dc_lum_bits, 1, 1,
+                        ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
+        INIT_VLC_STATIC(&ff_dc_chroma_vlc,  DC_VLC_BITS, 12,
+                        ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
+                        ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
+        INIT_VLC_STATIC(&ff_mv_vlc, MV_VLC_BITS, 17,
+                        &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1,
+                        &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 266);
+        INIT_VLC_STATIC(&ff_mbincr_vlc, MBINCR_VLC_BITS, 36,
+                        &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1,
+                        &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 538);
+        INIT_VLC_STATIC(&ff_mb_pat_vlc, MB_PAT_VLC_BITS, 64,
+                        &ff_mpeg12_mbPatTable[0][1], 2, 1,
+                        &ff_mpeg12_mbPatTable[0][0], 2, 1, 512);
+
+        INIT_VLC_STATIC(&ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
+                        &table_mb_ptype[0][1], 2, 1,
+                        &table_mb_ptype[0][0], 2, 1, 64);
+        INIT_VLC_STATIC(&ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
+                        &table_mb_btype[0][1], 2, 1,
+                        &table_mb_btype[0][0], 2, 1, 64);
+        ff_rl_init(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
+        ff_rl_init(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
+
+        INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0);
+        INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0);
+    }
 }
 
 /**
diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h
index 4cd48b5..9a7c2b6 100644
--- a/libavcodec/mpeg12.h
+++ b/libavcodec/mpeg12.h
@@ -25,6 +25,8 @@
 #include "mpeg12vlc.h"
 #include "mpegvideo.h"
 
+extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
+
 void ff_mpeg12_common_init(MpegEncContext *s);
 
 #define INIT_2D_VLC_RL(rl, static_size, flags)\
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 251d64f..97b05c8 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -30,9 +30,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/stereo3d.h"
-#include "libavutil/video_enc_params.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
@@ -1051,11 +1049,15 @@
     Mpeg1Context *s    = avctx->priv_data;
     MpegEncContext *s2 = &s->mpeg_enc_ctx;
 
+    ff_mpv_decode_defaults(s2);
+
     if (   avctx->codec_tag != AV_RL32("VCR2")
         && avctx->codec_tag != AV_RL32("BW10"))
         avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input
     ff_mpv_decode_init(s2, avctx);
 
+    s->mpeg_enc_ctx.avctx  = avctx;
+
     /* we need some permutation to store matrices,
      * until the decoder sets the real permutation. */
     ff_mpv_idct_init(s2);
@@ -2896,12 +2898,11 @@
     .capabilities          = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
                              AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
                              AV_CODEC_CAP_SLICE_THREADS,
-    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
-                             FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal         = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
     .flush                 = flush,
     .max_lowres            = 3,
     .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_MPEG1_NVDEC_HWACCEL
                                HWACCEL_NVDEC(mpeg1),
 #endif
@@ -2930,12 +2931,11 @@
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
                       AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
                       AV_CODEC_CAP_SLICE_THREADS,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
-                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
     .flush          = flush,
     .max_lowres     = 3,
     .profiles       = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
-    .hw_configs     = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs     = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_MPEG2_DXVA2_HWACCEL
                         HWACCEL_DXVA2(mpeg2),
 #endif
@@ -2975,8 +2975,7 @@
     .close          = mpeg_decode_end,
     .decode         = mpeg_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
-                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
     .flush          = flush,
     .max_lowres     = 3,
 };
@@ -3096,7 +3095,9 @@
 
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
+    ff_mpv_decode_defaults(m);
     ff_mpv_decode_init(m, avctx);
+    s->m.avctx = avctx;
     ff_mpv_idct_init(m);
     ff_mpeg12_common_init(m);
     ff_mpeg12_init_vlcs();
@@ -3137,5 +3138,5 @@
     .decode         = ipu_decode_frame,
     .close          = ipu_decode_end,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index a05c2db..d399e9e 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -62,6 +62,9 @@
 static uint32_t mpeg1_lum_dc_uni[512];
 static uint32_t mpeg1_chr_dc_uni[512];
 
+static uint8_t mpeg1_index_run[2][64];
+static int8_t  mpeg1_max_level[2][64];
+
 #define A53_MAX_CC_COUNT 0x1f
 #endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
 
@@ -719,8 +722,8 @@
             MASK_ABS(sign, alevel);
             sign &= 1;
 
-            if (alevel <= ff_rl_mpeg1.max_level[0][run]) {
-                code = ff_rl_mpeg1.index_run[0][run] + alevel - 1;
+            if (alevel <= mpeg1_max_level[0][run]) {
+                code = mpeg1_index_run[0][run] + alevel - 1;
                 /* store the VLC & sign at once */
                 put_bits(&s->pb, table_vlc[code][1] + 1,
                          (table_vlc[code][0] << 1) + sign);
@@ -1038,10 +1041,13 @@
 
 static av_cold void mpeg12_encode_init_static(void)
 {
-    static uint8_t mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
+    ff_rl_init(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
+    ff_rl_init(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
 
-    ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store[0]);
-    ff_rl_init(&ff_rl_mpeg2, mpeg12_static_rl_table_store[1]);
+    for (int i = 0; i < 64; i++) {
+        mpeg1_max_level[0][i] = ff_rl_mpeg1.max_level[0][i];
+        mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];
+    }
 
     ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
     ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
@@ -1199,7 +1205,7 @@
     .pix_fmts             = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                            AV_PIX_FMT_NONE },
     .capabilities         = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
-    .caps_internal        = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal        = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_class           = &mpeg1_class,
 };
 
@@ -1217,7 +1223,7 @@
                                                            AV_PIX_FMT_YUV422P,
                                                            AV_PIX_FMT_NONE },
     .capabilities         = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
-    .caps_internal        = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal        = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_class           = &mpeg2_class,
 };
 #endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
index 11b46c0..d0048c0 100644
--- a/libavcodec/mpeg2_metadata_bsf.c
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -21,13 +21,16 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
-#include "cbs_bsf.h"
 #include "cbs_mpeg2.h"
 #include "mpeg12.h"
 
 typedef struct MPEG2MetadataContext {
-    CBSBSFContext common;
+    const AVClass *class;
+
+    CodedBitstreamContext *cbc;
+    CodedBitstreamFragment fragment;
 
     MPEG2RawExtensionData sequence_display_extension;
 
@@ -45,7 +48,6 @@
 
 
 static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
-                                          AVPacket *pkt,
                                           CodedBitstreamFragment *frag)
 {
     MPEG2MetadataContext             *ctx = bsf->priv_data;
@@ -168,16 +170,49 @@
     return 0;
 }
 
-static const CBSBSFType mpeg2_metadata_type = {
-    .codec_id        = AV_CODEC_ID_MPEG2VIDEO,
-    .fragment_name   = "frame",
-    .unit_name       = "start code",
-    .update_fragment = &mpeg2_metadata_update_fragment,
-};
+static int mpeg2_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+{
+    MPEG2MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *frag = &ctx->fragment;
+    int err;
+
+    err = ff_bsf_get_packet_ref(bsf, pkt);
+    if (err < 0)
+        return err;
+
+    err = ff_cbs_read_packet(ctx->cbc, frag, pkt);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+        goto fail;
+    }
+
+    err = mpeg2_metadata_update_fragment(bsf, frag);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to update frame fragment.\n");
+        goto fail;
+    }
+
+    err = ff_cbs_write_packet(ctx->cbc, pkt, frag);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+        goto fail;
+    }
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(frag);
+
+    if (err < 0)
+        av_packet_unref(pkt);
+
+    return err;
+}
 
 static int mpeg2_metadata_init(AVBSFContext *bsf)
 {
     MPEG2MetadataContext *ctx = bsf->priv_data;
+    CodedBitstreamFragment *frag = &ctx->fragment;
+    int err;
 
 #define VALIDITY_CHECK(name) do { \
         if (!ctx->name) { \
@@ -191,7 +226,42 @@
     VALIDITY_CHECK(matrix_coefficients);
 #undef VALIDITY_CHECK
 
-    return ff_cbs_bsf_generic_init(bsf, &mpeg2_metadata_type);
+    err = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_MPEG2VIDEO, bsf);
+    if (err < 0)
+        return err;
+
+    if (bsf->par_in->extradata) {
+        err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
+            goto fail;
+        }
+
+        err = mpeg2_metadata_update_fragment(bsf, frag);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to update metadata fragment.\n");
+            goto fail;
+        }
+
+        err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag);
+        if (err < 0) {
+            av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
+            goto fail;
+        }
+    }
+
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(frag);
+    return err;
+}
+
+static void mpeg2_metadata_close(AVBSFContext *bsf)
+{
+    MPEG2MetadataContext *ctx = bsf->priv_data;
+
+    ff_cbs_fragment_free(&ctx->fragment);
+    ff_cbs_close(&ctx->cbc);
 }
 
 #define OFFSET(x) offsetof(MPEG2MetadataContext, x)
@@ -237,7 +307,7 @@
     .priv_data_size = sizeof(MPEG2MetadataContext),
     .priv_class     = &mpeg2_metadata_class,
     .init           = &mpeg2_metadata_init,
-    .close          = &ff_cbs_bsf_generic_close,
-    .filter         = &ff_cbs_bsf_generic_filter,
+    .close          = &mpeg2_metadata_close,
+    .filter         = &mpeg2_metadata_filter,
     .codec_ids      = mpeg2_metadata_codec_ids,
 };
diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index 2286303..77cf2fb 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -30,7 +30,7 @@
  * @param[in] c        MPEG4AudioConfig structure to fill
  * @return on success 0 is returned, otherwise a value < 0
  */
-static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c, void *logctx)
+static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c)
 {
     if (get_bits_left(gb) < 112)
         return AVERROR_INVALIDDATA;
@@ -43,7 +43,7 @@
     c->sample_rate = get_bits_long(gb, 32);
 
     if (c->sample_rate <= 0) {
-        av_log(logctx, AV_LOG_ERROR, "Invalid sample rate %d\n", c->sample_rate);
+        av_log(NULL, AV_LOG_ERROR, "Invalid sample rate %d\n", c->sample_rate);
         return AVERROR_INVALIDDATA;
     }
 
@@ -136,7 +136,7 @@
 
         specific_config_bitindex = get_bits_count(gb);
 
-        ret = parse_config_ALS(gb, c, logctx);
+        ret = parse_config_ALS(gb, c);
         if (ret < 0)
             return ret;
     }
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 51af77d..03b46e9 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -47,6 +47,8 @@
 #define MB_TYPE_B_VLC_BITS 4
 #define STUDIO_INTRA_BITS 9
 
+static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb);
+
 static VLC dc_lum, dc_chrom;
 static VLC sprite_trajectory;
 static VLC mb_type_b_vlc;
@@ -195,6 +197,10 @@
     if (w <= 0 || h <= 0)
         return AVERROR_INVALIDDATA;
 
+    /* the decoder was not properly initialized and we cannot continue */
+    if (sprite_trajectory.table == NULL)
+        return AVERROR_INVALIDDATA;
+
     for (i = 0; i < ctx->num_sprite_warping_points; i++) {
         int length;
         int x = 0, y = 0;
@@ -2140,158 +2146,6 @@
     }
 }
 
-static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb)
-{
-    int i, j, v;
-
-    if (get_bits1(gb)) {
-        if (get_bits_left(gb) < 64*8)
-            return AVERROR_INVALIDDATA;
-        /* intra_quantiser_matrix */
-        for (i = 0; i < 64; i++) {
-            v = get_bits(gb, 8);
-            j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
-            s->intra_matrix[j]        = v;
-            s->chroma_intra_matrix[j] = v;
-        }
-    }
-
-    if (get_bits1(gb)) {
-        if (get_bits_left(gb) < 64*8)
-            return AVERROR_INVALIDDATA;
-        /* non_intra_quantiser_matrix */
-        for (i = 0; i < 64; i++) {
-            get_bits(gb, 8);
-        }
-    }
-
-    if (get_bits1(gb)) {
-        if (get_bits_left(gb) < 64*8)
-            return AVERROR_INVALIDDATA;
-        /* chroma_intra_quantiser_matrix */
-        for (i = 0; i < 64; i++) {
-            v = get_bits(gb, 8);
-            j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
-            s->chroma_intra_matrix[j] = v;
-        }
-    }
-
-    if (get_bits1(gb)) {
-        if (get_bits_left(gb) < 64*8)
-            return AVERROR_INVALIDDATA;
-        /* chroma_non_intra_quantiser_matrix */
-        for (i = 0; i < 64; i++) {
-            get_bits(gb, 8);
-        }
-    }
-
-    next_start_code_studio(gb);
-    return 0;
-}
-
-static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id)
-{
-    uint32_t startcode;
-    uint8_t extension_type;
-
-    startcode = show_bits_long(gb, 32);
-    if (startcode == USER_DATA_STARTCODE || startcode == EXT_STARTCODE) {
-
-        if ((id == 2 || id == 4) && startcode == EXT_STARTCODE) {
-            skip_bits_long(gb, 32);
-            extension_type = get_bits(gb, 4);
-            if (extension_type == QUANT_MATRIX_EXT_ID)
-                read_quant_matrix_ext(s, gb);
-        }
-    }
-}
-
-static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
-{
-    MpegEncContext *s = &ctx->m;
-    int width, height;
-    int bits_per_raw_sample;
-    int rgb, chroma_format;
-
-    // random_accessible_vol and video_object_type_indication have already
-    // been read by the caller decode_vol_header()
-    skip_bits(gb, 4); /* video_object_layer_verid */
-    ctx->shape = get_bits(gb, 2); /* video_object_layer_shape */
-    skip_bits(gb, 4); /* video_object_layer_shape_extension */
-    skip_bits1(gb); /* progressive_sequence */
-    if (ctx->shape != RECT_SHAPE) {
-        avpriv_request_sample(s->avctx, "MPEG-4 Studio profile non rectangular shape");
-        return AVERROR_PATCHWELCOME;
-    }
-    if (ctx->shape != BIN_ONLY_SHAPE) {
-        rgb = get_bits1(gb); /* rgb_components */
-        chroma_format = get_bits(gb, 2); /* chroma_format */
-        if (!chroma_format || chroma_format == CHROMA_420 || (rgb && chroma_format == CHROMA_422)) {
-            av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
-            return AVERROR_INVALIDDATA;
-        }
-
-        bits_per_raw_sample = get_bits(gb, 4); /* bit_depth */
-        if (bits_per_raw_sample == 10) {
-            if (rgb) {
-                s->avctx->pix_fmt = AV_PIX_FMT_GBRP10;
-            } else {
-                s->avctx->pix_fmt = chroma_format == CHROMA_422 ? AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV444P10;
-            }
-        } else {
-            avpriv_request_sample(s->avctx, "MPEG-4 Studio profile bit-depth %u", bits_per_raw_sample);
-            return AVERROR_PATCHWELCOME;
-        }
-        if (rgb != ctx->rgb || s->chroma_format != chroma_format)
-            s->context_reinit = 1;
-        s->avctx->bits_per_raw_sample = bits_per_raw_sample;
-        ctx->rgb = rgb;
-        s->chroma_format = chroma_format;
-    }
-    if (ctx->shape == RECT_SHAPE) {
-        check_marker(s->avctx, gb, "before video_object_layer_width");
-        width  = get_bits(gb, 14); /* video_object_layer_width */
-        check_marker(s->avctx, gb, "before video_object_layer_height");
-        height = get_bits(gb, 14); /* video_object_layer_height */
-        check_marker(s->avctx, gb, "after video_object_layer_height");
-
-        /* Do the same check as non-studio profile */
-        if (width && height) {
-            if (s->width && s->height &&
-                (s->width != width || s->height != height))
-                s->context_reinit = 1;
-            s->width  = width;
-            s->height = height;
-        }
-    }
-    s->aspect_ratio_info = get_bits(gb, 4);
-    if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
-        s->avctx->sample_aspect_ratio.num = get_bits(gb, 8);  // par_width
-        s->avctx->sample_aspect_ratio.den = get_bits(gb, 8);  // par_height
-    } else {
-        s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
-    }
-    skip_bits(gb, 4); /* frame_rate_code */
-    skip_bits(gb, 15); /* first_half_bit_rate */
-    check_marker(s->avctx, gb, "after first_half_bit_rate");
-    skip_bits(gb, 15); /* latter_half_bit_rate */
-    check_marker(s->avctx, gb, "after latter_half_bit_rate");
-    skip_bits(gb, 15); /* first_half_vbv_buffer_size */
-    check_marker(s->avctx, gb, "after first_half_vbv_buffer_size");
-    skip_bits(gb, 3); /* latter_half_vbv_buffer_size */
-    skip_bits(gb, 11); /* first_half_vbv_buffer_size */
-    check_marker(s->avctx, gb, "after first_half_vbv_buffer_size");
-    skip_bits(gb, 15); /* latter_half_vbv_occupancy */
-    check_marker(s->avctx, gb, "after latter_half_vbv_occupancy");
-    s->low_delay  = get_bits1(gb);
-    s->mpeg_quant = get_bits1(gb); /* mpeg2_stream */
-
-    next_start_code_studio(gb);
-    extension_and_user_data(s, gb, 2);
-
-    return 0;
-}
-
 static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
 {
     MpegEncContext *s = &ctx->m;
@@ -3116,6 +2970,72 @@
     return 0;
 }
 
+static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb)
+{
+    int i, j, v;
+
+    if (get_bits1(gb)) {
+        if (get_bits_left(gb) < 64*8)
+            return AVERROR_INVALIDDATA;
+        /* intra_quantiser_matrix */
+        for (i = 0; i < 64; i++) {
+            v = get_bits(gb, 8);
+            j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
+            s->intra_matrix[j]        = v;
+            s->chroma_intra_matrix[j] = v;
+        }
+    }
+
+    if (get_bits1(gb)) {
+        if (get_bits_left(gb) < 64*8)
+            return AVERROR_INVALIDDATA;
+        /* non_intra_quantiser_matrix */
+        for (i = 0; i < 64; i++) {
+            get_bits(gb, 8);
+        }
+    }
+
+    if (get_bits1(gb)) {
+        if (get_bits_left(gb) < 64*8)
+            return AVERROR_INVALIDDATA;
+        /* chroma_intra_quantiser_matrix */
+        for (i = 0; i < 64; i++) {
+            v = get_bits(gb, 8);
+            j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
+            s->chroma_intra_matrix[j] = v;
+        }
+    }
+
+    if (get_bits1(gb)) {
+        if (get_bits_left(gb) < 64*8)
+            return AVERROR_INVALIDDATA;
+        /* chroma_non_intra_quantiser_matrix */
+        for (i = 0; i < 64; i++) {
+            get_bits(gb, 8);
+        }
+    }
+
+    next_start_code_studio(gb);
+    return 0;
+}
+
+static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id)
+{
+    uint32_t startcode;
+    uint8_t extension_type;
+
+    startcode = show_bits_long(gb, 32);
+    if (startcode == USER_DATA_STARTCODE || startcode == EXT_STARTCODE) {
+
+        if ((id == 2 || id == 4) && startcode == EXT_STARTCODE) {
+            skip_bits_long(gb, 32);
+            extension_type = get_bits(gb, 4);
+            if (extension_type == QUANT_MATRIX_EXT_ID)
+                read_quant_matrix_ext(s, gb);
+        }
+    }
+}
+
 static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb)
 {
     MpegEncContext *s = &ctx->m;
@@ -3195,15 +3115,103 @@
     MpegEncContext *s = &ctx->m;
     int visual_object_type;
 
-    skip_bits(gb, 4); /* visual_object_verid */
-    visual_object_type = get_bits(gb, 4);
-    if (visual_object_type != VOT_VIDEO_ID) {
-        avpriv_request_sample(s->avctx, "VO type %u", visual_object_type);
-        return AVERROR_PATCHWELCOME;
-    }
+        skip_bits(gb, 4); /* visual_object_verid */
+        visual_object_type = get_bits(gb, 4);
+        if (visual_object_type != VOT_VIDEO_ID) {
+            avpriv_request_sample(s->avctx, "VO type %u", visual_object_type);
+            return AVERROR_PATCHWELCOME;
+        }
 
-    next_start_code_studio(gb);
-    extension_and_user_data(s, gb, 1);
+        next_start_code_studio(gb);
+        extension_and_user_data(s, gb, 1);
+
+    return 0;
+}
+
+static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
+{
+    MpegEncContext *s = &ctx->m;
+    int width, height;
+    int bits_per_raw_sample;
+    int rgb, chroma_format;
+
+            // random_accessible_vol and video_object_type_indication have already
+            // been read by the caller decode_vol_header()
+            skip_bits(gb, 4); /* video_object_layer_verid */
+            ctx->shape = get_bits(gb, 2); /* video_object_layer_shape */
+            skip_bits(gb, 4); /* video_object_layer_shape_extension */
+            skip_bits1(gb); /* progressive_sequence */
+            if (ctx->shape != RECT_SHAPE) {
+                avpriv_request_sample(s->avctx, "MPEG-4 Studio profile non rectangular shape");
+                return AVERROR_PATCHWELCOME;
+            }
+            if (ctx->shape != BIN_ONLY_SHAPE) {
+                rgb = get_bits1(gb); /* rgb_components */
+                chroma_format = get_bits(gb, 2); /* chroma_format */
+                if (!chroma_format || chroma_format == CHROMA_420 || (rgb && chroma_format == CHROMA_422)) {
+                    av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
+                    return AVERROR_INVALIDDATA;
+                }
+
+                bits_per_raw_sample = get_bits(gb, 4); /* bit_depth */
+                if (bits_per_raw_sample == 10) {
+                    if (rgb) {
+                        s->avctx->pix_fmt = AV_PIX_FMT_GBRP10;
+                    }
+                    else {
+                        s->avctx->pix_fmt = chroma_format == CHROMA_422 ? AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV444P10;
+                    }
+                }
+                else {
+                    avpriv_request_sample(s->avctx, "MPEG-4 Studio profile bit-depth %u", bits_per_raw_sample);
+                    return AVERROR_PATCHWELCOME;
+                }
+                if (rgb != ctx->rgb || s->chroma_format != chroma_format)
+                    s->context_reinit = 1;
+                s->avctx->bits_per_raw_sample = bits_per_raw_sample;
+                ctx->rgb = rgb;
+                s->chroma_format = chroma_format;
+            }
+            if (ctx->shape == RECT_SHAPE) {
+                check_marker(s->avctx, gb, "before video_object_layer_width");
+                width = get_bits(gb, 14); /* video_object_layer_width */
+                check_marker(s->avctx, gb, "before video_object_layer_height");
+                height = get_bits(gb, 14); /* video_object_layer_height */
+                check_marker(s->avctx, gb, "after video_object_layer_height");
+
+                /* Do the same check as non-studio profile */
+                if (width && height) {
+                    if (s->width && s->height &&
+                        (s->width != width || s->height != height))
+                        s->context_reinit = 1;
+                    s->width  = width;
+                    s->height = height;
+                }
+            }
+            s->aspect_ratio_info = get_bits(gb, 4);
+            if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
+                s->avctx->sample_aspect_ratio.num = get_bits(gb, 8);  // par_width
+                s->avctx->sample_aspect_ratio.den = get_bits(gb, 8);  // par_height
+            } else {
+                s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
+            }
+            skip_bits(gb, 4); /* frame_rate_code */
+            skip_bits(gb, 15); /* first_half_bit_rate */
+            check_marker(s->avctx, gb, "after first_half_bit_rate");
+            skip_bits(gb, 15); /* latter_half_bit_rate */
+            check_marker(s->avctx, gb, "after latter_half_bit_rate");
+            skip_bits(gb, 15); /* first_half_vbv_buffer_size */
+            check_marker(s->avctx, gb, "after first_half_vbv_buffer_size");
+            skip_bits(gb, 3); /* latter_half_vbv_buffer_size */
+            skip_bits(gb, 11); /* first_half_vbv_buffer_size */
+            check_marker(s->avctx, gb, "after first_half_vbv_buffer_size");
+            skip_bits(gb, 15); /* latter_half_vbv_occupancy */
+            check_marker(s->avctx, gb, "after latter_half_vbv_occupancy");
+            s->low_delay = get_bits1(gb);
+            s->mpeg_quant = get_bits1(gb); /* mpeg2_stream */
+
+            next_start_code_studio(gb);
+            extension_and_user_data(s, gb, 2);
 
     return 0;
 }
@@ -3379,9 +3387,9 @@
         ff_rl_init(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
         ff_rl_init(&ff_rvlc_rl_inter, ff_mpeg4_static_rl_table_store[1]);
         ff_rl_init(&ff_rvlc_rl_intra, ff_mpeg4_static_rl_table_store[2]);
-        INIT_FIRST_VLC_RL(ff_mpeg4_rl_intra, 554);
+        INIT_VLC_RL(ff_mpeg4_rl_intra, 554);
         INIT_VLC_RL(ff_rvlc_rl_inter, 1072);
-        INIT_FIRST_VLC_RL(ff_rvlc_rl_intra, 1072);
+        INIT_VLC_RL(ff_rvlc_rl_intra, 1072);
         INIT_VLC_STATIC(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
                         &ff_mpeg4_DCtab_lum[0][1], 2, 1,
                         &ff_mpeg4_DCtab_lum[0][0], 2, 1, 512);
@@ -3549,11 +3557,9 @@
     return 0;
 }
 
-#define OFFSET(x) offsetof(MpegEncContext, x)
-#define FLAGS AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY
 static const AVOption mpeg4_options[] = {
-    {"quarter_sample", "1/4 subpel MC", OFFSET(quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
-    {"divx_packed", "divx style packed b frames", OFFSET(divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
+    {"quarter_sample", "1/4 subpel MC", offsetof(MpegEncContext, quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0},
+    {"divx_packed", "divx style packed b frames", offsetof(MpegEncContext, divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0},
     {NULL}
 };
 
@@ -3585,7 +3591,7 @@
     .profiles              = NULL_IF_CONFIG_SMALL(ff_mpeg4_video_profiles),
     .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg4_update_thread_context),
     .priv_class = &mpeg4_class,
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_MPEG4_NVDEC_HWACCEL
                                HWACCEL_NVDEC(mpeg4),
 #endif
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index a092ab0..b3fa910 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -961,6 +961,9 @@
 {
     int vo_ver_id;
 
+    if (!CONFIG_MPEG4_ENCODER)
+        return;
+
     if (s->max_b_frames || s->quarter_sample) {
         vo_ver_id  = 5;
         s->vo_type = ADV_SIMPLE_VO_TYPE;
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index 4fd9e3a..0ceeee2 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -30,9 +30,7 @@
 #include "libavutil/crc.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
-
 #include "avcodec.h"
 #include "get_bits.h"
 #include "internal.h"
diff --git a/libavcodec/mpegaudiodsp_template.c b/libavcodec/mpegaudiodsp_template.c
index 9731796..c67c456 100644
--- a/libavcodec/mpegaudiodsp_template.c
+++ b/libavcodec/mpegaudiodsp_template.c
@@ -22,9 +22,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
-
 #include "dct32.h"
 #include "mathops.h"
 #include "mpegaudiodsp.h"
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index e3f6488..13c11ec 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -203,6 +203,9 @@
     }
 
     if (out_format == FMT_H263 || encoding ||
+#if FF_API_DEBUG_MV
+        avctx->debug_mv ||
+#endif
         (avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS)) {
         int mv_size        = 2 * (b8_array_size + 4) * sizeof(int16_t);
         int ref_index_size = 4 * mb_array_size;
@@ -217,7 +220,6 @@
 
     pic->alloc_mb_width  = mb_width;
     pic->alloc_mb_height = mb_height;
-    pic->alloc_mb_stride = mb_stride;
 
     return 0;
 }
@@ -344,7 +346,6 @@
 
     dst->alloc_mb_width  = src->alloc_mb_width;
     dst->alloc_mb_height = src->alloc_mb_height;
-    dst->alloc_mb_stride = src->alloc_mb_stride;
 
     return 0;
 }
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index 4bcd666..2db3d67 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -69,7 +69,6 @@
 
     int alloc_mb_width;         ///< mb_width used to allocate tables
     int alloc_mb_height;        ///< mb_height used to allocate tables
-    int alloc_mb_stride;        ///< mb_stride used to allocate tables
 
     AVBufferRef *mb_mean_buf;
     uint8_t *mb_mean;           ///< Table for MB luminance
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index e5105ec..c0ee3aa 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -262,4 +262,132 @@
             av_log(avctx, AV_LOG_DEBUG, "\n");
         }
     }
+
+#if FF_API_DEBUG_MV
+    if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
+        (avctx->debug_mv)) {
+        int mb_y;
+        int i, ret;
+        int h_chroma_shift, v_chroma_shift, block_height;
+        const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1;
+        const int mv_stride      = (mb_width << mv_sample_log2) +
+                                   (avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 1);
+
+        if (low_delay)
+            *low_delay = 0; // needed to see the vectors without trashing the buffers
+
+        ret = av_pix_fmt_get_chroma_sub_sample (avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
+        if (ret)
+            return ret;
+
+        av_frame_make_writable(pict);
+
+        pict->opaque = NULL;
+        block_height = 16 >> v_chroma_shift;
+
+        for (mb_y = 0; mb_y < mb_height; mb_y++) {
+            int mb_x;
+            for (mb_x = 0; mb_x < mb_width; mb_x++) {
+                const int mb_index = mb_x + mb_y * mb_stride;
+                if ((avctx->debug & FF_DEBUG_VIS_QP)) {
+                    uint64_t c = (qscale_table[mb_index] * 128 / 31) *
+                                 0x0101010101010101ULL;
+                    int y;
+                    for (y = 0; y < block_height; y++) {
+                        *(uint64_t *)(pict->data[1] + 8 * mb_x +
+                                      (block_height * mb_y + y) *
+                                      pict->linesize[1]) = c;
+                        *(uint64_t *)(pict->data[2] + 8 * mb_x +
+                                      (block_height * mb_y + y) *
+                                      pict->linesize[2]) = c;
+                    }
+                }
+                if ((avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
+                    motion_val[0]) {
+                    int mb_type = mbtype_table[mb_index];
+                    uint64_t u,v;
+                    int y;
+#define COLOR(theta, r) \
+    u = (int)(128 + r * cos(theta * M_PI / 180)); \
+    v = (int)(128 + r * sin(theta * M_PI / 180));
+
+
+                    u = v = 128;
+                    if (IS_PCM(mb_type)) {
+                        COLOR(120, 48)
+                    } else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||
+                               IS_INTRA16x16(mb_type)) {
+                        COLOR(30, 48)
+                    } else if (IS_INTRA4x4(mb_type)) {
+                        COLOR(90, 48)
+                    } else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {
+                        // COLOR(120, 48)
+                    } else if (IS_DIRECT(mb_type)) {
+                        COLOR(150, 48)
+                    } else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {
+                        COLOR(170, 48)
+                    } else if (IS_GMC(mb_type)) {
+                        COLOR(190, 48)
+                    } else if (IS_SKIP(mb_type)) {
+                        // COLOR(180, 48)
+                    } else if (!USES_LIST(mb_type, 1)) {
+                        COLOR(240, 48)
+                    } else if (!USES_LIST(mb_type, 0)) {
+                        COLOR(0, 48)
+                    } else {
+                        av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
+                        COLOR(300,48)
+                    }
+
+                    u *= 0x0101010101010101ULL;
+                    v *= 0x0101010101010101ULL;
+                    for (y = 0; y < block_height; y++) {
+                        *(uint64_t *)(pict->data[1] + 8 * mb_x +
+                                      (block_height * mb_y + y) * pict->linesize[1]) = u;
+                        *(uint64_t *)(pict->data[2] + 8 * mb_x +
+                                      (block_height * mb_y + y) * pict->linesize[2]) = v;
+                    }
+
+                    // segmentation
+                    if (IS_8X8(mb_type) || IS_16X8(mb_type)) {
+                        *(uint64_t *)(pict->data[0] + 16 * mb_x + 0 +
+                                      (16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
+                        *(uint64_t *)(pict->data[0] + 16 * mb_x + 8 +
+                                      (16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
+                    }
+                    if (IS_8X8(mb_type) || IS_8X16(mb_type)) {
+                        for (y = 0; y < 16; y++)
+                            pict->data[0][16 * mb_x + 8 + (16 * mb_y + y) *
+                                          pict->linesize[0]] ^= 0x80;
+                    }
+                    if (IS_8X8(mb_type) && mv_sample_log2 >= 2) {
+                        int dm = 1 << (mv_sample_log2 - 2);
+                        for (i = 0; i < 4; i++) {
+                            int sx = mb_x * 16 + 8 * (i & 1);
+                            int sy = mb_y * 16 + 8 * (i >> 1);
+                            int xy = (mb_x * 2 + (i & 1) +
+                                     (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
+                            // FIXME bidir
+                            int32_t *mv = (int32_t *) &motion_val[0][xy];
+                            if (mv[0] != mv[dm] ||
+                                mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
+                                for (y = 0; y < 8; y++)
+                                    pict->data[0][sx + 4 + (sy + y) * pict->linesize[0]] ^= 0x80;
+                            if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
+                                *(uint64_t *)(pict->data[0] + sx + (sy + 4) *
+                                              pict->linesize[0]) ^= 0x8080808080808080ULL;
+                        }
+                    }
+
+                    if (IS_INTERLACED(mb_type) &&
+                        avctx->codec->id == AV_CODEC_ID_H264) {
+                        // hmm
+                    }
+                }
+                if (mbskip_table)
+                    mbskip_table[mb_index] = 0;
+            }
+        }
+    }
+#endif
 }
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 988dd18..c28d1ad 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -32,8 +32,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/motion_vector.h"
-#include "libavutil/video_enc_params.h"
-
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "h264chroma.h"
@@ -662,14 +660,17 @@
 }
 
 /**
- * Initialize the given MpegEncContext for decoding.
+ * Set the given MpegEncContext to defaults for decoding.
  * the changed fields will not depend upon
  * the prior state of the MpegEncContext.
  */
-void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
+void ff_mpv_decode_defaults(MpegEncContext *s)
 {
     ff_mpv_common_defaults(s);
+}
 
+void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
+{
     s->avctx           = avctx;
     s->width           = avctx->coded_width;
     s->height          = avctx->coded_height;
@@ -789,7 +790,7 @@
     }
 
     /* which mb is an intra block,  init macroblock skip table */
-    if (!FF_ALLOC_TYPED_ARRAY(s->mbintra_table, mb_array_size) ||
+    if (!FF_ALLOCZ_TYPED_ARRAY(s->mbintra_table, mb_array_size) ||
         // Note the + 1 is for a quicker MPEG-4 slice_end detection
         !FF_ALLOCZ_TYPED_ARRAY(s->mbskip_table,  mb_array_size + 2))
         return AVERROR(ENOMEM);
@@ -1424,33 +1425,14 @@
 
 int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)
 {
-    AVVideoEncParams *par;
-    int mult = (qp_type == FF_QSCALE_TYPE_MPEG1) ? 2 : 1;
-    unsigned int nb_mb = p->alloc_mb_height * p->alloc_mb_width;
-    unsigned int x, y;
-
-    if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS))
-        return 0;
-
-    par = av_video_enc_params_create_side_data(f, AV_VIDEO_ENC_PARAMS_MPEG2, nb_mb);
-    if (!par)
+    AVBufferRef *ref = av_buffer_ref(p->qscale_table_buf);
+    int offset = 2*s->mb_stride + 1;
+    if(!ref)
         return AVERROR(ENOMEM);
-
-    for (y = 0; y < p->alloc_mb_height; y++)
-        for (x = 0; x < p->alloc_mb_width; x++) {
-            const unsigned int block_idx = y * p->alloc_mb_width + x;
-            const unsigned int     mb_xy = y * p->alloc_mb_stride + x;
-            AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx);
-
-            b->src_x = x * 16;
-            b->src_y = y * 16;
-            b->w     = 16;
-            b->h     = 16;
-
-            b->delta_qp = p->qscale_table[mb_xy] * mult;
-        }
-
-    return 0;
+    av_assert0(ref->size >= offset + s->mb_stride * ((f->height+15)/16));
+    ref->size -= offset;
+    ref->data += offset;
+    return av_frame_set_qp_table(f, ref, s->mb_stride, qp_type);
 }
 
 static inline int hpel_motion_lowres(MpegEncContext *s,
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 5a99c19..974c71b 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -276,7 +276,7 @@
     int mv[2][4][2];
     int field_select[2][2];
     int last_mv[2][2][2];             ///< last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4
-    const uint8_t *fcode_tab;         ///< smallest fcode needed for each MV
+    uint8_t *fcode_tab;               ///< smallest fcode needed for each MV
     int16_t direct_scale_mv[2][64];   ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
 
     MotionEstContext me;
@@ -369,9 +369,7 @@
     uint8_t *mb_info_ptr;
     int mb_info_size;
     int ehc_mode;
-#if FF_API_MPV_RC_STRATEGY
     int rc_strategy;                ///< deprecated
-#endif
 
     /* H.263+ specific */
     int umvplus;                    ///< == H.263+ && unrestricted_mv
@@ -617,14 +615,6 @@
 #ifndef FF_MPV_OFFSET
 #define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
 #endif
-#if FF_API_MPV_RC_STRATEGY
-#define FF_MPV_RC_STRATEGY_OPTS \
-{"rc_strategy", "ratecontrol method",                               FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" },   \
-    { "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
-    { "xvid",   "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" },
-#else
-#define FF_MPV_RC_STRATEGY_OPTS
-#endif
 #define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 #define FF_MPV_COMMON_OPTS \
 FF_MPV_OPT_CMP_FUNC, \
@@ -658,6 +648,9 @@
 {"lmax", "maximum Lagrange factor (VBR)",                           FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS },            \
 {"ibias", "intra quant bias",                                       FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
 {"pbias", "inter quant bias",                                       FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
+{"rc_strategy", "ratecontrol method",                               FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" },   \
+    { "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
+    { "xvid",   "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
 {"motion_est", "motion estimation algorithm",                       FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" },   \
 { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
@@ -678,7 +671,6 @@
 {"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \
 {"a53cc", "Use A53 Closed Captions (if available)", FF_MPV_OFFSET(a53_cc), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FF_MPV_OPT_FLAGS }, \
-FF_MPV_RC_STRATEGY_OPTS
 
 extern const AVOption ff_mpv_generic_options[];
 
@@ -702,6 +694,7 @@
 int ff_mpv_common_frame_size_change(MpegEncContext *s);
 void ff_mpv_common_end(MpegEncContext *s);
 
+void ff_mpv_decode_defaults(MpegEncContext *s);
 void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx);
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]);
 void ff_mpv_report_decode_progress(MpegEncContext *s);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 5a5cff4..243d3ca 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -36,10 +36,8 @@
 #include "libavutil/internal.h"
 #include "libavutil/intmath.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
-#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "dct.h"
 #include "idctdsp.h"
@@ -67,6 +65,7 @@
 #include "wmv2.h"
 #include "rv10.h"
 #include "packet_internal.h"
+#include "libxvid.h"
 #include <limits.h>
 #include "sp5x.h"
 
@@ -249,24 +248,18 @@
 #undef COPY
 }
 
-static void mpv_encode_init_static(void)
-{
-   for (int i = -16; i < 16; i++)
-        default_fcode_tab[i + MAX_MV] = 1;
-}
-
 /**
  * Set the given MpegEncContext to defaults for encoding.
  * the changed fields will not depend upon the prior state of the MpegEncContext.
  */
 static void mpv_encode_defaults(MpegEncContext *s)
 {
-    static AVOnce init_static_once = AV_ONCE_INIT;
-
+    int i;
     ff_mpv_common_defaults(s);
 
-    ff_thread_once(&init_static_once, mpv_encode_init_static);
-
+    for (i = -16; i < 16; i++) {
+        default_fcode_tab[i + MAX_MV] = 1;
+    }
     s->me.mv_penalty = default_mv_penalty;
     s->fcode_tab     = default_fcode_tab;
 
@@ -2792,6 +2785,8 @@
 static int estimate_motion_thread(AVCodecContext *c, void *arg){
     MpegEncContext *s= *(void**)arg;
 
+    ff_check_alignment();
+
     s->me.dia_size= s->avctx->dia_size;
     s->first_slice_line=1;
     for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
@@ -2818,6 +2813,8 @@
     MpegEncContext *s= *(void**)arg;
     int mb_x, mb_y;
 
+    ff_check_alignment();
+
     for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
         for(mb_x=0; mb_x < s->mb_width; mb_x++) {
             int xx = mb_x * 16;
@@ -2946,6 +2943,8 @@
     uint8_t bit_buf_tex[2][MAX_MB_BYTES];
     PutBitContext pb[2], pb2[2], tex_pb[2];
 
+    ff_check_alignment();
+
     for(i=0; i<2; i++){
         init_put_bits(&pb    [i], bit_buf    [i], MAX_MB_BYTES);
         init_put_bits(&pb2   [i], bit_buf2   [i], MAX_MB_BYTES);
@@ -3880,8 +3879,8 @@
         for(i=1;i<64;i++){
             int j= s->idsp.idct_permutation[ff_zigzag_direct[i]];
 
-            s->intra_matrix[j]        = sp5x_qscale_five_quant_table[0][i];
-            s->chroma_intra_matrix[j] = sp5x_qscale_five_quant_table[1][i];
+            s->intra_matrix[j] = sp5x_quant_table[5*2+0][i];
+            s->chroma_intra_matrix[j] = sp5x_quant_table[5*2+1][i];
         }
         s->y_dc_scale_table= y;
         s->c_dc_scale_table= c;
diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index 427bc96..5624c10 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -21,16 +21,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <string.h>
+
 #include "libavutil/avassert.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "h261.h"
 #include "mpegutils.h"
 #include "mpegvideo.h"
+#include "mjpegenc.h"
+#include "msmpeg4.h"
 #include "qpeldsp.h"
 #include "wmv2.h"
+#include <limits.h>
 
 static void gmc1_motion(MpegEncContext *s,
                         uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
@@ -208,16 +211,16 @@
         dxy |= (motion_y & 1) << 1;
     src += src_y * s->linesize + src_x;
 
-    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
-        (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
-        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,
-                                 s->linesize, s->linesize,
-                                 9, 9,
-                                 src_x, src_y,
-                                 s->h_edge_pos, s->v_edge_pos);
-        src = s->sc.edge_emu_buffer;
-        emu = 1;
-    }
+        if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
+            (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
+            s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,
+                                     s->linesize, s->linesize,
+                                     9, 9,
+                                     src_x, src_y,
+                                     s->h_edge_pos, s->v_edge_pos);
+            src = s->sc.edge_emu_buffer;
+            emu = 1;
+        }
     pix_op[dxy](dest, src, s->linesize, 8);
     return emu;
 }
@@ -301,9 +304,9 @@
 
     if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15   , 0) ||
         (unsigned)src_y >= FFMAX(   v_edge_pos - (motion_y & 1) - h + 1, 0)) {
-        if (is_mpeg12 || (CONFIG_SMALL &&
-                          (s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
-                           s->codec_id == AV_CODEC_ID_MPEG1VIDEO))) {
+        if (is_mpeg12 ||
+            s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
+            s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
             av_log(s->avctx, AV_LOG_DEBUG,
                    "MPEG motion vector out of boundary (%d %d)\n", src_x,
                    src_y);
@@ -848,7 +851,7 @@
 
     switch (s->mv_type) {
     case MV_TYPE_16X16:
-        if (!is_mpeg12 && s->mcsel) {
+        if (s->mcsel) {
             if (s->real_sprite_warping_points == 1) {
                 gmc1_motion(s, dest_y, dest_cb, dest_cr,
                             ref_picture);
@@ -910,63 +913,60 @@
         }
         break;
     case MV_TYPE_16X8:
-        if (CONFIG_SMALL || is_mpeg12) {
-            for (i = 0; i < 2; i++) {
-                uint8_t **ref2picture;
+        for (i = 0; i < 2; i++) {
+            uint8_t **ref2picture;
 
-                if ((s->picture_structure == s->field_select[dir][i] + 1 ||
-                     s->pict_type == AV_PICTURE_TYPE_B || s->first_field) &&
-                    ref_picture[0]) {
-                    ref2picture = ref_picture;
-                } else {
-                    ref2picture = s->current_picture_ptr->f->data;
-                }
-
-                mpeg_motion(s, dest_y, dest_cb, dest_cr,
-                            s->field_select[dir][i],
-                            ref2picture, pix_op,
-                            s->mv[dir][i][0], s->mv[dir][i][1],
-                            8, 1, (mb_y & ~1) + i);
-
-                dest_y  += 16 * s->linesize;
-                dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
-                dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
-            }
-            break;
-        }
-    case MV_TYPE_DMV:
-        if (CONFIG_SMALL || is_mpeg12) {
-            if (s->picture_structure == PICT_FRAME) {
-                for (i = 0; i < 2; i++) {
-                    for (int j = 0; j < 2; j++)
-                        mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
-                                          j, j ^ i, ref_picture, pix_op,
-                                          s->mv[dir][2 * i + j][0],
-                                          s->mv[dir][2 * i + j][1], 8, mb_y);
-                    pix_op = s->hdsp.avg_pixels_tab;
-                }
+            if ((s->picture_structure == s->field_select[dir][i] + 1
+                || s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && ref_picture[0]) {
+                ref2picture = ref_picture;
             } else {
-                if (!ref_picture[0]) {
+                ref2picture = s->current_picture_ptr->f->data;
+            }
+
+            mpeg_motion(s, dest_y, dest_cb, dest_cr,
+                        s->field_select[dir][i],
+                        ref2picture, pix_op,
+                        s->mv[dir][i][0], s->mv[dir][i][1],
+                        8, 1, (mb_y & ~1) + i);
+
+            dest_y  += 16 * s->linesize;
+            dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
+            dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
+        }
+        break;
+    case MV_TYPE_DMV:
+        if (s->picture_structure == PICT_FRAME) {
+            for (i = 0; i < 2; i++) {
+                int j;
+                for (j = 0; j < 2; j++)
+                    mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
+                                      j, j ^ i, ref_picture, pix_op,
+                                      s->mv[dir][2 * i + j][0],
+                                      s->mv[dir][2 * i + j][1], 8, mb_y);
+                pix_op = s->hdsp.avg_pixels_tab;
+            }
+        } else {
+            if (!ref_picture[0]) {
+                ref_picture = s->current_picture_ptr->f->data;
+            }
+            for (i = 0; i < 2; i++) {
+                mpeg_motion(s, dest_y, dest_cb, dest_cr,
+                            s->picture_structure != i + 1,
+                            ref_picture, pix_op,
+                            s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
+                            16, 0, mb_y >> 1);
+
+                // after put we make avg of the same block
+                pix_op = s->hdsp.avg_pixels_tab;
+
+                /* opposite parity is always in the same frame if this is
+                 * second field */
+                if (!s->first_field) {
                     ref_picture = s->current_picture_ptr->f->data;
                 }
-                for (i = 0; i < 2; i++) {
-                    mpeg_motion(s, dest_y, dest_cb, dest_cr,
-                                s->picture_structure != i + 1,
-                                ref_picture, pix_op,
-                                s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
-                                16, 0, mb_y >> 1);
-
-                    // after put we make avg of the same block
-                    pix_op = s->hdsp.avg_pixels_tab;
-
-                    /* opposite parity is always in the same frame if this is
-                     * second field */
-                    if (!s->first_field)
-                        ref_picture = s->current_picture_ptr->f->data;
-                }
             }
-            break;
         }
+        break;
     default: av_assert2(0);
     }
 }
diff --git a/libavcodec/mqc.h b/libavcodec/mqc.h
index 73604d5..8bf7223 100644
--- a/libavcodec/mqc.h
+++ b/libavcodec/mqc.h
@@ -54,6 +54,9 @@
 /** code bit d with context cx */
 void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d);
 
+/** number of encoded bytes */
+int ff_mqc_length(MqcState *mqc);
+
 /** flush the encoder [returns number of bytes encoded] */
 int ff_mqc_flush(MqcState *mqc);
 int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len);
diff --git a/libavcodec/mqcenc.c b/libavcodec/mqcenc.c
index c941f84..7c9e1a0 100644
--- a/libavcodec/mqcenc.c
+++ b/libavcodec/mqcenc.c
@@ -102,6 +102,11 @@
     }
 }
 
+int ff_mqc_length(MqcState *mqc)
+{
+    return mqc->bp - mqc->bpstart;
+}
+
 int ff_mqc_flush(MqcState *mqc)
 {
     setbits(mqc);
diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c
index fe02649..86e4e88 100644
--- a/libavcodec/mscc.c
+++ b/libavcodec/mscc.c
@@ -152,7 +152,7 @@
     }
 
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
 
         if (pal && size == AVPALETTE_SIZE) {
diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h
index f9c63b5..bcdb967 100644
--- a/libavcodec/msmpeg4.h
+++ b/libavcodec/msmpeg4.h
@@ -59,7 +59,7 @@
 int ff_msmpeg4_decode_init(AVCodecContext *avctx);
 int ff_msmpeg4_decode_picture_header(MpegEncContext *s);
 int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size);
-void ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
+int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
 int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
                             int n, int coded, const uint8_t *scan_table);
 int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c
index fb0c618..b9c1d8e 100644
--- a/libavcodec/msmpeg4data.c
+++ b/libavcodec/msmpeg4data.c
@@ -1771,11 +1771,13 @@
 };
 
 MVTable ff_mv_tables[2] = {
-    { table0_mv_code,
+    { 1099,
+      table0_mv_code,
       table0_mv_bits,
       table0_mvx,
       table0_mvy, },
-    { table1_mv_code,
+    { 1099,
+      table1_mv_code,
       table1_mv_bits,
       table1_mvx,
       table1_mvy, }
diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
index 68a1d14..02199d0 100644
--- a/libavcodec/msmpeg4data.h
+++ b/libavcodec/msmpeg4data.h
@@ -37,6 +37,7 @@
 
 /* motion vector table */
 typedef struct MVTable {
+    int n;
     const uint16_t *table_mv_code;
     const uint8_t *table_mv_bits;
     const uint8_t *table_mvx;
@@ -68,7 +69,6 @@
 extern const uint8_t ff_wmv1_c_dc_scale_table[32];
 extern const uint8_t ff_old_ff_y_dc_scale_table[32];
 
-#define MSMPEG4_MV_TABLES_NB_ELEMS 1099
 extern MVTable ff_mv_tables[2];
 
 extern const uint8_t ff_v2_mb_type[8][2];
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 405fda4..49df06a 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -38,6 +38,7 @@
 #define V2_INTRA_CBPC_VLC_BITS 3
 #define V2_MB_TYPE_VLC_BITS 7
 #define MV_VLC_BITS 9
+#define V2_MV_VLC_BITS 9
 #define TEX_VLC_BITS 9
 
 #define DEFAULT_INTER_INDEX 3
@@ -65,6 +66,7 @@
 static VLC v2_dc_chroma_vlc;
 static VLC v2_intra_cbpc_vlc;
 static VLC v2_mb_type_vlc;
+static VLC v2_mv_vlc;
 VLC ff_inter_intra_vlc;
 
 /* This is identical to H.263 except that its range is multiplied by 2. */
@@ -72,7 +74,7 @@
 {
     int code, val, sign, shift;
 
-    code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2);
+    code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2);
     ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
     if (code < 0)
         return 0xffff;
@@ -228,6 +230,8 @@
         }
 
         code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
+        if (code < 0)
+            return -1;
         //s->mb_intra = (code & 0x40) ? 0 : 1;
         s->mb_intra = (~code & 0x40) >> 6;
 
@@ -235,6 +239,8 @@
     } else {
         s->mb_intra = 1;
         code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
+        if (code < 0)
+            return -1;
         /* predict coded block pattern */
         cbp = 0;
         for(i=0;i<6;i++) {
@@ -255,7 +261,8 @@
             s->rl_chroma_table_index = s->rl_table_index;
         }
         ff_h263_pred_motion(s, 0, 0, &mx, &my);
-        ff_msmpeg4_decode_motion(s, &mx, &my);
+        if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
+            return -1;
         s->mv_dir = MV_DIR_FORWARD;
         s->mv_type = MV_TYPE_16X16;
         s->mv[0][0][0] = mx;
@@ -310,22 +317,19 @@
         for(i=0;i<NB_RL_TABLES;i++) {
             ff_rl_init(&ff_rl_table[i], ff_static_rl_table_store[i]);
         }
-        INIT_FIRST_VLC_RL(ff_rl_table[0], 642);
-        INIT_FIRST_VLC_RL(ff_rl_table[1], 1104);
-        INIT_FIRST_VLC_RL(ff_rl_table[2], 554);
+        INIT_VLC_RL(ff_rl_table[0], 642);
+        INIT_VLC_RL(ff_rl_table[1], 1104);
+        INIT_VLC_RL(ff_rl_table[2], 554);
         INIT_VLC_RL(ff_rl_table[3], 940);
         INIT_VLC_RL(ff_rl_table[4], 962);
-        /* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been
-         * initialized in ff_h263_decode_init() above. So just copy the VLCs. */
-        av_assert1(ff_h263_rl_inter.rl_vlc[0]);
-        memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
+        INIT_VLC_RL(ff_rl_table[5], 554);
 
         mv = &ff_mv_tables[0];
-        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
+        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
                     mv->table_mv_bits, 1, 1,
                     mv->table_mv_code, 2, 2, 3714);
         mv = &ff_mv_tables[1];
-        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
+        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
                     mv->table_mv_bits, 1, 1,
                     mv->table_mv_code, 2, 2, 2694);
 
@@ -355,6 +359,9 @@
         INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
                  &ff_v2_mb_type[0][1], 2, 1,
                  &ff_v2_mb_type[0][0], 2, 1, 128);
+        INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
+                 &ff_mvtab[0][1], 2, 1,
+                 &ff_mvtab[0][0], 2, 1, 538);
 
         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
                      &ff_wmv2_inter_table[0][0][1], 8, 4,
@@ -607,6 +614,11 @@
         } else {
             level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
         }
+        if (level < 0){
+            av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
+            *dir_ptr = 0;
+            return -1;
+        }
 
         if (level == DC_MAX) {
             level = get_bits(&s->gb, 8);
@@ -828,7 +840,8 @@
     return 0;
 }
 
-void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
+int ff_msmpeg4_decode_motion(MpegEncContext * s,
+                                 int *mx_ptr, int *my_ptr)
 {
     MVTable *mv;
     int code, mx, my;
@@ -836,7 +849,11 @@
     mv = &ff_mv_tables[s->mv_table_index];
 
     code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
-    if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
+    if (code < 0){
+        av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
+        return -1;
+    }
+    if (code == mv->n) {
         mx = get_bits(&s->gb, 6);
         my = get_bits(&s->gb, 6);
     } else {
@@ -858,6 +875,7 @@
         my -= 64;
     *mx_ptr = mx;
     *my_ptr = my;
+    return 0;
 }
 
 AVCodec ff_msmpeg4v1_decoder = {
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 5f809c2..2c61735 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -56,9 +56,9 @@
 
     /* mark all entries as not used */
     for(i=0;i<4096;i++)
-        tab->table_mv_index[i] = MSMPEG4_MV_TABLES_NB_ELEMS;
+        tab->table_mv_index[i] = tab->n;
 
-    for (i = 0; i < MSMPEG4_MV_TABLES_NB_ELEMS; i++) {
+    for(i=0;i<tab->n;i++) {
         x = tab->table_mvx[i];
         y = tab->table_mvy[i];
         tab->table_mv_index[(x << 6) | y] = i;
@@ -320,7 +320,7 @@
     put_bits(&s->pb,
              mv->table_mv_bits[code],
              mv->table_mv_code[code]);
-    if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
+    if (code == mv->n) {
         /* escape : code literally */
         put_bits(&s->pb, 6, mx);
         put_bits(&s->pb, 6, my);
diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
index feea2b6..9233b34 100644
--- a/libavcodec/msrle.c
+++ b/libavcodec/msrle.c
@@ -97,7 +97,7 @@
         return ret;
 
     if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
 
         if (pal && size == AVPALETTE_SIZE) {
diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c
index b4b5ea4..c9bcce5 100644
--- a/libavcodec/msvideo1.c
+++ b/libavcodec/msvideo1.c
@@ -314,7 +314,7 @@
         return ret;
 
     if (s->mode_8bit) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
 
         if (pal && size == AVPALETTE_SIZE) {
diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c
index 763ce58..725e435 100644
--- a/libavcodec/mxpegdec.c
+++ b/libavcodec/mxpegdec.c
@@ -245,17 +245,16 @@
                            "Multiple SOF in a frame\n");
                     return AVERROR_INVALIDDATA;
                 }
+                s->got_sof_data = 0;
                 ret = ff_mjpeg_decode_sof(jpg);
                 if (ret < 0) {
                     av_log(avctx, AV_LOG_ERROR,
                            "SOF data decode error\n");
-                    s->got_sof_data = 0;
                     return ret;
                 }
                 if (jpg->interlaced) {
                     av_log(avctx, AV_LOG_ERROR,
                            "Interlaced mode not supported in MxPEG\n");
-                    s->got_sof_data = 0;
                     return AVERROR(EINVAL);
                 }
                 s->got_sof_data ++;
diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index e091ec9..9ea679d 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -34,7 +34,6 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/lfg.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/random_seed.h"
 
 #define BITSTREAM_READER_LE
diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c
index 9a53cad..57ce70e 100644
--- a/libavcodec/notchlc.c
+++ b/libavcodec/notchlc.c
@@ -496,9 +496,6 @@
 
         bytestream2_init(gb, s->lzf_buffer, uncompressed_size);
     } else if (s->format == 1) {
-        if (bytestream2_get_bytes_left(gb) < uncompressed_size / 255)
-            return AVERROR_INVALIDDATA;
-
         av_fast_padded_malloc(&s->uncompressed_buffer, &s->uncompressed_size,
                               uncompressed_size);
         if (!s->uncompressed_buffer)
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index d6b6608..23c84d9 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -242,7 +242,7 @@
     return ret;
 }
 
-static AVBufferRef *nvdec_decoder_frame_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *nvdec_decoder_frame_alloc(void *opaque, int size)
 {
     NVDECFramePool *pool = opaque;
     AVBufferRef *ret;
@@ -283,7 +283,7 @@
     av_buffer_pool_uninit(&ctx->pool);
 }
 
-static AVBufferRef *nvdec_alloc_dummy(buffer_size_t size)
+static AVBufferRef *nvdec_alloc_dummy(int size)
 {
     return av_buffer_create(NULL, 0, NULL, NULL, 0);
 }
diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c
index 1ce846a..bd920d8 100644
--- a/libavcodec/nvdec_av1.c
+++ b/libavcodec/nvdec_av1.c
@@ -53,10 +53,9 @@
 
     unsigned char remap_lr_type[4] = { AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ };
 
-    int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain;
     int ret, i, j;
 
-    ret = ff_nvdec_start_frame_sep_ref(avctx, cur_frame, apply_grain);
+    ret = ff_nvdec_start_frame_sep_ref(avctx, cur_frame, film_grain->apply_grain);
     if (ret < 0)
         return ret;
 
@@ -96,8 +95,7 @@
             .enable_superres            = seq->enable_superres,
             .enable_cdef                = seq->enable_cdef,
             .enable_restoration         = seq->enable_restoration,
-            .enable_fgs                 = seq->film_grain_params_present &&
-                                          !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN),
+            .enable_fgs                 = seq->film_grain_params_present,
 
             /* Frame Header */
             .frame_type                   = frame_header->frame_type,
@@ -184,7 +182,7 @@
             .spatial_layer_id  = s->cur_frame.spatial_id,
 
             /* Film Grain Params */
-            .apply_grain              = apply_grain,
+            .apply_grain              = film_grain->apply_grain,
             .overlap_flag             = film_grain->overlap_flag,
             .scaling_shift_minus8     = film_grain->grain_scaling_minus_8,
             .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
@@ -261,7 +259,7 @@
     }
 
     /* Film Grain Params */
-    if (apply_grain) {
+    if (film_grain->apply_grain) {
         for (i = 0; i < 14; ++i) {
             ppc->scaling_points_y[i][0] = film_grain->point_y_value[i];
             ppc->scaling_points_y[i][1] = film_grain->point_y_scaling[i];
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a061dee..1c06b6a 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1921,7 +1921,7 @@
     pkt->pts = params->outputTimeStamp;
     pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
 
-    pkt->dts -= FFMAX(avctx->max_b_frames, 0) * FFMAX(avctx->ticks_per_frame, 1);
+    pkt->dts -= FFMAX(avctx->max_b_frames, 0) * FFMIN(avctx->ticks_per_frame, 1);
 
     return 0;
 }
@@ -2247,7 +2247,7 @@
 
             if (tc_data) {
                 sei_data[sei_count].payloadSize = (uint32_t)tc_size;
-                sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE;
+                sei_data[sei_count].payloadType = HEVC_SEI_TYPE_TIME_CODE;
                 sei_data[sei_count].payload = (uint8_t*)tc_data;
                 sei_count ++;
             }
diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
index 4c118d3..750ff33 100644
--- a/libavcodec/nvenc_h264.c
+++ b/libavcodec/nvenc_h264.c
@@ -193,7 +193,7 @@
     { "qblur", "-1" },
     { "qcomp", "-1" },
     { "g", "250" },
-    { "bf", "-1" },
+    { "bf", "0" },
     { "refs", "0" },
     { NULL },
 };
diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
index 031d2ef..37c2ebe 100644
--- a/libavcodec/nvenc_hevc.c
+++ b/libavcodec/nvenc_hevc.c
@@ -174,7 +174,7 @@
     { "qblur", "-1" },
     { "qcomp", "-1" },
     { "g", "250" },
-    { "bf", "-1" },
+    { "bf", "0" },
     { "refs", "0" },
     { NULL },
 };
diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index d7a3e49..3885f9a 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -23,8 +23,6 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "bytestream.h"
 #include "fft.h"
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 6e904b6..4bbf74e 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -312,7 +312,6 @@
     return &av_codec_context_class;
 }
 
-#if FF_API_GET_FRAME_CLASS
 #define FOFFSET(x) offsetof(AVFrame,x)
 
 static const AVOption frame_options[]={
@@ -328,6 +327,7 @@
 {NULL},
 };
 
+#if FF_API_COPY_CONTEXT
 static const AVClass av_frame_class = {
     .class_name              = "AVFrame",
     .item_name               = NULL,
@@ -354,6 +354,7 @@
 {NULL},
 };
 
+#if FF_API_COPY_CONTEXT
 static const AVClass av_subtitle_rect_class = {
     .class_name             = "AVSubtitleRect",
     .item_name              = NULL,
@@ -365,3 +366,4 @@
 {
     return &av_subtitle_rect_class;
 }
+#endif
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index e12159f..1b9d39a 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -140,15 +140,15 @@
 {"unofficial", "allow unofficial extensions", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_UNOFFICIAL }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
 {"experimental", "allow non-standardized experimental things", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
 {"b_qoffset", "QP offset between P- and B-frames", OFFSET(b_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E},
-{"err_detect", "set error detection flags", OFFSET(err_recognition), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_BUFFER }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_EXPLODE }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"ignore_err", "ignore errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_IGNORE_ERR }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"careful",    "consider things that violate the spec, are fast to check and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_CAREFUL }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"compliant",  "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_COMPLIANT | AV_EF_CAREFUL }, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
-{"aggressive", "consider things that a sane encoder should not do as an error", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_AGGRESSIVE | AV_EF_COMPLIANT | AV_EF_CAREFUL}, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"},
+{"err_detect", "set error detection flags", OFFSET(err_recognition), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_BUFFER }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_EXPLODE }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"ignore_err", "ignore errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_IGNORE_ERR }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"careful",    "consider things that violate the spec, are fast to check and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_CAREFUL }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"compliant",  "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_COMPLIANT | AV_EF_CAREFUL }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"aggressive", "consider things that a sane encoder should not do as an error", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_AGGRESSIVE | AV_EF_COMPLIANT | AV_EF_CAREFUL}, INT_MIN, INT_MAX, A|V|D, "err_detect"},
 {"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX},
 {"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX},
 #if FF_API_PRIVATE_OPT
@@ -208,6 +208,9 @@
 {"bitstream", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BITSTREAM }, INT_MIN, INT_MAX, V|D, "debug"},
 {"mb_type", "macroblock (MB) type", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"},
 {"qp", "per-block quantization parameter (QP)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_QP }, INT_MIN, INT_MAX, V|D, "debug"},
+#if FF_API_DEBUG_MV
+{"mv", "motion vector", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MV }, INT_MIN, INT_MAX, V|D, "debug"},
+#endif
 {"dct_coeff", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_DCT_COEFF }, INT_MIN, INT_MAX, V|D, "debug"},
 {"green_metadata", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_GREEN_MD }, INT_MIN, INT_MAX, V|D, "debug"},
 {"skip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_SKIP }, INT_MIN, INT_MAX, V|D, "debug"},
@@ -215,6 +218,10 @@
 {"er", "error recognition", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_ER }, INT_MIN, INT_MAX, V|D, "debug"},
 {"mmco", "memory management control operations (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MMCO }, INT_MIN, INT_MAX, V|D, "debug"},
 {"bugs", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUGS }, INT_MIN, INT_MAX, V|D, "debug"},
+#if FF_API_DEBUG_MV
+{"vis_qp", "visualize quantization parameter (QP), lower QP are tinted greener", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_QP }, INT_MIN, INT_MAX, V|D, "debug"},
+{"vis_mb_type", "visualize block types", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"},
+#endif
 {"buffers", "picture buffer allocations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"},
 {"thread_ops", "threading operations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|A|D, "debug"},
 {"nomc", "skip motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_NOMC }, INT_MIN, INT_MAX, V|A|D, "debug"},
@@ -441,9 +448,7 @@
 #if FF_API_ASS_TIMING
 {"ass_with_timings", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS}, INT_MIN, INT_MAX, S|D, "sub_text_format"},
 #endif
-#if FF_API_OLD_ENCDEC
 {"refcounted_frames", NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|V|D },
-#endif
 #if FF_API_SIDEDATA_ONLY_PKT
 {"side_data_only_packets", NULL, OFFSET(side_data_only_packets), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, A|V|E },
 #endif
diff --git a/libavcodec/opus.h b/libavcodec/opus.h
index b73949a..63ecd0a 100644
--- a/libavcodec/opus.h
+++ b/libavcodec/opus.h
@@ -28,7 +28,6 @@
 #include "libavutil/audio_fifo.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/frame.h"
-#include "libavutil/mem_internal.h"
 
 #include "libswresample/swresample.h"
 
@@ -102,15 +101,6 @@
     AVCodecContext *avctx;
     int output_channels;
 
-    /* number of decoded samples for this stream */
-    int decoded_samples;
-    /* current output buffers for this stream */
-    float *out[2];
-    int out_size;
-    /* Buffer with samples from this stream for synchronizing
-     * the streams when they have different resampling delays */
-    AVAudioFifo *sync_buffer;
-
     OpusRangeCoder rc;
     OpusRangeCoder redundancy_rc;
     SilkContext *silk;
@@ -125,9 +115,9 @@
     DECLARE_ALIGNED(32, float, redundancy_buf)[2][960];
     float *redundancy_output[2];
 
-    /* buffers for the next samples to be decoded */
-    float *cur_out[2];
-    int remaining_out_size;
+    /* data buffers for the final output data */
+    float *out[2];
+    int out_size;
 
     float *out_dummy;
     int    out_dummy_allocated_size;
@@ -164,6 +154,15 @@
     OpusStreamContext *streams;
     int apply_phase_inv;
 
+    /* current output buffers for each streams */
+    float **out;
+    int   *out_size;
+    /* Buffers for synchronizing the streams when they have different
+     * resampling delays */
+    AVAudioFifo **sync_buffers;
+    /* number of decoded samples for each stream */
+    int         *decoded_samples;
+
     int             nb_streams;
     int      nb_stereo_streams;
 
diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h
index 661ca25..7c1c531 100644
--- a/libavcodec/opus_celt.h
+++ b/libavcodec/opus_celt.h
@@ -33,7 +33,6 @@
 #include "mdct15.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
-#include "libavutil/mem_internal.h"
 
 #define CELT_VECTORS                 11
 #define CELT_ALLOC_STEPS             6
diff --git a/libavcodec/opus_pvq.h b/libavcodec/opus_pvq.h
index b30407f..52f9a4e 100644
--- a/libavcodec/opus_pvq.h
+++ b/libavcodec/opus_pvq.h
@@ -23,8 +23,6 @@
 #ifndef AVCODEC_OPUS_PVQ_H
 #define AVCODEC_OPUS_PVQ_H
 
-#include "libavutil/mem_internal.h"
-
 #include "opus_celt.h"
 
 #define QUANT_FN(name) uint32_t (name)(struct CeltPVQ *pvq, CeltFrame *f,            \
diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index f0d7ed6..a08758d 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -87,7 +87,7 @@
     int celt_size = av_audio_fifo_size(s->celt_delay);
     int ret, i;
     ret = swr_convert(s->swr,
-                      (uint8_t**)s->cur_out, nb_samples,
+                      (uint8_t**)s->out, nb_samples,
                       NULL, 0);
     if (ret < 0)
         return ret;
@@ -104,7 +104,7 @@
         }
         av_audio_fifo_read(s->celt_delay, (void**)s->celt_output, nb_samples);
         for (i = 0; i < s->output_channels; i++) {
-            s->fdsp->vector_fmac_scalar(s->cur_out[i],
+            s->fdsp->vector_fmac_scalar(s->out[i],
                                         s->celt_output[i], 1.0,
                                         nb_samples);
         }
@@ -112,15 +112,15 @@
 
     if (s->redundancy_idx) {
         for (i = 0; i < s->output_channels; i++)
-            opus_fade(s->cur_out[i], s->cur_out[i],
+            opus_fade(s->out[i], s->out[i],
                       s->redundancy_output[i] + 120 + s->redundancy_idx,
                       ff_celt_window2 + s->redundancy_idx, 120 - s->redundancy_idx);
         s->redundancy_idx = 0;
     }
 
-    s->cur_out[0]         += nb_samples;
-    s->cur_out[1]         += nb_samples;
-    s->remaining_out_size -= nb_samples * sizeof(float);
+    s->out[0]   += nb_samples;
+    s->out[1]   += nb_samples;
+    s->out_size -= nb_samples * sizeof(float);
 
     return 0;
 }
@@ -199,7 +199,7 @@
             return samples;
         }
         samples = swr_convert(s->swr,
-                              (uint8_t**)s->cur_out, s->packet.frame_duration,
+                              (uint8_t**)s->out, s->packet.frame_duration,
                               (const uint8_t**)s->silk_output, samples);
         if (samples < 0) {
             av_log(s->avctx, AV_LOG_ERROR, "Error resampling SILK data.\n");
@@ -240,7 +240,7 @@
 
     /* decode the CELT frame */
     if (s->packet.mode == OPUS_MODE_CELT || s->packet.mode == OPUS_MODE_HYBRID) {
-        float *out_tmp[2] = { s->cur_out[0], s->cur_out[1] };
+        float *out_tmp[2] = { s->out[0], s->out[1] };
         float **dst = (s->packet.mode == OPUS_MODE_CELT) ?
                       out_tmp : s->celt_output;
         int celt_output_samples = samples;
@@ -295,7 +295,7 @@
 
     if (s->redundancy_idx) {
         for (i = 0; i < s->output_channels; i++)
-            opus_fade(s->cur_out[i], s->cur_out[i],
+            opus_fade(s->out[i], s->out[i],
                       s->redundancy_output[i] + 120 + s->redundancy_idx,
                       ff_celt_window2 + s->redundancy_idx, 120 - s->redundancy_idx);
         s->redundancy_idx = 0;
@@ -308,8 +308,8 @@
                 return ret;
 
             for (i = 0; i < s->output_channels; i++) {
-                opus_fade(s->cur_out[i] + samples - 120 + delayed_samples,
-                          s->cur_out[i] + samples - 120 + delayed_samples,
+                opus_fade(s->out[i] + samples - 120 + delayed_samples,
+                          s->out[i] + samples - 120 + delayed_samples,
                           s->redundancy_output[i] + 120,
                           ff_celt_window2, 120 - delayed_samples);
                 if (delayed_samples)
@@ -317,10 +317,10 @@
             }
         } else {
             for (i = 0; i < s->output_channels; i++) {
-                memcpy(s->cur_out[i] + delayed_samples, s->redundancy_output[i], 120 * sizeof(float));
-                opus_fade(s->cur_out[i] + 120 + delayed_samples,
+                memcpy(s->out[i] + delayed_samples, s->redundancy_output[i], 120 * sizeof(float));
+                opus_fade(s->out[i] + 120 + delayed_samples,
                           s->redundancy_output[i] + 120,
-                          s->cur_out[i] + 120 + delayed_samples,
+                          s->out[i] + 120 + delayed_samples,
                           ff_celt_window2, 120);
             }
         }
@@ -331,15 +331,16 @@
 
 static int opus_decode_subpacket(OpusStreamContext *s,
                                  const uint8_t *buf, int buf_size,
+                                 float **out, int out_size,
                                  int nb_samples)
 {
     int output_samples = 0;
     int flush_needed   = 0;
     int i, j, ret;
 
-    s->cur_out[0]         = s->out[0];
-    s->cur_out[1]         = s->out[1];
-    s->remaining_out_size = s->out_size;
+    s->out[0]   = out[0];
+    s->out[1]   = out[1];
+    s->out_size = out_size;
 
     /* check if we need to flush the resampler */
     if (swr_is_initialized(s->swr)) {
@@ -356,16 +357,15 @@
         return 0;
 
     /* use dummy output buffers if the channel is not mapped to anything */
-    if (!s->cur_out[0] ||
-        (s->output_channels == 2 && !s->cur_out[1])) {
-        av_fast_malloc(&s->out_dummy, &s->out_dummy_allocated_size,
-                       s->remaining_out_size);
+    if (!s->out[0] ||
+        (s->output_channels == 2 && !s->out[1])) {
+        av_fast_malloc(&s->out_dummy, &s->out_dummy_allocated_size, s->out_size);
         if (!s->out_dummy)
             return AVERROR(ENOMEM);
-        if (!s->cur_out[0])
-            s->cur_out[0] = s->out_dummy;
-        if (!s->cur_out[1])
-            s->cur_out[1] = s->out_dummy;
+        if (!s->out[0])
+            s->out[0] = s->out_dummy;
+        if (!s->out[1])
+            s->out[1] = s->out_dummy;
     }
 
     /* flush the resampler if necessary */
@@ -394,19 +394,19 @@
                 return samples;
 
             for (j = 0; j < s->output_channels; j++)
-                memset(s->cur_out[j], 0, s->packet.frame_duration * sizeof(float));
+                memset(s->out[j], 0, s->packet.frame_duration * sizeof(float));
             samples = s->packet.frame_duration;
         }
         output_samples += samples;
 
         for (j = 0; j < s->output_channels; j++)
-            s->cur_out[j] += samples;
-        s->remaining_out_size -= samples * sizeof(float);
+            s->out[j] += samples;
+        s->out_size -= samples * sizeof(float);
     }
 
 finish:
-    s->cur_out[0] = s->cur_out[1] = NULL;
-    s->remaining_out_size = 0;
+    s->out[0] = s->out[1] = NULL;
+    s->out_size = 0;
 
     return output_samples;
 }
@@ -429,7 +429,7 @@
         s->out[0] =
         s->out[1] = NULL;
         delayed_samples = FFMAX(delayed_samples,
-                                s->delayed_samples + av_audio_fifo_size(s->sync_buffer));
+                                s->delayed_samples + av_audio_fifo_size(c->sync_buffers[i]));
     }
 
     /* decode the header of the first sub-packet to find out the sample count */
@@ -458,17 +458,17 @@
         return ret;
     frame->nb_samples = 0;
 
+    memset(c->out, 0, c->nb_streams * 2 * sizeof(*c->out));
     for (i = 0; i < avctx->channels; i++) {
         ChannelMap *map = &c->channel_maps[i];
         if (!map->copy)
-            c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i];
+            c->out[2 * map->stream_idx + map->channel_idx] = (float*)frame->extended_data[i];
     }
 
     /* read the data from the sync buffers */
     for (i = 0; i < c->nb_streams; i++) {
-        OpusStreamContext *s = &c->streams[i];
-        float          **out = s->out;
-        int sync_size = av_audio_fifo_size(s->sync_buffer);
+        float          **out = c->out + 2 * i;
+        int sync_size = av_audio_fifo_size(c->sync_buffers[i]);
 
         float sync_dummy[32];
         int out_dummy = (!out[0]) | ((!out[1]) << 1);
@@ -480,7 +480,7 @@
         if (out_dummy && sync_size > FF_ARRAY_ELEMS(sync_dummy))
             return AVERROR_BUG;
 
-        ret = av_audio_fifo_read(s->sync_buffer, (void**)out, sync_size);
+        ret = av_audio_fifo_read(c->sync_buffers[i], (void**)out, sync_size);
         if (ret < 0)
             return ret;
 
@@ -493,7 +493,7 @@
         else
             out[1] += ret;
 
-        s->out_size = frame->linesize[0] - ret * sizeof(float);
+        c->out_size[i] = frame->linesize[0] - ret * sizeof(float);
     }
 
     /* decode each sub-packet */
@@ -516,10 +516,10 @@
         }
 
         ret = opus_decode_subpacket(&c->streams[i], buf, s->packet.data_size,
-                                    coded_samples);
+                                    c->out + 2 * i, c->out_size[i], coded_samples);
         if (ret < 0)
             return ret;
-        s->decoded_samples = ret;
+        c->decoded_samples[i] = ret;
         decoded_samples       = FFMIN(decoded_samples, ret);
 
         buf      += s->packet.packet_size;
@@ -528,14 +528,13 @@
 
     /* buffer the extra samples */
     for (i = 0; i < c->nb_streams; i++) {
-        OpusStreamContext *s = &c->streams[i];
-        int   buffer_samples = s->decoded_samples - decoded_samples;
+        int buffer_samples = c->decoded_samples[i] - decoded_samples;
         if (buffer_samples) {
-            float *buf[2] = { s->out[0] ? s->out[0] : (float*)frame->extended_data[0],
-                              s->out[1] ? s->out[1] : (float*)frame->extended_data[0] };
+            float *buf[2] = { c->out[2 * i + 0] ? c->out[2 * i + 0] : (float*)frame->extended_data[0],
+                              c->out[2 * i + 1] ? c->out[2 * i + 1] : (float*)frame->extended_data[0] };
             buf[0] += decoded_samples;
             buf[1] += decoded_samples;
-            ret = av_audio_fifo_write(s->sync_buffer, (void**)buf, buffer_samples);
+            ret = av_audio_fifo_write(c->sync_buffers[i], (void**)buf, buffer_samples);
             if (ret < 0)
                 return ret;
         }
@@ -577,10 +576,11 @@
         memset(&s->packet, 0, sizeof(s->packet));
         s->delayed_samples = 0;
 
-        av_audio_fifo_drain(s->celt_delay, av_audio_fifo_size(s->celt_delay));
+        if (s->celt_delay)
+            av_audio_fifo_drain(s->celt_delay, av_audio_fifo_size(s->celt_delay));
         swr_close(s->swr);
 
-        av_audio_fifo_drain(s->sync_buffer, av_audio_fifo_size(s->sync_buffer));
+        av_audio_fifo_drain(c->sync_buffers[i], av_audio_fifo_size(c->sync_buffers[i]));
 
         ff_silk_flush(s->silk);
         ff_celt_flush(s->celt);
@@ -601,13 +601,21 @@
         av_freep(&s->out_dummy);
         s->out_dummy_allocated_size = 0;
 
-        av_audio_fifo_free(s->sync_buffer);
         av_audio_fifo_free(s->celt_delay);
         swr_free(&s->swr);
     }
 
     av_freep(&c->streams);
 
+    if (c->sync_buffers) {
+        for (i = 0; i < c->nb_streams; i++)
+            av_audio_fifo_free(c->sync_buffers[i]);
+    }
+    av_freep(&c->sync_buffers);
+    av_freep(&c->decoded_samples);
+    av_freep(&c->out);
+    av_freep(&c->out_size);
+
     c->nb_streams = 0;
 
     av_freep(&c->channel_maps);
@@ -630,14 +638,21 @@
 
     /* find out the channel configuration */
     ret = ff_opus_parse_extradata(avctx, c);
-    if (ret < 0)
+    if (ret < 0) {
+        av_freep(&c->fdsp);
         return ret;
+    }
 
     /* allocate and init each independent decoder */
     c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams));
-    if (!c->streams) {
+    c->out             = av_mallocz_array(c->nb_streams, 2 * sizeof(*c->out));
+    c->out_size        = av_mallocz_array(c->nb_streams, sizeof(*c->out_size));
+    c->sync_buffers    = av_mallocz_array(c->nb_streams, sizeof(*c->sync_buffers));
+    c->decoded_samples = av_mallocz_array(c->nb_streams, sizeof(*c->decoded_samples));
+    if (!c->streams || !c->sync_buffers || !c->decoded_samples || !c->out || !c->out_size) {
         c->nb_streams = 0;
-        return AVERROR(ENOMEM);
+        ret = AVERROR(ENOMEM);
+        goto fail;
     }
 
     for (i = 0; i < c->nb_streams; i++) {
@@ -658,7 +673,7 @@
 
         s->swr =swr_alloc();
         if (!s->swr)
-            return AVERROR(ENOMEM);
+            goto fail;
 
         layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
         av_opt_set_int(s->swr, "in_sample_fmt",      avctx->sample_fmt,  0);
@@ -670,24 +685,31 @@
 
         ret = ff_silk_init(avctx, &s->silk, s->output_channels);
         if (ret < 0)
-            return ret;
+            goto fail;
 
         ret = ff_celt_init(avctx, &s->celt, s->output_channels, c->apply_phase_inv);
         if (ret < 0)
-            return ret;
+            goto fail;
 
         s->celt_delay = av_audio_fifo_alloc(avctx->sample_fmt,
                                             s->output_channels, 1024);
-        if (!s->celt_delay)
-            return AVERROR(ENOMEM);
+        if (!s->celt_delay) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
 
-        s->sync_buffer = av_audio_fifo_alloc(avctx->sample_fmt,
-                                             s->output_channels, 32);
-        if (!s->sync_buffer)
-            return AVERROR(ENOMEM);
+        c->sync_buffers[i] = av_audio_fifo_alloc(avctx->sample_fmt,
+                                                 s->output_channels, 32);
+        if (!c->sync_buffers[i]) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
     }
 
     return 0;
+fail:
+    opus_decode_close(avctx);
+    return ret;
 }
 
 #define OFFSET(x) offsetof(OpusContext, x)
@@ -716,5 +738,4 @@
     .decode          = opus_decode_packet,
     .flush           = opus_decode_flush,
     .capabilities    = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_CHANNEL_CONF,
-    .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 8bc9e9d..953749a 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -25,7 +25,6 @@
 #include "opustab.h"
 
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "internal.h"
 #include "bytestream.h"
diff --git a/libavcodec/opusenc_psy.h b/libavcodec/opusenc_psy.h
index d4fb096..b91e4f1 100644
--- a/libavcodec/opusenc_psy.h
+++ b/libavcodec/opusenc_psy.h
@@ -22,8 +22,6 @@
 #ifndef AVCODEC_OPUSENC_PSY_H
 #define AVCODEC_OPUSENC_PSY_H
 
-#include "libavutil/mem_internal.h"
-
 #include "opusenc.h"
 #include "opusenc_utils.h"
 #include "libavfilter/window_func.h"
diff --git a/libavcodec/opustab.c b/libavcodec/opustab.c
index b23ca4f..64070f8 100644
--- a/libavcodec/opustab.c
+++ b/libavcodec/opustab.c
@@ -20,8 +20,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "opustab.h"
 
 const uint8_t ff_opus_default_coupled_streams[] = { 0, 1, 1, 2, 2, 2, 2, 3 };
@@ -952,7 +950,7 @@
     16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048
 };
 
-static const uint32_t celt_pvq_u[1272] = {
+const uint32_t ff_celt_pvq_u[1272] = {
     /* N = 0, K = 0...176 */
     1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1132,7 +1130,7 @@
     1.00000000f, 1.00000000f, 1.00000000f,
 };
 
-const float *const ff_celt_window = &ff_celt_window_padded[8];
+const float *ff_celt_window = &ff_celt_window_padded[8];
 
 /* square of the window, used for the postfilter */
 const float ff_celt_window2[120] = {
@@ -1155,9 +1153,9 @@
 };
 
 const uint32_t * const ff_celt_pvq_u_row[15] = {
-    celt_pvq_u +    0, celt_pvq_u +  176, celt_pvq_u +  351,
-    celt_pvq_u +  525, celt_pvq_u +  698, celt_pvq_u +  870,
-    celt_pvq_u + 1041, celt_pvq_u + 1131, celt_pvq_u + 1178,
-    celt_pvq_u + 1207, celt_pvq_u + 1226, celt_pvq_u + 1240,
-    celt_pvq_u + 1248, celt_pvq_u + 1254, celt_pvq_u + 1257
+    ff_celt_pvq_u +    0, ff_celt_pvq_u +  176, ff_celt_pvq_u +  351,
+    ff_celt_pvq_u +  525, ff_celt_pvq_u +  698, ff_celt_pvq_u +  870,
+    ff_celt_pvq_u + 1041, ff_celt_pvq_u + 1131, ff_celt_pvq_u + 1178,
+    ff_celt_pvq_u + 1207, ff_celt_pvq_u + 1226, ff_celt_pvq_u + 1240,
+    ff_celt_pvq_u + 1248, ff_celt_pvq_u + 1254, ff_celt_pvq_u + 1257
 };
diff --git a/libavcodec/opustab.h b/libavcodec/opustab.h
index 4525837..892126b 100644
--- a/libavcodec/opustab.h
+++ b/libavcodec/opustab.h
@@ -152,11 +152,12 @@
 extern const uint8_t  ff_celt_hadamard_order[];
 
 extern const uint16_t ff_celt_qn_exp2[];
+extern const uint32_t ff_celt_pvq_u[1272];
 
 extern const float    ff_celt_postfilter_taps[3][3];
 
 extern const float    ff_celt_window2[120];
-extern const float *const ff_celt_window;
+extern const float   *ff_celt_window;
 
 extern const uint32_t * const ff_celt_pvq_u_row[15];
 
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 3d9013d..b9d4c9c 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -305,11 +305,7 @@
 
 typedef struct AVPacketSideData {
     uint8_t *data;
-#if FF_API_BUFFER_SIZE_T
     int      size;
-#else
-    size_t   size;
-#endif
     enum AVPacketSideDataType type;
 } AVPacketSideData;
 
@@ -563,11 +559,7 @@
  * @return pointer to fresh allocated data or NULL otherwise
  */
 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-#if FF_API_BUFFER_SIZE_T
                                  int size);
-#else
-                                 size_t size);
-#endif
 
 /**
  * Wrap an existing array as a packet side data.
@@ -594,11 +586,7 @@
  * @return 0 on success, < 0 on failure
  */
 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-#if FF_API_BUFFER_SIZE_T
                                int size);
-#else
-                               size_t size);
-#endif
 
 /**
  * Get side information from packet.
@@ -610,11 +598,7 @@
  * @return pointer to data if present or NULL otherwise
  */
 uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
-#if FF_API_BUFFER_SIZE_T
                                  int *size);
-#else
-                                 size_t *size);
-#endif
 
 #if FF_API_MERGE_SD_API
 attribute_deprecated
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index f4bc00d..a63f532 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -186,7 +186,6 @@
     return index;
 }
 
-#if FF_API_PARSER_CHANGE
 int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
                      uint8_t **poutbuf, int *poutbuf_size,
                      const uint8_t *buf, int buf_size, int keyframe)
@@ -221,7 +220,7 @@
 
     return 0;
 }
-#endif
+
 void av_parser_close(AVCodecParserContext *s)
 {
     if (s) {
diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c
index 3d944f5..83271d9 100644
--- a/libavcodec/parsers.c
+++ b/libavcodec/parsers.c
@@ -33,11 +33,9 @@
 extern AVCodecParser ff_bmp_parser;
 extern AVCodecParser ff_cavsvideo_parser;
 extern AVCodecParser ff_cook_parser;
-extern AVCodecParser ff_cri_parser;
 extern AVCodecParser ff_dca_parser;
 extern AVCodecParser ff_dirac_parser;
 extern AVCodecParser ff_dnxhd_parser;
-extern AVCodecParser ff_dolby_e_parser;
 extern AVCodecParser ff_dpx_parser;
 extern AVCodecParser ff_dvaudio_parser;
 extern AVCodecParser ff_dvbsub_parser;
@@ -73,13 +71,11 @@
 extern AVCodecParser ff_vp8_parser;
 extern AVCodecParser ff_vp9_parser;
 extern AVCodecParser ff_webp_parser;
-extern AVCodecParser ff_xbm_parser;
 extern AVCodecParser ff_xma_parser;
 
 #include "libavcodec/parser_list.c"
 
 #if FF_API_NEXT
-FF_DISABLE_DEPRECATION_WARNINGS
 static AVOnce av_parser_next_init = AV_ONCE_INIT;
 
 static void av_parser_init_next(void)
@@ -107,7 +103,6 @@
 {
     ff_thread_once(&av_parser_next_init, av_parser_init_next);
 }
-FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 const AVCodecParser *av_parser_iterate(void **opaque)
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 19d04e9..7f0af85 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -419,14 +419,6 @@
         for (; n > 0; n--)
             *samples++ = *src++ + 128;
         break;
-    case AV_CODEC_ID_PCM_SGA:
-        for (; n > 0; n--) {
-            int sign = *src >> 7;
-            int magn = *src & 0x7f;
-            *samples++ = sign ? 128 - magn : 128 + magn;
-            src++;
-        }
-        break;
     case AV_CODEC_ID_PCM_S8_PLANAR:
         n /= avctx->channels;
         for (c = 0; c < avctx->channels; c++) {
@@ -630,4 +622,3 @@
 PCM_CODEC  (PCM_S64BE,        AV_SAMPLE_FMT_S64, pcm_s64be,        "PCM signed 64-bit big-endian");
 PCM_CODEC  (PCM_S64LE,        AV_SAMPLE_FMT_S64, pcm_s64le,        "PCM signed 64-bit little-endian");
 PCM_CODEC  (PCM_VIDC,         AV_SAMPLE_FMT_S16, pcm_vidc,         "PCM Archimedes VIDC");
-PCM_DECODER(PCM_SGA,          AV_SAMPLE_FMT_U8,  pcm_sga,          "PCM SGA");
diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c
index 65b2929..5c73589 100644
--- a/libavcodec/pgxdec.c
+++ b/libavcodec/pgxdec.c
@@ -95,7 +95,7 @@
 }
 
 #define WRITE_FRAME(D, PIXEL, suffix)                                                       \
-    static inline void write_frame_ ##D(AVFrame *frame, GetByteContext *g, \
+    static inline void write_frame_ ##D(AVPacket *avpkt, AVFrame *frame, GetByteContext *g, \
                                         int width, int height, int sign, int depth)         \
     {                                                                                       \
         int i, j;                                                                           \
@@ -151,9 +151,9 @@
     p->key_frame = 1;
     avctx->bits_per_raw_sample = depth;
     if (bpp == 8)
-        write_frame_8(p, &g, width, height, sign, depth);
+        write_frame_8(avpkt, p, &g, width, height, sign, depth);
     else if (bpp == 16)
-        write_frame_16(p, &g, width, height, sign, depth);
+        write_frame_16(avpkt, p, &g, width, height, sign, depth);
     *got_frame = 1;
     return 0;
 }
diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index ad9d830..42acd68 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -525,7 +525,7 @@
 }
 
 static int decode_plane(AVCodecContext *avctx, int plane,
-                        const AVPacket *avpkt, AVFrame *frame)
+                        AVPacket *avpkt, AVFrame *frame)
 {
     PixletContext *ctx = avctx->priv_data;
     ptrdiff_t stride   = frame->linesize[plane] / 2;
diff --git a/libavcodec/png.h b/libavcodec/png.h
index a155601..e967fcf 100644
--- a/libavcodec/png.h
+++ b/libavcodec/png.h
@@ -24,8 +24,6 @@
 
 #include <stdint.h>
 
-#include "pngdsp.h"
-
 #define PNG_COLOR_MASK_PALETTE    1
 #define PNG_COLOR_MASK_COLOR      2
 #define PNG_COLOR_MASK_ALPHA      4
@@ -63,7 +61,4 @@
 
 void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
 
-void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
-                       uint8_t *src, uint8_t *last, int size, int bpp);
-
 #endif /* AVCODEC_PNG_H */
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index a5a71ef..395b86b 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -54,6 +54,7 @@
     AVCodecContext *avctx;
 
     GetByteContext gb;
+    ThreadFrame previous_picture;
     ThreadFrame last_picture;
     ThreadFrame picture;
 
@@ -249,8 +250,8 @@
     }
 
 /* NOTE: 'dst' can be equal to 'last' */
-void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
-                       uint8_t *src, uint8_t *last, int size, int bpp)
+static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
+                           uint8_t *src, uint8_t *last, int size, int bpp)
 {
     int i, p, r, g, b, a;
 
@@ -342,8 +343,8 @@
         else
             last_row = ptr - s->image_linesize;
 
-        ff_png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1,
-                          last_row, s->row_size, s->bpp);
+        png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1,
+                       last_row, s->row_size, s->bpp);
         /* loco lags by 1 row so that it doesn't interfere with top prediction */
         if (s->filter_type == PNG_FILTER_TYPE_LOCO && s->y > 0) {
             if (s->bit_depth == 16) {
@@ -376,8 +377,8 @@
                  * wait for the next one */
                 if (got_line)
                     break;
-                ff_png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
-                                  s->last_row, s->pass_row_size, s->bpp);
+                png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
+                               s->last_row, s->pass_row_size, s->bpp);
                 FFSWAP(uint8_t *, s->last_row, s->tmp_row);
                 FFSWAP(unsigned int, s->last_row_size, s->tmp_row_size);
                 got_line = 1;
@@ -710,10 +711,13 @@
             s->bpp += byte_depth;
         }
 
-        ff_thread_release_buffer(avctx, &s->picture);
         if ((ret = ff_thread_get_buffer(avctx, &s->picture, AV_GET_BUFFER_FLAG_REF)) < 0)
             return ret;
-
+        if (avctx->codec_id == AV_CODEC_ID_APNG && s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) {
+            ff_thread_release_buffer(avctx, &s->previous_picture);
+            if ((ret = ff_thread_get_buffer(avctx, &s->previous_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
+                return ret;
+        }
         p->pict_type        = AV_PICTURE_TYPE_I;
         p->key_frame        = 1;
         p->interlaced_frame = !!s->interlace_type;
@@ -1016,7 +1020,7 @@
         return AVERROR_INVALIDDATA;
     }
 
-    if ((sequence_number == 0 || !s->last_picture.f->data[0]) &&
+    if ((sequence_number == 0 || !s->previous_picture.f->data[0]) &&
         dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
         // No previous frame to revert to for the first frame
         // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND
@@ -1084,23 +1088,23 @@
     if (!buffer)
         return AVERROR(ENOMEM);
 
-    ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
 
-    // need to reset a rectangle to background:
-    // create a new writable copy
-    if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
-        int ret = av_frame_make_writable(s->last_picture.f);
-        if (ret < 0)
-            return ret;
+    // Do the disposal operation specified by the last frame on the frame
+    if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) {
+        ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
+        memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * s->height);
 
-        for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) {
-            memset(s->last_picture.f->data[0] + s->image_linesize * y +
-                   s->bpp * s->last_x_offset, 0, s->bpp * s->last_w);
-        }
+        if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND)
+            for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; ++y)
+                memset(buffer + s->image_linesize * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w);
+
+        memcpy(s->previous_picture.f->data[0], buffer, s->image_linesize * s->height);
+        ff_thread_report_progress(&s->previous_picture, INT_MAX, 0);
+    } else {
+        ff_thread_await_progress(&s->previous_picture, INT_MAX, 0);
+        memcpy(buffer, s->previous_picture.f->data[0], s->image_linesize * s->height);
     }
 
-    memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * s->height);
-
     // Perform blending
     if (s->blend_op == APNG_BLEND_OP_SOURCE) {
         for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) {
@@ -1179,7 +1183,7 @@
 }
 
 static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
-                               AVFrame *p, const AVPacket *avpkt)
+                               AVFrame *p, AVPacket *avpkt)
 {
     const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
     AVDictionary **metadatap = NULL;
@@ -1444,17 +1448,22 @@
             if (CONFIG_PNG_DECODER && avctx->codec_id != AV_CODEC_ID_APNG)
                 handle_p_frame_png(s, p);
             else if (CONFIG_APNG_DECODER &&
+                     s->previous_picture.f->width == p->width  &&
+                     s->previous_picture.f->height== p->height &&
+                     s->previous_picture.f->format== p->format &&
                      avctx->codec_id == AV_CODEC_ID_APNG &&
                      (ret = handle_p_frame_apng(avctx, s, p)) < 0)
                 goto fail;
         }
     }
     ff_thread_report_progress(&s->picture, INT_MAX, 0);
+    ff_thread_report_progress(&s->previous_picture, INT_MAX, 0);
 
     return 0;
 
 fail:
     ff_thread_report_progress(&s->picture, INT_MAX, 0);
+    ff_thread_report_progress(&s->previous_picture, INT_MAX, 0);
     return ret;
 }
 
@@ -1466,10 +1475,14 @@
     PNGDecContext *const s = avctx->priv_data;
     const uint8_t *buf     = avpkt->data;
     int buf_size           = avpkt->size;
-    AVFrame *p = s->picture.f;
+    AVFrame *p;
     int64_t sig;
     int ret;
 
+    ff_thread_release_buffer(avctx, &s->last_picture);
+    FFSWAP(ThreadFrame, s->picture, s->last_picture);
+    p = s->picture.f;
+
     bytestream2_init(&s->gb, buf, buf_size);
 
     /* check signature */
@@ -1506,11 +1519,6 @@
     if ((ret = av_frame_ref(data, s->picture.f)) < 0)
         goto the_end;
 
-    if (!(avctx->active_thread_type & FF_THREAD_FRAME)) {
-        ff_thread_release_buffer(avctx, &s->last_picture);
-        FFSWAP(ThreadFrame, s->picture, s->last_picture);
-    }
-
     *got_frame = 1;
 
     ret = bytestream2_tell(&s->gb);
@@ -1528,7 +1536,11 @@
 {
     PNGDecContext *const s = avctx->priv_data;
     int ret;
-    AVFrame *p = s->picture.f;
+    AVFrame *p;
+
+    ff_thread_release_buffer(avctx, &s->last_picture);
+    FFSWAP(ThreadFrame, s->picture, s->last_picture);
+    p = s->picture.f;
 
     if (!(s->hdr_state & PNG_IHDR)) {
         if (!avctx->extradata_size)
@@ -1564,15 +1576,6 @@
     if ((ret = av_frame_ref(data, s->picture.f)) < 0)
         goto end;
 
-    if (!(avctx->active_thread_type & FF_THREAD_FRAME)) {
-        if (s->dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
-            ff_thread_release_buffer(avctx, &s->picture);
-        } else if (s->dispose_op == APNG_DISPOSE_OP_NONE) {
-            ff_thread_release_buffer(avctx, &s->last_picture);
-            FFSWAP(ThreadFrame, s->picture, s->last_picture);
-        }
-    }
-
     *got_frame = 1;
     ret = bytestream2_tell(&s->gb);
 
@@ -1582,19 +1585,163 @@
 }
 #endif
 
+#if CONFIG_LSCR_DECODER
+static int decode_frame_lscr(AVCodecContext *avctx,
+                             void *data, int *got_frame,
+                             AVPacket *avpkt)
+{
+    PNGDecContext *const s = avctx->priv_data;
+    GetByteContext *gb = &s->gb;
+    AVFrame *frame = data;
+    int ret, nb_blocks, offset = 0;
+
+    if (avpkt->size < 2)
+        return AVERROR_INVALIDDATA;
+    if (avpkt->size == 2)
+        return 0;
+
+    bytestream2_init(gb, avpkt->data, avpkt->size);
+
+    if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
+        return ret;
+
+    nb_blocks = bytestream2_get_le16(gb);
+    if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * (12 + 8))
+        return AVERROR_INVALIDDATA;
+
+    if (s->last_picture.f->data[0]) {
+        ret = av_frame_copy(frame, s->last_picture.f);
+        if (ret < 0)
+            return ret;
+    }
+
+    for (int b = 0; b < nb_blocks; b++) {
+        int x, y, x2, y2, w, h, left;
+        uint32_t csize, size;
+
+        s->zstream.zalloc = ff_png_zalloc;
+        s->zstream.zfree  = ff_png_zfree;
+        s->zstream.opaque = NULL;
+
+        if ((ret = inflateInit(&s->zstream)) != Z_OK) {
+            av_log(avctx, AV_LOG_ERROR, "inflateInit returned error %d\n", ret);
+            ret = AVERROR_EXTERNAL;
+            goto end;
+        }
+
+        bytestream2_seek(gb, 2 + b * 12, SEEK_SET);
+
+        x = bytestream2_get_le16(gb);
+        y = bytestream2_get_le16(gb);
+        x2 = bytestream2_get_le16(gb);
+        y2 = bytestream2_get_le16(gb);
+        s->width  = s->cur_w = w = x2-x;
+        s->height = s->cur_h = h = y2-y;
+
+        if (w <= 0 || x < 0 || x >= avctx->width || w + x > avctx->width ||
+            h <= 0 || y < 0 || y >= avctx->height || h + y > avctx->height) {
+            ret = AVERROR_INVALIDDATA;
+            goto end;
+        }
+
+        size = bytestream2_get_le32(gb);
+
+        frame->key_frame = (nb_blocks == 1) &&
+                           (w == avctx->width) &&
+                           (h == avctx->height) &&
+                           (x == 0) && (y == 0);
+
+        bytestream2_seek(gb, 2 + nb_blocks * 12 + offset, SEEK_SET);
+        csize = bytestream2_get_be32(gb);
+        if (bytestream2_get_le32(gb) != MKTAG('I', 'D', 'A', 'T')) {
+            ret = AVERROR_INVALIDDATA;
+            goto end;
+        }
+
+        offset += size;
+        left = size;
+
+        s->y                 = 0;
+        s->row_size          = w * 3;
+
+        av_fast_padded_malloc(&s->buffer, &s->buffer_size, s->row_size + 16);
+        if (!s->buffer) {
+            ret = AVERROR(ENOMEM);
+            goto end;
+        }
+
+        av_fast_padded_malloc(&s->last_row, &s->last_row_size, s->row_size);
+        if (!s->last_row) {
+            ret = AVERROR(ENOMEM);
+            goto end;
+        }
+
+        s->crow_size         = w * 3 + 1;
+        s->crow_buf          = s->buffer + 15;
+        s->zstream.avail_out = s->crow_size;
+        s->zstream.next_out  = s->crow_buf;
+        s->image_buf         = frame->data[0] + (avctx->height - y - 1) * frame->linesize[0] + x * 3;
+        s->image_linesize    =-frame->linesize[0];
+        s->bpp               = 3;
+        s->pic_state         = 0;
+
+        while (left > 16) {
+            ret = png_decode_idat(s, csize);
+            if (ret < 0)
+                goto end;
+            left -= csize + 16;
+            if (left > 16) {
+                bytestream2_skip(gb, 4);
+                csize = bytestream2_get_be32(gb);
+                if (bytestream2_get_le32(gb) != MKTAG('I', 'D', 'A', 'T')) {
+                    ret = AVERROR_INVALIDDATA;
+                    goto end;
+                }
+            }
+        }
+
+        inflateEnd(&s->zstream);
+    }
+
+    frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+
+    av_frame_unref(s->last_picture.f);
+    if ((ret = av_frame_ref(s->last_picture.f, frame)) < 0)
+        return ret;
+
+    *got_frame = 1;
+end:
+    inflateEnd(&s->zstream);
+
+    if (ret < 0)
+        return ret;
+    return avpkt->size;
+}
+
+static void decode_flush(AVCodecContext *avctx)
+{
+    PNGDecContext *s = avctx->priv_data;
+
+    av_frame_unref(s->last_picture.f);
+}
+
+#endif
+
 #if HAVE_THREADS
 static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
 {
     PNGDecContext *psrc = src->priv_data;
     PNGDecContext *pdst = dst->priv_data;
-    ThreadFrame *src_frame = NULL;
     int ret;
 
     if (dst == src)
         return 0;
 
+    ff_thread_release_buffer(dst, &pdst->picture);
+    if (psrc->picture.f->data[0] &&
+        (ret = ff_thread_ref_frame(&pdst->picture, &psrc->picture)) < 0)
+        return ret;
     if (CONFIG_APNG_DECODER && dst->codec_id == AV_CODEC_ID_APNG) {
-
         pdst->width             = psrc->width;
         pdst->height            = psrc->height;
         pdst->bit_depth         = psrc->bit_depth;
@@ -1614,15 +1761,15 @@
         memcpy(pdst->palette, psrc->palette, sizeof(pdst->palette));
 
         pdst->hdr_state |= psrc->hdr_state;
-    }
 
-    src_frame = psrc->dispose_op == APNG_DISPOSE_OP_NONE ?
-                &psrc->picture : &psrc->last_picture;
+        ff_thread_release_buffer(dst, &pdst->last_picture);
+        if (psrc->last_picture.f->data[0] &&
+            (ret = ff_thread_ref_frame(&pdst->last_picture, &psrc->last_picture)) < 0)
+            return ret;
 
-    ff_thread_release_buffer(dst, &pdst->last_picture);
-    if (src_frame && src_frame->f->data[0]) {
-        ret = ff_thread_ref_frame(&pdst->last_picture, src_frame);
-        if (ret < 0)
+        ff_thread_release_buffer(dst, &pdst->previous_picture);
+        if (psrc->previous_picture.f->data[0] &&
+            (ret = ff_thread_ref_frame(&pdst->previous_picture, &psrc->previous_picture)) < 0)
             return ret;
     }
 
@@ -1636,10 +1783,15 @@
 
     avctx->color_range = AVCOL_RANGE_JPEG;
 
+    if (avctx->codec_id == AV_CODEC_ID_LSCR)
+        avctx->pix_fmt = AV_PIX_FMT_BGR24;
+
     s->avctx = avctx;
+    s->previous_picture.f = av_frame_alloc();
     s->last_picture.f = av_frame_alloc();
     s->picture.f = av_frame_alloc();
-    if (!s->last_picture.f || !s->picture.f) {
+    if (!s->previous_picture.f || !s->last_picture.f || !s->picture.f) {
+        av_frame_free(&s->previous_picture.f);
         av_frame_free(&s->last_picture.f);
         av_frame_free(&s->picture.f);
         return AVERROR(ENOMEM);
@@ -1654,6 +1806,8 @@
 {
     PNGDecContext *s = avctx->priv_data;
 
+    ff_thread_release_buffer(avctx, &s->previous_picture);
+    av_frame_free(&s->previous_picture.f);
     ff_thread_release_buffer(avctx, &s->last_picture);
     av_frame_free(&s->last_picture.f);
     ff_thread_release_buffer(avctx, &s->picture);
@@ -1701,3 +1855,20 @@
                       FF_CODEC_CAP_ALLOCATE_PROGRESS,
 };
 #endif
+
+#if CONFIG_LSCR_DECODER
+AVCodec ff_lscr_decoder = {
+    .name           = "lscr",
+    .long_name      = NULL_IF_CONFIG_SMALL("LEAD Screen Capture"),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_LSCR,
+    .priv_data_size = sizeof(PNGDecContext),
+    .init           = png_dec_init,
+    .close          = png_dec_end,
+    .decode         = decode_frame_lscr,
+    .flush          = decode_flush,
+    .capabilities   = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
+    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_ALLOCATE_PROGRESS,
+};
+#endif
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index eebb164..efcae8c 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -1174,7 +1174,7 @@
         AV_PIX_FMT_PAL8,
         AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A,
         AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_YA16BE,
-        AV_PIX_FMT_NONE
+        AV_PIX_FMT_MONOBLACK, AV_PIX_FMT_NONE
     },
     .priv_class     = &apngenc_class,
 };
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 958f2a3..aad23c7 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -72,7 +72,6 @@
         s->bytestream[0] != 'P' ||
         (s->bytestream[1] < '1' ||
          s->bytestream[1] > '7' &&
-         s->bytestream[1] != 'f' &&
          s->bytestream[1] != 'F')) {
         s->bytestream += s->bytestream_end > s->bytestream;
         s->bytestream += s->bytestream_end > s->bytestream;
@@ -83,8 +82,6 @@
 
     if (buf1[1] == 'F') {
         avctx->pix_fmt = AV_PIX_FMT_GBRPF32;
-    } else if (buf1[1] == 'f') {
-        avctx->pix_fmt = AV_PIX_FMT_GRAYF32;
     } else if (s->type==1 || s->type==4) {
         avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
     } else if (s->type==2 || s->type==5) {
@@ -180,7 +177,7 @@
     if (ret < 0)
         return ret;
 
-    if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 || avctx->pix_fmt == AV_PIX_FMT_GRAYF32) {
+    if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32) {
         pnm_get(s, buf1, sizeof(buf1));
         if (av_sscanf(buf1, "%f", &s->scale) != 1 || s->scale == 0.0 || !isfinite(s->scale)) {
             av_log(avctx, AV_LOG_ERROR, "Invalid scale.\n");
@@ -221,8 +218,7 @@
         return AVERROR_INVALIDDATA;
 
     /* more check if YUV420 */
-    if ((av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) &&
-        avctx->pix_fmt != AV_PIX_FMT_GBRPF32) {
+    if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
         if ((avctx->width & 1) != 0)
             return AVERROR_INVALIDDATA;
         h = (avctx->height * 2);
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index f3be6d6..d19dbfe 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -109,10 +109,8 @@
         if (next == END_NOT_FOUND)
             pnmpc->ascii_scan = sync - pnmctx.bytestream + skip;
     } else {
-        int ret = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
-        next = pnmctx.bytestream - pnmctx.bytestream_start + skip;
-        if (ret >= 0)
-            next += ret;
+        next = pnmctx.bytestream - pnmctx.bytestream_start + skip
+               + av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
     }
     if (next != END_NOT_FOUND && pnmctx.bytestream_start != buf + skip)
         next -= pc->index;
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index 4d5ce0b..9add5cf 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -297,30 +297,6 @@
             }
         }
         break;
-    case AV_PIX_FMT_GRAYF32:
-        if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
-            return AVERROR_INVALIDDATA;
-        scale = 1.f / s->scale;
-        if (s->endian) {
-            float *g = (float *)p->data[0];
-            for (int i = 0; i < avctx->height; i++) {
-                for (int j = 0; j < avctx->width; j++) {
-                    g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
-                    s->bytestream += 4;
-                }
-                g += p->linesize[0] / 4;
-            }
-        } else {
-            float *g = (float *)p->data[0];
-            for (int i = 0; i < avctx->height; i++) {
-                for (int j = 0; j < avctx->width; j++) {
-                    g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
-                    s->bytestream += 4;
-                }
-                g += p->linesize[0] / 4;
-            }
-        }
-        break;
     }
     *got_frame = 1;
 
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 276504b..7bb42c5 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
@@ -78,46 +77,19 @@
         n  = avctx->width * 2;
         h1 = (h * 3) / 2;
         break;
-    case AV_PIX_FMT_GBRPF32:
-        c  = 'F';
-        n  = avctx->width * 4;
-        break;
     default:
         return -1;
     }
     snprintf(bytestream, bytestream_end - bytestream,
              "P%c\n%d %d\n", c, avctx->width, h1);
     bytestream += strlen(bytestream);
-    if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32)
-        snprintf(bytestream, bytestream_end - bytestream,
-                 "%f\n", avctx->pix_fmt == AV_PIX_FMT_GBRPF32BE ? 1.f: -1.f);
-    bytestream += strlen(bytestream);
-    if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE &&
-        avctx->pix_fmt != AV_PIX_FMT_GBRPF32) {
+    if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE) {
         int maxdepth = (1 << av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth) - 1;
         snprintf(bytestream, bytestream_end - bytestream,
                  "%d\n", maxdepth);
         bytestream += strlen(bytestream);
     }
 
-    if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32) {
-        float *r = (float *)p->data[2];
-        float *g = (float *)p->data[0];
-        float *b = (float *)p->data[1];
-
-        for (int i = 0; i < avctx->height; i++) {
-            for (int j = 0; j < avctx->width; j++) {
-                AV_WN32(bytestream + 0, av_float2int(r[j]));
-                AV_WN32(bytestream + 4, av_float2int(g[j]));
-                AV_WN32(bytestream + 8, av_float2int(b[j]));
-                bytestream += 12;
-            }
-
-            r += p->linesize[2] / 4;
-            g += p->linesize[0] / 4;
-            b += p->linesize[1] / 4;
-        }
-    } else {
     ptr      = p->data[0];
     linesize = p->linesize[0];
     for (i = 0; i < h; i++) {
@@ -125,7 +97,6 @@
         bytestream += n;
         ptr        += linesize;
     }
-    }
 
     if (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16BE) {
         h >>= 1;
@@ -218,17 +189,3 @@
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
-
-#if CONFIG_PFM_ENCODER
-AVCodec ff_pfm_encoder = {
-    .name           = "pfm",
-    .long_name      = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"),
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_PFM,
-    .init           = pnm_encode_init,
-    .encode2        = pnm_encode_frame,
-    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_GBRPF32,
-                                                    AV_PIX_FMT_NONE },
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
-};
-#endif
diff --git a/libavcodec/ppc/h264chroma_template.c b/libavcodec/ppc/h264chroma_template.c
index eda98c6..8f43e5d 100644
--- a/libavcodec/ppc/h264chroma_template.c
+++ b/libavcodec/ppc/h264chroma_template.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/ppc/util_altivec.h"
 
 /* this code assume that stride % 16 == 0 */
diff --git a/libavcodec/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c
index 779092f..d8a3baa 100644
--- a/libavcodec/ppc/h264dsp.c
+++ b/libavcodec/ppc/h264dsp.c
@@ -26,7 +26,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/h264qpel.c b/libavcodec/ppc/h264qpel.c
index fe896c8..bef421f 100644
--- a/libavcodec/ppc/h264qpel.c
+++ b/libavcodec/ppc/h264qpel.c
@@ -23,7 +23,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/mpegaudiodsp_altivec.c b/libavcodec/ppc/mpegaudiodsp_altivec.c
index 6794ed0..efa9fd5 100644
--- a/libavcodec/ppc/mpegaudiodsp_altivec.c
+++ b/libavcodec/ppc/mpegaudiodsp_altivec.c
@@ -23,7 +23,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 #include "libavcodec/mpegaudiodsp.h"
diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c
index bcb59ba..2c6ff91 100644
--- a/libavcodec/ppc/mpegvideo_altivec.c
+++ b/libavcodec/ppc/mpegvideo_altivec.c
@@ -28,7 +28,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/mpegvideodsp.c b/libavcodec/ppc/mpegvideodsp.c
index 81f4845..990a974 100644
--- a/libavcodec/ppc/mpegvideodsp.c
+++ b/libavcodec/ppc/mpegvideodsp.c
@@ -21,7 +21,7 @@
  */
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/vp8dsp_altivec.c b/libavcodec/ppc/vp8dsp_altivec.c
index 64ee703..31201ed 100644
--- a/libavcodec/ppc/vp8dsp_altivec.c
+++ b/libavcodec/ppc/vp8dsp_altivec.c
@@ -23,7 +23,7 @@
 #include "config.h"
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbe..e59a3a5 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -74,12 +74,6 @@
     { FF_PROFILE_UNKNOWN },
 };
 
-const AVProfile ff_vvc_profiles[] = {
-    { FF_PROFILE_VVC_MAIN_10,                   "Main 10" },
-    { FF_PROFILE_VVC_MAIN_10_444,               "Main 10 4:4:4" },
-    { FF_PROFILE_UNKNOWN },
-};
-
 const AVProfile ff_hevc_profiles[] = {
     { FF_PROFILE_HEVC_MAIN,                 "Main"                },
     { FF_PROFILE_HEVC_MAIN_10,              "Main 10"             },
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa..6baaba5 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -61,7 +61,6 @@
 extern const AVProfile ff_dnxhd_profiles[];
 extern const AVProfile ff_h264_profiles[];
 extern const AVProfile ff_hevc_profiles[];
-extern const AVProfile ff_vvc_profiles[];
 extern const AVProfile ff_jpeg2000_profiles[];
 extern const AVProfile ff_mpeg2_video_profiles[];
 extern const AVProfile ff_mpeg4_video_profiles[];
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 136f341..5fd2796 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -29,8 +29,6 @@
 #define LONG_BITSTREAM_READER
 
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "get_bits.h"
 #include "idctdsp.h"
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index c34e55f..8bc13fd 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -27,7 +27,6 @@
  * Known FOURCCs: 'ap4h' (444), 'apch' (HQ), 'apcn' (422), 'apcs' (LT), 'acpo' (Proxy)
  */
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "dct.h"
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 0e70163..8e6f905 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -23,7 +23,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 4429a4d..c9d2e00 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -342,6 +342,7 @@
 
     dst->opaque   = src->opaque;
     dst->debug    = src->debug;
+    dst->debug_mv = src->debug_mv;
 
     dst->slice_flags = src->slice_flags;
     dst->flags2      = src->flags2;
@@ -773,6 +774,10 @@
 
     if (!thread_count) {
         int nb_cpus = av_cpu_count();
+#if FF_API_DEBUG_MV
+        if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv)
+            nb_cpus = 1;
+#endif
         // use number of cores + 1 as thread count if there is more than one
         if (nb_cpus > 1)
             thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index 07dea55..1eb6ce3 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -36,7 +36,6 @@
 #include <stdio.h>
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #define BITSTREAM_READER_LE
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index a8c930f..94681a0 100644
--- a/libavcodec/qdmc.c
+++ b/libavcodec/qdmc.c
@@ -736,5 +736,4 @@
     .decode           = qdmc_decode_frame,
     .flush            = qdmc_flush,
     .capabilities     = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
-    .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index f4edc4b..8bc710a 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -274,7 +274,7 @@
     AVFrame * const ref = a->ref;
     uint8_t* outdata;
     int delta, intra, ret;
-    buffer_size_t pal_size;
+    int pal_size;
     const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
 
     if (avpkt->size < 0x86) {
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 5f2e641..c666aae 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -21,20 +21,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdint.h>
 #include <string.h>
 #include <sys/types.h>
 
 #include <mfx/mfxvideo.h>
 
 #include "libavutil/common.h"
-#include "libavutil/fifo.h"
-#include "libavutil/frame.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/hwcontext_qsv.h"
 #include "libavutil/mem.h"
 #include "libavutil/log.h"
-#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/time.h"
 #include "libavutil/imgutils.h"
@@ -42,49 +39,11 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "decode.h"
-#include "hwconfig.h"
 #include "qsv.h"
 #include "qsv_internal.h"
+#include "qsvdec.h"
 
-typedef struct QSVContext {
-    // the session used for decoding
-    mfxSession session;
-
-    // the session we allocated internally, in case the caller did not provide
-    // one
-    QSVSession internal_qs;
-
-    QSVFramesContext frames_ctx;
-
-    /**
-     * a linked list of frames currently being used by QSV
-     */
-    QSVFrame *work_frames;
-
-    AVFifoBuffer *async_fifo;
-    int zero_consume_run;
-    int buffered_count;
-    int reinit_flag;
-
-    enum AVPixelFormat orig_pix_fmt;
-    uint32_t fourcc;
-    mfxFrameInfo frame_info;
-    AVBufferPool *pool;
-
-    int initialized;
-
-    // options set by the caller
-    int async_depth;
-    int iopattern;
-    int gpu_copy;
-
-    char *load_plugins;
-
-    mfxExtBuffer **ext_buffers;
-    int         nb_ext_buffers;
-} QSVContext;
-
-static const AVCodecHWConfigInternal *const qsv_hw_configs[] = {
+const AVCodecHWConfigInternal *const ff_qsv_hw_configs[] = {
     &(const AVCodecHWConfigInternal) {
         .public = {
             .pix_fmt     = AV_PIX_FMT_QSV,
@@ -97,8 +56,7 @@
     NULL
 };
 
-static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame,
-                                     AVBufferPool *pool)
+static int ff_qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, AVBufferPool *pool)
 {
     int ret = 0;
 
@@ -270,7 +228,7 @@
     return 0;
  }
 
-static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q, mfxVideoParam *param)
+static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxVideoParam *param)
 {
     int ret;
 
@@ -296,9 +254,7 @@
     return 0;
 }
 
-static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q,
-                             const AVPacket *avpkt, enum AVPixelFormat pix_fmt,
-                             mfxVideoParam *param)
+static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt, enum AVPixelFormat pix_fmt, mfxVideoParam *param)
 {
     int ret;
 
@@ -342,7 +298,7 @@
     int ret;
 
     if (q->pool)
-        ret = qsv_get_continuous_buffer(avctx, frame->frame, q->pool);
+        ret = ff_qsv_get_continuous_buffer(avctx, frame->frame, q->pool);
     else
         ret = ff_get_buffer(avctx, frame->frame, AV_GET_BUFFER_FLAG_REF);
 
@@ -443,7 +399,7 @@
 
 static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
                       AVFrame *frame, int *got_frame,
-                      const AVPacket *avpkt)
+                      AVPacket *avpkt)
 {
     QSVFrame *out_frame;
     mfxFrameSurface1 *insurf;
@@ -574,7 +530,7 @@
     return bs.DataOffset;
 }
 
-static void qsv_decode_close_qsvcontext(QSVContext *q)
+int ff_qsv_decode_close(QSVContext *q)
 {
     QSVFrame *cur = q->work_frames;
 
@@ -606,10 +562,12 @@
     av_buffer_unref(&q->frames_ctx.hw_frames_ctx);
     av_buffer_unref(&q->frames_ctx.mids_buf);
     av_buffer_pool_uninit(&q->pool);
+
+    return 0;
 }
 
-static int qsv_process_data(AVCodecContext *avctx, QSVContext *q,
-                            AVFrame *frame, int *got_frame, const AVPacket *pkt)
+int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
+                        AVFrame *frame, int *got_frame, AVPacket *pkt)
 {
     int ret;
     mfxVideoParam param = { 0 };
@@ -657,7 +615,7 @@
     }
 
     if (!q->initialized) {
-        ret = qsv_decode_init_context(avctx, q, &param);
+        ret = qsv_decode_init(avctx, q, &param);
         if (ret < 0)
             goto reinit_fail;
         q->initialized = 1;
@@ -670,248 +628,8 @@
     return ret;
 }
 
-enum LoadPlugin {
-    LOAD_PLUGIN_NONE,
-    LOAD_PLUGIN_HEVC_SW,
-    LOAD_PLUGIN_HEVC_HW,
-};
-
-typedef struct QSVDecContext {
-    AVClass *class;
-    QSVContext qsv;
-
-    int load_plugin;
-
-    AVFifoBuffer *packet_fifo;
-
-    AVPacket buffer_pkt;
-} QSVDecContext;
-
-static void qsv_clear_buffers(QSVDecContext *s)
+void ff_qsv_decode_flush(AVCodecContext *avctx, QSVContext *q)
 {
-    AVPacket pkt;
-    while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
-        av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL);
-        av_packet_unref(&pkt);
-    }
-
-    av_packet_unref(&s->buffer_pkt);
+    q->orig_pix_fmt = AV_PIX_FMT_NONE;
+    q->initialized = 0;
 }
-
-static av_cold int qsv_decode_close(AVCodecContext *avctx)
-{
-    QSVDecContext *s = avctx->priv_data;
-
-    av_freep(&s->qsv.load_plugins);
-
-    qsv_decode_close_qsvcontext(&s->qsv);
-
-    qsv_clear_buffers(s);
-
-    av_fifo_free(s->packet_fifo);
-
-    return 0;
-}
-
-static av_cold int qsv_decode_init(AVCodecContext *avctx)
-{
-    QSVDecContext *s = avctx->priv_data;
-    int ret;
-    const char *uid = NULL;
-
-    if (avctx->codec_id == AV_CODEC_ID_VP8) {
-        uid = "f622394d8d87452f878c51f2fc9b4131";
-    } else if (avctx->codec_id == AV_CODEC_ID_VP9) {
-        uid = "a922394d8d87452f878c51f2fc9b4131";
-    }
-    else if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != LOAD_PLUGIN_NONE) {
-        static const char * const uid_hevcdec_sw = "15dd936825ad475ea34e35f3f54217a6";
-        static const char * const uid_hevcdec_hw = "33a61c0b4c27454ca8d85dde757c6f8e";
-
-        if (s->qsv.load_plugins[0]) {
-            av_log(avctx, AV_LOG_WARNING,
-                   "load_plugins is not empty, but load_plugin is not set to 'none'."
-                   "The load_plugin value will be ignored.\n");
-        } else {
-            if (s->load_plugin == LOAD_PLUGIN_HEVC_SW)
-                uid = uid_hevcdec_sw;
-            else
-                uid = uid_hevcdec_hw;
-        }
-    }
-    if (uid) {
-        av_freep(&s->qsv.load_plugins);
-        s->qsv.load_plugins = av_strdup(uid);
-        if (!s->qsv.load_plugins)
-            return AVERROR(ENOMEM);
-    }
-
-    s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
-    s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
-    if (!s->packet_fifo) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
-
-    return 0;
-fail:
-    qsv_decode_close(avctx);
-    return ret;
-}
-
-static int qsv_decode_frame(AVCodecContext *avctx, void *data,
-                            int *got_frame, AVPacket *avpkt)
-{
-    QSVDecContext *s = avctx->priv_data;
-    AVFrame *frame    = data;
-    int ret;
-
-    /* buffer the input packet */
-    if (avpkt->size) {
-        AVPacket input_ref;
-
-        if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) {
-            ret = av_fifo_realloc2(s->packet_fifo,
-                                   av_fifo_size(s->packet_fifo) + sizeof(input_ref));
-            if (ret < 0)
-                return ret;
-        }
-
-        ret = av_packet_ref(&input_ref, avpkt);
-        if (ret < 0)
-            return ret;
-        av_fifo_generic_write(s->packet_fifo, &input_ref, sizeof(input_ref), NULL);
-    }
-
-    /* process buffered data */
-    while (!*got_frame) {
-        /* prepare the input data */
-        if (s->buffer_pkt.size <= 0) {
-            /* no more data */
-            if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket))
-                return avpkt->size ? avpkt->size : qsv_process_data(avctx, &s->qsv, frame, got_frame, avpkt);
-            /* in progress of reinit, no read from fifo and keep the buffer_pkt */
-            if (!s->qsv.reinit_flag) {
-                av_packet_unref(&s->buffer_pkt);
-                av_fifo_generic_read(s->packet_fifo, &s->buffer_pkt, sizeof(s->buffer_pkt), NULL);
-            }
-        }
-
-        ret = qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->buffer_pkt);
-        if (ret < 0){
-            /* Drop buffer_pkt when failed to decode the packet. Otherwise,
-               the decoder will keep decoding the failure packet. */
-            av_packet_unref(&s->buffer_pkt);
-            return ret;
-        }
-        if (s->qsv.reinit_flag)
-            continue;
-
-        s->buffer_pkt.size -= ret;
-        s->buffer_pkt.data += ret;
-    }
-
-    return avpkt->size;
-}
-
-static void qsv_decode_flush(AVCodecContext *avctx)
-{
-    QSVDecContext *s = avctx->priv_data;
-
-    qsv_clear_buffers(s);
-
-    s->qsv.orig_pix_fmt = AV_PIX_FMT_NONE;
-    s->qsv.initialized = 0;
-}
-
-#define OFFSET(x) offsetof(QSVDecContext, x)
-#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
-
-#define DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, opt) \
-static const AVClass x##_qsv_class = { \
-    .class_name = #x "_qsv", \
-    .item_name  = av_default_item_name, \
-    .option     = opt, \
-    .version    = LIBAVUTIL_VERSION_INT, \
-}; \
-AVCodec ff_##x##_qsv_decoder = { \
-    .name           = #x "_qsv", \
-    .long_name      = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync Video acceleration)"), \
-    .priv_data_size = sizeof(QSVDecContext), \
-    .type           = AVMEDIA_TYPE_VIDEO, \
-    .id             = AV_CODEC_ID_##X, \
-    .init           = qsv_decode_init, \
-    .decode         = qsv_decode_frame, \
-    .flush          = qsv_decode_flush, \
-    .close          = qsv_decode_close, \
-    .bsfs           = bsf_name, \
-    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
-    .priv_class     = &x##_qsv_class, \
-    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
-                                                    AV_PIX_FMT_P010, \
-                                                    AV_PIX_FMT_QSV, \
-                                                    AV_PIX_FMT_NONE }, \
-    .hw_configs     = qsv_hw_configs, \
-    .wrapper_name   = "qsv", \
-}; \
-
-#define DEFINE_QSV_DECODER(x, X, bsf_name) DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, options)
-
-#if CONFIG_HEVC_QSV_DECODER
-static const AVOption hevc_options[] = {
-    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
-
-    { "load_plugin", "A user plugin to load in an internal session", OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_HW }, LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VD, "load_plugin" },
-    { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE },    0, 0, VD, "load_plugin" },
-    { "hevc_sw",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_SW }, 0, 0, VD, "load_plugin" },
-    { "hevc_hw",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_HW }, 0, 0, VD, "load_plugin" },
-
-    { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session",
-        OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
-
-    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
-        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
-        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
-        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
-    { NULL },
-};
-DEFINE_QSV_DECODER_WITH_OPTION(hevc, HEVC, "hevc_mp4toannexb", hevc_options)
-#endif
-
-static const AVOption options[] = {
-    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
-
-    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
-        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
-        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
-        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
-    { NULL },
-};
-
-#if CONFIG_H264_QSV_DECODER
-DEFINE_QSV_DECODER(h264, H264, "h264_mp4toannexb")
-#endif
-
-#if CONFIG_MPEG2_QSV_DECODER
-DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
-#endif
-
-#if CONFIG_VC1_QSV_DECODER
-DEFINE_QSV_DECODER(vc1, VC1, NULL)
-#endif
-
-#if CONFIG_MJPEG_QSV_DECODER
-DEFINE_QSV_DECODER(mjpeg, MJPEG, NULL)
-#endif
-
-#if CONFIG_VP8_QSV_DECODER
-DEFINE_QSV_DECODER(vp8, VP8, NULL)
-#endif
-
-#if CONFIG_VP9_QSV_DECODER
-DEFINE_QSV_DECODER(vp9, VP9, NULL)
-#endif
-
-#if CONFIG_AV1_QSV_DECODER
-DEFINE_QSV_DECODER(av1, AV1, NULL)
-#endif
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
new file mode 100644
index 0000000..f3b7344
--- /dev/null
+++ b/libavcodec/qsvdec.h
@@ -0,0 +1,86 @@
+/*
+ * Intel MediaSDK QSV utility functions
+ *
+ * copyright (c) 2013 Luca Barbato
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_QSVDEC_H
+#define AVCODEC_QSVDEC_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <mfx/mfxvideo.h>
+
+#include "libavutil/fifo.h"
+#include "libavutil/frame.h"
+#include "libavutil/pixfmt.h"
+
+#include "avcodec.h"
+#include "hwconfig.h"
+#include "qsv_internal.h"
+
+typedef struct QSVContext {
+    // the session used for decoding
+    mfxSession session;
+
+    // the session we allocated internally, in case the caller did not provide
+    // one
+    QSVSession internal_qs;
+
+    QSVFramesContext frames_ctx;
+
+    /**
+     * a linked list of frames currently being used by QSV
+     */
+    QSVFrame *work_frames;
+
+    AVFifoBuffer *async_fifo;
+    int zero_consume_run;
+    int buffered_count;
+    int reinit_flag;
+
+    enum AVPixelFormat orig_pix_fmt;
+    uint32_t fourcc;
+    mfxFrameInfo frame_info;
+    AVBufferPool *pool;
+
+    int initialized;
+
+    // options set by the caller
+    int async_depth;
+    int iopattern;
+    int gpu_copy;
+
+    char *load_plugins;
+
+    mfxExtBuffer **ext_buffers;
+    int         nb_ext_buffers;
+} QSVContext;
+
+extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[];
+
+int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
+                        AVFrame *frame, int *got_frame, AVPacket *pkt);
+
+void ff_qsv_decode_flush(AVCodecContext *avctx, QSVContext *q);
+
+int ff_qsv_decode_close(QSVContext *q);
+
+#endif /* AVCODEC_QSVDEC_H */
diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
new file mode 100644
index 0000000..02c4188
--- /dev/null
+++ b/libavcodec/qsvdec_h2645.c
@@ -0,0 +1,271 @@
+/*
+ * Intel MediaSDK QSV based H.264 / HEVC decoder
+ *
+ * copyright (c) 2013 Luca Barbato
+ * copyright (c) 2015 Anton Khirnov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdint.h>
+#include <string.h>
+
+#include <mfx/mfxvideo.h>
+
+#include "libavutil/common.h"
+#include "libavutil/fifo.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
+#include "internal.h"
+#include "qsv_internal.h"
+#include "qsvdec.h"
+#include "qsv.h"
+
+enum LoadPlugin {
+    LOAD_PLUGIN_NONE,
+    LOAD_PLUGIN_HEVC_SW,
+    LOAD_PLUGIN_HEVC_HW,
+};
+
+typedef struct QSVH2645Context {
+    AVClass *class;
+    QSVContext qsv;
+
+    int load_plugin;
+
+    AVFifoBuffer *packet_fifo;
+
+    AVPacket buffer_pkt;
+} QSVH2645Context;
+
+static void qsv_clear_buffers(QSVH2645Context *s)
+{
+    AVPacket pkt;
+    while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
+        av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL);
+        av_packet_unref(&pkt);
+    }
+
+    av_packet_unref(&s->buffer_pkt);
+}
+
+static av_cold int qsv_decode_close(AVCodecContext *avctx)
+{
+    QSVH2645Context *s = avctx->priv_data;
+
+    ff_qsv_decode_close(&s->qsv);
+
+    qsv_clear_buffers(s);
+
+    av_fifo_free(s->packet_fifo);
+
+    return 0;
+}
+
+static av_cold int qsv_decode_init(AVCodecContext *avctx)
+{
+    QSVH2645Context *s = avctx->priv_data;
+    int ret;
+
+    if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != LOAD_PLUGIN_NONE) {
+        static const char * const uid_hevcdec_sw = "15dd936825ad475ea34e35f3f54217a6";
+        static const char * const uid_hevcdec_hw = "33a61c0b4c27454ca8d85dde757c6f8e";
+
+        if (s->qsv.load_plugins[0]) {
+            av_log(avctx, AV_LOG_WARNING,
+                   "load_plugins is not empty, but load_plugin is not set to 'none'."
+                   "The load_plugin value will be ignored.\n");
+        } else {
+            av_freep(&s->qsv.load_plugins);
+
+            if (s->load_plugin == LOAD_PLUGIN_HEVC_SW)
+                s->qsv.load_plugins = av_strdup(uid_hevcdec_sw);
+            else
+                s->qsv.load_plugins = av_strdup(uid_hevcdec_hw);
+            if (!s->qsv.load_plugins)
+                return AVERROR(ENOMEM);
+        }
+    }
+
+    s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
+    s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
+    if (!s->packet_fifo) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
+
+    return 0;
+fail:
+    qsv_decode_close(avctx);
+    return ret;
+}
+
+static int qsv_decode_frame(AVCodecContext *avctx, void *data,
+                            int *got_frame, AVPacket *avpkt)
+{
+    QSVH2645Context *s = avctx->priv_data;
+    AVFrame *frame    = data;
+    int ret;
+
+    /* buffer the input packet */
+    if (avpkt->size) {
+        AVPacket input_ref;
+
+        if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) {
+            ret = av_fifo_realloc2(s->packet_fifo,
+                                   av_fifo_size(s->packet_fifo) + sizeof(input_ref));
+            if (ret < 0)
+                return ret;
+        }
+
+        ret = av_packet_ref(&input_ref, avpkt);
+        if (ret < 0)
+            return ret;
+        av_fifo_generic_write(s->packet_fifo, &input_ref, sizeof(input_ref), NULL);
+    }
+
+    /* process buffered data */
+    while (!*got_frame) {
+        /* prepare the input data */
+        if (s->buffer_pkt.size <= 0) {
+            /* no more data */
+            if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket))
+                return avpkt->size ? avpkt->size : ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, avpkt);
+            /* in progress of reinit, no read from fifo and keep the buffer_pkt */
+            if (!s->qsv.reinit_flag) {
+                av_packet_unref(&s->buffer_pkt);
+                av_fifo_generic_read(s->packet_fifo, &s->buffer_pkt, sizeof(s->buffer_pkt), NULL);
+            }
+        }
+
+        ret = ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->buffer_pkt);
+        if (ret < 0){
+            /* Drop buffer_pkt when failed to decode the packet. Otherwise,
+               the decoder will keep decoding the failure packet. */
+            av_packet_unref(&s->buffer_pkt);
+            return ret;
+        }
+        if (s->qsv.reinit_flag)
+            continue;
+
+        s->buffer_pkt.size -= ret;
+        s->buffer_pkt.data += ret;
+    }
+
+    return avpkt->size;
+}
+
+static void qsv_decode_flush(AVCodecContext *avctx)
+{
+    QSVH2645Context *s = avctx->priv_data;
+
+    qsv_clear_buffers(s);
+    ff_qsv_decode_flush(avctx, &s->qsv);
+}
+
+#define OFFSET(x) offsetof(QSVH2645Context, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+
+#if CONFIG_HEVC_QSV_DECODER
+static const AVOption hevc_options[] = {
+    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
+
+    { "load_plugin", "A user plugin to load in an internal session", OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_HW }, LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VD, "load_plugin" },
+    { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE },    0, 0, VD, "load_plugin" },
+    { "hevc_sw",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_SW }, 0, 0, VD, "load_plugin" },
+    { "hevc_hw",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_HW }, 0, 0, VD, "load_plugin" },
+
+    { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session",
+        OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
+
+    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
+        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
+        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
+        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
+    { NULL },
+};
+
+static const AVClass hevc_class = {
+    .class_name = "hevc_qsv",
+    .item_name  = av_default_item_name,
+    .option     = hevc_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_hevc_qsv_decoder = {
+    .name           = "hevc_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("HEVC (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVH2645Context),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_HEVC,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &hevc_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .bsfs           = "hevc_mp4toannexb",
+    .wrapper_name   = "qsv",
+};
+#endif
+
+#if CONFIG_H264_QSV_DECODER
+static const AVOption options[] = {
+    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
+
+    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
+        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
+        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
+        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
+    { NULL },
+};
+
+static const AVClass class = {
+    .class_name = "h264_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_h264_qsv_decoder = {
+    .name           = "h264_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVH2645Context),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_H264,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .bsfs           = "h264_mp4toannexb",
+    .wrapper_name   = "qsv",
+};
+#endif
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
new file mode 100644
index 0000000..2775e07
--- /dev/null
+++ b/libavcodec/qsvdec_other.c
@@ -0,0 +1,358 @@
+/*
+ * Intel MediaSDK QSV based MPEG-2, VC-1, VP8, MJPEG, VP9 and AV1 decoders
+ *
+ * copyright (c) 2015 Anton Khirnov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdint.h>
+#include <string.h>
+
+#include <mfx/mfxvideo.h>
+
+#include "libavutil/common.h"
+#include "libavutil/fifo.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
+#include "internal.h"
+#include "qsv_internal.h"
+#include "qsvdec.h"
+#include "qsv.h"
+
+typedef struct QSVOtherContext {
+    AVClass *class;
+    QSVContext qsv;
+
+    AVFifoBuffer *packet_fifo;
+
+    AVPacket input_ref;
+} QSVOtherContext;
+
+static void qsv_clear_buffers(QSVOtherContext *s)
+{
+    AVPacket pkt;
+    while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
+        av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL);
+        av_packet_unref(&pkt);
+    }
+
+    av_packet_unref(&s->input_ref);
+}
+
+static av_cold int qsv_decode_close(AVCodecContext *avctx)
+{
+    QSVOtherContext *s = avctx->priv_data;
+
+#if CONFIG_VP8_QSV_DECODER || CONFIG_VP9_QSV_DECODER
+    if (avctx->codec_id == AV_CODEC_ID_VP8 || avctx->codec_id == AV_CODEC_ID_VP9)
+        av_freep(&s->qsv.load_plugins);
+#endif
+
+    ff_qsv_decode_close(&s->qsv);
+
+    qsv_clear_buffers(s);
+
+    av_fifo_free(s->packet_fifo);
+
+    return 0;
+}
+
+static av_cold int qsv_decode_init(AVCodecContext *avctx)
+{
+    QSVOtherContext *s = avctx->priv_data;
+    int ret;
+
+#if CONFIG_VP8_QSV_DECODER
+    if (avctx->codec_id == AV_CODEC_ID_VP8) {
+        static const char *uid_vp8dec_hw = "f622394d8d87452f878c51f2fc9b4131";
+
+        av_freep(&s->qsv.load_plugins);
+        s->qsv.load_plugins = av_strdup(uid_vp8dec_hw);
+        if (!s->qsv.load_plugins)
+            return AVERROR(ENOMEM);
+    }
+#endif
+
+#if CONFIG_VP9_QSV_DECODER
+    if (avctx->codec_id == AV_CODEC_ID_VP9) {
+        static const char *uid_vp9dec_hw = "a922394d8d87452f878c51f2fc9b4131";
+
+        av_freep(&s->qsv.load_plugins);
+        s->qsv.load_plugins = av_strdup(uid_vp9dec_hw);
+        if (!s->qsv.load_plugins)
+            return AVERROR(ENOMEM);
+    }
+#endif
+
+    s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
+    s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
+    if (!s->packet_fifo) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
+
+    return 0;
+fail:
+    qsv_decode_close(avctx);
+    return ret;
+}
+
+static int qsv_decode_frame(AVCodecContext *avctx, void *data,
+                            int *got_frame, AVPacket *avpkt)
+{
+    QSVOtherContext *s = avctx->priv_data;
+    AVFrame *frame    = data;
+    int ret;
+
+    /* buffer the input packet */
+    if (avpkt->size) {
+        AVPacket input_ref;
+
+        if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) {
+            ret = av_fifo_realloc2(s->packet_fifo,
+                                   av_fifo_size(s->packet_fifo) + sizeof(input_ref));
+            if (ret < 0)
+                return ret;
+        }
+
+        ret = av_packet_ref(&input_ref, avpkt);
+        if (ret < 0)
+            return ret;
+        av_fifo_generic_write(s->packet_fifo, &input_ref, sizeof(input_ref), NULL);
+    }
+
+    /* process buffered data */
+    while (!*got_frame) {
+        if (s->input_ref.size <= 0) {
+            /* no more data */
+            if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket))
+                return avpkt->size ? avpkt->size : ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, avpkt);
+            /* in progress of reinit, no read from fifo and keep the buffer_pkt */
+            if (!s->qsv.reinit_flag) {
+                av_packet_unref(&s->input_ref);
+                av_fifo_generic_read(s->packet_fifo, &s->input_ref, sizeof(s->input_ref), NULL);
+            }
+        }
+
+        ret = ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->input_ref);
+        if (ret < 0) {
+            /* Drop input packet when failed to decode the packet. Otherwise,
+               the decoder will keep decoding the failure packet. */
+            av_packet_unref(&s->input_ref);
+
+            return ret;
+        }
+        if (s->qsv.reinit_flag)
+            continue;
+
+        s->input_ref.size -= ret;
+        s->input_ref.data += ret;
+    }
+
+    return avpkt->size;
+}
+
+static void qsv_decode_flush(AVCodecContext *avctx)
+{
+    QSVOtherContext *s = avctx->priv_data;
+
+    qsv_clear_buffers(s);
+    ff_qsv_decode_flush(avctx, &s->qsv);
+}
+
+#define OFFSET(x) offsetof(QSVOtherContext, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption options[] = {
+    { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
+
+    { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"},
+        { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"},
+        { "on",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON },      0, 0, VD, "gpu_copy"},
+        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },     0, 0, VD, "gpu_copy"},
+    { NULL },
+};
+
+#if CONFIG_MPEG2_QSV_DECODER
+static const AVClass mpeg2_qsv_class = {
+    .class_name = "mpeg2_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_mpeg2_qsv_decoder = {
+    .name           = "mpeg2_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_MPEG2VIDEO,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &mpeg2_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .wrapper_name   = "qsv",
+};
+#endif
+
+#if CONFIG_VC1_QSV_DECODER
+static const AVClass vc1_qsv_class = {
+    .class_name = "vc1_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_vc1_qsv_decoder = {
+    .name           = "vc1_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_VC1,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &vc1_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .wrapper_name   = "qsv",
+};
+#endif
+
+#if CONFIG_VP8_QSV_DECODER
+static const AVClass vp8_qsv_class = {
+    .class_name = "vp8_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_vp8_qsv_decoder = {
+    .name           = "vp8_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("VP8 video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_VP8,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &vp8_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .wrapper_name   = "qsv",
+};
+#endif
+
+#if CONFIG_MJPEG_QSV_DECODER
+static const AVClass mjpeg_qsv_class = {
+    .class_name = "mjpeg_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_mjpeg_qsv_decoder = {
+    .name           = "mjpeg_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("MJPEG video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_MJPEG,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &mjpeg_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+};
+#endif
+
+#if CONFIG_VP9_QSV_DECODER
+static const AVClass vp9_qsv_class = {
+    .class_name = "vp9_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_vp9_qsv_decoder = {
+    .name           = "vp9_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_VP9,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &vp9_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .wrapper_name   = "qsv",
+};
+#endif
+
+#if CONFIG_AV1_QSV_DECODER
+static const AVClass av1_qsv_class = {
+    .class_name = "av1_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_av1_qsv_decoder = {
+    .name           = "av1_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("AV1 video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_AV1,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &av1_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .wrapper_name   = "qsv",
+};
+#endif
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 566a5c8..2bd2a56 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1132,7 +1132,6 @@
     if (!iopattern)
         iopattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
     q->param.IOPattern = iopattern;
-    ff_qsv_print_iopattern(avctx, iopattern, "Encoder");
 
     ret = qsvenc_init_session(avctx, q);
     if (ret < 0)
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index e04fd31..6bdde75 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -540,7 +540,7 @@
     }
 
     if(has_palette) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
 
         if (pal && size == AVPALETTE_SIZE) {
diff --git a/libavcodec/ra144.h b/libavcodec/ra144.h
index 82ef852..19a4ce0 100644
--- a/libavcodec/ra144.h
+++ b/libavcodec/ra144.h
@@ -23,9 +23,6 @@
 #define AVCODEC_RA144_H
 
 #include <stdint.h>
-
-#include "libavutil/mem_internal.h"
-
 #include "lpc.h"
 #include "audio_frame_queue.h"
 #include "audiodsp.h"
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index 0eb2a66..6495026 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -22,7 +22,6 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
diff --git a/libavcodec/ra288.h b/libavcodec/ra288.h
index 96b074b..fa0b528 100644
--- a/libavcodec/ra288.h
+++ b/libavcodec/ra288.h
@@ -24,7 +24,6 @@
 
 #include <stdint.h>
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
 
 static const float amptable[8]={
      0.515625,  0.90234375,  1.57910156,  2.76342773,
diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c
index fa7d552..a6a3f08 100644
--- a/libavcodec/rangecoder.c
+++ b/libavcodec/rangecoder.c
@@ -121,3 +121,22 @@
 
     return c->bytestream - c->bytestream_start;
 }
+
+int ff_rac_check_termination(RangeCoder *c, int version)
+{
+    if (version == 1) {
+        RangeCoder tmp = *c;
+        get_rac(c, (uint8_t[]) { 129 });
+
+        if (c->bytestream == tmp.bytestream && c->bytestream > c->bytestream_start)
+            tmp.low -= *--tmp.bytestream;
+        tmp.bytestream_end = tmp.bytestream;
+
+        if (get_rac(&tmp, (uint8_t[]) { 129 }))
+            return AVERROR_INVALIDDATA;
+    } else {
+        if (c->bytestream_end != c->bytestream)
+            return AVERROR_INVALIDDATA;
+    }
+    return 0;
+}
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index 4495f6d..4d4ca4d 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -57,6 +57,15 @@
  */
 int ff_rac_terminate(RangeCoder *c, int version);
 
+/**
+ * Check if at the current position there is a valid looking termination
+ * @param version version 0 requires the decoder to know the data size in bytes
+ *                version 1 needs about 1 bit more space but does not need to
+ *                          carry the size from encoder to decoder
+ * @returns negative AVERROR code on error or non negative.
+ */
+int ff_rac_check_termination(RangeCoder *c, int version);
+
 void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
 
 static inline void renorm_encoder(RangeCoder *c)
diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
index 207d50c..cdf20a6 100644
--- a/libavcodec/rasc.c
+++ b/libavcodec/rasc.c
@@ -70,9 +70,6 @@
     RASCContext *s = avctx->priv_data;
     uint8_t *dst = frame->data[0];
 
-    if (!dst)
-        return;
-
     for (int y = 0; y < avctx->height; y++) {
         memset(dst, 0, avctx->width * s->bpp);
         dst += frame->linesize[0];
@@ -112,7 +109,7 @@
 }
 
 static int decode_fint(AVCodecContext *avctx,
-                       const AVPacket *avpkt, unsigned size)
+                       AVPacket *avpkt, unsigned size)
 {
     RASCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -171,7 +168,7 @@
     return 0;
 }
 
-static int decode_zlib(AVCodecContext *avctx, const AVPacket *avpkt,
+static int decode_zlib(AVCodecContext *avctx, AVPacket *avpkt,
                        unsigned size, unsigned uncompressed_size)
 {
     RASCContext *s = avctx->priv_data;
@@ -205,7 +202,7 @@
 }
 
 static int decode_move(AVCodecContext *avctx,
-                       const AVPacket *avpkt, unsigned size)
+                       AVPacket *avpkt, unsigned size)
 {
     RASCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -329,7 +326,7 @@
     len--;
 
 static int decode_dlta(AVCodecContext *avctx,
-                       const AVPacket *avpkt, unsigned size)
+                       AVPacket *avpkt, unsigned size)
 {
     RASCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -471,7 +468,7 @@
 }
 
 static int decode_kfrm(AVCodecContext *avctx,
-                       const AVPacket *avpkt, unsigned size)
+                       AVPacket *avpkt, unsigned size)
 {
     RASCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -534,7 +531,7 @@
 }
 
 static int decode_mous(AVCodecContext *avctx,
-                       const AVPacket *avpkt, unsigned size)
+                       AVPacket *avpkt, unsigned size)
 {
     RASCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -574,7 +571,7 @@
 }
 
 static int decode_mpos(AVCodecContext *avctx,
-                       const AVPacket *avpkt, unsigned size)
+                       AVPacket *avpkt, unsigned size)
 {
     RASCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index c18c3dd..26663ca 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -367,7 +367,7 @@
     }
 
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        buffer_size_t pal_size;
+        int pal_size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
                                                      &pal_size);
         int ret;
diff --git a/libavcodec/rl.c b/libavcodec/rl.c
index 93153ff..6eac306 100644
--- a/libavcodec/rl.c
+++ b/libavcodec/rl.c
@@ -25,16 +25,27 @@
 
 #include "rl.h"
 
-av_cold void ff_rl_init(RLTable *rl,
-                        uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
+void ff_rl_free(RLTable *rl)
+{
+    int i;
+
+    for (i = 0; i < 2; i++) {
+        av_freep(&rl->max_run[i]);
+        av_freep(&rl->max_level[i]);
+        av_freep(&rl->index_run[i]);
+    }
+}
+
+av_cold int ff_rl_init(RLTable *rl,
+                       uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
 {
     int8_t  max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
     uint8_t index_run[MAX_RUN + 1];
     int last, run, level, start, end, i;
 
-    /* If rl->max_level[0] is set, this RLTable has already been initialized */
-    if (rl->max_level[0])
-        return;
+    /* If table is static, we can quit if rl->max_level[0] is not NULL */
+    if (static_store && rl->max_level[0])
+        return 0;
 
     /* compute max_level[], max_run[] and index_run[] */
     for (last = 0; last < 2; last++) {
@@ -59,13 +70,36 @@
             if (run > max_run[level])
                 max_run[level] = run;
         }
-        rl->max_level[last] = static_store[last];
+        if (static_store)
+            rl->max_level[last] = static_store[last];
+        else {
+            rl->max_level[last] = av_malloc(MAX_RUN + 1);
+            if (!rl->max_level[last])
+                goto fail;
+        }
         memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
-        rl->max_run[last]   = static_store[last] + MAX_RUN + 1;
+        if (static_store)
+            rl->max_run[last]   = static_store[last] + MAX_RUN + 1;
+        else {
+            rl->max_run[last]   = av_malloc(MAX_LEVEL + 1);
+            if (!rl->max_run[last])
+                goto fail;
+        }
         memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
-        rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
+        if (static_store)
+            rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
+        else {
+            rl->index_run[last] = av_malloc(MAX_RUN + 1);
+            if (!rl->index_run[last])
+                goto fail;
+        }
         memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
     }
+    return 0;
+
+fail:
+    ff_rl_free(rl);
+    return AVERROR(ENOMEM);
 }
 
 av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size)
@@ -80,9 +114,6 @@
         int qmul = q * 2;
         int qadd = (q - 1) | 1;
 
-        if (!rl->rl_vlc[q])
-            return;
-
         if (q == 0) {
             qmul = 1;
             qadd = 0;
diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index 26e0b32..9a767bc 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -49,12 +49,17 @@
 } RLTable;
 
 /**
- * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3]
- *                     to hold the level and run tables.
+ * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold
+ *                     the level and run tables, if this is NULL av_malloc() will be used
  */
-void ff_rl_init(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
+int ff_rl_init(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
 void ff_rl_init_vlc(RLTable *rl, unsigned static_size);
 
+/**
+ * Free the contents of a dynamically allocated table.
+ */
+void ff_rl_free(RLTable *rl);
+
 #define INIT_VLC_RL(rl, static_size)\
 {\
     int q;\
@@ -68,14 +73,6 @@
     }\
 }
 
-#define INIT_FIRST_VLC_RL(rl, static_size)              \
-do {                                                    \
-    static RL_VLC_ELEM rl_vlc_table[static_size];       \
-                                                        \
-    rl.rl_vlc[0] = rl_vlc_table;                        \
-    ff_rl_init_vlc(&rl, static_size);                   \
-} while (0)
-
 static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
 {
     int index;
diff --git a/libavcodec/roqvideo.h b/libavcodec/roqvideo.h
index 8318b6e..f47b2c8 100644
--- a/libavcodec/roqvideo.h
+++ b/libavcodec/roqvideo.h
@@ -22,7 +22,9 @@
 #ifndef AVCODEC_ROQVIDEO_H
 #define AVCODEC_ROQVIDEO_H
 
+#include "libavutil/lfg.h"
 #include "avcodec.h"
+#include "bytestream.h"
 
 typedef struct roq_cell {
     unsigned char y[4];
@@ -37,15 +39,39 @@
     int d[2];
 } motion_vect;
 
+struct RoqTempData;
+
 typedef struct RoqContext {
+
     const AVClass *class;
     AVCodecContext *avctx;
     AVFrame *last_frame;
     AVFrame *current_frame;
-    int width, height;
+    int first_frame;
 
     roq_cell cb2x2[256];
     roq_qcell cb4x4[256];
+
+    int width, height;
+
+    /* Encoder only data */
+    AVLFG randctx;
+    uint64_t lambda;
+
+    motion_vect *this_motion4;
+    motion_vect *last_motion4;
+
+    motion_vect *this_motion8;
+    motion_vect *last_motion8;
+
+    unsigned int framesSinceKeyframe;
+
+    const AVFrame *frame_to_enc;
+    uint8_t *out_buf;
+    struct RoqTempData *tmpData;
+
+    int quake3_compat; // Quake 3 compatibility option
+
 } RoqContext;
 
 #define RoQ_INFO              0x1001
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 1ab0de0..dc6a630 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -57,7 +57,6 @@
 #include <string.h>
 
 #include "libavutil/attributes.h"
-#include "libavutil/lfg.h"
 #include "libavutil/opt.h"
 #include "roqvideo.h"
 #include "bytestream.h"
@@ -78,85 +77,6 @@
 /* The cast is useful when multiplying it by INT_MAX */
 #define ROQ_LAMBDA_SCALE ((uint64_t) FF_LAMBDA_SCALE)
 
-typedef struct RoqCodebooks {
-    int numCB4;
-    int numCB2;
-    int usedCB2[MAX_CBS_2x2];
-    int usedCB4[MAX_CBS_4x4];
-    uint8_t unpacked_cb2[MAX_CBS_2x2*2*2*3];
-    uint8_t unpacked_cb4[MAX_CBS_4x4*4*4*3];
-    uint8_t unpacked_cb4_enlarged[MAX_CBS_4x4*8*8*3];
-} RoqCodebooks;
-
-/**
- * Temporary vars
- */
-typedef struct RoqTempData
-{
-    int f2i4[MAX_CBS_4x4];
-    int i2f4[MAX_CBS_4x4];
-    int f2i2[MAX_CBS_2x2];
-    int i2f2[MAX_CBS_2x2];
-
-    int mainChunkSize;
-
-    int numCB4;
-    int numCB2;
-
-    RoqCodebooks codebooks;
-
-    int used_option[4];
-} RoqTempData;
-
-typedef struct SubcelEvaluation {
-    int eval_dist[4];
-    int best_bit_use;
-    int best_coding;
-
-    int subCels[4];
-    motion_vect motion;
-    int cbEntry;
-} SubcelEvaluation;
-
-typedef struct CelEvaluation {
-    int eval_dist[4];
-    int best_coding;
-
-    SubcelEvaluation subCels[4];
-
-    motion_vect motion;
-    int cbEntry;
-
-    int sourceX, sourceY;
-} CelEvaluation;
-
-typedef struct RoqEncContext {
-    RoqContext common;
-    AVLFG randctx;
-    uint64_t lambda;
-
-    motion_vect *this_motion4;
-    motion_vect *last_motion4;
-
-    motion_vect *this_motion8;
-    motion_vect *last_motion8;
-
-    unsigned int framesSinceKeyframe;
-
-    const AVFrame *frame_to_enc;
-    uint8_t *out_buf;
-    RoqTempData tmp_data;
-    roq_cell results4[4 * MAX_CBS_4x4];
-    int tmp_codebook_buf[FFMAX(24 * MAX_CBS_4x4, 6 * MAX_CBS_2x2)];
-
-    CelEvaluation *cel_evals;
-    int *closest_cb;
-    int *points;  // Allocated together with closest_cb
-
-    int first_frame;
-    int quake3_compat; // Quake 3 compatibility option
-} RoqEncContext;
-
 /* Macroblock support functions */
 static void unpack_roq_cell(roq_cell *cell, uint8_t u[4*3])
 {
@@ -223,10 +143,9 @@
     return sse;
 }
 
-static int eval_motion_dist(RoqEncContext *enc, int x, int y, motion_vect vect,
+static int eval_motion_dist(RoqContext *enc, int x, int y, motion_vect vect,
                              int size)
 {
-    RoqContext *const roq = &enc->common;
     int mx=vect.d[0];
     int my=vect.d[1];
 
@@ -239,12 +158,12 @@
     mx += x;
     my += y;
 
-    if ((unsigned) mx > roq->width-size || (unsigned) my > roq->height-size)
+    if ((unsigned) mx > enc->width-size || (unsigned) my > enc->height-size)
         return INT_MAX;
 
-    return block_sse(enc->frame_to_enc->data, roq->last_frame->data, x, y,
+    return block_sse(enc->frame_to_enc->data, enc->last_frame->data, x, y,
                      mx, my,
-                     enc->frame_to_enc->linesize, roq->last_frame->linesize,
+                     enc->frame_to_enc->linesize, enc->last_frame->linesize,
                      size);
 }
 
@@ -265,23 +184,78 @@
     return sdiff;
 }
 
+typedef struct SubcelEvaluation {
+    int eval_dist[4];
+    int best_bit_use;
+    int best_coding;
+
+    int subCels[4];
+    motion_vect motion;
+    int cbEntry;
+} SubcelEvaluation;
+
+typedef struct CelEvaluation {
+    int eval_dist[4];
+    int best_coding;
+
+    SubcelEvaluation subCels[4];
+
+    motion_vect motion;
+    int cbEntry;
+
+    int sourceX, sourceY;
+} CelEvaluation;
+
+typedef struct RoqCodebooks {
+    int numCB4;
+    int numCB2;
+    int usedCB2[MAX_CBS_2x2];
+    int usedCB4[MAX_CBS_4x4];
+    uint8_t unpacked_cb2[MAX_CBS_2x2*2*2*3];
+    uint8_t unpacked_cb4[MAX_CBS_4x4*4*4*3];
+    uint8_t unpacked_cb4_enlarged[MAX_CBS_4x4*8*8*3];
+} RoqCodebooks;
+
+/**
+ * Temporary vars
+ */
+typedef struct RoqTempData
+{
+    CelEvaluation *cel_evals;
+
+    int f2i4[MAX_CBS_4x4];
+    int i2f4[MAX_CBS_4x4];
+    int f2i2[MAX_CBS_2x2];
+    int i2f2[MAX_CBS_2x2];
+
+    int mainChunkSize;
+
+    int numCB4;
+    int numCB2;
+
+    RoqCodebooks codebooks;
+
+    int *closest_cb2;
+    int used_option[4];
+} RoqTempdata;
+
 /**
  * Initialize cel evaluators and set their source coordinates
  */
-static int create_cel_evals(RoqEncContext *enc)
+static int create_cel_evals(RoqContext *enc, RoqTempdata *tempData)
 {
-    RoqContext *const roq = &enc->common;
+    int n=0, x, y, i;
 
-    enc->cel_evals = av_malloc_array(roq->width * roq->height / 64, sizeof(CelEvaluation));
-    if (!enc->cel_evals)
+    tempData->cel_evals = av_malloc_array(enc->width*enc->height/64, sizeof(CelEvaluation));
+    if (!tempData->cel_evals)
         return AVERROR(ENOMEM);
 
     /* Map to the ROQ quadtree order */
-    for (int y = 0, n = 0; y < roq->height; y += 16)
-        for (int x = 0; x < roq->width; x += 16)
-            for(int i = 0; i < 4; i++) {
-                enc->cel_evals[n  ].sourceX = x + (i&1)*8;
-                enc->cel_evals[n++].sourceY = y + (i&2)*4;
+    for (y=0; y<enc->height; y+=16)
+        for (x=0; x<enc->width; x+=16)
+            for(i=0; i<4; i++) {
+                tempData->cel_evals[n  ].sourceX = x + (i&1)*8;
+                tempData->cel_evals[n++].sourceY = y + (i&2)*4;
             }
 
     return 0;
@@ -333,7 +307,7 @@
         } \
     } while(0)
 
-static void motion_search(RoqEncContext *enc, int blocksize)
+static void motion_search(RoqContext *enc, int blocksize)
 {
     static const motion_vect offsets[8] = {
         {{ 0,-1}},
@@ -346,7 +320,6 @@
         {{ 1, 1}},
     };
 
-    RoqContext *const roq = &enc->common;
     int diff, lowestdiff, oldbest;
     int off[3];
     motion_vect bestpick = {{0,0}};
@@ -355,7 +328,8 @@
     motion_vect *last_motion;
     motion_vect *this_motion;
     motion_vect vect, vect2;
-    const int max = (roq->width / blocksize) * roq->height / blocksize;
+
+    int max=(enc->width/blocksize)*enc->height/blocksize;
 
     if (blocksize == 4) {
         last_motion = enc->last_motion4;
@@ -365,17 +339,17 @@
         this_motion = enc->this_motion8;
     }
 
-    for (i = 0; i< roq->height; i += blocksize)
-        for (j = 0; j < roq->width; j += blocksize) {
+    for (i=0; i<enc->height; i+=blocksize)
+        for (j=0; j<enc->width; j+=blocksize) {
             lowestdiff = eval_motion_dist(enc, j, i, (motion_vect) {{0,0}},
                                           blocksize);
             bestpick.d[0] = 0;
             bestpick.d[1] = 0;
 
             if (blocksize == 4)
-                EVAL_MOTION(enc->this_motion8[(i/8) * (roq->width/8) + j/8]);
+                EVAL_MOTION(enc->this_motion8[(i/8)*(enc->width/8) + j/8]);
 
-            offset = (i/blocksize) * roq->width / blocksize + j / blocksize;
+            offset = (i/blocksize)*enc->width/blocksize + j/blocksize;
             if (offset < max && offset >= 0)
                 EVAL_MOTION(last_motion[offset]);
 
@@ -383,12 +357,12 @@
             if (offset < max && offset >= 0)
                 EVAL_MOTION(last_motion[offset]);
 
-            offset = (i/blocksize + 1) * roq->width / blocksize + j / blocksize;
+            offset = (i/blocksize + 1)*enc->width/blocksize + j/blocksize;
             if (offset < max && offset >= 0)
                 EVAL_MOTION(last_motion[offset]);
 
-            off[0]= (i/blocksize) * roq->width / blocksize + j/blocksize - 1;
-            off[1]= off[0] - roq->width / blocksize + 1;
+            off[0]= (i/blocksize)*enc->width/blocksize + j/blocksize - 1;
+            off[1]= off[0] - enc->width/blocksize + 1;
             off[2]= off[1] + 1;
 
             if (i) {
@@ -417,7 +391,7 @@
                 }
                 vect = bestpick;
             }
-            offset = (i/blocksize) * roq->width / blocksize + j/blocksize;
+            offset = (i/blocksize)*enc->width/blocksize + j/blocksize;
             this_motion[offset] = bestpick;
         }
 }
@@ -426,10 +400,8 @@
  * Get distortion for all options available to a subcel
  */
 static void gather_data_for_subcel(SubcelEvaluation *subcel, int x,
-                                   int y, RoqEncContext *enc)
+                                   int y, RoqContext *enc, RoqTempdata *tempData)
 {
-    RoqContext *const roq = &enc->common;
-    RoqTempData *const tempData = &enc->tmp_data;
     uint8_t mb4[4*4*3];
     uint8_t mb2[2*2*3];
     int cluster_index;
@@ -438,25 +410,25 @@
     static const int bitsUsed[4] = {2, 10, 10, 34};
 
     if (enc->framesSinceKeyframe >= 1) {
-        subcel->motion = enc->this_motion4[y * roq->width / 16 + x / 4];
+        subcel->motion = enc->this_motion4[y*enc->width/16 + x/4];
 
         subcel->eval_dist[RoQ_ID_FCC] =
             eval_motion_dist(enc, x, y,
-                             enc->this_motion4[y * roq->width / 16 + x / 4], 4);
+                             enc->this_motion4[y*enc->width/16 + x/4], 4);
     } else
         subcel->eval_dist[RoQ_ID_FCC] = INT_MAX;
 
     if (enc->framesSinceKeyframe >= 2)
         subcel->eval_dist[RoQ_ID_MOT] = block_sse(enc->frame_to_enc->data,
-                                                  roq->current_frame->data, x,
+                                                  enc->current_frame->data, x,
                                                   y, x, y,
                                                   enc->frame_to_enc->linesize,
-                                                  roq->current_frame->linesize,
+                                                  enc->current_frame->linesize,
                                                   4);
     else
         subcel->eval_dist[RoQ_ID_MOT] = INT_MAX;
 
-    cluster_index = y * roq->width / 16 + x / 4;
+    cluster_index = y*enc->width/16 + x/4;
 
     get_frame_mb(enc->frame_to_enc, x, y, mb4, 4);
 
@@ -468,7 +440,7 @@
     subcel->eval_dist[RoQ_ID_CCC] = 0;
 
     for(i=0;i<4;i++) {
-        subcel->subCels[i] = enc->closest_cb[cluster_index*4+i];
+        subcel->subCels[i] = tempData->closest_cb2[cluster_index*4+i];
 
         get_frame_mb(enc->frame_to_enc, x+2*(i&1),
                      y+(i&2), mb2, 2);
@@ -491,12 +463,11 @@
 /**
  * Get distortion for all options available to a cel
  */
-static void gather_data_for_cel(CelEvaluation *cel, RoqEncContext *enc)
+static void gather_data_for_cel(CelEvaluation *cel, RoqContext *enc,
+                                RoqTempdata *tempData)
 {
-    RoqContext *const roq = &enc->common;
-    RoqTempData *const tempData = &enc->tmp_data;
     uint8_t mb8[8*8*3];
-    int index = cel->sourceY * roq->width / 64 + cel->sourceX/8;
+    int index = cel->sourceY*enc->width/64 + cel->sourceX/8;
     int i, j, best_dist, divide_bit_use;
 
     int bitsUsed[4] = {2, 10, 10, 0};
@@ -512,11 +483,11 @@
 
     if (enc->framesSinceKeyframe >= 2)
         cel->eval_dist[RoQ_ID_MOT] = block_sse(enc->frame_to_enc->data,
-                                               roq->current_frame->data,
+                                               enc->current_frame->data,
                                                cel->sourceX, cel->sourceY,
                                                cel->sourceX, cel->sourceY,
                                                enc->frame_to_enc->linesize,
-                                               roq->current_frame->linesize,8);
+                                               enc->current_frame->linesize,8);
     else
         cel->eval_dist[RoQ_ID_MOT] = INT_MAX;
 
@@ -526,10 +497,10 @@
         index_mb(mb8, tempData->codebooks.unpacked_cb4_enlarged,
                  tempData->codebooks.numCB4, &cel->cbEntry, 8);
 
-    gather_data_for_subcel(cel->subCels + 0, cel->sourceX+0, cel->sourceY+0, enc);
-    gather_data_for_subcel(cel->subCels + 1, cel->sourceX+4, cel->sourceY+0, enc);
-    gather_data_for_subcel(cel->subCels + 2, cel->sourceX+0, cel->sourceY+4, enc);
-    gather_data_for_subcel(cel->subCels + 3, cel->sourceX+4, cel->sourceY+4, enc);
+    gather_data_for_subcel(cel->subCels + 0, cel->sourceX+0, cel->sourceY+0, enc, tempData);
+    gather_data_for_subcel(cel->subCels + 1, cel->sourceX+4, cel->sourceY+0, enc, tempData);
+    gather_data_for_subcel(cel->subCels + 2, cel->sourceX+0, cel->sourceY+4, enc, tempData);
+    gather_data_for_subcel(cel->subCels + 3, cel->sourceX+4, cel->sourceY+4, enc, tempData);
 
     cel->eval_dist[RoQ_ID_CCC] = 0;
     divide_bit_use = 0;
@@ -566,10 +537,8 @@
         }
 }
 
-static void remap_codebooks(RoqEncContext *enc)
+static void remap_codebooks(RoqContext *enc, RoqTempdata *tempData)
 {
-    RoqContext *const roq = &enc->common;
-    RoqTempData *const tempData = &enc->tmp_data;
     int i, j, idx=0;
 
     /* Make remaps for the final codebook usage */
@@ -578,7 +547,7 @@
             tempData->i2f4[i] = idx;
             tempData->f2i4[idx] = i;
             for (j=0; j<4; j++)
-                tempData->codebooks.usedCB2[roq->cb4x4[i].idx[j]]++;
+                tempData->codebooks.usedCB2[enc->cb4x4[i].idx[j]]++;
             idx++;
         }
     }
@@ -600,10 +569,8 @@
 /**
  * Write codebook chunk
  */
-static void write_codebooks(RoqEncContext *enc)
+static void write_codebooks(RoqContext *enc, RoqTempdata *tempData)
 {
-    RoqContext *const roq = &enc->common;
-    RoqTempData *const tempData = &enc->tmp_data;
     int i, j;
     uint8_t **outp= &enc->out_buf;
 
@@ -614,14 +581,14 @@
         bytestream_put_byte(outp, tempData->numCB2);
 
         for (i=0; i<tempData->numCB2; i++) {
-            bytestream_put_buffer(outp, roq->cb2x2[tempData->f2i2[i]].y, 4);
-            bytestream_put_byte(outp, roq->cb2x2[tempData->f2i2[i]].u);
-            bytestream_put_byte(outp, roq->cb2x2[tempData->f2i2[i]].v);
+            bytestream_put_buffer(outp, enc->cb2x2[tempData->f2i2[i]].y, 4);
+            bytestream_put_byte(outp, enc->cb2x2[tempData->f2i2[i]].u);
+            bytestream_put_byte(outp, enc->cb2x2[tempData->f2i2[i]].v);
         }
 
         for (i=0; i<tempData->numCB4; i++)
             for (j=0; j<4; j++)
-                bytestream_put_byte(outp, tempData->i2f2[roq->cb4x4[tempData->f2i4[i]].idx[j]]);
+                bytestream_put_byte(outp, tempData->i2f2[enc->cb4x4[tempData->f2i4[i]].idx[j]]);
 
     }
 }
@@ -656,11 +623,8 @@
     }
 }
 
-static void reconstruct_and_encode_image(RoqEncContext *enc,
-                                         int w, int h, int numBlocks)
+static void reconstruct_and_encode_image(RoqContext *enc, RoqTempdata *tempData, int w, int h, int numBlocks)
 {
-    RoqContext *const roq = &enc->common;
-    RoqTempData *const tempData = &enc->tmp_data;
     int i, j, k;
     int x, y;
     int subX, subY;
@@ -686,7 +650,7 @@
     bytestream_put_byte(&enc->out_buf, 0x0);
 
     for (i=0; i<numBlocks; i++) {
-        eval = enc->cel_evals + i;
+        eval = tempData->cel_evals + i;
 
         x = eval->sourceX;
         y = eval->sourceY;
@@ -701,7 +665,7 @@
             bytestream_put_byte(&spool.args, motion_arg(eval->motion));
 
             write_typecode(&spool, RoQ_ID_FCC);
-            ff_apply_motion_8x8(roq, x, y,
+            ff_apply_motion_8x8(enc, x, y,
                                 eval->motion.d[0], eval->motion.d[1]);
             break;
 
@@ -709,11 +673,11 @@
             bytestream_put_byte(&spool.args, tempData->i2f4[eval->cbEntry]);
             write_typecode(&spool, RoQ_ID_SLD);
 
-            qcell = roq->cb4x4 + eval->cbEntry;
-            ff_apply_vector_4x4(roq, x  , y  , roq->cb2x2 + qcell->idx[0]);
-            ff_apply_vector_4x4(roq, x+4, y  , roq->cb2x2 + qcell->idx[1]);
-            ff_apply_vector_4x4(roq, x  , y+4, roq->cb2x2 + qcell->idx[2]);
-            ff_apply_vector_4x4(roq, x+4, y+4, roq->cb2x2 + qcell->idx[3]);
+            qcell = enc->cb4x4 + eval->cbEntry;
+            ff_apply_vector_4x4(enc, x  , y  , enc->cb2x2 + qcell->idx[0]);
+            ff_apply_vector_4x4(enc, x+4, y  , enc->cb2x2 + qcell->idx[1]);
+            ff_apply_vector_4x4(enc, x  , y+4, enc->cb2x2 + qcell->idx[2]);
+            ff_apply_vector_4x4(enc, x+4, y+4, enc->cb2x2 + qcell->idx[3]);
             break;
 
         case RoQ_ID_CCC:
@@ -731,7 +695,7 @@
                     bytestream_put_byte(&spool.args,
                                         motion_arg(eval->subCels[j].motion));
 
-                    ff_apply_motion_4x4(roq, subX, subY,
+                    ff_apply_motion_4x4(enc, subX, subY,
                                         eval->subCels[j].motion.d[0],
                                         eval->subCels[j].motion.d[1]);
                     break;
@@ -740,16 +704,16 @@
                     bytestream_put_byte(&spool.args,
                                         tempData->i2f4[eval->subCels[j].cbEntry]);
 
-                    qcell = roq->cb4x4 + eval->subCels[j].cbEntry;
+                    qcell = enc->cb4x4 + eval->subCels[j].cbEntry;
 
-                    ff_apply_vector_2x2(roq, subX  , subY  ,
-                                        roq->cb2x2 + qcell->idx[0]);
-                    ff_apply_vector_2x2(roq, subX+2, subY  ,
-                                        roq->cb2x2 + qcell->idx[1]);
-                    ff_apply_vector_2x2(roq, subX  , subY+2,
-                                        roq->cb2x2 + qcell->idx[2]);
-                    ff_apply_vector_2x2(roq, subX+2, subY+2,
-                                        roq->cb2x2 + qcell->idx[3]);
+                    ff_apply_vector_2x2(enc, subX  , subY  ,
+                                        enc->cb2x2 + qcell->idx[0]);
+                    ff_apply_vector_2x2(enc, subX+2, subY  ,
+                                        enc->cb2x2 + qcell->idx[1]);
+                    ff_apply_vector_2x2(enc, subX  , subY+2,
+                                        enc->cb2x2 + qcell->idx[2]);
+                    ff_apply_vector_2x2(enc, subX+2, subY+2,
+                                        enc->cb2x2 + qcell->idx[3]);
                     break;
 
                 case RoQ_ID_CCC:
@@ -758,8 +722,8 @@
                         bytestream_put_byte(&spool.args,
                                             tempData->i2f2[cb_idx]);
 
-                        ff_apply_vector_2x2(roq, subX + 2*(k&1), subY + (k&2),
-                                            roq->cb2x2 + cb_idx);
+                        ff_apply_vector_2x2(enc, subX + 2*(k&1), subY + (k&2),
+                                            enc->cb2x2 + cb_idx);
                     }
                     break;
                 }
@@ -778,7 +742,7 @@
 /**
  * Create a single YUV cell from a 2x2 section of the image
  */
-static inline void frame_block_to_cell(int *block, uint8_t * const *data,
+static inline void frame_block_to_cell(uint8_t *block, uint8_t * const *data,
                                        int top, int left, const int *stride)
 {
     int i, j, u=0, v=0;
@@ -792,14 +756,14 @@
             v       += data[2][x];
         }
 
-    *block++ = (u + 2) / 4 * CHROMA_BIAS;
-    *block++ = (v + 2) / 4 * CHROMA_BIAS;
+    *block++ = (u+2)/4;
+    *block++ = (v+2)/4;
 }
 
 /**
  * Create YUV clusters for the entire image
  */
-static void create_clusters(const AVFrame *frame, int w, int h, int *points)
+static void create_clusters(const AVFrame *frame, int w, int h, uint8_t *yuvClusters)
 {
     int i, j, k, l;
 
@@ -807,30 +771,42 @@
         for (j=0; j<w; j+=4) {
             for (k=0; k < 2; k++)
                 for (l=0; l < 2; l++)
-                    frame_block_to_cell(points + (l + 2*k)*6, frame->data,
+                    frame_block_to_cell(yuvClusters + (l + 2*k)*6, frame->data,
                                         i+2*k, j+2*l, frame->linesize);
-            points += 24;
+            yuvClusters += 24;
         }
 }
 
-static int generate_codebook(RoqEncContext *enc,
+static int generate_codebook(RoqContext *enc, RoqTempdata *tempdata,
                              int *points, int inputCount, roq_cell *results,
                              int size, int cbsize)
 {
     int i, j, k, ret = 0;
     int c_size = size*size/4;
     int *buf;
-    int *codebook = enc->tmp_codebook_buf;
-    int *closest_cb = enc->closest_cb;
+    int *codebook = av_malloc_array(6*c_size, cbsize*sizeof(int));
+    int *closest_cb;
+
+    if (!codebook)
+        return AVERROR(ENOMEM);
+
+    if (size == 4) {
+        closest_cb = av_malloc_array(6*c_size, inputCount*sizeof(int));
+        if (!closest_cb) {
+            ret = AVERROR(ENOMEM);
+            goto out;
+        }
+    } else
+        closest_cb = tempdata->closest_cb2;
 
     ret = avpriv_init_elbg(points, 6 * c_size, inputCount, codebook,
                        cbsize, 1, closest_cb, &enc->randctx);
     if (ret < 0)
-        return ret;
+        goto out;
     ret = avpriv_do_elbg(points, 6 * c_size, inputCount, codebook,
                      cbsize, 1, closest_cb, &enc->randctx);
     if (ret < 0)
-        return ret;
+        goto out;
 
     buf = codebook;
     for (i=0; i<cbsize; i++)
@@ -842,64 +818,93 @@
             results->v =    (*buf++ + CHROMA_BIAS/2)/CHROMA_BIAS;
             results++;
         }
-    return 0;
+out:
+    if (size == 4)
+        av_free(closest_cb);
+    av_free(codebook);
+    return ret;
 }
 
-static int generate_new_codebooks(RoqEncContext *enc)
+static int generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
 {
     int i, j, ret = 0;
-    RoqCodebooks *codebooks = &enc->tmp_data.codebooks;
-    RoqContext *const roq = &enc->common;
-    int max = roq->width * roq->height / 16;
+    RoqCodebooks *codebooks = &tempData->codebooks;
+    int max = enc->width*enc->height/16;
     uint8_t mb2[3*4];
-    int *points = enc->points;
+    roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
+    uint8_t *yuvClusters=av_malloc_array(max, sizeof(int)*6*4);
+    int *points = av_malloc_array(max, 6*4*sizeof(int));
+    int bias;
+
+    if (!results4 || !yuvClusters || !points) {
+        ret = AVERROR(ENOMEM);
+        goto out;
+    }
 
     /* Subsample YUV data */
-    create_clusters(enc->frame_to_enc, roq->width, roq->height, points);
+    create_clusters(enc->frame_to_enc, enc->width, enc->height, yuvClusters);
+
+    /* Cast to integer and apply chroma bias */
+    for (i=0; i<max*24; i++) {
+        bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
+        points[i] = bias*yuvClusters[i];
+    }
+
+    /* Create 4x4 codebooks */
+    if ((ret = generate_codebook(enc, tempData, points, max,
+                                 results4, 4, (enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4))) < 0)
+        goto out;
 
     codebooks->numCB4 = (enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4);
 
-    /* Create 4x4 codebooks */
-    if ((ret = generate_codebook(enc, points, max, enc->results4,
-                                 4, codebooks->numCB4)) < 0)
-        return ret;
+    tempData->closest_cb2 = av_malloc_array(max, 4*sizeof(int));
+    if (!tempData->closest_cb2) {
+        ret = AVERROR(ENOMEM);
+        goto out;
+    }
 
     /* Create 2x2 codebooks */
-    if ((ret = generate_codebook(enc, points, max * 4,
-                                 roq->cb2x2, 2, MAX_CBS_2x2)) < 0)
-        return ret;
+    if ((ret = generate_codebook(enc, tempData, points, max * 4,
+                                 enc->cb2x2, 2, MAX_CBS_2x2)) < 0)
+        goto out;
 
     codebooks->numCB2 = MAX_CBS_2x2;
 
     /* Unpack 2x2 codebook clusters */
     for (i=0; i<codebooks->numCB2; i++)
-        unpack_roq_cell(roq->cb2x2 + i, codebooks->unpacked_cb2 + i*2*2*3);
+        unpack_roq_cell(enc->cb2x2 + i, codebooks->unpacked_cb2 + i*2*2*3);
 
     /* Index all 4x4 entries to the 2x2 entries, unpack, and enlarge */
     for (i=0; i<codebooks->numCB4; i++) {
         for (j=0; j<4; j++) {
-            unpack_roq_cell(&enc->results4[4*i + j], mb2);
+            unpack_roq_cell(&results4[4*i + j], mb2);
             index_mb(mb2, codebooks->unpacked_cb2, codebooks->numCB2,
-                     &roq->cb4x4[i].idx[j], 2);
+                     &enc->cb4x4[i].idx[j], 2);
         }
-        unpack_roq_qcell(codebooks->unpacked_cb2, roq->cb4x4 + i,
+        unpack_roq_qcell(codebooks->unpacked_cb2, enc->cb4x4 + i,
                          codebooks->unpacked_cb4 + i*4*4*3);
         enlarge_roq_mb4(codebooks->unpacked_cb4 + i*4*4*3,
                         codebooks->unpacked_cb4_enlarged + i*8*8*3);
     }
-
-    return 0;
+out:
+    av_free(yuvClusters);
+    av_free(points);
+    av_free(results4);
+    return ret;
 }
 
-static int roq_encode_video(RoqEncContext *enc)
+static int roq_encode_video(RoqContext *enc)
 {
-    RoqTempData *const tempData = &enc->tmp_data;
-    RoqContext *const roq = &enc->common;
-    int ret;
+    RoqTempdata *tempData = enc->tmpData;
+    int i, ret;
 
     memset(tempData, 0, sizeof(*tempData));
 
-    ret = generate_new_codebooks(enc);
+    ret = create_cel_evals(enc, tempData);
+    if (ret < 0)
+        return ret;
+
+    ret = generate_new_codebooks(enc, tempData);
     if (ret < 0)
         return ret;
 
@@ -909,16 +914,16 @@
     }
 
  retry_encode:
-    for (int i = 0; i < roq->width * roq->height / 64; i++)
-        gather_data_for_cel(enc->cel_evals + i, enc);
+    for (i=0; i<enc->width*enc->height/64; i++)
+        gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
 
     /* Quake 3 can't handle chunks bigger than 65535 bytes */
     if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {
         if (enc->lambda > 100000) {
-            av_log(roq->avctx, AV_LOG_ERROR, "Cannot encode video in Quake compatible form\n");
+            av_log(enc->avctx, AV_LOG_ERROR, "Cannot encode video in Quake compatible form\n");
             return AVERROR(EINVAL);
         }
-        av_log(roq->avctx, AV_LOG_ERROR,
+        av_log(enc->avctx, AV_LOG_ERROR,
                "Warning, generated a frame too big for Quake (%d > 65535), "
                "now switching to a bigger qscale value.\n",
                tempData->mainChunkSize/8);
@@ -933,18 +938,21 @@
         goto retry_encode;
     }
 
-    remap_codebooks(enc);
+    remap_codebooks(enc, tempData);
 
-    write_codebooks(enc);
+    write_codebooks(enc, tempData);
 
-    reconstruct_and_encode_image(enc, roq->width, roq->height,
-                                 roq->width * roq->height / 64);
+    reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,
+                                 enc->width*enc->height/64);
 
     /* Rotate frame history */
-    FFSWAP(AVFrame *,    roq->current_frame,   roq->last_frame);
+    FFSWAP(AVFrame *, enc->current_frame, enc->last_frame);
     FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);
     FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);
 
+    av_freep(&tempData->cel_evals);
+    av_freep(&tempData->closest_cb2);
+
     enc->framesSinceKeyframe++;
 
     return 0;
@@ -952,13 +960,12 @@
 
 static av_cold int roq_encode_end(AVCodecContext *avctx)
 {
-    RoqEncContext *const enc = avctx->priv_data;
+    RoqContext *enc = avctx->priv_data;
 
-    av_frame_free(&enc->common.current_frame);
-    av_frame_free(&enc->common.last_frame);
+    av_frame_free(&enc->current_frame);
+    av_frame_free(&enc->last_frame);
 
-    av_freep(&enc->cel_evals);
-    av_freep(&enc->closest_cb);
+    av_freep(&enc->tmpData);
     av_freep(&enc->this_motion4);
     av_freep(&enc->last_motion4);
     av_freep(&enc->this_motion8);
@@ -969,12 +976,11 @@
 
 static av_cold int roq_encode_init(AVCodecContext *avctx)
 {
-    RoqEncContext *const enc = avctx->priv_data;
-    RoqContext    *const roq = &enc->common;
+    RoqContext *enc = avctx->priv_data;
 
     av_lfg_init(&enc->randctx, 1);
 
-    roq->avctx = avctx;
+    enc->avctx = avctx;
 
     enc->framesSinceKeyframe = 0;
     if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
@@ -990,44 +996,39 @@
     if (((avctx->width)&(avctx->width-1))||((avctx->height)&(avctx->height-1)))
         av_log(avctx, AV_LOG_ERROR, "Warning: dimensions not power of two, this is not supported by quake\n");
 
-    roq->width  = avctx->width;
-    roq->height = avctx->height;
+    enc->width = avctx->width;
+    enc->height = avctx->height;
 
     enc->framesSinceKeyframe = 0;
     enc->first_frame = 1;
 
-    roq->last_frame    = av_frame_alloc();
-    roq->current_frame = av_frame_alloc();
-    if (!roq->last_frame || !roq->current_frame)
+    enc->last_frame    = av_frame_alloc();
+    enc->current_frame = av_frame_alloc();
+    if (!enc->last_frame || !enc->current_frame)
         return AVERROR(ENOMEM);
 
+    enc->tmpData      = av_malloc(sizeof(RoqTempdata));
+
     enc->this_motion4 =
-        av_mallocz_array(roq->width * roq->height / 16, sizeof(motion_vect));
+        av_mallocz_array((enc->width*enc->height/16), sizeof(motion_vect));
 
     enc->last_motion4 =
-        av_malloc_array (roq->width * roq->height / 16, sizeof(motion_vect));
+        av_malloc_array ((enc->width*enc->height/16), sizeof(motion_vect));
 
     enc->this_motion8 =
-        av_mallocz_array(roq->width * roq->height / 64, sizeof(motion_vect));
+        av_mallocz_array((enc->width*enc->height/64), sizeof(motion_vect));
 
     enc->last_motion8 =
-        av_malloc_array (roq->width * roq->height / 64, sizeof(motion_vect));
+        av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
 
-    /* 4x4 codebook needs 6 * 4 * 4 / 4 * width * height / 16 * sizeof(int);
-     * and so does the points buffer. */
-    enc->closest_cb   =
-        av_malloc_array(roq->width * roq->height, 3 * sizeof(int));
-
-    if (!enc->this_motion4 || !enc->last_motion4 ||
-        !enc->this_motion8 || !enc->last_motion8 || !enc->closest_cb)
+    if (!enc->tmpData || !enc->this_motion4 || !enc->last_motion4 ||
+        !enc->this_motion8 || !enc->last_motion8)
         return AVERROR(ENOMEM);
 
-    enc->points = enc->closest_cb + roq->width * roq->height * 3 / 2;
-
-    return create_cel_evals(enc);
+    return 0;
 }
 
-static void roq_write_video_info_chunk(RoqEncContext *enc)
+static void roq_write_video_info_chunk(RoqContext *enc)
 {
     /* ROQ info chunk */
     bytestream_put_le16(&enc->out_buf, RoQ_INFO);
@@ -1040,10 +1041,10 @@
     bytestream_put_byte(&enc->out_buf, 0x00);
 
     /* Width */
-    bytestream_put_le16(&enc->out_buf, enc->common.width);
+    bytestream_put_le16(&enc->out_buf, enc->width);
 
     /* Height */
-    bytestream_put_le16(&enc->out_buf, enc->common.height);
+    bytestream_put_le16(&enc->out_buf, enc->height);
 
     /* Unused in Quake 3, mimics the output of the real encoder */
     bytestream_put_byte(&enc->out_buf, 0x08);
@@ -1055,11 +1056,10 @@
 static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                             const AVFrame *frame, int *got_packet)
 {
-    RoqEncContext *const enc = avctx->priv_data;
-    RoqContext    *const roq = &enc->common;
+    RoqContext *enc = avctx->priv_data;
     int size, ret;
 
-    roq->avctx = avctx;
+    enc->avctx = avctx;
 
     enc->frame_to_enc = frame;
 
@@ -1070,7 +1070,7 @@
 
     /* 138 bits max per 8x8 block +
      *     256 codebooks*(6 bytes 2x2 + 4 bytes 4x4) + 8 bytes frame header */
-    size = ((roq->width * roq->height / 64) * 138 + 7) / 8 + 256 * (6 + 4) + 8;
+    size = ((enc->width * enc->height / 64) * 138 + 7) / 8 + 256 * (6 + 4) + 8;
     if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0)
         return ret;
     enc->out_buf = pkt->data;
@@ -1082,8 +1082,8 @@
     if (enc->first_frame) {
         /* Alloc memory for the reconstruction data (we must know the stride
          for that) */
-        if ((ret = ff_get_buffer(avctx, roq->current_frame, 0)) < 0 ||
-            (ret = ff_get_buffer(avctx, roq->last_frame,    0)) < 0)
+        if ((ret = ff_get_buffer(avctx, enc->current_frame, 0)) < 0 ||
+            (ret = ff_get_buffer(avctx, enc->last_frame,    0)) < 0)
             return ret;
 
         /* Before the first video frame, write a "video info" chunk */
@@ -1105,7 +1105,7 @@
     return 0;
 }
 
-#define OFFSET(x) offsetof(RoqEncContext, x)
+#define OFFSET(x) offsetof(RoqContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
     { "quake3_compat", "Whether to respect known limitations in Quake 3 decoder", OFFSET(quake3_compat), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
@@ -1124,7 +1124,7 @@
     .long_name            = NULL_IF_CONFIG_SMALL("id RoQ video"),
     .type                 = AVMEDIA_TYPE_VIDEO,
     .id                   = AV_CODEC_ID_ROQ,
-    .priv_data_size       = sizeof(RoqEncContext),
+    .priv_data_size       = sizeof(RoqContext),
     .init                 = roq_encode_init,
     .encode2              = roq_encode_frame,
     .close                = roq_encode_end,
diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index 79b02da..bd05209 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -300,10 +300,6 @@
             ret = AVERROR_INVALIDDATA;
             goto end;
         }
-        if (ctx->inflated_size < pixel_size) {
-            ret = AVERROR_INVALIDDATA;
-            goto end;
-        }
         ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
         if (ret) {
             av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);
@@ -346,7 +342,7 @@
 
     /* Palette handling */
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        buffer_size_t size;
+        int size;
         const uint8_t *palette = av_packet_get_side_data(avpkt,
                                                          AV_PKT_DATA_PALETTE,
                                                          &size);
diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h
index d4dc074..d22ff40 100644
--- a/libavcodec/rtjpeg.h
+++ b/libavcodec/rtjpeg.h
@@ -24,7 +24,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "idctdsp.h"
 
 #define RTJPEG_FILE_VERSION 0
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index d5c7480..d118515 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -374,6 +374,7 @@
                                    avctx->coded_height, 0, avctx)) < 0)
         return ret;
 
+    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
 
     s->out_format  = FMT_H263;
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 7e5bfe0..13f9b60 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -27,9 +27,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
-#include "libavutil/video_enc_params.h"
 
 #include "avcodec.h"
 #include "error_resilience.h"
@@ -1489,6 +1487,7 @@
     MpegEncContext *s = &r->s;
     int ret;
 
+    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
     s->out_format = FMT_H263;
 
diff --git a/libavcodec/rv34.h b/libavcodec/rv34.h
index 53b29dc..1d55225 100644
--- a/libavcodec/rv34.h
+++ b/libavcodec/rv34.h
@@ -27,8 +27,6 @@
 #ifndef AVCODEC_RV34_H
 #define AVCODEC_RV34_H
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "mpegvideo.h"
 
diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h
index 4509e1f..32ecc39 100644
--- a/libavcodec/rv34data.h
+++ b/libavcodec/rv34data.h
@@ -100,6 +100,19 @@
 };
 
 /**
+ * table for obtaining the quantizer difference
+ * @todo Use with ff_modified_quant_tab from h263data.h.
+ */
+static const uint8_t rv34_dquant_tab[2][32]={
+//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+{
+    0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,10,11,12,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28
+},{
+    0, 2, 3, 4, 5, 6, 7, 8, 9,10,11,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,31,31,26
+}
+};
+
+/**
  * maximum number of macroblocks for each of the possible slice offset sizes
  * @todo This is the same as ff_mba_max, maybe use it instead.
  */
diff --git a/libavcodec/sbc.h b/libavcodec/sbc.h
index 419c8ea..de9c8d9 100644
--- a/libavcodec/sbc.h
+++ b/libavcodec/sbc.h
@@ -35,7 +35,6 @@
 
 #include "avcodec.h"
 #include "libavutil/crc.h"
-#include "libavutil/mem_internal.h"
 
 #define MSBC_BLOCKS 15
 
diff --git a/libavcodec/sbc_parser.c b/libavcodec/sbc_parser.c
index 5549b19..f565641 100644
--- a/libavcodec/sbc_parser.c
+++ b/libavcodec/sbc_parser.c
@@ -42,6 +42,7 @@
 
     if (data[0] == MSBC_SYNCWORD && data[1] == 0 && data[2] == 0) {
         avctx->channels = 1;
+        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
         avctx->sample_rate = 16000;
         avctx->frame_size = 120;
         s->duration = avctx->frame_size;
@@ -65,6 +66,7 @@
                  + (joint * subbands)) + 7) / 8;
 
     avctx->channels = channels;
+    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     avctx->sample_rate = sample_rates[sr];
     avctx->frame_size = subbands * blocks;
     s->duration = avctx->frame_size;
diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c
index bb590e8..b8f01d5 100644
--- a/libavcodec/sbcdec.c
+++ b/libavcodec/sbcdec.c
@@ -33,7 +33,6 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 #include "sbc.h"
 #include "sbcdec_data.h"
 
diff --git a/libavcodec/sbcdsp.h b/libavcodec/sbcdsp.h
index 24264df..334c058 100644
--- a/libavcodec/sbcdsp.h
+++ b/libavcodec/sbcdsp.h
@@ -32,8 +32,6 @@
 #ifndef AVCODEC_SBCDSP_H
 #define AVCODEC_SBCDSP_H
 
-#include "libavutil/mem_internal.h"
-
 #include "sbc.h"
 #include "sbcdsp_data.h"
 
diff --git a/libavcodec/sbcdsp_data.c b/libavcodec/sbcdsp_data.c
index ad6390c..78c07c0 100644
--- a/libavcodec/sbcdsp_data.c
+++ b/libavcodec/sbcdsp_data.c
@@ -29,8 +29,6 @@
  * miscellaneous SBC tables
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "sbcdsp_data.h"
 
 #define F_PROTO(x) ((int32_t) (((x) * 2) * ((int32_t) 1 << 15) + 0.5))
diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h
index f80f122..eb7d1ae 100644
--- a/libavcodec/sbr.h
+++ b/libavcodec/sbr.h
@@ -30,9 +30,6 @@
 #define AVCODEC_SBR_H
 
 #include <stdint.h>
-
-#include "libavutil/mem_internal.h"
-
 #include "fft.h"
 #include "aacps.h"
 #include "sbrdsp.h"
diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c
index 78c5888..1ed764b 100644
--- a/libavcodec/scpr3.c
+++ b/libavcodec/scpr3.c
@@ -524,16 +524,32 @@
 
 static int update_model1_to_5(PixelModel3 *m, uint32_t val)
 {
+    PixelModel3 n = {0};
     int i, size, freqs;
     uint32_t a;
 
-    update_model1_to_4(m, val);
     size = m->size;
+    n.size = size;
+    for (i = 0; i < size; i++) {
+        n.symbols[i] = m->symbols[i];
+    }
+    AV_QSORT(n.symbols, size, uint8_t, cmpbytes);
+    size = n.size;
+    for (i = 0; i < size; i++) {
+        if (val == n.symbols[i]) {
+            n.freqs[i] = 100;
+            n.maxpos = i;
+        } else {
+            n.freqs[i] = 50;
+        }
+    }
     a = 256 - size;
     for (i = 0; i < size; i++, a += freqs)
-        freqs = m->freqs[i];
-    m->type = 5;
-    m->cntsum = a;
+        freqs = n.freqs[i];
+    n.type = 5;
+    n.cntsum = a;
+
+    memcpy(m, &n, sizeof(n));
 
     return 0;
 }
diff --git a/libavcodec/sei.h b/libavcodec/sei.h
deleted file mode 100644
index 5513590..0000000
--- a/libavcodec/sei.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SEI_H
-#define AVCODEC_SEI_H
-
-// SEI payload types form a common namespace between the H.264, H.265
-// and H.266 standards.  A given payload type always has the same
-// meaning, but some names have different payload types in different
-// standards (e.g. scalable-nesting is 30 in H.264 but 133 in H.265).
-// The content of the payload data depends on the standard, though
-// many generic parts have the same interpretation everywhere (such as
-// mastering-display-colour-volume and user-data-unregistered).
-enum {
-    SEI_TYPE_BUFFERING_PERIOD                            = 0,
-    SEI_TYPE_PIC_TIMING                                  = 1,
-    SEI_TYPE_PAN_SCAN_RECT                               = 2,
-    SEI_TYPE_FILLER_PAYLOAD                              = 3,
-    SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35              = 4,
-    SEI_TYPE_USER_DATA_UNREGISTERED                      = 5,
-    SEI_TYPE_RECOVERY_POINT                              = 6,
-    SEI_TYPE_DEC_REF_PIC_MARKING_REPETITION              = 7,
-    SEI_TYPE_SPARE_PIC                                   = 8,
-    SEI_TYPE_SCENE_INFO                                  = 9,
-    SEI_TYPE_SUB_SEQ_INFO                                = 10,
-    SEI_TYPE_SUB_SEQ_LAYER_CHARACTERISTICS               = 11,
-    SEI_TYPE_SUB_SEQ_CHARACTERISTICS                     = 12,
-    SEI_TYPE_FULL_FRAME_FREEZE                           = 13,
-    SEI_TYPE_FULL_FRAME_FREEZE_RELEASE                   = 14,
-    SEI_TYPE_FULL_FRAME_SNAPSHOT                         = 15,
-    SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START        = 16,
-    SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END          = 17,
-    SEI_TYPE_MOTION_CONSTRAINED_SLICE_GROUP_SET          = 18,
-    SEI_TYPE_FILM_GRAIN_CHARACTERISTICS                  = 19,
-    SEI_TYPE_DEBLOCKING_FILTER_DISPLAY_PREFERENCE        = 20,
-    SEI_TYPE_STEREO_VIDEO_INFO                           = 21,
-    SEI_TYPE_POST_FILTER_HINT                            = 22,
-    SEI_TYPE_TONE_MAPPING_INFO                           = 23,
-    SEI_TYPE_SCALABILITY_INFO                            = 24,
-    SEI_TYPE_SUB_PIC_SCALABLE_LAYER                      = 25,
-    SEI_TYPE_NON_REQUIRED_LAYER_REP                      = 26,
-    SEI_TYPE_PRIORITY_LAYER_INFO                         = 27,
-    SEI_TYPE_LAYERS_NOT_PRESENT_4                        = 28,
-    SEI_TYPE_LAYER_DEPENDENCY_CHANGE                     = 29,
-    SEI_TYPE_SCALABLE_NESTING_4                          = 30,
-    SEI_TYPE_BASE_LAYER_TEMPORAL_HRD                     = 31,
-    SEI_TYPE_QUALITY_LAYER_INTEGRITY_CHECK               = 32,
-    SEI_TYPE_REDUNDANT_PIC_PROPERTY                      = 33,
-    SEI_TYPE_TL0_DEP_REP_INDEX                           = 34,
-    SEI_TYPE_TL_SWITCHING_POINT                          = 35,
-    SEI_TYPE_PARALLEL_DECODING_INFO                      = 36,
-    SEI_TYPE_MVC_SCALABLE_NESTING                        = 37,
-    SEI_TYPE_VIEW_SCALABILITY_INFO                       = 38,
-    SEI_TYPE_MULTIVIEW_SCENE_INFO_4                      = 39,
-    SEI_TYPE_MULTIVIEW_ACQUISITION_INFO_4                = 40,
-    SEI_TYPE_NON_REQUIRED_VIEW_COMPONENT                 = 41,
-    SEI_TYPE_VIEW_DEPENDENCY_CHANGE                      = 42,
-    SEI_TYPE_OPERATION_POINTS_NOT_PRESENT                = 43,
-    SEI_TYPE_BASE_VIEW_TEMPORAL_HRD                      = 44,
-    SEI_TYPE_FRAME_PACKING_ARRANGEMENT                   = 45,
-    SEI_TYPE_MULTIVIEW_VIEW_POSITION_4                   = 46,
-    SEI_TYPE_DISPLAY_ORIENTATION                         = 47,
-    SEI_TYPE_MVCD_SCALABLE_NESTING                       = 48,
-    SEI_TYPE_MVCD_VIEW_SCALABILITY_INFO                  = 49,
-    SEI_TYPE_DEPTH_REPRESENTATION_INFO_4                 = 50,
-    SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO_4 = 51,
-    SEI_TYPE_DEPTH_TIMING                                = 52,
-    SEI_TYPE_DEPTH_SAMPLING_INFO                         = 53,
-    SEI_TYPE_CONSTRAINED_DEPTH_PARAMETER_SET_IDENTIFIER  = 54,
-    SEI_TYPE_GREEN_METADATA                              = 56,
-    SEI_TYPE_STRUCTURE_OF_PICTURES_INFO                  = 128,
-    SEI_TYPE_ACTIVE_PARAMETER_SETS                       = 129,
-    SEI_TYPE_PARAMETER_SETS_INCLUSION_INDICATION         = SEI_TYPE_ACTIVE_PARAMETER_SETS,
-    SEI_TYPE_DECODING_UNIT_INFO                          = 130,
-    SEI_TYPE_TEMPORAL_SUB_LAYER_ZERO_IDX                 = 131,
-    SEI_TYPE_DECODED_PICTURE_HASH                        = 132,
-    SEI_TYPE_SCALABLE_NESTING_5                          = 133,
-    SEI_TYPE_REGION_REFRESH_INFO                         = 134,
-    SEI_TYPE_NO_DISPLAY                                  = 135,
-    SEI_TYPE_TIME_CODE                                   = 136,
-    SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME             = 137,
-    SEI_TYPE_SEGMENTED_RECT_FRAME_PACKING_ARRANGEMENT    = 138,
-    SEI_TYPE_TEMPORAL_MOTION_CONSTRAINED_TILE_SETS       = 139,
-    SEI_TYPE_CHROMA_RESAMPLING_FILTER_HINT               = 140,
-    SEI_TYPE_KNEE_FUNCTION_INFO                          = 141,
-    SEI_TYPE_COLOUR_REMAPPING_INFO                       = 142,
-    SEI_TYPE_DEINTERLACED_FIELD_IDENTIFICATION           = 143,
-    SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO                    = 144,
-    SEI_TYPE_DEPENDENT_RAP_INDICATION                    = 145,
-    SEI_TYPE_CODED_REGION_COMPLETION                     = 146,
-    SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS        = 147,
-    SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT                 = 148,
-    SEI_TYPE_CONTENT_COLOUR_VOLUME                       = 149,
-    SEI_TYPE_EQUIRECTANGULAR_PROJECTION                  = 150,
-    SEI_TYPE_CUBEMAP_PROJECTION                          = 151,
-    SEI_TYPE_FISHEYE_VIDEO_INFO                          = 152,
-    SEI_TYPE_SPHERE_ROTATION                             = 154,
-    SEI_TYPE_REGIONWISE_PACKING                          = 155,
-    SEI_TYPE_OMNI_VIEWPORT                               = 156,
-    SEI_TYPE_REGIONAL_NESTING                            = 157,
-    SEI_TYPE_MCTS_EXTRACTION_INFO_SETS                   = 158,
-    SEI_TYPE_MCTS_EXTRACTION_INFO_NESTING                = 159,
-    SEI_TYPE_LAYERS_NOT_PRESENT_5                        = 160,
-    SEI_TYPE_INTER_LAYER_CONSTRAINED_TILE_SETS           = 161,
-    SEI_TYPE_BSP_NESTING                                 = 162,
-    SEI_TYPE_BSP_INITIAL_ARRIVAL_TIME                    = 163,
-    SEI_TYPE_SUB_BITSTREAM_PROPERTY                      = 164,
-    SEI_TYPE_ALPHA_CHANNEL_INFO                          = 165,
-    SEI_TYPE_OVERLAY_INFO                                = 166,
-    SEI_TYPE_TEMPORAL_MV_PREDICTION_CONSTRAINTS          = 167,
-    SEI_TYPE_FRAME_FIELD_INFO                            = 168,
-    SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO   = 176,
-    SEI_TYPE_DEPTH_REPRESENTATION_INFO_5                 = 177,
-    SEI_TYPE_MULTIVIEW_SCENE_INFO_5                      = 178,
-    SEI_TYPE_MULTIVIEW_ACQUISITION_INFO_5                = 179,
-    SEI_TYPE_MULTIVIEW_VIEW_POSITION_5                   = 180,
-    SEI_TYPE_ALTERNATIVE_DEPTH_INFO                      = 181,
-    SEI_TYPE_SEI_MANIFEST                                = 200,
-    SEI_TYPE_SEI_PREFIX_INDICATION                       = 201,
-    SEI_TYPE_ANNOTATED_REGIONS                           = 202,
-    SEI_TYPE_SUBPIC_LEVEL_INFO                           = 203,
-    SEI_TYPE_SAMPLE_ASPECT_RATIO_INFO                    = 204,
-};
-
-#endif /* AVCODEC_SEI_H */
diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
deleted file mode 100644
index 5b6b256..0000000
--- a/libavcodec/setts_bsf.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Change the PTS/DTS timestamps.
- */
-
-#include "libavutil/opt.h"
-#include "libavutil/eval.h"
-
-#include "avcodec.h"
-#include "bsf.h"
-#include "bsf_internal.h"
-
-static const char *const var_names[] = {
-    "N",           ///< frame number (starting at zero)
-    "TS",
-    "POS",         ///< original position in the file of the frame
-    "PREV_INPTS",  ///< previous  input PTS
-    "PREV_INDTS",  ///< previous  input DTS
-    "PREV_OUTPTS", ///< previous output PTS
-    "PREV_OUTDTS", ///< previous output DTS
-    "PTS",         ///< original PTS in the file of the frame
-    "DTS",         ///< original DTS in the file of the frame
-    "STARTPTS",    ///< PTS at start of movie
-    "STARTDTS",    ///< DTS at start of movie
-    "TB",          ///< timebase of the stream
-    "SR",          ///< sample rate of the stream
-    NULL
-};
-
-enum var_name {
-    VAR_N,
-    VAR_TS,
-    VAR_POS,
-    VAR_PREV_INPTS,
-    VAR_PREV_INDTS,
-    VAR_PREV_OUTPTS,
-    VAR_PREV_OUTDTS,
-    VAR_PTS,
-    VAR_DTS,
-    VAR_STARTPTS,
-    VAR_STARTDTS,
-    VAR_TB,
-    VAR_SR,
-    VAR_VARS_NB
-};
-
-typedef struct SetTSContext {
-    const AVClass *class;
-
-    char *ts_str;
-    char *pts_str;
-    char *dts_str;
-
-    int64_t frame_number;
-
-    int64_t start_pts;
-    int64_t start_dts;
-    int64_t prev_inpts;
-    int64_t prev_indts;
-    int64_t prev_outpts;
-    int64_t prev_outdts;
-
-    double var_values[VAR_VARS_NB];
-
-    AVExpr *ts_expr;
-    AVExpr *pts_expr;
-    AVExpr *dts_expr;
-} SetTSContext;
-
-static int setts_init(AVBSFContext *ctx)
-{
-    SetTSContext *s = ctx->priv_data;
-    int ret;
-
-    if ((ret = av_expr_parse(&s->ts_expr, s->ts_str,
-                             var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Error while parsing ts expression '%s'\n", s->ts_str);
-        return ret;
-    }
-
-    if (s->pts_str) {
-        if ((ret = av_expr_parse(&s->pts_expr, s->pts_str,
-                                 var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
-            av_log(ctx, AV_LOG_ERROR, "Error while parsing pts expression '%s'\n", s->pts_str);
-            return ret;
-        }
-    }
-
-    if (s->dts_str) {
-        if ((ret = av_expr_parse(&s->dts_expr, s->dts_str,
-                                 var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
-            av_log(ctx, AV_LOG_ERROR, "Error while parsing dts expression '%s'\n", s->dts_str);
-            return ret;
-        }
-    }
-
-    s->frame_number= 0;
-    s->start_pts   = AV_NOPTS_VALUE;
-    s->start_dts   = AV_NOPTS_VALUE;
-    s->prev_inpts  = AV_NOPTS_VALUE;
-    s->prev_indts  = AV_NOPTS_VALUE;
-    s->prev_outpts = AV_NOPTS_VALUE;
-    s->prev_outdts = AV_NOPTS_VALUE;
-
-    return 0;
-}
-
-static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
-{
-    SetTSContext *s = ctx->priv_data;
-    int64_t new_ts, new_pts, new_dts;
-    int ret;
-
-    ret = ff_bsf_get_packet_ref(ctx, pkt);
-    if (ret < 0)
-        return ret;
-
-    if (s->start_pts == AV_NOPTS_VALUE)
-        s->start_pts = pkt->pts;
-
-    if (s->start_dts == AV_NOPTS_VALUE)
-        s->start_dts = pkt->dts;
-
-    s->var_values[VAR_N]           = s->frame_number++;
-    s->var_values[VAR_TS]          = pkt->dts;
-    s->var_values[VAR_POS]         = pkt->pos;
-    s->var_values[VAR_PTS]         = pkt->pts;
-    s->var_values[VAR_DTS]         = pkt->dts;
-    s->var_values[VAR_PREV_INPTS]  = s->prev_inpts;
-    s->var_values[VAR_PREV_INDTS]  = s->prev_indts;
-    s->var_values[VAR_PREV_OUTPTS] = s->prev_outpts;
-    s->var_values[VAR_PREV_OUTDTS] = s->prev_outdts;
-    s->var_values[VAR_STARTPTS]    = s->start_pts;
-    s->var_values[VAR_STARTDTS]    = s->start_dts;
-    s->var_values[VAR_TB]          = av_q2d(ctx->time_base_out);
-    s->var_values[VAR_SR]          = ctx->par_in->sample_rate;
-
-    new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL));
-
-    if (s->pts_str) {
-        s->var_values[VAR_TS] = pkt->pts;
-        new_pts = llrint(av_expr_eval(s->pts_expr, s->var_values, NULL));
-    } else {
-        new_pts = new_ts;
-    }
-
-    if (s->dts_str) {
-        s->var_values[VAR_TS] = pkt->dts;
-        new_dts = llrint(av_expr_eval(s->dts_expr, s->var_values, NULL));
-    } else {
-        new_dts = new_ts;
-    }
-
-    s->var_values[VAR_PREV_INPTS]  = pkt->pts;
-    s->var_values[VAR_PREV_INDTS]  = pkt->dts;
-    s->var_values[VAR_PREV_OUTPTS] = new_pts;
-    s->var_values[VAR_PREV_OUTDTS] = new_dts;
-
-    pkt->pts = new_pts;
-    pkt->dts = new_dts;
-
-    return ret;
-}
-
-static void setts_close(AVBSFContext *bsf)
-{
-    SetTSContext *s = bsf->priv_data;
-
-    av_expr_free(s->ts_expr);
-    s->ts_expr = NULL;
-    av_expr_free(s->pts_expr);
-    s->pts_expr = NULL;
-    av_expr_free(s->dts_expr);
-    s->dts_expr = NULL;
-}
-
-#define OFFSET(x) offsetof(SetTSContext, x)
-#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_SUBTITLE_PARAM|AV_OPT_FLAG_BSF_PARAM)
-
-static const AVOption options[] = {
-    { "ts",  "set expression for packet PTS and DTS", OFFSET(ts_str),  AV_OPT_TYPE_STRING, {.str="TS"}, 0, 0, FLAGS },
-    { "pts", "set expression for packet PTS", OFFSET(pts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "dts", "set expression for packet DTS", OFFSET(dts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { NULL },
-};
-
-static const AVClass setts_class = {
-    .class_name = "setts_bsf",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
-const AVBitStreamFilter ff_setts_bsf = {
-    .name           = "setts",
-    .priv_data_size = sizeof(SetTSContext),
-    .priv_class     = &setts_class,
-    .init           = setts_init,
-    .close          = setts_close,
-    .filter         = setts_filter,
-};
diff --git a/libavcodec/sga.c b/libavcodec/sga.c
deleted file mode 100644
index 00752a5..0000000
--- a/libavcodec/sga.c
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/avassert.h"
-#include "libavutil/common.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "bytestream.h"
-#include "internal.h"
-
-#define PALDATA_FOLLOWS_TILEDATA 4
-#define HAVE_COMPRESSED_TILEMAP 32
-#define HAVE_TILEMAP 128
-
-typedef struct SGAVideoContext {
-    GetByteContext gb;
-
-    int metadata_size;
-    int tiledata_size;
-    int tiledata_offset;
-    int tilemapdata_size;
-    int tilemapdata_offset;
-    int paldata_size;
-    int paldata_offset;
-    int palmapdata_offset;
-    int palmapdata_size;
-
-    int flags;
-    int nb_pal;
-    int nb_tiles;
-    int tiles_w, tiles_h;
-    int shift;
-    int plus;
-    int swap;
-
-    uint32_t pal[256];
-    uint8_t *tileindex_data;
-    unsigned tileindex_size;
-    uint8_t *palmapindex_data;
-    unsigned palmapindex_size;
-    uint8_t uncompressed[65536];
-} SGAVideoContext;
-
-static av_cold int sga_decode_init(AVCodecContext *avctx)
-{
-    avctx->pix_fmt = AV_PIX_FMT_PAL8;
-    return 0;
-}
-
-static int decode_palette(GetByteContext *gb, uint32_t *pal)
-{
-    GetBitContext gbit;
-
-    if (bytestream2_get_bytes_left(gb) < 18)
-        return AVERROR_INVALIDDATA;
-
-    memset(pal, 0, 16 * sizeof(*pal));
-    init_get_bits8(&gbit, gb->buffer, 18);
-
-    for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
-        for (int index = 0; index < 16; index++) {
-            unsigned color = get_bits1(&gbit) << RGBIndex;
-            pal[15 - index] |= color << (5 + 16);
-        }
-    }
-
-    for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
-        for (int index = 0; index < 16; index++) {
-            unsigned color = get_bits1(&gbit) << RGBIndex;
-            pal[15 - index] |= color << (5 + 8);
-        }
-    }
-
-    for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
-        for (int index = 0; index < 16; index++) {
-            unsigned color = get_bits1(&gbit) << RGBIndex;
-            pal[15 - index] |= color << (5 + 0);
-        }
-    }
-
-    for (int index = 0; index < 16; index++)
-        pal[index] = (0xFFU << 24) | pal[index] | (pal[index] >> 3);
-
-    bytestream2_skip(gb, 18);
-
-    return 0;
-}
-
-static int decode_index_palmap(SGAVideoContext *s, AVFrame *frame)
-{
-    const uint8_t *tt = s->tileindex_data;
-
-    for (int y = 0; y < s->tiles_h; y++) {
-        for (int x = 0; x < s->tiles_w; x++) {
-            int pal_idx = s->palmapindex_data[y * s->tiles_w + x] * 16;
-            uint8_t *dst = frame->data[0] + y * 8 * frame->linesize[0] + x * 8;
-
-            for (int yy = 0; yy < 8; yy++) {
-                for (int xx = 0; xx < 8; xx++)
-                    dst[xx] = pal_idx + tt[xx];
-                tt += 8;
-
-                dst += frame->linesize[0];
-            }
-        }
-    }
-
-    return 0;
-}
-
-static int decode_index_tilemap(SGAVideoContext *s, AVFrame *frame)
-{
-    GetByteContext *gb = &s->gb;
-    GetBitContext pm;
-
-    bytestream2_seek(gb, s->tilemapdata_offset, SEEK_SET);
-    if (bytestream2_get_bytes_left(gb) < s->tilemapdata_size)
-        return AVERROR_INVALIDDATA;
-
-    init_get_bits8(&pm, gb->buffer, s->tilemapdata_size);
-
-    for (int y = 0; y < s->tiles_h; y++) {
-        for (int x = 0; x < s->tiles_w; x++) {
-            uint8_t tile[64];
-            int tilemap = get_bits(&pm, 16);
-            int flip_x = (tilemap >> 11) & 1;
-            int flip_y = (tilemap >> 12) & 1;
-            int tindex = av_clip((tilemap & 511) - 1, 0, s->nb_tiles - 1);
-            const uint8_t *tt = s->tileindex_data + tindex * 64;
-            int pal_idx = ((tilemap >> 13) & 3) * 16;
-            uint8_t *dst = frame->data[0] + y * 8 * frame->linesize[0] + x * 8;
-
-            if (!flip_x && !flip_y) {
-                memcpy(tile, tt, 64);
-            } else if (flip_x && flip_y) {
-                for (int i = 0; i < 8; i++) {
-                    for (int j = 0; j < 8; j++)
-                        tile[i * 8 + j] = tt[(7 - i) * 8 + 7 - j];
-                }
-            } else if (flip_x) {
-                for (int i = 0; i < 8; i++) {
-                    for (int j = 0; j < 8; j++)
-                        tile[i * 8 + j] = tt[i * 8 + 7 - j];
-                }
-            } else {
-                for (int i = 0; i < 8; i++) {
-                    for (int j = 0; j < 8; j++)
-                        tile[i * 8 + j] = tt[(7 - i) * 8 + j];
-                }
-            }
-
-            for (int yy = 0; yy < 8; yy++) {
-                for (int xx = 0; xx < 8; xx++)
-                    dst[xx] = pal_idx + tile[xx + yy * 8];
-
-                dst += frame->linesize[0];
-            }
-        }
-    }
-
-    return 0;
-}
-
-static int decode_index(SGAVideoContext *s, AVFrame *frame)
-{
-    const uint8_t *src = s->tileindex_data;
-    uint8_t *dst = frame->data[0];
-
-    for (int y = 0; y < frame->height; y += 8) {
-        for (int x = 0; x < frame->width; x += 8) {
-            for (int yy = 0; yy < 8; yy++) {
-                for (int xx = 0; xx < 8; xx++)
-                    dst[x + xx + yy * frame->linesize[0]] = src[xx];
-                src += 8;
-            }
-        }
-
-        dst += 8 * frame->linesize[0];
-    }
-
-    return 0;
-}
-
-static int lzss_decompress(AVCodecContext *avctx,
-                           GetByteContext *gb, uint8_t *dst,
-                           int dst_size, int shift, int plus)
-{
-    int oi = 0;
-
-    while (bytestream2_get_bytes_left(gb) > 0 && oi < dst_size) {
-        uint16_t displace, header = bytestream2_get_be16(gb);
-        int count, offset;
-
-        for (int i = 0; i < 16; i++) {
-            switch (header >> 15) {
-            case 0:
-                if (oi + 2 < dst_size) {
-                    dst[oi++] = bytestream2_get_byte(gb);
-                    dst[oi++] = bytestream2_get_byte(gb);
-                }
-                break;
-            case 1:
-                displace = bytestream2_get_be16(gb);
-                count = displace >> shift;
-                offset = displace & ((1 << shift) - 1);
-
-                if (displace == 0) {
-                    while (bytestream2_get_bytes_left(gb) > 0 &&
-                           oi < dst_size)
-                        dst[oi++] = bytestream2_get_byte(gb);
-                    return oi;
-                }
-
-                count += plus;
-
-                if (offset <= 0)
-                    offset = 1;
-                if (oi < offset)
-                    return AVERROR_INVALIDDATA;
-                for (int j = 0; j < count * 2; j++) {
-                    dst[oi] = dst[oi - offset];
-                    oi++;
-                }
-                break;
-            }
-
-            header <<= 1;
-        }
-    }
-
-    return AVERROR_INVALIDDATA;
-}
-
-static int decode_palmapdata(AVCodecContext *avctx)
-{
-    SGAVideoContext *s = avctx->priv_data;
-    const int bits = (s->nb_pal + 1) / 2;
-    GetByteContext *gb = &s->gb;
-    GetBitContext pm;
-
-    bytestream2_seek(gb, s->palmapdata_offset, SEEK_SET);
-    if (bytestream2_get_bytes_left(gb) < s->palmapdata_size)
-        return AVERROR_INVALIDDATA;
-    init_get_bits8(&pm, gb->buffer, s->palmapdata_size);
-
-    for (int y = 0; y < s->tiles_h; y++) {
-        uint8_t *dst = s->palmapindex_data + y * s->tiles_w;
-
-        for (int x = 0; x < s->tiles_w; x++)
-            dst[x] = get_bits(&pm, bits);
-
-        dst += s->tiles_w;
-    }
-
-    return 0;
-}
-
-static int decode_tiledata(AVCodecContext *avctx)
-{
-    SGAVideoContext *s = avctx->priv_data;
-    GetByteContext *gb = &s->gb;
-    GetBitContext tm;
-
-    bytestream2_seek(gb, s->tiledata_offset, SEEK_SET);
-    if (bytestream2_get_bytes_left(gb) < s->tiledata_size)
-        return AVERROR_INVALIDDATA;
-    init_get_bits8(&tm, gb->buffer, s->tiledata_size);
-
-    for (int n = 0; n < s->nb_tiles; n++) {
-        uint8_t *dst = s->tileindex_data + n * 64;
-
-        for (int yy = 0; yy < 8; yy++) {
-            for (int xx = 0; xx < 8; xx++)
-                dst[xx] = get_bits(&tm, 4);
-
-            dst += 8;
-        }
-    }
-
-    for (int i = 0; i < s->nb_tiles && s->swap; i++) {
-        uint8_t *dst = s->tileindex_data + i * 64;
-
-        for (int j = 8; j < 64; j += 16) {
-            for (int k = 0; k < 8; k += 2)
-                FFSWAP(uint8_t, dst[j + k], dst[j+k+1]);
-        }
-    }
-
-    return 0;
-}
-
-static int sga_decode_frame(AVCodecContext *avctx, void *data,
-                            int *got_frame, AVPacket *avpkt)
-{
-    SGAVideoContext *s = avctx->priv_data;
-    GetByteContext *gb = &s->gb;
-    AVFrame *frame = data;
-    int ret, type;
-
-    if (avpkt->size <= 14)
-        return AVERROR_INVALIDDATA;
-
-    s->flags  = avpkt->data[8];
-    s->nb_pal = avpkt->data[9];
-    s->tiles_w = avpkt->data[10];
-    s->tiles_h = avpkt->data[11];
-
-    if (s->nb_pal > 4)
-        return AVERROR_INVALIDDATA;
-
-    if ((ret = ff_set_dimensions(avctx,
-                                 s->tiles_w * 8,
-                                 s->tiles_h * 8)) < 0)
-        return ret;
-
-    av_fast_padded_malloc(&s->tileindex_data, &s->tileindex_size,
-                          avctx->width * avctx->height);
-    if (!s->tileindex_data)
-        return AVERROR(ENOMEM);
-
-    av_fast_padded_malloc(&s->palmapindex_data, &s->palmapindex_size,
-                          s->tiles_w * s->tiles_h);
-    if (!s->palmapindex_data)
-        return AVERROR(ENOMEM);
-
-    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
-        return ret;
-
-    bytestream2_init(gb, avpkt->data, avpkt->size);
-
-    type = bytestream2_get_byte(gb);
-    s->metadata_size = 12 + ((!!(s->flags & HAVE_TILEMAP)) * 2);
-    s->nb_tiles = s->flags & HAVE_TILEMAP ? AV_RB16(avpkt->data + 12) : s->tiles_w * s->tiles_h;
-    if (s->nb_tiles > s->tiles_w * s->tiles_h)
-        return AVERROR_INVALIDDATA;
-
-    av_log(avctx, AV_LOG_DEBUG, "type: %X flags: %X nb_tiles: %d\n", type, s->flags, s->nb_tiles);
-
-    switch (type) {
-    case 0xE7:
-    case 0xCB:
-    case 0xCD:
-        s->swap = 1;
-        s->shift = 12;
-        s->plus = 1;
-        break;
-    case 0xC9:
-        s->swap = 1;
-        s->shift = 13;
-        s->plus = 1;
-        break;
-    case 0xC8:
-        s->swap = 1;
-        s->shift = 13;
-        s->plus = 0;
-        break;
-    case 0xC7:
-        s->swap = 0;
-        s->shift = 13;
-        s->plus = 1;
-        break;
-    case 0xC6:
-        s->swap = 0;
-        s->shift = 13;
-        s->plus = 0;
-        break;
-    }
-
-    if (type == 0xE7) {
-        int offset = s->metadata_size, left;
-        int sizes[3];
-
-        bytestream2_seek(gb, s->metadata_size, SEEK_SET);
-
-        for (int i = 0; i < 3; i++)
-            sizes[i] = bytestream2_get_be16(gb);
-
-        for (int i = 0; i < 3; i++) {
-            int size = sizes[i];
-            int raw = size >> 15;
-
-            size &= (1 << 15) - 1;
-
-            if (raw) {
-                if (bytestream2_get_bytes_left(gb) < size)
-                    return AVERROR_INVALIDDATA;
-
-                if (sizeof(s->uncompressed) - offset < size)
-                    return AVERROR_INVALIDDATA;
-
-                memcpy(s->uncompressed + offset, gb->buffer, size);
-                bytestream2_skip(gb, size);
-            } else {
-                GetByteContext gb2;
-
-                if (bytestream2_get_bytes_left(gb) < size)
-                    return AVERROR_INVALIDDATA;
-
-                bytestream2_init(&gb2, gb->buffer, size);
-                ret = lzss_decompress(avctx, &gb2, s->uncompressed + offset,
-                                      sizeof(s->uncompressed) - offset, s->shift, s->plus);
-                if (ret < 0)
-                    return ret;
-                bytestream2_skip(gb, size);
-                size = ret;
-            }
-
-            offset += size;
-        }
-
-        left = bytestream2_get_bytes_left(gb);
-        if (sizeof(s->uncompressed) - offset < left)
-            return AVERROR_INVALIDDATA;
-
-        bytestream2_get_buffer(gb, s->uncompressed + offset, left);
-
-        offset += left;
-        bytestream2_init(gb, s->uncompressed, offset);
-    }
-
-    switch (type) {
-    case 0xCD:
-    case 0xCB:
-    case 0xC9:
-    case 0xC8:
-    case 0xC7:
-    case 0xC6:
-        bytestream2_seek(gb, s->metadata_size, SEEK_SET);
-        ret = lzss_decompress(avctx, gb, s->uncompressed + s->metadata_size,
-                              sizeof(s->uncompressed) - s->metadata_size, s->shift, s->plus);
-        if (ret < 0)
-            return ret;
-        bytestream2_init(gb, s->uncompressed, ret + s->metadata_size);
-    case 0xE7:
-    case 0xC1:
-        s->tiledata_size = s->nb_tiles * 32;
-        s->paldata_size = s->nb_pal * 18;
-        s->tiledata_offset = s->flags & PALDATA_FOLLOWS_TILEDATA ? s->metadata_size : s->metadata_size + s->paldata_size;
-        s->paldata_offset = s->flags & PALDATA_FOLLOWS_TILEDATA ? s->metadata_size + s->tiledata_size : s->metadata_size;
-        s->palmapdata_offset = (s->flags & HAVE_TILEMAP) ? -1 : s->paldata_offset + s->paldata_size;
-        s->palmapdata_size = (s->flags & HAVE_TILEMAP) || s->nb_pal < 2 ? 0 : (s->tiles_w * s->tiles_h * ((s->nb_pal + 1) / 2) + 7) / 8;
-        s->tilemapdata_size = (s->flags & HAVE_TILEMAP) ? s->tiles_w * s->tiles_h * 2 : 0;
-        s->tilemapdata_offset = (s->flags & HAVE_TILEMAP) ? s->paldata_offset + s->paldata_size: -1;
-
-        bytestream2_seek(gb, s->paldata_offset, SEEK_SET);
-        for (int n = 0; n < s->nb_pal; n++) {
-            ret = decode_palette(gb, s->pal + 16 * n);
-            if (ret < 0)
-                return ret;
-        }
-
-        if (s->tiledata_size > 0) {
-            ret = decode_tiledata(avctx);
-            if (ret < 0)
-                return ret;
-        }
-
-        if (s->palmapdata_size > 0) {
-            ret = decode_palmapdata(avctx);
-            if (ret < 0)
-                return ret;
-        }
-
-        if (s->palmapdata_size > 0 && s->tiledata_size > 0) {
-            ret = decode_index_palmap(s, frame);
-            if (ret < 0)
-                return ret;
-        } else if (s->tilemapdata_size > 0 && s->tiledata_size > 0) {
-            ret = decode_index_tilemap(s, frame);
-            if (ret < 0)
-                return ret;
-        } else if (s->tiledata_size > 0) {
-            ret = decode_index(s, frame);
-            if (ret < 0)
-                return ret;
-        }
-        break;
-    default:
-        av_log(avctx, AV_LOG_ERROR, "Unknown type: %X\n", type);
-        return AVERROR_INVALIDDATA;
-    }
-
-    memcpy(frame->data[1], s->pal, AVPALETTE_SIZE);
-    frame->palette_has_changed = 1;
-    frame->pict_type = AV_PICTURE_TYPE_I;
-    frame->key_frame = 1;
-
-    *got_frame = 1;
-
-    return avpkt->size;
-}
-
-static av_cold int sga_decode_end(AVCodecContext *avctx)
-{
-    SGAVideoContext *s = avctx->priv_data;
-
-    av_freep(&s->tileindex_data);
-    s->tileindex_size = 0;
-
-    av_freep(&s->palmapindex_data);
-    s->palmapindex_size = 0;
-
-    return 0;
-}
-
-AVCodec ff_sga_decoder = {
-    .name           = "sga",
-    .long_name      = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_SGA_VIDEO,
-    .priv_data_size = sizeof(SGAVideoContext),
-    .init           = sga_decode_init,
-    .decode         = sga_decode_frame,
-    .close          = sga_decode_end,
-    .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
-};
diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c
index 0ef1674..3b2e736 100644
--- a/libavcodec/simple_idct.c
+++ b/libavcodec/simple_idct.c
@@ -175,8 +175,7 @@
 #define R_SHIFT 11
 static inline void idct4row(int16_t *row)
 {
-    unsigned c0, c1, c2, c3;
-    int a0, a1, a2, a3;
+    int c0, c1, c2, c3, a0, a1, a2, a3;
 
     a0 = row[0];
     a1 = row[1];
diff --git a/libavcodec/sinewin.c b/libavcodec/sinewin.c
index 1fa0e95..4532dc7 100644
--- a/libavcodec/sinewin.c
+++ b/libavcodec/sinewin.c
@@ -16,5 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#define USE_FIXED 0
 #include "sinewin.h"
 #include "sinewin_tablegen.h"
diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h
index fc4e69a..1348740 100644
--- a/libavcodec/sinewin.h
+++ b/libavcodec/sinewin.h
@@ -22,7 +22,8 @@
 #define AVCODEC_SINEWIN_H
 
 #include "config.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
+#include "libavcodec/aac_defines.h"
 
 #if CONFIG_HARDCODED_TABLES
 #   define SINETABLE_CONST const
@@ -30,20 +31,24 @@
 #   define SINETABLE_CONST
 #endif
 
+#ifndef USE_FIXED
+#define USE_FIXED 0
+#endif
+
 #define SINETABLE(size) \
-    SINETABLE_CONST DECLARE_ALIGNED(32, float, ff_sine_##size)[size]
+    SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size]
 
 /**
  * Generate a sine window.
  * @param   window  pointer to half window
  * @param   n       size of half window
  */
-void ff_sine_window_init(float *window, int n);
+void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n);
 
 /**
  * initialize the specified entry of ff_sine_windows
  */
-void ff_init_ff_sine_windows(int index);
+void AAC_RENAME(ff_init_ff_sine_windows)(int index);
 
 extern SINETABLE(  32);
 extern SINETABLE(  64);
@@ -55,6 +60,6 @@
 extern SINETABLE(4096);
 extern SINETABLE(8192);
 
-extern SINETABLE_CONST float *const ff_sine_windows[];
+extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[];
 
 #endif /* AVCODEC_SINEWIN_H */
diff --git a/libavcodec/ttmlenc.h b/libavcodec/sinewin_fixed.c
similarity index 71%
copy from libavcodec/ttmlenc.h
copy to libavcodec/sinewin_fixed.c
index c1dd5ec..27ead29 100644
--- a/libavcodec/ttmlenc.h
+++ b/libavcodec/sinewin_fixed.c
@@ -1,7 +1,4 @@
 /*
- * TTML subtitle encoder shared functionality
- * Copyright (c) 2020 24i
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -19,10 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_TTMLENC_H
-#define AVCODEC_TTMLENC_H
-
-#define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc"
-#define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1)
-
-#endif /* AVCODEC_TTMLENC_H */
+#define USE_FIXED 1
+#include "sinewin.h"
+#include "sinewin_tablegen.h"
diff --git a/libavcodec/sinewin_fixed_tablegen.c b/libavcodec/sinewin_fixed_tablegen.c
index 61e5274..977e6f3 100644
--- a/libavcodec/sinewin_fixed_tablegen.c
+++ b/libavcodec/sinewin_fixed_tablegen.c
@@ -20,23 +20,5 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "tableprint.h"
-
-#define BUILD_TABLES
-#define CONFIG_HARDCODED_TABLES 0
-#include "sinewin_fixed_tablegen.h"
-
-int main(void)
-{
-    write_fileheader();
-
-    init_sine_windows_fixed();
-#define PRINT_TABLE(size)                               \
-    printf("SINETABLE("#size") = {\n");                 \
-    write_int32_t_array(sine_ ## size ## _fixed, size); \
-    printf("};\n")
-    PRINT_TABLE(128);
-    PRINT_TABLE(512);
-    PRINT_TABLE(1024);
-    return 0;
-}
+#define USE_FIXED 1
+#include "sinewin_tablegen_template.c"
diff --git a/libavcodec/sinewin_fixed_tablegen.h b/libavcodec/sinewin_fixed_tablegen.h
deleted file mode 100644
index c52c90b..0000000
--- a/libavcodec/sinewin_fixed_tablegen.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Header file for hardcoded sine windows
- *
- * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SINEWIN_FIXED_TABLEGEN_H
-#define AVCODEC_SINEWIN_FIXED_TABLEGEN_H
-
-#ifdef BUILD_TABLES
-#undef DECLARE_ALIGNED
-#define DECLARE_ALIGNED(align, type, name) type name
-#else
-#include "libavutil/mem_internal.h"
-#endif
-
-#define SINETABLE(size) \
-    static SINETABLE_CONST DECLARE_ALIGNED(32, int, sine_##size##_fixed)[size]
-
-#if CONFIG_HARDCODED_TABLES
-#define init_sine_windows_fixed()
-#define SINETABLE_CONST const
-#include "libavcodec/sinewin_fixed_tables.h"
-#else
-// do not use libavutil/libm.h since this is compiled both
-// for the host and the target and config.h is only valid for the target
-#include <math.h>
-#include "libavutil/attributes.h"
-
-#define SINETABLE_CONST
-SINETABLE( 128);
-SINETABLE( 512);
-SINETABLE(1024);
-
-#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5)
-
-// Generate a sine window.
-static av_cold void sine_window_init_fixed(int *window, int n)
-{
-    for (int i = 0; i < n; i++)
-        window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n))));
-}
-
-static av_cold void init_sine_windows_fixed(void)
-{
-    sine_window_init_fixed(sine_128_fixed,  128);
-    sine_window_init_fixed(sine_512_fixed,  512);
-    sine_window_init_fixed(sine_1024_fixed, 1024);
-}
-#endif /* CONFIG_HARDCODED_TABLES */
-#endif /* AVCODEC_SINEWIN_FIXED_TABLEGEN_H */
diff --git a/libavcodec/sinewin_tablegen.c b/libavcodec/sinewin_tablegen.c
index 438030e..dd60266 100644
--- a/libavcodec/sinewin_tablegen.c
+++ b/libavcodec/sinewin_tablegen.c
@@ -20,26 +20,5 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define CONFIG_HARDCODED_TABLES 0
-#define BUILD_TABLES
-
-#define SINETABLE_CONST
-#define SINETABLE(size) \
-    float ff_sine_##size[size]
-#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
-#include "sinewin_tablegen.h"
-#include "tableprint.h"
-
-int main(void)
-{
-    write_fileheader();
-
-    for (int i = 5; i <= 13; i++) {
-        ff_init_ff_sine_windows(i);
-        printf("SINETABLE(%4i) = {\n", 1 << i);
-        write_float_array(ff_sine_windows[i], 1 << i);
-        printf("};\n");
-    }
-
-    return 0;
-}
+#define USE_FIXED 0
+#include "sinewin_tablegen_template.c"
diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h
index 6887d59..ced3b78 100644
--- a/libavcodec/sinewin_tablegen.h
+++ b/libavcodec/sinewin_tablegen.h
@@ -27,6 +27,7 @@
 // do not use libavutil/libm.h since this is compiled both
 // for the host and the target and config.h is only valid for the target
 #include <math.h>
+#include "libavcodec/aac_defines.h"
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
 
@@ -45,29 +46,38 @@
 SINETABLE(4096);
 SINETABLE(8192);
 #else
+#if USE_FIXED
+#include "libavcodec/sinewin_fixed_tables.h"
+#else
 #include "libavcodec/sinewin_tables.h"
 #endif
+#endif
 
-SINETABLE_CONST float *const ff_sine_windows[] = {
+#if USE_FIXED
+#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5)
+#else
+#define SIN_FIX(a) a
+#endif
+
+SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
     NULL, NULL, NULL, NULL, NULL, // unused
-    ff_sine_32,   ff_sine_64,   ff_sine_128,
-    ff_sine_256,  ff_sine_512,  ff_sine_1024,
-    ff_sine_2048, ff_sine_4096, ff_sine_8192,
+    AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128),
+    AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024),
+    AAC_RENAME(ff_sine_2048), AAC_RENAME(ff_sine_4096), AAC_RENAME(ff_sine_8192),
 };
 
 // Generate a sine window.
-av_cold void ff_sine_window_init(float *window, int n)
-{
+av_cold void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n) {
     int i;
     for(i = 0; i < n; i++)
-        window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
+        window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n))));
 }
 
 #if !CONFIG_HARDCODED_TABLES && !defined(BUILD_TABLES)
 #define INIT_FF_SINE_WINDOW_INIT_FUNC(index)        \
 static void init_ff_sine_window_ ## index(void)     \
 {                                                   \
-    ff_sine_window_init(ff_sine_windows[index], 1 << index);\
+    AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index);\
 }
 
 INIT_FF_SINE_WINDOW_INIT_FUNC(5)
@@ -98,12 +108,11 @@
 };
 #endif
 
-av_cold void ff_init_ff_sine_windows(int index)
-{
-    assert(index >= 5 && index < FF_ARRAY_ELEMS(ff_sine_windows));
+av_cold void AAC_RENAME(ff_init_ff_sine_windows)(int index) {
+    assert(index >= 5 && index < FF_ARRAY_ELEMS(AAC_RENAME(ff_sine_windows)));
 #if !CONFIG_HARDCODED_TABLES
 #ifdef BUILD_TABLES
-    ff_sine_window_init(ff_sine_windows[index], 1 << index);
+    AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index);
 #else
     ff_thread_once(&init_sine_window_once[index - 5], sine_window_init_func_array[index - 5]);
 #endif
diff --git a/libavcodec/sinewin_tablegen_template.c b/libavcodec/sinewin_tablegen_template.c
new file mode 100644
index 0000000..7c3c1d8
--- /dev/null
+++ b/libavcodec/sinewin_tablegen_template.c
@@ -0,0 +1,55 @@
+/*
+ * Generate a header file for hardcoded sine windows
+ *
+ * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include "libavcodec/aac_defines.h"
+#define CONFIG_HARDCODED_TABLES 0
+#define BUILD_TABLES
+
+#if USE_FIXED
+#define WRITE_FUNC write_int32_t_array
+#else
+#define WRITE_FUNC write_float_array
+#endif
+
+#define SINETABLE_CONST
+#define SINETABLE(size) \
+    INTFLOAT AAC_RENAME(ff_sine_##size)[size]
+#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
+#include "sinewin_tablegen.h"
+#include "tableprint.h"
+
+int main(void)
+{
+    int i;
+
+    write_fileheader();
+
+    for (i = 5; i <= 13; i++) {
+        AAC_RENAME(ff_init_ff_sine_windows)(i);
+        printf("SINETABLE(%4i) = {\n", 1 << i);
+        WRITE_FUNC(AAC_RENAME(ff_sine_windows)[i], 1 << i);
+        printf("};\n");
+    }
+
+    return 0;
+}
diff --git a/libavcodec/sipr.h b/libavcodec/sipr.h
index e1ef35d..34f7f99 100644
--- a/libavcodec/sipr.h
+++ b/libavcodec/sipr.h
@@ -26,7 +26,7 @@
 
 #include "avcodec.h"
 #include "acelp_pitch_delay.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 #define LP_FILTER_ORDER_16k  16
 #define L_SUBFR_16k          80
diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index 22b6997..b1b4944 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -23,7 +23,6 @@
 
 #include "libavutil/tx.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
@@ -342,18 +341,17 @@
     { 0.0f, 1.964f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }
 };
 
-static const float noise_category5[21] = {
+static const float noise_category5[20] = {
     0.70711f, 0.6179f, 0.5005f, 0.3220f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f,
     0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f
 };
 
-static const float noise_category6[21] = {
+static const float noise_category6[20] = {
     0.70711f, 0.5686f, 0.3563f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f,
     0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f
 };
 
 #define FRAME_SIZE 320
-#define REGION_SIZE 20
 
 typedef struct SirenContext {
     GetBitContext gb;
@@ -363,6 +361,7 @@
     int number_of_regions;
     int scale_factor;
     int sample_rate_bits;
+    int region_size;
 
     unsigned dw1, dw2, dw3, dw4;
 
@@ -403,6 +402,7 @@
     s->esf_adjustment = 7;
     s->number_of_regions = 14;
     s->scale_factor = 22;
+    s->region_size = 20;
     s->dw1 = s->dw2 = s->dw3 = s->dw4 = 1;
 
     for (i = 0; i < 64; i++) {
@@ -574,7 +574,7 @@
 
     for (region = 0; region < number_of_regions; region++) {
         category = power_categories[region];
-        coefs_ptr = coefs + (region * REGION_SIZE);
+        coefs_ptr = coefs + (region * s->region_size);
 
         if (category >= 0 && category < 7) {
             decoder_tree = decoder_tables[category];
@@ -623,27 +623,32 @@
             }
         }
 
-        coefs_ptr = coefs + (region * REGION_SIZE);
+        coefs_ptr = coefs + (region * s->region_size);
 
-        if (category == 5 || category == 6) {
+        if (category == 5) {
             i = 0;
-            for (j = 0; j < REGION_SIZE; j++) {
+            for (j = 0; j < s->region_size; j++) {
                 if (*coefs_ptr != 0)
                     i++;
                 coefs_ptr++;
             }
 
-            if (category == 5) {
-                noise = decoder_standard_deviation[region] * noise_category5[i];
-            } else
-                noise = decoder_standard_deviation[region] * noise_category6[i];
+            noise = decoder_standard_deviation[region] * noise_category5[i];
+        } else if (category == 6) {
+            i = 0;
+            for (j = 0; j < s->region_size; j++) {
+                if (*coefs_ptr++ != 0)
+                    i++;
+            }
+
+            noise = decoder_standard_deviation[region] * noise_category6[i];
         } else if (category == 7) {
             noise = decoder_standard_deviation[region] * 0.70711f;
         } else {
             noise = 0;
         }
 
-        coefs_ptr = coefs + (region * REGION_SIZE);
+        coefs_ptr = coefs + (region * s->region_size);
 
         if (category == 5 || category == 6 || category == 7) {
             dw1 = get_dw(s);
diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index 33581bb..342ebb7 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -435,7 +435,7 @@
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     SmcContext *s = avctx->priv_data;
-    buffer_size_t pal_size;
+    int pal_size;
     const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
     int ret;
     int total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
diff --git a/libavcodec/sp5x.h b/libavcodec/sp5x.h
index d84d851..21c4571 100644
--- a/libavcodec/sp5x.h
+++ b/libavcodec/sp5x.h
@@ -132,8 +132,58 @@
 };
 
 
-static const uint8_t sp5x_qscale_five_quant_table[][64]=
+static const uint8_t sp5x_quant_table[20][64]=
 {
+    /* index 0, Q50 */
+    {  16, 11, 12, 14, 12, 10, 16, 14, 13, 14, 18, 17, 16, 19, 24, 40,
+       26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51,
+       56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80,109, 81, 87,
+       95, 98,103,104,103, 62, 77,113,121,112,100,120, 92,101,103, 99 },
+    {  17, 18, 18, 24, 21, 24, 47, 26, 26, 47, 99, 66, 56, 66, 99, 99,
+       99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
+       99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
+       99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 },
+
+    /* index 1, Q70 */
+    {  10,  7,  7,  8,  7,  6, 10,  8,  8,  8, 11, 10, 10, 11, 14, 24,
+       16, 14, 13, 13, 14, 29, 21, 22, 17, 24, 35, 31, 37, 36, 34, 31,
+       34, 33, 38, 43, 55, 47, 38, 41, 52, 41, 33, 34, 48, 65, 49, 52,
+       57, 59, 62, 62, 62, 37, 46, 68, 73, 67, 60, 72, 55, 61, 62, 59 },
+    {  10, 11, 11, 14, 13, 14, 28, 16, 16, 28, 59, 40, 34, 40, 59, 59,
+       59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+       59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+       59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 },
+
+    /* index 2, Q80 */
+    {   6,  4,  5,  6,  5,  4,  6,  6,  5,  6,  7,  7,  6,  8, 10, 16,
+       10, 10,  9,  9, 10, 20, 14, 15, 12, 16, 23, 20, 24, 24, 23, 20,
+       22, 22, 26, 29, 37, 31, 26, 27, 35, 28, 22, 22, 32, 44, 32, 35,
+       38, 39, 41, 42, 41, 25, 31, 45, 48, 45, 40, 48, 37, 40, 41, 40 },
+    {   7,  7,  7, 10,  8, 10, 19, 10, 10, 19, 40, 26, 22, 26, 40, 40,
+       40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+       40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+       40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
+
+    /* index 3, Q85 */
+    {   5,  3,  4,  4,  4,  3,  5,  4,  4,  4,  5,  5,  5,  6,  7, 12,
+        8,  7,  7,  7,  7, 15, 11, 11,  9, 12, 17, 15, 18, 18, 17, 15,
+       17, 17, 19, 22, 28, 23, 19, 20, 26, 21, 17, 17, 24, 33, 24, 26,
+       29, 29, 31, 31, 31, 19, 23, 34, 36, 34, 30, 36, 28, 30, 31, 30 },
+    {   5,  5,  5,  7,  6,  7, 14,  8,  8, 14, 30, 20, 17, 20, 30, 30,
+       30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+       30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+       30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 },
+
+    /* index 4, Q90 */
+    {   3,  2,  2,  3,  2,  2,  3,  3,  3,  3,  4,  3,  3,  4,  5,  8,
+        5,  5,  4,  4,  5, 10,  7,  7,  6,  8, 12, 10, 12, 12, 11, 10,
+       11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17,
+       19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20 },
+    {   3,  4,  4,  5,  4,  5,  9,  5,  5,  9, 20, 13, 11, 13, 20, 20,
+       20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+       20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+       20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 },
+
     /* index 5, Q60 */
     {  13,  9, 10, 11, 10,  8, 13, 11, 10, 11, 14, 14, 13, 15, 19, 32,
        21, 19, 18, 18, 19, 39, 28, 30, 23, 32, 46, 41, 49, 48, 46, 41,
@@ -143,6 +193,46 @@
        79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
        79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
        79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 },
+
+    /* index 6, Q25 */
+    {  32, 22, 24, 28, 24, 20, 32, 28, 26, 28, 36, 34, 32, 38, 48, 80,
+       52, 48, 44, 44, 48, 98, 70, 74, 58, 80,116,102,122,120,114,102,
+      112,110,128,144,184,156,128,136,174,138,110,112,160,218,162,174,
+      190,196,206,208,206,124,154,226,242,224,200,240,184,202,206,198 },
+    {  34, 36, 36, 48, 42, 48, 94, 52, 52, 94,198,132,112,132,198,198,
+      198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
+      198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
+      198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 },
+
+    /* index 7, Q95 */
+    {   2,  1,  1,  1,  1,  1,  2,  1,  1,  1,  2,  2,  2,  2,  2,  4,
+        3,  2,  2,  2,  2,  5,  4,  4,  3,  4,  6,  5,  6,  6,  6,  5,
+        6,  6,  6,  7,  9,  8,  6,  7,  9,  7,  6,  6,  8, 11,  8,  9,
+       10, 10, 10, 10, 10,  6,  8, 11, 12, 11, 10, 12,  9, 10, 10, 10 },
+    {   2,  2,  2,  2,  2,  2,  5,  3,  3,  5, 10,  7,  6,  7, 10, 10,
+       10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+       10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+       10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
+
+    /* index 8, Q93 */
+    {   2,  2,  2,  2,  2,  1,  2,  2,  2,  2,  3,  2,  2,  3,  3,  6,
+        4,  3,  3,  3,  3,  7,  5,  5,  4,  6,  8,  7,  9,  8,  8,  7,
+        8,  8,  9, 10, 13, 11,  9, 10, 12, 10,  8,  8, 11, 15, 11, 12,
+       13, 14, 14, 15, 14,  9, 11, 16, 17, 16, 14, 17, 13, 14, 14, 14 },
+    {   2,  3,  3,  3,  3,  3,  7,  4,  4,  7, 14,  9,  8,  9, 14, 14,
+       14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+       14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+       14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 },
+
+    /* index 9, Q40 */
+    {  20, 14, 15, 18, 15, 13, 20, 18, 16, 18, 23, 21, 20, 24, 30, 50,
+       33, 30, 28, 28, 30, 61, 44, 46, 36, 50, 73, 64, 76, 75, 71, 64,
+       70, 69, 80, 90,115, 98, 80, 85,109, 86, 69, 70,100,136,101,109,
+      119,123,129,130,129, 78, 96,141,151,140,125,150,115,126,129,124 },
+    {  21, 23, 23, 30, 26, 30, 59, 33, 33, 59,124, 83, 70, 83,124,124,
+      124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
+      124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
+      124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124 }
 };
 
 #endif /* AVCODEC_SP5X_H */
diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c
index 0b2b2d8..302fdb0 100644
--- a/libavcodec/sp5xdec.c
+++ b/libavcodec/sp5xdec.c
@@ -35,6 +35,7 @@
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     AVBufferRef *buf_recoded;
+    const int qscale = 5;
     uint8_t *recoded;
     int i = 0, j = 0;
 
@@ -51,8 +52,8 @@
     recoded[j++] = 0xD8;
 
     memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
-    memcpy(recoded + j + 5,  &sp5x_qscale_five_quant_table[0], 64);
-    memcpy(recoded + j + 70, &sp5x_qscale_five_quant_table[1], 64);
+    memcpy(recoded+j+5, &sp5x_quant_table[qscale * 2], 64);
+    memcpy(recoded+j+70, &sp5x_quant_table[(qscale * 2) + 1], 64);
     j += sizeof(sp5x_data_dqt);
 
     memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index 5861b7f..748e861 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -26,9 +26,7 @@
 
 #define BITSTREAM_READER_LE
 
-#include "config.h"
 #include "libavutil/attributes.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
@@ -137,12 +135,11 @@
 RLTable ff_rl_speedhq = {
     121,
     121,
-    speedhq_vlc,
+    (const uint16_t (*)[])speedhq_vlc,
     speedhq_run,
     speedhq_level,
 };
 
-#if CONFIG_SPEEDHQ_DECODER
 /* NOTE: The first element is always 16, unscaled. */
 static const uint8_t unscaled_quant_matrix[64] = {
     16, 16, 19, 22, 26, 27, 29, 34,
@@ -276,78 +273,6 @@
     return 0;
 }
 
-static int decode_speedhq_border(const SHQContext *s, GetBitContext *gb, AVFrame *frame, int field_number, int line_stride)
-{
-    int linesize_y  = frame->linesize[0] * line_stride;
-    int linesize_cb = frame->linesize[1] * line_stride;
-    int linesize_cr = frame->linesize[2] * line_stride;
-    int linesize_a;
-    int ret;
-
-    if (s->alpha_type != SHQ_NO_ALPHA)
-        linesize_a = frame->linesize[3] * line_stride;
-
-    for (int y = 0; y < frame->height; y += 16 * line_stride) {
-        int last_dc[4] = { 1024, 1024, 1024, 1024 };
-        uint8_t *dest_y, *dest_cb, *dest_cr, *dest_a;
-        uint8_t last_alpha[16];
-        int x = frame->width - 8;
-
-        dest_y = frame->data[0] + frame->linesize[0] * (y + field_number) + x;
-        if (s->subsampling == SHQ_SUBSAMPLING_420) {
-            dest_cb = frame->data[1] + frame->linesize[1] * (y/2 + field_number) + x / 2;
-            dest_cr = frame->data[2] + frame->linesize[2] * (y/2 + field_number) + x / 2;
-        } else if (s->subsampling == SHQ_SUBSAMPLING_422) {
-            dest_cb = frame->data[1] + frame->linesize[1] * (y + field_number) + x / 2;
-            dest_cr = frame->data[2] + frame->linesize[2] * (y + field_number) + x / 2;
-        }
-        if (s->alpha_type != SHQ_NO_ALPHA) {
-            memset(last_alpha, 255, sizeof(last_alpha));
-            dest_a = frame->data[3] + frame->linesize[3] * (y + field_number) + x;
-        }
-
-        if ((ret = decode_dct_block(s, gb, last_dc, 0, dest_y, linesize_y)) < 0)
-            return ret;
-        if ((ret = decode_dct_block(s, gb, last_dc, 0, dest_y + 8, linesize_y)) < 0)
-            return ret;
-        if ((ret = decode_dct_block(s, gb, last_dc, 0, dest_y + 8 * linesize_y, linesize_y)) < 0)
-            return ret;
-        if ((ret = decode_dct_block(s, gb, last_dc, 0, dest_y + 8 * linesize_y + 8, linesize_y)) < 0)
-            return ret;
-        if ((ret = decode_dct_block(s, gb, last_dc, 1, dest_cb, linesize_cb)) < 0)
-            return ret;
-        if ((ret = decode_dct_block(s, gb, last_dc, 2, dest_cr, linesize_cr)) < 0)
-            return ret;
-
-        if (s->subsampling != SHQ_SUBSAMPLING_420) {
-            if ((ret = decode_dct_block(s, gb, last_dc, 1, dest_cb + 8 * linesize_cb, linesize_cb)) < 0)
-                return ret;
-            if ((ret = decode_dct_block(s, gb, last_dc, 2, dest_cr + 8 * linesize_cr, linesize_cr)) < 0)
-                return ret;
-        }
-
-        if (s->alpha_type == SHQ_RLE_ALPHA) {
-            /* Alpha coded using 16x8 RLE blocks. */
-            if ((ret = decode_alpha_block(s, gb, last_alpha, dest_a, linesize_a)) < 0)
-                return ret;
-            if ((ret = decode_alpha_block(s, gb, last_alpha, dest_a + 8 * linesize_a, linesize_a)) < 0)
-                return ret;
-        } else if (s->alpha_type == SHQ_DCT_ALPHA) {
-            /* Alpha encoded exactly like luma. */
-            if ((ret = decode_dct_block(s, gb, last_dc, 3, dest_a, linesize_a)) < 0)
-                return ret;
-            if ((ret = decode_dct_block(s, gb, last_dc, 3, dest_a + 8, linesize_a)) < 0)
-                return ret;
-            if ((ret = decode_dct_block(s, gb, last_dc, 3, dest_a + 8 * linesize_a, linesize_a)) < 0)
-                return ret;
-            if ((ret = decode_dct_block(s, gb, last_dc, 3, dest_a + 8 * linesize_a + 8, linesize_a)) < 0)
-                return ret;
-        }
-    }
-
-    return 0;
-}
-
 static int decode_speedhq_field(const SHQContext *s, const uint8_t *buf, int buf_size, AVFrame *frame, int field_number, int start, int end, int line_stride)
 {
     int ret, slice_number, slice_offsets[5];
@@ -355,7 +280,6 @@
     int linesize_cb = frame->linesize[1] * line_stride;
     int linesize_cr = frame->linesize[2] * line_stride;
     int linesize_a;
-    GetBitContext gb;
 
     if (s->alpha_type != SHQ_NO_ALPHA)
         linesize_a = frame->linesize[3] * line_stride;
@@ -377,6 +301,7 @@
     }
 
     for (slice_number = 0; slice_number < 4; slice_number++) {
+        GetBitContext gb;
         uint32_t slice_begin, slice_end;
         int x, y;
 
@@ -405,7 +330,7 @@
                 dest_a = frame->data[3] + frame->linesize[3] * (y + field_number);
             }
 
-            for (x = 0; x < frame->width - 8 * (s->subsampling != SHQ_SUBSAMPLING_444); x += 16) {
+            for (x = 0; x < frame->width; x += 16) {
                 /* Decode the four luma blocks. */
                 if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y, linesize_y)) < 0)
                     return ret;
@@ -474,9 +399,6 @@
         }
     }
 
-    if (s->subsampling != SHQ_SUBSAMPLING_444 && (frame->width & 15))
-        return decode_speedhq_border(s, &gb, frame, field_number, line_stride);
-
     return 0;
 }
 
@@ -734,4 +656,3 @@
     .decode         = speedhq_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
 };
-#endif /* CONFIG_SPEEDHQ_DECODER */
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index a5bedd5..51f67c0 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -46,6 +46,9 @@
 static uint32_t speedhq_lum_dc_uni[512];
 static uint32_t speedhq_chr_dc_uni[512];
 
+static uint8_t speedhq_index_run[2][64];
+static int8_t  speedhq_max_level[2][64];
+
 static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2];
 
 static uint32_t reverse(uint32_t num, int bits)
@@ -74,6 +77,11 @@
 
     ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store);
 
+    for (int i = 0; i < 64; i++) {
+        speedhq_max_level[0][i] = ff_rl_speedhq.max_level[0][i];
+        speedhq_index_run[0][i] = ff_rl_speedhq.index_run[0][i];
+    }
+
     /* build unified dc encoding tables */
     for (int i = -255; i < 256; i++) {
         int adiff, index;
@@ -223,8 +231,8 @@
             MASK_ABS(sign, alevel);
             sign &= 1;
 
-            if (alevel <= ff_rl_speedhq.max_level[0][run]) {
-                code = ff_rl_speedhq.index_run[0][run] + alevel - 1;
+            if (alevel <= speedhq_max_level[0][run]) {
+                code = speedhq_index_run[0][run] + alevel - 1;
                 /* store the VLC & sign at once */
                 put_bits_le(&s->pb, ff_rl_speedhq.table_vlc[code][1] + 1,
                             ff_rl_speedhq.table_vlc[code][0] + (sign << ff_rl_speedhq.table_vlc[code][1]));
diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index 98f84ac..ecc0801 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -58,8 +58,7 @@
     AVSubtitle *sub = data;
     AVBPrint buffer;
     int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
-    int ret;
-    buffer_size_t size;
+    int size, ret;
     const uint8_t *p = av_packet_get_side_data(avpkt, AV_PKT_DATA_SUBTITLE_POSITION, &size);
     FFASSDecoderContext *s = avctx->priv_data;
 
diff --git a/libavcodec/svq1_cb.h b/libavcodec/svq1_cb.h
index 30cca19..11f7969 100644
--- a/libavcodec/svq1_cb.h
+++ b/libavcodec/svq1_cb.h
@@ -34,7 +34,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 
 /* 6x16-entry codebook for inter-coded 4x2 vectors */
 DECLARE_ALIGNED(4, static const int8_t, svq1_inter_codebook_4x2)[768] = {
diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
index d6b6bec..7aea138 100644
--- a/libavcodec/svq1dec.c
+++ b/libavcodec/svq1dec.c
@@ -43,7 +43,6 @@
 #include "mathops.h"
 #include "svq1.h"
 
-#define SVQ1_BLOCK_TYPE_VLC_BITS 3
 static VLC svq1_block_type;
 static VLC svq1_motion_component;
 static VLC svq1_intra_multistage[6];
@@ -65,9 +64,6 @@
     uint8_t *pkt_swapped;
     int pkt_swapped_allocated;
 
-    svq1_pmv *pmv;
-    int pmv_allocated;
-
     int width;
     int height;
     int frame_code;
@@ -460,8 +456,7 @@
     int result = 0;
 
     /* get block type */
-    block_type = get_vlc2(bitbuf, svq1_block_type.table,
-                          SVQ1_BLOCK_TYPE_VLC_BITS, 1);
+    block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);
 
     /* reset motion vectors */
     if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
@@ -625,6 +620,7 @@
     AVFrame       *cur = data;
     uint8_t *current;
     int result, i, x, y, width, height;
+    svq1_pmv *pmv;
     int ret;
 
     /* initialize bit buffer */
@@ -684,8 +680,8 @@
     if (result < 0)
         return result;
 
-    av_fast_padded_malloc(&s->pmv, &s->pmv_allocated, (FFALIGN(s->width, 16) / 8 + 3) * sizeof(*s->pmv));
-    if (!s->pmv)
+    pmv = av_malloc_array(FFALIGN(s->width, 16) / 8 + 3, sizeof(*pmv));
+    if (!pmv)
         return AVERROR(ENOMEM);
 
     /* decode y, u and v components */
@@ -713,7 +709,7 @@
                         av_log(avctx, AV_LOG_ERROR,
                                "Error in svq1_decode_block %i (keyframe)\n",
                                result);
-                        return result;
+                        goto err;
                     }
                 }
                 current += 16 * linesize;
@@ -724,27 +720,28 @@
             if (!previous ||
                 s->prev->width != s->width || s->prev->height != s->height) {
                 av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
-                return AVERROR_INVALIDDATA;
+                result = AVERROR_INVALIDDATA;
+                goto err;
             }
 
-            memset(s->pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv));
+            memset(pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv));
 
             for (y = 0; y < height; y += 16) {
                 for (x = 0; x < width; x += 16) {
                     result = svq1_decode_delta_block(avctx, &s->hdsp,
                                                      &s->gb, &current[x],
                                                      previous, linesize,
-                                                     s->pmv, x, y, width, height);
+                                                     pmv, x, y, width, height);
                     if (result != 0) {
                         ff_dlog(avctx,
                                 "Error in svq1_decode_delta_block %i\n",
                                 result);
-                        return result;
+                        goto err;
                     }
                 }
 
-                s->pmv[0].x =
-                s->pmv[0].y = 0;
+                pmv[0].x     =
+                    pmv[0].y = 0;
 
                 current += 16 * linesize;
             }
@@ -755,20 +752,22 @@
         av_frame_unref(s->prev);
         result = av_frame_ref(s->prev, cur);
         if (result < 0)
-            return result;
+            goto err;
     }
 
     *got_frame = 1;
     result     = buf_size;
 
+err:
+    av_free(pmv);
     return result;
 }
 
 static av_cold void svq1_static_init(void)
 {
-    INIT_VLC_STATIC(&svq1_block_type, SVQ1_BLOCK_TYPE_VLC_BITS, 4,
+    INIT_VLC_STATIC(&svq1_block_type, 2, 4,
                     &ff_svq1_block_type_vlc[0][1], 2, 1,
-                    &ff_svq1_block_type_vlc[0][0], 2, 1, 8);
+                    &ff_svq1_block_type_vlc[0][0], 2, 1, 6);
 
     INIT_VLC_STATIC(&svq1_motion_component, 7, 33,
                     &ff_mvtab[0][1], 2, 1,
@@ -830,8 +829,6 @@
     av_frame_free(&s->prev);
     av_freep(&s->pkt_swapped);
     s->pkt_swapped_allocated = 0;
-    av_freep(&s->pmv);
-    s->pmv_allocated = 0;
 
     return 0;
 }
diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h
index bb6af08..b4ef763 100644
--- a/libavcodec/svq1enc.h
+++ b/libavcodec/svq1enc.h
@@ -24,7 +24,6 @@
 #include <stdint.h>
 
 #include "libavutil/frame.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "hpeldsp.h"
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 54ef4ad..fb7b992 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -44,7 +44,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/crc.h"
-#include "libavutil/mem_internal.h"
 
 #include "internal.h"
 #include "avcodec.h"
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index 931e5d3..6bf5dcc 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -26,7 +26,6 @@
  */
 
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/samplefmt.h"
 
 #define BITSTREAM_READER_LE
diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore
index 92aab1b..a01a700 100644
--- a/libavcodec/tests/.gitignore
+++ b/libavcodec/tests/.gitignore
@@ -5,6 +5,7 @@
 /codec_desc
 /dct
 /fft
+/fft-fixed
 /fft-fixed32
 /golomb
 /h264_levels
@@ -17,6 +18,7 @@
 /mjpegenc_huffman
 /motion
 /mpeg12framerate
+/options
 /rangecoder
 /snowenc
 /utils
diff --git a/libavcodec/tests/cabac.c b/libavcodec/tests/cabac.c
index a8bd131..affe4eb 100644
--- a/libavcodec/tests/cabac.c
+++ b/libavcodec/tests/cabac.c
@@ -24,51 +24,41 @@
 
 #include "libavutil/lfg.h"
 #include "libavcodec/avcodec.h"
-#include "libavcodec/put_bits.h"
 
-typedef struct CABACTestContext {
-    CABACContext dec;
-    int outstanding_count;
-    PutBitContext pb;
-} CABACTestContext;
-
-static inline void put_cabac_bit(CABACTestContext *c, int b)
-{
+static inline void put_cabac_bit(CABACContext *c, int b){
     put_bits(&c->pb, 1, b);
     for(;c->outstanding_count; c->outstanding_count--){
         put_bits(&c->pb, 1, 1-b);
     }
 }
 
-static inline void renorm_cabac_encoder(CABACTestContext *c)
-{
-    while (c->dec.range < 0x100) {
+static inline void renorm_cabac_encoder(CABACContext *c){
+    while(c->range < 0x100){
         //FIXME optimize
-        if (c->dec.low < 0x100) {
+        if(c->low<0x100){
             put_cabac_bit(c, 0);
-        } else if (c->dec.low < 0x200) {
+        }else if(c->low<0x200){
             c->outstanding_count++;
-            c->dec.low -= 0x100;
+            c->low -= 0x100;
         }else{
             put_cabac_bit(c, 1);
-            c->dec.low -= 0x200;
+            c->low -= 0x200;
         }
 
-        c->dec.range += c->dec.range;
-        c->dec.low   += c->dec.low;
+        c->range+= c->range;
+        c->low += c->low;
     }
 }
 
-static void put_cabac(CABACTestContext *c, uint8_t * const state, int bit)
-{
-    int RangeLPS = ff_h264_lps_range[2 * (c->dec.range & 0xC0) + *state];
+static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
+    int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state];
 
     if(bit == ((*state)&1)){
-        c->dec.range -= RangeLPS;
+        c->range -= RangeLPS;
         *state    = ff_h264_mlps_state[128 + *state];
     }else{
-        c->dec.low  += c->dec.range - RangeLPS;
-        c->dec.range = RangeLPS;
+        c->low += c->range - RangeLPS;
+        c->range = RangeLPS;
         *state= ff_h264_mlps_state[127 - *state];
     }
 
@@ -78,22 +68,21 @@
 /**
  * @param bit 0 -> write zero bit, !=0 write one bit
  */
-static void put_cabac_bypass(CABACTestContext *c, int bit)
-{
-    c->dec.low += c->dec.low;
+static void put_cabac_bypass(CABACContext *c, int bit){
+    c->low += c->low;
 
     if(bit){
-        c->dec.low += c->dec.range;
+        c->low += c->range;
     }
 //FIXME optimize
-    if (c->dec.low < 0x200) {
+    if(c->low<0x200){
         put_cabac_bit(c, 0);
-    } else if (c->dec.low < 0x400) {
+    }else if(c->low<0x400){
         c->outstanding_count++;
-        c->dec.low -= 0x200;
+        c->low -= 0x200;
     }else{
         put_cabac_bit(c, 1);
-        c->dec.low -= 0x400;
+        c->low -= 0x400;
     }
 }
 
@@ -101,21 +90,20 @@
  *
  * @return the number of bytes written
  */
-static int put_cabac_terminate(CABACTestContext *c, int bit)
-{
-    c->dec.range -= 2;
+static int put_cabac_terminate(CABACContext *c, int bit){
+    c->range -= 2;
 
     if(!bit){
         renorm_cabac_encoder(c);
     }else{
-        c->dec.low  += c->dec.range;
-        c->dec.range = 2;
+        c->low += c->range;
+        c->range= 2;
 
         renorm_cabac_encoder(c);
 
-        av_assert0(c->dec.low <= 0x1FF);
-        put_cabac_bit(c, c->dec.low >> 9);
-        put_bits(&c->pb, 2, ((c->dec.low >> 7) & 3) | 1);
+        av_assert0(c->low <= 0x1FF);
+        put_cabac_bit(c, c->low>>9);
+        put_bits(&c->pb, 2, ((c->low>>7)&3)|1);
 
         flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
     }
@@ -123,21 +111,8 @@
     return (put_bits_count(&c->pb)+7)>>3;
 }
 
-/**
- * @param buf_size size of buf in bits
- */
-static void init_cabac_encoder(CABACTestContext *c, uint8_t *buf, int buf_size)
-{
-    init_put_bits(&c->pb, buf, buf_size);
-
-    c->dec.low   = 0;
-    c->dec.range = 0x1FE;
-    c->outstanding_count = 0;
-    c->pb.bit_left++; //avoids firstBitFlag
-}
-
 int main(void){
-    CABACTestContext c;
+    CABACContext c;
     uint8_t b[9*SIZE];
     uint8_t r[9*SIZE];
     int i, ret = 0;
@@ -145,7 +120,7 @@
     AVLFG prng;
 
     av_lfg_init(&prng, 1);
-    init_cabac_encoder(&c, b, SIZE);
+    ff_init_cabac_encoder(&c, b, SIZE);
 
     for(i=0; i<SIZE; i++){
         if(2*i<SIZE) r[i] = av_lfg_get(&prng) % 7;
@@ -164,24 +139,24 @@
     b[i++] = av_lfg_get(&prng);
     b[i  ] = av_lfg_get(&prng);
 
-    ff_init_cabac_decoder(&c.dec, b, SIZE);
+    ff_init_cabac_decoder(&c, b, SIZE);
 
     memset(state, 0, sizeof(state));
 
     for(i=0; i<SIZE; i++){
-        if ((r[i] & 1) != get_cabac_bypass(&c.dec)) {
+        if( (r[i]&1) != get_cabac_bypass(&c) ) {
             av_log(NULL, AV_LOG_ERROR, "CABAC bypass failure at %d\n", i);
             ret = 1;
         }
     }
 
     for(i=0; i<SIZE; i++){
-        if ((r[i] & 1) != get_cabac_noinline(&c.dec, state)) {
+        if( (r[i]&1) != get_cabac_noinline(&c, state) ) {
             av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
             ret = 1;
         }
     }
-    if (!get_cabac_terminate(&c.dec)) {
+    if(!get_cabac_terminate(&c)) {
         av_log(NULL, AV_LOG_ERROR, "where's the Terminator?\n");
         ret = 1;
     }
diff --git a/libavcodec/tests/dct.c b/libavcodec/tests/dct.c
index eab39e9..2ca8039 100644
--- a/libavcodec/tests/dct.c
+++ b/libavcodec/tests/dct.c
@@ -38,7 +38,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/lfg.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/time.h"
 
 #include "libavcodec/dct.h"
diff --git a/libavcodec/ttmlenc.h b/libavcodec/tests/fft-fixed.c
similarity index 71%
copy from libavcodec/ttmlenc.h
copy to libavcodec/tests/fft-fixed.c
index c1dd5ec..3c50bf1 100644
--- a/libavcodec/ttmlenc.h
+++ b/libavcodec/tests/fft-fixed.c
@@ -1,7 +1,4 @@
 /*
- * TTML subtitle encoder shared functionality
- * Copyright (c) 2020 24i
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -19,10 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_TTMLENC_H
-#define AVCODEC_TTMLENC_H
-
-#define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc"
-#define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1)
-
-#endif /* AVCODEC_TTMLENC_H */
+#define FFT_FLOAT 0
+#define AVFFT 0
+#include "fft.c"
diff --git a/libavcodec/tests/options.c b/libavcodec/tests/options.c
new file mode 100644
index 0000000..010e3c0
--- /dev/null
+++ b/libavcodec/tests/options.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/options.c"
+
+static int dummy_init(AVCodecContext *ctx)
+{
+    //TODO: this code should set every possible pointer that could be set by codec and is not an option;
+    ctx->extradata_size = 8;
+    ctx->extradata = av_malloc(ctx->extradata_size);
+    return 0;
+}
+
+static int dummy_close(AVCodecContext *ctx)
+{
+    av_freep(&ctx->extradata);
+    ctx->extradata_size = 0;
+    return 0;
+}
+
+static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
+{
+    return AVERROR(ENOSYS);
+}
+
+typedef struct Dummy12Context {
+    AVClass  *av_class;
+    int      num;
+    char*    str;
+} Dummy12Context;
+
+typedef struct Dummy3Context {
+    void     *fake_av_class;
+    int      num;
+    char*    str;
+} Dummy3Context;
+
+#define OFFSET(x) offsetof(Dummy12Context, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption dummy_options[] = {
+    { "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src default value" }, 0, 0, VE},
+    { "num", "set num", OFFSET(num), AV_OPT_TYPE_INT,    { .i64 = 1500100900 },    0, INT_MAX, VE},
+    { NULL },
+};
+
+static const AVClass dummy_v1_class = {
+    .class_name = "dummy_v1_class",
+    .item_name  = av_default_item_name,
+    .option     = dummy_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+static const AVClass dummy_v2_class = {
+    .class_name = "dummy_v2_class",
+    .item_name  = av_default_item_name,
+    .option     = dummy_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+/* codec with options */
+static AVCodec dummy_v1_encoder = {
+    .name             = "dummy_v1_codec",
+    .type             = AVMEDIA_TYPE_VIDEO,
+    .id               = AV_CODEC_ID_NONE - 1,
+    .encode2          = dummy_encode,
+    .init             = dummy_init,
+    .close            = dummy_close,
+    .priv_class       = &dummy_v1_class,
+    .priv_data_size   = sizeof(Dummy12Context),
+};
+
+/* codec with options, different class */
+static AVCodec dummy_v2_encoder = {
+    .name             = "dummy_v2_codec",
+    .type             = AVMEDIA_TYPE_VIDEO,
+    .id               = AV_CODEC_ID_NONE - 2,
+    .encode2          = dummy_encode,
+    .init             = dummy_init,
+    .close            = dummy_close,
+    .priv_class       = &dummy_v2_class,
+    .priv_data_size   = sizeof(Dummy12Context),
+};
+
+/* codec with priv data, but no class */
+static AVCodec dummy_v3_encoder = {
+    .name             = "dummy_v3_codec",
+    .type             = AVMEDIA_TYPE_VIDEO,
+    .id               = AV_CODEC_ID_NONE - 3,
+    .encode2          = dummy_encode,
+    .init             = dummy_init,
+    .close            = dummy_close,
+    .priv_data_size   = sizeof(Dummy3Context),
+};
+
+/* codec without priv data */
+static AVCodec dummy_v4_encoder = {
+    .name             = "dummy_v4_codec",
+    .type             = AVMEDIA_TYPE_VIDEO,
+    .id               = AV_CODEC_ID_NONE - 4,
+    .encode2          = dummy_encode,
+    .init             = dummy_init,
+    .close            = dummy_close,
+};
+
+static void test_copy_print_codec(const AVCodecContext *ctx)
+{
+    printf("%-14s: %dx%d prv: %s",
+           ctx->codec ? ctx->codec->name : "NULL",
+           ctx->width, ctx->height,
+           ctx->priv_data ? "set" : "null");
+    if (ctx->codec && ctx->codec->priv_class && ctx->codec->priv_data_size) {
+        int64_t i64;
+        char *str = NULL;
+        av_opt_get_int(ctx->priv_data, "num", 0, &i64);
+        av_opt_get(ctx->priv_data, "str", 0, (uint8_t**)&str);
+        printf(" opts: %"PRId64" %s", i64, str);
+        av_free(str);
+    }
+    printf("\n");
+}
+
+static void test_copy(const AVCodec *c1, const AVCodec *c2)
+{
+    AVCodecContext *ctx1, *ctx2;
+    printf("%s -> %s\nclosed:\n", c1 ? c1->name : "NULL", c2 ? c2->name : "NULL");
+    ctx1 = avcodec_alloc_context3(c1);
+    ctx2 = avcodec_alloc_context3(c2);
+    ctx1->width = ctx1->height = 128;
+    ctx1->time_base = (AVRational){12,34};
+    if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) {
+        av_opt_set(ctx2->priv_data, "num", "667", 0);
+        av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0);
+    }
+    avcodec_copy_context(ctx2, ctx1);
+    test_copy_print_codec(ctx1);
+    test_copy_print_codec(ctx2);
+    if (ctx1->codec) {
+        int ret;
+        printf("opened:\n");
+        ret = avcodec_open2(ctx1, ctx1->codec, NULL);
+        if (ret < 0) {
+            fprintf(stderr, "avcodec_open2 failed\n");
+            exit(1);
+        }
+        if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) {
+            av_opt_set(ctx2->priv_data, "num", "667", 0);
+            av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0);
+        }
+        avcodec_copy_context(ctx2, ctx1);
+        test_copy_print_codec(ctx1);
+        test_copy_print_codec(ctx2);
+    }
+    avcodec_free_context(&ctx1);
+    avcodec_free_context(&ctx2);
+}
+
+int main(void)
+{
+    AVCodec *dummy_codec[] = {
+        &dummy_v1_encoder,
+        &dummy_v2_encoder,
+        &dummy_v3_encoder,
+        &dummy_v4_encoder,
+        NULL,
+    };
+    int i, j;
+
+    for (i = 0; dummy_codec[i]; i++)
+        avcodec_register(dummy_codec[i]);
+
+    printf("testing avcodec_copy_context()\n");
+    for (i = 0; i < FF_ARRAY_ELEMS(dummy_codec); i++)
+        for (j = 0; j < FF_ARRAY_ELEMS(dummy_codec); j++)
+            test_copy(dummy_codec[i], dummy_codec[j]);
+    return 0;
+}
diff --git a/libavcodec/tests/rangecoder.c b/libavcodec/tests/rangecoder.c
index ca96e13..d6cf9ec 100644
--- a/libavcodec/tests/rangecoder.c
+++ b/libavcodec/tests/rangecoder.c
@@ -26,32 +26,6 @@
 
 #define SIZE 1240
 
-/**
- * Check if at the current position there is a valid looking termination
- * @param version version 0 requires the decoder to know the data size in bytes
- *                version 1 needs about 1 bit more space but does not need to
- *                          carry the size from encoder to decoder
- * @returns negative AVERROR code on error or non negative.
- */
-static int rac_check_termination(RangeCoder *c, int version)
-{
-    if (version == 1) {
-        RangeCoder tmp = *c;
-        get_rac(c, (uint8_t[]) { 129 });
-
-        if (c->bytestream == tmp.bytestream && c->bytestream > c->bytestream_start)
-            tmp.low -= *--tmp.bytestream;
-        tmp.bytestream_end = tmp.bytestream;
-
-        if (get_rac(&tmp, (uint8_t[]) { 129 }))
-            return AVERROR_INVALIDDATA;
-    } else {
-        if (c->bytestream_end != c->bytestream)
-            return AVERROR_INVALIDDATA;
-    }
-    return 0;
-}
-
 int main(void)
 {
     RangeCoder c;
@@ -87,7 +61,7 @@
                     return 1;
                 }
 
-            if (rac_check_termination(&c, version) < 0) {
+            if (ff_rac_check_termination(&c, version) < 0) {
                 av_log(NULL, AV_LOG_ERROR, "rac failure at termination pass %d version %d\n", p, version);
                 return 1;
             }
diff --git a/libavcodec/tests/x86/dct.c b/libavcodec/tests/x86/dct.c
index f5c238e..afb03b1 100644
--- a/libavcodec/tests/x86/dct.c
+++ b/libavcodec/tests/x86/dct.c
@@ -18,8 +18,6 @@
 
 #include "config.h"
 
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/x86/fdct.h"
 #include "libavcodec/x86/xvididct.h"
 #include "libavcodec/x86/simple_idct.h"
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 9cd2876..fa1f44c 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -132,8 +132,8 @@
 
 #define RET_GEOKEY(TYPE, array, element)\
     if (key >= TIFF_##TYPE##_KEY_ID_OFFSET &&\
-        key - TIFF_##TYPE##_KEY_ID_OFFSET < FF_ARRAY_ELEMS(tiff_##array##_name_type_map))\
-        return tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].element;
+        key - TIFF_##TYPE##_KEY_ID_OFFSET < FF_ARRAY_ELEMS(ff_tiff_##array##_name_type_map))\
+        return ff_tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].element;
 
 static const char *get_geokey_name(int key)
 {
@@ -180,8 +180,8 @@
 
 #define RET_GEOKEY_VAL(TYPE, array)\
     if (val >= TIFF_##TYPE##_OFFSET &&\
-        val - TIFF_##TYPE##_OFFSET < FF_ARRAY_ELEMS(tiff_##array##_codes))\
-        return av_strdup(tiff_##array##_codes[val - TIFF_##TYPE##_OFFSET]);
+        val - TIFF_##TYPE##_OFFSET < FF_ARRAY_ELEMS(ff_tiff_##array##_codes))\
+        return av_strdup(ff_tiff_##array##_codes[val - TIFF_##TYPE##_OFFSET]);
 
     switch (key) {
     case TIFF_GT_MODEL_TYPE_GEOKEY:
@@ -214,11 +214,11 @@
         RET_GEOKEY_VAL(PRIME_MERIDIAN, prime_meridian);
         break;
     case TIFF_PROJECTED_CS_TYPE_GEOKEY:
-        ap = av_strdup(search_keyval(tiff_proj_cs_type_codes, FF_ARRAY_ELEMS(tiff_proj_cs_type_codes), val));
+        ap = av_strdup(search_keyval(ff_tiff_proj_cs_type_codes, FF_ARRAY_ELEMS(ff_tiff_proj_cs_type_codes), val));
         if(ap) return ap;
         break;
     case TIFF_PROJECTION_GEOKEY:
-        ap = av_strdup(search_keyval(tiff_projection_codes, FF_ARRAY_ELEMS(tiff_projection_codes), val));
+        ap = av_strdup(search_keyval(ff_tiff_projection_codes, FF_ARRAY_ELEMS(ff_tiff_projection_codes), val));
         if(ap) return ap;
         break;
     case TIFF_PROJ_COORD_TRANS_GEOKEY:
@@ -964,8 +964,7 @@
     return 0;
 }
 
-static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
-                            const AVPacket *avpkt)
+static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame, AVPacket *avpkt)
 {
     TiffContext *s = avctx->priv_data;
     int tile_idx;
@@ -1924,17 +1923,14 @@
     has_strip_bits = s->strippos || s->strips || s->stripoff || s->rps || s->sot || s->sstype || s->stripsize || s->stripsizesoff;
 
     if (has_tile_bits && has_strip_bits) {
-        int tiled_dng = s->is_tiled && is_dng;
-        av_log(avctx, tiled_dng ? AV_LOG_WARNING : AV_LOG_ERROR, "Tiled TIFF is not allowed to strip\n");
-        if (!tiled_dng)
-            return AVERROR_INVALIDDATA;
+        av_log(avctx, AV_LOG_WARNING, "Tiled TIFF is not allowed to strip\n");
     }
 
     /* now we have the data and may start decoding */
     if ((ret = init_image(s, &frame)) < 0)
         return ret;
 
-    if (!s->is_tiled || has_strip_bits) {
+    if (!s->is_tiled) {
         if (s->strips == 1 && !s->stripsize) {
             av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
             s->stripsize = avpkt->size - s->stripoff;
diff --git a/libavcodec/tiff_common.h b/libavcodec/tiff_common.h
index 019d23e..03558c3 100644
--- a/libavcodec/tiff_common.h
+++ b/libavcodec/tiff_common.h
@@ -79,6 +79,26 @@
 /** Reads a byte from the bytestream using given endianness. */
 unsigned ff_tget(GetByteContext *gb, int type, int le);
 
+/** Returns an allocated string containing count
+ *  rational values using the given separator.
+ */
+char *ff_trationals2str(int *rp, int count, const char *sep);
+
+/** Returns an allocated string containing count
+ *  long values using the given separator.
+ */
+char *ff_tlongs2str(int32_t *lp, int count, const char *sep);
+
+/** Returns an allocated string containing count
+ *  double values using the given separator.
+ */
+char *ff_tdoubles2str(double *dp, int count, const char *sep);
+
+/** Returns an allocated string containing count
+ *  short values using the given separator.
+ */
+char *ff_tshorts2str(int16_t *sp, int count, const char *sep);
+
 /** Adds count rationals converted to a string
  *  into the metadata dictionary.
  */
diff --git a/libavcodec/tiff_data.c b/libavcodec/tiff_data.c
new file mode 100644
index 0000000..88c2256
--- /dev/null
+++ b/libavcodec/tiff_data.c
@@ -0,0 +1,1870 @@
+/*
+ * TIFF data tables
+ * Copyright (c) 2011 Thomas Kuehnel
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * TIFF data tables
+ * @author Thomas Kuehnel
+ * @see GeoTIFF specification at
+ * http://www.remotesensing.org/geotiff/spec/geotiffhome.html
+ */
+
+#include "tiff_data.h"
+
+const TiffGeoTagNameType ff_tiff_conf_name_type_map[] = {
+    {"GTModelTypeGeoKey",              GEOTIFF_SHORT },
+    {"GTRasterTypeGeoKey",             GEOTIFF_SHORT },
+    {"GTCitationGeoKey",               GEOTIFF_STRING}
+};
+
+const TiffGeoTagNameType ff_tiff_geog_name_type_map[] = {
+    {"GeographicTypeGeoKey",           GEOTIFF_SHORT },
+    {"GeogCitationGeoKey",             GEOTIFF_STRING},
+    {"GeogGeodeticDatumGeoKey",        GEOTIFF_SHORT },
+    {"GeogPrimeMeridianGeoKey",        GEOTIFF_SHORT },
+    {"GeogLinearUnitsGeoKey",          GEOTIFF_SHORT },
+    {"GeogLinearUnitSizeGeoKey",       GEOTIFF_DOUBLE},
+    {"GeogAngularUnitsGeoKey",         GEOTIFF_SHORT },
+    {"GeogAngularUnitSizeGeoKey",      GEOTIFF_DOUBLE},
+    {"GeogEllipsoidGeoKey",            GEOTIFF_SHORT },
+    {"GeogSemiMajorAxisGeoKey",        GEOTIFF_DOUBLE},
+    {"GeogSemiMinorAxisGeoKey",        GEOTIFF_DOUBLE},
+    {"GeogInvFlatteningGeoKey",        GEOTIFF_DOUBLE},
+    {"GeogAzimuthUnitsGeoKey",         GEOTIFF_SHORT },
+    {"GeogPrimeMeridianLongGeoKey",    GEOTIFF_DOUBLE}
+};
+
+const TiffGeoTagNameType ff_tiff_proj_name_type_map[] = {
+    {"ProjectedCSTypeGeoKey",          GEOTIFF_SHORT },
+    {"PCSCitationGeoKey",              GEOTIFF_STRING},
+    {"ProjectionGeoKey",               GEOTIFF_SHORT },
+    {"ProjCoordTransGeoKey",           GEOTIFF_SHORT },
+    {"ProjLinearUnitsGeoKey",          GEOTIFF_SHORT },
+    {"ProjLinearUnitSizeGeoKey",       GEOTIFF_DOUBLE},
+    {"ProjStdParallel1GeoKey",         GEOTIFF_DOUBLE},
+    {"ProjStdParallel2GeoKey",         GEOTIFF_DOUBLE},
+    {"ProjNatOriginLongGeoKey",        GEOTIFF_DOUBLE},
+    {"ProjNatOriginLatGeoKey",         GEOTIFF_DOUBLE},
+    {"ProjFalseEastingGeoKey",         GEOTIFF_DOUBLE},
+    {"ProjFalseNorthingGeoKey",        GEOTIFF_DOUBLE},
+    {"ProjFalseOriginLongGeoKey",      GEOTIFF_DOUBLE},
+    {"ProjFalseOriginLatGeoKey",       GEOTIFF_DOUBLE},
+    {"ProjFalseOriginEastingGeoKey",   GEOTIFF_DOUBLE},
+    {"ProjFalseOriginNorthingGeoKey",  GEOTIFF_DOUBLE},
+    {"ProjCenterLongGeoKey",           GEOTIFF_DOUBLE},
+    {"ProjCenterLatGeoKey",            GEOTIFF_DOUBLE},
+    {"ProjCenterEastingGeoKey",        GEOTIFF_DOUBLE},
+    {"ProjCenterNorthingGeoKey",       GEOTIFF_DOUBLE},
+    {"ProjScaleAtNatOriginGeoKey",     GEOTIFF_DOUBLE},
+    {"ProjScaleAtCenterGeoKey",        GEOTIFF_DOUBLE},
+    {"ProjAzimuthAngleGeoKey",         GEOTIFF_DOUBLE},
+    {"ProjStraightVertPoleLongGeoKey", GEOTIFF_DOUBLE}
+};
+
+const TiffGeoTagNameType ff_tiff_vert_name_type_map[] = {
+    {"VerticalCSTypeGeoKey",           GEOTIFF_SHORT },
+    {"VerticalCitationGeoKey",         GEOTIFF_STRING},
+    {"VerticalDatumGeoKey",            GEOTIFF_SHORT },
+    {"VerticalUnitsGeoKey",            GEOTIFF_SHORT }
+};
+
+const char *const ff_tiff_gt_model_type_codes[] = {
+    "ModelTypeProjected",
+    "ModelTypeGeographic",
+    "ModelTypeGeocentric"
+};
+
+const char *const ff_tiff_gt_raster_type_codes[] = {
+    "RasterPixelIsArea",
+    "RasterPixelIsPoint"
+};
+
+const char *const ff_tiff_linear_unit_codes[] = {
+    "Linear_Meter",
+    "Linear_Foot",
+    "Linear_Foot_US_Survey",
+    "Linear_Foot_Modified_American",
+    "Linear_Foot_Clarke",
+    "Linear_Foot_Indian",
+    "Linear_Link",
+    "Linear_Link_Benoit",
+    "Linear_Link_Sears",
+    "Linear_Chain_Benoit",
+    "Linear_Chain_Sears",
+    "Linear_Yard_Sears",
+    "Linear_Yard_Indian",
+    "Linear_Fathom",
+    "Linear_Mile_International_Nautical"
+};
+
+const char *const ff_tiff_angular_unit_codes[] = {
+    "Angular_Radian",
+    "Angular_Degree",
+    "Angular_Arc_Minute",
+    "Angular_Arc_Second",
+    "Angular_Grad",
+    "Angular_Gon",
+    "Angular_DMS",
+    "Angular_DMS_Hemisphere"
+};
+
+const char *const ff_tiff_gcs_type_codes[] = {
+    "GCS_Adindan",
+    "GCS_AGD66",
+    "GCS_AGD84",
+    "GCS_Ain_el_Abd",
+    "GCS_Afgooye",
+    "GCS_Agadez",
+    "GCS_Lisbon",
+    "GCS_Aratu",
+    "GCS_Arc_1950",
+    "GCS_Arc_1960",
+    "GCS_Batavia",
+    "GCS_Barbados",
+    "GCS_Beduaram",
+    "GCS_Beijing_1954",
+    "GCS_Belge_1950",
+    "GCS_Bermuda_1957",
+    "GCS_Bern_1898",
+    "GCS_Bogota",
+    "GCS_Bukit_Rimpah",
+    "GCS_Camacupa",
+    "GCS_Campo_Inchauspe",
+    "GCS_Cape",
+    "GCS_Carthage",
+    "GCS_Chua",
+    "GCS_Corrego_Alegre",
+    "GCS_Cote_d_Ivoire",
+    "GCS_Deir_ez_Zor",
+    "GCS_Douala",
+    "GCS_Egypt_1907",
+    "GCS_ED50",
+    "GCS_ED87",
+    "GCS_Fahud",
+    "GCS_Gandajika_1970",
+    "GCS_Garoua",
+    "GCS_Guyane_Francaise",
+    "GCS_Hu_Tzu_Shan",
+    "GCS_HD72",
+    "GCS_ID74",
+    "GCS_Indian_1954",
+    "GCS_Indian_1975",
+    "GCS_Jamaica_1875",
+    "GCS_JAD69",
+    "GCS_Kalianpur",
+    "GCS_Kandawala",
+    "GCS_Kertau",
+    "GCS_KOC",
+    "GCS_La_Canoa",
+    "GCS_PSAD56",
+    "GCS_Lake",
+    "GCS_Leigon",
+    "GCS_Liberia_1964",
+    "GCS_Lome",
+    "GCS_Luzon_1911",
+    "GCS_Hito_XVIII_1963",
+    "GCS_Herat_North",
+    "GCS_Mahe_1971",
+    "GCS_Makassar",
+    "GCS_EUREF89",
+    "GCS_Malongo_1987",
+    "GCS_Manoca",
+    "GCS_Merchich",
+    "GCS_Massawa",
+    "GCS_Minna",
+    "GCS_Mhast",
+    "GCS_Monte_Mario",
+    "GCS_M_poraloko",
+    "GCS_NAD27",
+    "GCS_NAD_Michigan",
+    "GCS_NAD83",
+    "GCS_Nahrwan_1967",
+    "GCS_Naparima_1972",
+    "GCS_GD49",
+    "GCS_NGO_1948",
+    "GCS_Datum_73",
+    "GCS_NTF",
+    "GCS_NSWC_9Z_2",
+    "GCS_OSGB_1936",
+    "GCS_OSGB70",
+    "GCS_OS_SN80",
+    "GCS_Padang",
+    "GCS_Palestine_1923",
+    "GCS_Pointe_Noire",
+    "GCS_GDA94",
+    "GCS_Pulkovo_1942",
+    "GCS_Qatar",
+    "GCS_Qatar_1948",
+    "GCS_Qornoq",
+    "GCS_Loma_Quintana",
+    "GCS_Amersfoort",
+    "GCS_RT38",
+    "GCS_SAD69",
+    "GCS_Sapper_Hill_1943",
+    "GCS_Schwarzeck",
+    "GCS_Segora",
+    "GCS_Serindung",
+    "GCS_Sudan",
+    "GCS_Tananarive",
+    "GCS_Timbalai_1948",
+    "GCS_TM65",
+    "GCS_TM75",
+    "GCS_Tokyo",
+    "GCS_Trinidad_1903",
+    "GCS_TC_1948",
+    "GCS_Voirol_1875",
+    "GCS_Voirol_Unifie",
+    "GCS_Bern_1938",
+    "GCS_Nord_Sahara_1959",
+    "GCS_Stockholm_1938",
+    "GCS_Yacare",
+    "GCS_Yoff",
+    "GCS_Zanderij",
+    "GCS_MGI",
+    "GCS_Belge_1972",
+    "GCS_DHDN",
+    "GCS_Conakry_1905",
+    "GCS_WGS_72",
+    "GCS_WGS_72BE",
+    "GCS_WGS_84",
+    "GCS_Bern_1898_Bern",
+    "GCS_Bogota_Bogota",
+    "GCS_Lisbon_Lisbon",
+    "GCS_Makassar_Jakarta",
+    "GCS_MGI_Ferro",
+    "GCS_Monte_Mario_Rome",
+    "GCS_NTF_Paris",
+    "GCS_Padang_Jakarta",
+    "GCS_Belge_1950_Brussels",
+    "GCS_Tananarive_Paris",
+    "GCS_Voirol_1875_Paris",
+    "GCS_Voirol_Unifie_Paris",
+    "GCS_Batavia_Jakarta",
+    "GCS_ATF_Paris",
+    "GCS_NDG_Paris"
+};
+
+const char *const ff_tiff_gcse_type_codes[] = {
+    "GCSE_Airy1830",
+    "GCSE_AiryModified1849",
+    "GCSE_AustralianNationalSpheroid",
+    "GCSE_Bessel1841",
+    "GCSE_BesselModified",
+    "GCSE_BesselNamibia",
+    "GCSE_Clarke1858",
+    "GCSE_Clarke1866",
+    "GCSE_Clarke1866Michigan",
+    "GCSE_Clarke1880_Benoit",
+    "GCSE_Clarke1880_IGN",
+    "GCSE_Clarke1880_RGS",
+    "GCSE_Clarke1880_Arc",
+    "GCSE_Clarke1880_SGA1922",
+    "GCSE_Everest1830_1937Adjustment",
+    "GCSE_Everest1830_1967Definition",
+    "GCSE_Everest1830_1975Definition",
+    "GCSE_Everest1830Modified",
+    "GCSE_GRS1980",
+    "GCSE_Helmert1906",
+    "GCSE_IndonesianNationalSpheroid",
+    "GCSE_International1924",
+    "GCSE_International1967",
+    "GCSE_Krassowsky1940",
+    "GCSE_NWL9D",
+    "GCSE_NWL10D",
+    "GCSE_Plessis1817",
+    "GCSE_Struve1860",
+    "GCSE_WarOffice",
+    "GCSE_WGS84",
+    "GCSE_GEM10C",
+    "GCSE_OSU86F",
+    "GCSE_OSU91A",
+    "GCSE_Clarke1880",
+    "GCSE_Sphere"
+};
+
+const char *const ff_tiff_geodetic_datum_codes[] = {
+    "Datum_Adindan",
+    "Datum_Australian_Geodetic_Datum_1966",
+    "Datum_Australian_Geodetic_Datum_1984",
+    "Datum_Ain_el_Abd_1970",
+    "Datum_Afgooye",
+    "Datum_Agadez",
+    "Datum_Lisbon",
+    "Datum_Aratu",
+    "Datum_Arc_1950",
+    "Datum_Arc_1960",
+    "Datum_Batavia",
+    "Datum_Barbados",
+    "Datum_Beduaram",
+    "Datum_Beijing_1954",
+    "Datum_Reseau_National_Belge_1950",
+    "Datum_Bermuda_1957",
+    "Datum_Bern_1898",
+    "Datum_Bogota",
+    "Datum_Bukit_Rimpah",
+    "Datum_Camacupa",
+    "Datum_Campo_Inchauspe",
+    "Datum_Cape",
+    "Datum_Carthage",
+    "Datum_Chua",
+    "Datum_Corrego_Alegre",
+    "Datum_Cote_d_Ivoire",
+    "Datum_Deir_ez_Zor",
+    "Datum_Douala",
+    "Datum_Egypt_1907",
+    "Datum_European_Datum_1950",
+    "Datum_European_Datum_1987",
+    "Datum_Fahud",
+    "Datum_Gandajika_1970",
+    "Datum_Garoua",
+    "Datum_Guyane_Francaise",
+    "Datum_Hu_Tzu_Shan",
+    "Datum_Hungarian_Datum_1972",
+    "Datum_Indonesian_Datum_1974",
+    "Datum_Indian_1954",
+    "Datum_Indian_1975",
+    "Datum_Jamaica_1875",
+    "Datum_Jamaica_1969",
+    "Datum_Kalianpur",
+    "Datum_Kandawala",
+    "Datum_Kertau",
+    "Datum_Kuwait_Oil_Company",
+    "Datum_La_Canoa",
+    "Datum_Provisional_S_American_Datum_1956",
+    "Datum_Lake",
+    "Datum_Leigon",
+    "Datum_Liberia_1964",
+    "Datum_Lome",
+    "Datum_Luzon_1911",
+    "Datum_Hito_XVIII_1963",
+    "Datum_Herat_North",
+    "Datum_Mahe_1971",
+    "Datum_Makassar",
+    "Datum_European_Reference_System_1989",
+    "Datum_Malongo_1987",
+    "Datum_Manoca",
+    "Datum_Merchich",
+    "Datum_Massawa",
+    "Datum_Minna",
+    "Datum_Mhast",
+    "Datum_Monte_Mario",
+    "Datum_M_poraloko",
+    "Datum_North_American_Datum_1927",
+    "Datum_NAD_Michigan",
+    "Datum_North_American_Datum_1983",
+    "Datum_Nahrwan_1967",
+    "Datum_Naparima_1972",
+    "Datum_New_Zealand_Geodetic_Datum_1949",
+    "Datum_NGO_1948",
+    "Datum_Datum_73",
+    "Datum_Nouvelle_Triangulation_Francaise",
+    "Datum_NSWC_9Z_2",
+    "Datum_OSGB_1936",
+    "Datum_OSGB_1970_SN",
+    "Datum_OS_SN_1980",
+    "Datum_Padang_1884",
+    "Datum_Palestine_1923",
+    "Datum_Pointe_Noire",
+    "Datum_Geocentric_Datum_of_Australia_1994",
+    "Datum_Pulkovo_1942",
+    "Datum_Qatar",
+    "Datum_Qatar_1948",
+    "Datum_Qornoq",
+    "Datum_Loma_Quintana",
+    "Datum_Amersfoort",
+    "Datum_RT38",
+    "Datum_South_American_Datum_1969",
+    "Datum_Sapper_Hill_1943",
+    "Datum_Schwarzeck",
+    "Datum_Segora",
+    "Datum_Serindung",
+    "Datum_Sudan",
+    "Datum_Tananarive_1925",
+    "Datum_Timbalai_1948",
+    "Datum_TM65",
+    "Datum_TM75",
+    "Datum_Tokyo",
+    "Datum_Trinidad_1903",
+    "Datum_Trucial_Coast_1948",
+    "Datum_Voirol_1875",
+    "Datum_Voirol_Unifie_1960",
+    "Datum_Bern_1938",
+    "Datum_Nord_Sahara_1959",
+    "Datum_Stockholm_1938",
+    "Datum_Yacare",
+    "Datum_Yoff",
+    "Datum_Zanderij",
+    "Datum_Militar_Geographische_Institut",
+    "Datum_Reseau_National_Belge_1972",
+    "Datum_Deutsche_Hauptdreiecksnetz",
+    "Datum_Conakry_1905",
+    "Datum_WGS72",
+    "Datum_WGS72_Transit_Broadcast_Ephemeris",
+    "Datum_WGS84",
+    "Datum_Ancienne_Triangulation_Francaise",
+    "Datum_Nord_de_Guerre"
+};
+
+const char *const ff_tiff_geodetic_datum_e_codes[] = {
+    "DatumE_Airy1830",
+    "DatumE_AiryModified1849",
+    "DatumE_AustralianNationalSpheroid",
+    "DatumE_Bessel1841",
+    "DatumE_BesselModified",
+    "DatumE_BesselNamibia",
+    "DatumE_Clarke1858",
+    "DatumE_Clarke1866",
+    "DatumE_Clarke1866Michigan",
+    "DatumE_Clarke1880_Benoit",
+    "DatumE_Clarke1880_IGN",
+    "DatumE_Clarke1880_RGS",
+    "DatumE_Clarke1880_Arc",
+    "DatumE_Clarke1880_SGA1922",
+    "DatumE_Everest1830_1937Adjustment",
+    "DatumE_Everest1830_1967Definition",
+    "DatumE_Everest1830_1975Definition",
+    "DatumE_Everest1830Modified",
+    "DatumE_GRS1980",
+    "DatumE_Helmert1906",
+    "DatumE_IndonesianNationalSpheroid",
+    "DatumE_International1924",
+    "DatumE_International1967",
+    "DatumE_Krassowsky1960",
+    "DatumE_NWL9D",
+    "DatumE_NWL10D",
+    "DatumE_Plessis1817",
+    "DatumE_Struve1860",
+    "DatumE_WarOffice",
+    "DatumE_WGS84",
+    "DatumE_GEM10C",
+    "DatumE_OSU86F",
+    "DatumE_OSU91A",
+    "DatumE_Clarke1880",
+    "DatumE_Sphere"
+};
+
+const char *const ff_tiff_ellipsoid_codes[] = {
+    "Ellipse_Airy_1830",
+    "Ellipse_Airy_Modified_1849",
+    "Ellipse_Australian_National_Spheroid",
+    "Ellipse_Bessel_1841",
+    "Ellipse_Bessel_Modified",
+    "Ellipse_Bessel_Namibia",
+    "Ellipse_Clarke_1858",
+    "Ellipse_Clarke_1866",
+    "Ellipse_Clarke_1866_Michigan",
+    "Ellipse_Clarke_1880_Benoit",
+    "Ellipse_Clarke_1880_IGN",
+    "Ellipse_Clarke_1880_RGS",
+    "Ellipse_Clarke_1880_Arc",
+    "Ellipse_Clarke_1880_SGA_1922",
+    "Ellipse_Everest_1830_1937_Adjustment",
+    "Ellipse_Everest_1830_1967_Definition",
+    "Ellipse_Everest_1830_1975_Definition",
+    "Ellipse_Everest_1830_Modified",
+    "Ellipse_GRS_1980",
+    "Ellipse_Helmert_1906",
+    "Ellipse_Indonesian_National_Spheroid",
+    "Ellipse_International_1924",
+    "Ellipse_International_1967",
+    "Ellipse_Krassowsky_1940",
+    "Ellipse_NWL_9D",
+    "Ellipse_NWL_10D",
+    "Ellipse_Plessis_1817",
+    "Ellipse_Struve_1860",
+    "Ellipse_War_Office",
+    "Ellipse_WGS_84",
+    "Ellipse_GEM_10C",
+    "Ellipse_OSU86F",
+    "Ellipse_OSU91A",
+    "Ellipse_Clarke_1880",
+    "Ellipse_Sphere"
+};
+
+const char *const ff_tiff_prime_meridian_codes[] = {
+    "PM_Greenwich",
+    "PM_Lisbon",
+    "PM_Paris",
+    "PM_Bogota",
+    "PM_Madrid",
+    "PM_Rome",
+    "PM_Bern",
+    "PM_Jakarta",
+    "PM_Ferro",
+    "PM_Brussels",
+    "PM_Stockholm"
+};
+
+const TiffGeoTagKeyName ff_tiff_proj_cs_type_codes[] = {
+    {20137, "PCS_Adindan_UTM_zone_37N"},
+    {20138, "PCS_Adindan_UTM_zone_38N"},
+    {20248, "PCS_AGD66_AMG_zone_48"},
+    {20249, "PCS_AGD66_AMG_zone_49"},
+    {20250, "PCS_AGD66_AMG_zone_50"},
+    {20251, "PCS_AGD66_AMG_zone_51"},
+    {20252, "PCS_AGD66_AMG_zone_52"},
+    {20253, "PCS_AGD66_AMG_zone_53"},
+    {20254, "PCS_AGD66_AMG_zone_54"},
+    {20255, "PCS_AGD66_AMG_zone_55"},
+    {20256, "PCS_AGD66_AMG_zone_56"},
+    {20257, "PCS_AGD66_AMG_zone_57"},
+    {20258, "PCS_AGD66_AMG_zone_58"},
+    {20348, "PCS_AGD84_AMG_zone_48"},
+    {20349, "PCS_AGD84_AMG_zone_49"},
+    {20350, "PCS_AGD84_AMG_zone_50"},
+    {20351, "PCS_AGD84_AMG_zone_51"},
+    {20352, "PCS_AGD84_AMG_zone_52"},
+    {20353, "PCS_AGD84_AMG_zone_53"},
+    {20354, "PCS_AGD84_AMG_zone_54"},
+    {20355, "PCS_AGD84_AMG_zone_55"},
+    {20356, "PCS_AGD84_AMG_zone_56"},
+    {20357, "PCS_AGD84_AMG_zone_57"},
+    {20358, "PCS_AGD84_AMG_zone_58"},
+    {20437, "PCS_Ain_el_Abd_UTM_zone_37N"},
+    {20438, "PCS_Ain_el_Abd_UTM_zone_38N"},
+    {20439, "PCS_Ain_el_Abd_UTM_zone_39N"},
+    {20499, "PCS_Ain_el_Abd_Bahrain_Grid"},
+    {20538, "PCS_Afgooye_UTM_zone_38N"},
+    {20539, "PCS_Afgooye_UTM_zone_39N"},
+    {20700, "PCS_Lisbon_Portugese_Grid"},
+    {20822, "PCS_Aratu_UTM_zone_22S"},
+    {20823, "PCS_Aratu_UTM_zone_23S"},
+    {20824, "PCS_Aratu_UTM_zone_24S"},
+    {20973, "PCS_Arc_1950_Lo13"},
+    {20975, "PCS_Arc_1950_Lo15"},
+    {20977, "PCS_Arc_1950_Lo17"},
+    {20979, "PCS_Arc_1950_Lo19"},
+    {20981, "PCS_Arc_1950_Lo21"},
+    {20983, "PCS_Arc_1950_Lo23"},
+    {20985, "PCS_Arc_1950_Lo25"},
+    {20987, "PCS_Arc_1950_Lo27"},
+    {20989, "PCS_Arc_1950_Lo29"},
+    {20991, "PCS_Arc_1950_Lo31"},
+    {20993, "PCS_Arc_1950_Lo33"},
+    {20995, "PCS_Arc_1950_Lo35"},
+    {21100, "PCS_Batavia_NEIEZ"},
+    {21148, "PCS_Batavia_UTM_zone_48S"},
+    {21149, "PCS_Batavia_UTM_zone_49S"},
+    {21150, "PCS_Batavia_UTM_zone_50S"},
+    {21413, "PCS_Beijing_Gauss_zone_13"},
+    {21414, "PCS_Beijing_Gauss_zone_14"},
+    {21415, "PCS_Beijing_Gauss_zone_15"},
+    {21416, "PCS_Beijing_Gauss_zone_16"},
+    {21417, "PCS_Beijing_Gauss_zone_17"},
+    {21418, "PCS_Beijing_Gauss_zone_18"},
+    {21419, "PCS_Beijing_Gauss_zone_19"},
+    {21420, "PCS_Beijing_Gauss_zone_20"},
+    {21421, "PCS_Beijing_Gauss_zone_21"},
+    {21422, "PCS_Beijing_Gauss_zone_22"},
+    {21423, "PCS_Beijing_Gauss_zone_23"},
+    {21473, "PCS_Beijing_Gauss_13N"},
+    {21474, "PCS_Beijing_Gauss_14N"},
+    {21475, "PCS_Beijing_Gauss_15N"},
+    {21476, "PCS_Beijing_Gauss_16N"},
+    {21477, "PCS_Beijing_Gauss_17N"},
+    {21478, "PCS_Beijing_Gauss_18N"},
+    {21479, "PCS_Beijing_Gauss_19N"},
+    {21480, "PCS_Beijing_Gauss_20N"},
+    {21481, "PCS_Beijing_Gauss_21N"},
+    {21482, "PCS_Beijing_Gauss_22N"},
+    {21483, "PCS_Beijing_Gauss_23N"},
+    {21500, "PCS_Belge_Lambert_50"},
+    {21790, "PCS_Bern_1898_Swiss_Old"},
+    {21817, "PCS_Bogota_UTM_zone_17N"},
+    {21818, "PCS_Bogota_UTM_zone_18N"},
+    {21891, "PCS_Bogota_Colombia_3W"},
+    {21892, "PCS_Bogota_Colombia_Bogota"},
+    {21893, "PCS_Bogota_Colombia_3E"},
+    {21894, "PCS_Bogota_Colombia_6E"},
+    {22032, "PCS_Camacupa_UTM_32S"},
+    {22033, "PCS_Camacupa_UTM_33S"},
+    {22191, "PCS_C_Inchauspe_Argentina_1"},
+    {22192, "PCS_C_Inchauspe_Argentina_2"},
+    {22193, "PCS_C_Inchauspe_Argentina_3"},
+    {22194, "PCS_C_Inchauspe_Argentina_4"},
+    {22195, "PCS_C_Inchauspe_Argentina_5"},
+    {22196, "PCS_C_Inchauspe_Argentina_6"},
+    {22197, "PCS_C_Inchauspe_Argentina_7"},
+    {22332, "PCS_Carthage_UTM_zone_32N"},
+    {22391, "PCS_Carthage_Nord_Tunisie"},
+    {22392, "PCS_Carthage_Sud_Tunisie"},
+    {22523, "PCS_Corrego_Alegre_UTM_23S"},
+    {22524, "PCS_Corrego_Alegre_UTM_24S"},
+    {22832, "PCS_Douala_UTM_zone_32N"},
+    {22992, "PCS_Egypt_1907_Red_Belt"},
+    {22993, "PCS_Egypt_1907_Purple_Belt"},
+    {22994, "PCS_Egypt_1907_Ext_Purple"},
+    {23028, "PCS_ED50_UTM_zone_28N"},
+    {23029, "PCS_ED50_UTM_zone_29N"},
+    {23030, "PCS_ED50_UTM_zone_30N"},
+    {23031, "PCS_ED50_UTM_zone_31N"},
+    {23032, "PCS_ED50_UTM_zone_32N"},
+    {23033, "PCS_ED50_UTM_zone_33N"},
+    {23034, "PCS_ED50_UTM_zone_34N"},
+    {23035, "PCS_ED50_UTM_zone_35N"},
+    {23036, "PCS_ED50_UTM_zone_36N"},
+    {23037, "PCS_ED50_UTM_zone_37N"},
+    {23038, "PCS_ED50_UTM_zone_38N"},
+    {23239, "PCS_Fahud_UTM_zone_39N"},
+    {23240, "PCS_Fahud_UTM_zone_40N"},
+    {23433, "PCS_Garoua_UTM_zone_33N"},
+    {23846, "PCS_ID74_UTM_zone_46N"},
+    {23847, "PCS_ID74_UTM_zone_47N"},
+    {23848, "PCS_ID74_UTM_zone_48N"},
+    {23849, "PCS_ID74_UTM_zone_49N"},
+    {23850, "PCS_ID74_UTM_zone_50N"},
+    {23851, "PCS_ID74_UTM_zone_51N"},
+    {23852, "PCS_ID74_UTM_zone_52N"},
+    {23853, "PCS_ID74_UTM_zone_53N"},
+    {23886, "PCS_ID74_UTM_zone_46S"},
+    {23887, "PCS_ID74_UTM_zone_47S"},
+    {23888, "PCS_ID74_UTM_zone_48S"},
+    {23889, "PCS_ID74_UTM_zone_49S"},
+    {23890, "PCS_ID74_UTM_zone_50S"},
+    {23891, "PCS_ID74_UTM_zone_51S"},
+    {23892, "PCS_ID74_UTM_zone_52S"},
+    {23893, "PCS_ID74_UTM_zone_53S"},
+    {23894, "PCS_ID74_UTM_zone_54S"},
+    {23947, "PCS_Indian_1954_UTM_47N"},
+    {23948, "PCS_Indian_1954_UTM_48N"},
+    {24047, "PCS_Indian_1975_UTM_47N"},
+    {24048, "PCS_Indian_1975_UTM_48N"},
+    {24100, "PCS_Jamaica_1875_Old_Grid"},
+    {24200, "PCS_JAD69_Jamaica_Grid"},
+    {24370, "PCS_Kalianpur_India_0"},
+    {24371, "PCS_Kalianpur_India_I"},
+    {24372, "PCS_Kalianpur_India_IIa"},
+    {24373, "PCS_Kalianpur_India_IIIa"},
+    {24374, "PCS_Kalianpur_India_IVa"},
+    {24382, "PCS_Kalianpur_India_IIb"},
+    {24383, "PCS_Kalianpur_India_IIIb"},
+    {24384, "PCS_Kalianpur_India_IVb"},
+    {24500, "PCS_Kertau_Singapore_Grid"},
+    {24547, "PCS_Kertau_UTM_zone_47N"},
+    {24548, "PCS_Kertau_UTM_zone_48N"},
+    {24720, "PCS_La_Canoa_UTM_zone_20N"},
+    {24721, "PCS_La_Canoa_UTM_zone_21N"},
+    {24818, "PCS_PSAD56_UTM_zone_18N"},
+    {24819, "PCS_PSAD56_UTM_zone_19N"},
+    {24820, "PCS_PSAD56_UTM_zone_20N"},
+    {24821, "PCS_PSAD56_UTM_zone_21N"},
+    {24877, "PCS_PSAD56_UTM_zone_17S"},
+    {24878, "PCS_PSAD56_UTM_zone_18S"},
+    {24879, "PCS_PSAD56_UTM_zone_19S"},
+    {24880, "PCS_PSAD56_UTM_zone_20S"},
+    {24891, "PCS_PSAD56_Peru_west_zone"},
+    {24892, "PCS_PSAD56_Peru_central"},
+    {24893, "PCS_PSAD56_Peru_east_zone"},
+    {25000, "PCS_Leigon_Ghana_Grid"},
+    {25231, "PCS_Lome_UTM_zone_31N"},
+    {25391, "PCS_Luzon_Philippines_I"},
+    {25392, "PCS_Luzon_Philippines_II"},
+    {25393, "PCS_Luzon_Philippines_III"},
+    {25394, "PCS_Luzon_Philippines_IV"},
+    {25395, "PCS_Luzon_Philippines_V"},
+    {25700, "PCS_Makassar_NEIEZ"},
+    {25932, "PCS_Malongo_1987_UTM_32S"},
+    {26191, "PCS_Merchich_Nord_Maroc"},
+    {26192, "PCS_Merchich_Sud_Maroc"},
+    {26193, "PCS_Merchich_Sahara"},
+    {26237, "PCS_Massawa_UTM_zone_37N"},
+    {26331, "PCS_Minna_UTM_zone_31N"},
+    {26332, "PCS_Minna_UTM_zone_32N"},
+    {26391, "PCS_Minna_Nigeria_West"},
+    {26392, "PCS_Minna_Nigeria_Mid_Belt"},
+    {26393, "PCS_Minna_Nigeria_East"},
+    {26432, "PCS_Mhast_UTM_zone_32S"},
+    {26591, "PCS_Monte_Mario_Italy_1"},
+    {26592, "PCS_Monte_Mario_Italy_2"},
+    {26632, "PCS_M_poraloko_UTM_32N"},
+    {26692, "PCS_M_poraloko_UTM_32S"},
+    {26703, "PCS_NAD27_UTM_zone_3N"},
+    {26704, "PCS_NAD27_UTM_zone_4N"},
+    {26705, "PCS_NAD27_UTM_zone_5N"},
+    {26706, "PCS_NAD27_UTM_zone_6N"},
+    {26707, "PCS_NAD27_UTM_zone_7N"},
+    {26708, "PCS_NAD27_UTM_zone_8N"},
+    {26709, "PCS_NAD27_UTM_zone_9N"},
+    {26710, "PCS_NAD27_UTM_zone_10N"},
+    {26711, "PCS_NAD27_UTM_zone_11N"},
+    {26712, "PCS_NAD27_UTM_zone_12N"},
+    {26713, "PCS_NAD27_UTM_zone_13N"},
+    {26714, "PCS_NAD27_UTM_zone_14N"},
+    {26715, "PCS_NAD27_UTM_zone_15N"},
+    {26716, "PCS_NAD27_UTM_zone_16N"},
+    {26717, "PCS_NAD27_UTM_zone_17N"},
+    {26718, "PCS_NAD27_UTM_zone_18N"},
+    {26719, "PCS_NAD27_UTM_zone_19N"},
+    {26720, "PCS_NAD27_UTM_zone_20N"},
+    {26721, "PCS_NAD27_UTM_zone_21N"},
+    {26722, "PCS_NAD27_UTM_zone_22N"},
+    {26729, "PCS_NAD27_Alabama_East"},
+    {26730, "PCS_NAD27_Alabama_West"},
+    {26731, "PCS_NAD27_Alaska_zone_1"},
+    {26732, "PCS_NAD27_Alaska_zone_2"},
+    {26733, "PCS_NAD27_Alaska_zone_3"},
+    {26734, "PCS_NAD27_Alaska_zone_4"},
+    {26735, "PCS_NAD27_Alaska_zone_5"},
+    {26736, "PCS_NAD27_Alaska_zone_6"},
+    {26737, "PCS_NAD27_Alaska_zone_7"},
+    {26738, "PCS_NAD27_Alaska_zone_8"},
+    {26739, "PCS_NAD27_Alaska_zone_9"},
+    {26740, "PCS_NAD27_Alaska_zone_10"},
+    {26741, "PCS_NAD27_California_I"},
+    {26742, "PCS_NAD27_California_II"},
+    {26743, "PCS_NAD27_California_III"},
+    {26744, "PCS_NAD27_California_IV"},
+    {26745, "PCS_NAD27_California_V"},
+    {26746, "PCS_NAD27_California_VI"},
+    {26747, "PCS_NAD27_California_VII"},
+    {26748, "PCS_NAD27_Arizona_East"},
+    {26749, "PCS_NAD27_Arizona_Central"},
+    {26750, "PCS_NAD27_Arizona_West"},
+    {26751, "PCS_NAD27_Arkansas_North"},
+    {26752, "PCS_NAD27_Arkansas_South"},
+    {26753, "PCS_NAD27_Colorado_North"},
+    {26754, "PCS_NAD27_Colorado_Central"},
+    {26755, "PCS_NAD27_Colorado_South"},
+    {26756, "PCS_NAD27_Connecticut"},
+    {26757, "PCS_NAD27_Delaware"},
+    {26758, "PCS_NAD27_Florida_East"},
+    {26759, "PCS_NAD27_Florida_West"},
+    {26760, "PCS_NAD27_Florida_North"},
+    {26761, "PCS_NAD27_Hawaii_zone_1"},
+    {26762, "PCS_NAD27_Hawaii_zone_2"},
+    {26763, "PCS_NAD27_Hawaii_zone_3"},
+    {26764, "PCS_NAD27_Hawaii_zone_4"},
+    {26765, "PCS_NAD27_Hawaii_zone_5"},
+    {26766, "PCS_NAD27_Georgia_East"},
+    {26767, "PCS_NAD27_Georgia_West"},
+    {26768, "PCS_NAD27_Idaho_East"},
+    {26769, "PCS_NAD27_Idaho_Central"},
+    {26770, "PCS_NAD27_Idaho_West"},
+    {26771, "PCS_NAD27_Illinois_East"},
+    {26772, "PCS_NAD27_Illinois_West"},
+    {26773, "PCS_NAD27_Indiana_East"},
+    {26774, "PCS_NAD27_BLM_14N_feet"},
+    {26774, "PCS_NAD27_Indiana_West"},
+    {26775, "PCS_NAD27_BLM_15N_feet"},
+    {26775, "PCS_NAD27_Iowa_North"},
+    {26776, "PCS_NAD27_BLM_16N_feet"},
+    {26776, "PCS_NAD27_Iowa_South"},
+    {26777, "PCS_NAD27_BLM_17N_feet"},
+    {26777, "PCS_NAD27_Kansas_North"},
+    {26778, "PCS_NAD27_Kansas_South"},
+    {26779, "PCS_NAD27_Kentucky_North"},
+    {26780, "PCS_NAD27_Kentucky_South"},
+    {26781, "PCS_NAD27_Louisiana_North"},
+    {26782, "PCS_NAD27_Louisiana_South"},
+    {26783, "PCS_NAD27_Maine_East"},
+    {26784, "PCS_NAD27_Maine_West"},
+    {26785, "PCS_NAD27_Maryland"},
+    {26786, "PCS_NAD27_Massachusetts"},
+    {26787, "PCS_NAD27_Massachusetts_Is"},
+    {26788, "PCS_NAD27_Michigan_North"},
+    {26789, "PCS_NAD27_Michigan_Central"},
+    {26790, "PCS_NAD27_Michigan_South"},
+    {26791, "PCS_NAD27_Minnesota_North"},
+    {26792, "PCS_NAD27_Minnesota_Cent"},
+    {26793, "PCS_NAD27_Minnesota_South"},
+    {26794, "PCS_NAD27_Mississippi_East"},
+    {26795, "PCS_NAD27_Mississippi_West"},
+    {26796, "PCS_NAD27_Missouri_East"},
+    {26797, "PCS_NAD27_Missouri_Central"},
+    {26798, "PCS_NAD27_Missouri_West"},
+    {26801, "PCS_NAD_Michigan_Michigan_East"},
+    {26802, "PCS_NAD_Michigan_Michigan_Old_Central"},
+    {26803, "PCS_NAD_Michigan_Michigan_West"},
+    {26903, "PCS_NAD83_UTM_zone_3N"},
+    {26904, "PCS_NAD83_UTM_zone_4N"},
+    {26905, "PCS_NAD83_UTM_zone_5N"},
+    {26906, "PCS_NAD83_UTM_zone_6N"},
+    {26907, "PCS_NAD83_UTM_zone_7N"},
+    {26908, "PCS_NAD83_UTM_zone_8N"},
+    {26909, "PCS_NAD83_UTM_zone_9N"},
+    {26910, "PCS_NAD83_UTM_zone_10N"},
+    {26911, "PCS_NAD83_UTM_zone_11N"},
+    {26912, "PCS_NAD83_UTM_zone_12N"},
+    {26913, "PCS_NAD83_UTM_zone_13N"},
+    {26914, "PCS_NAD83_UTM_zone_14N"},
+    {26915, "PCS_NAD83_UTM_zone_15N"},
+    {26916, "PCS_NAD83_UTM_zone_16N"},
+    {26917, "PCS_NAD83_UTM_zone_17N"},
+    {26918, "PCS_NAD83_UTM_zone_18N"},
+    {26919, "PCS_NAD83_UTM_zone_19N"},
+    {26920, "PCS_NAD83_UTM_zone_20N"},
+    {26921, "PCS_NAD83_UTM_zone_21N"},
+    {26922, "PCS_NAD83_UTM_zone_22N"},
+    {26923, "PCS_NAD83_UTM_zone_23N"},
+    {26929, "PCS_NAD83_Alabama_East"},
+    {26930, "PCS_NAD83_Alabama_West"},
+    {26931, "PCS_NAD83_Alaska_zone_1"},
+    {26932, "PCS_NAD83_Alaska_zone_2"},
+    {26933, "PCS_NAD83_Alaska_zone_3"},
+    {26934, "PCS_NAD83_Alaska_zone_4"},
+    {26935, "PCS_NAD83_Alaska_zone_5"},
+    {26936, "PCS_NAD83_Alaska_zone_6"},
+    {26937, "PCS_NAD83_Alaska_zone_7"},
+    {26938, "PCS_NAD83_Alaska_zone_8"},
+    {26939, "PCS_NAD83_Alaska_zone_9"},
+    {26940, "PCS_NAD83_Alaska_zone_10"},
+    {26941, "PCS_NAD83_California_1"},
+    {26942, "PCS_NAD83_California_2"},
+    {26943, "PCS_NAD83_California_3"},
+    {26944, "PCS_NAD83_California_4"},
+    {26945, "PCS_NAD83_California_5"},
+    {26946, "PCS_NAD83_California_6"},
+    {26948, "PCS_NAD83_Arizona_East"},
+    {26949, "PCS_NAD83_Arizona_Central"},
+    {26950, "PCS_NAD83_Arizona_West"},
+    {26951, "PCS_NAD83_Arkansas_North"},
+    {26952, "PCS_NAD83_Arkansas_South"},
+    {26953, "PCS_NAD83_Colorado_North"},
+    {26954, "PCS_NAD83_Colorado_Central"},
+    {26955, "PCS_NAD83_Colorado_South"},
+    {26956, "PCS_NAD83_Connecticut"},
+    {26957, "PCS_NAD83_Delaware"},
+    {26958, "PCS_NAD83_Florida_East"},
+    {26959, "PCS_NAD83_Florida_West"},
+    {26960, "PCS_NAD83_Florida_North"},
+    {26961, "PCS_NAD83_Hawaii_zone_1"},
+    {26962, "PCS_NAD83_Hawaii_zone_2"},
+    {26963, "PCS_NAD83_Hawaii_zone_3"},
+    {26964, "PCS_NAD83_Hawaii_zone_4"},
+    {26965, "PCS_NAD83_Hawaii_zone_5"},
+    {26966, "PCS_NAD83_Georgia_East"},
+    {26967, "PCS_NAD83_Georgia_West"},
+    {26968, "PCS_NAD83_Idaho_East"},
+    {26969, "PCS_NAD83_Idaho_Central"},
+    {26970, "PCS_NAD83_Idaho_West"},
+    {26971, "PCS_NAD83_Illinois_East"},
+    {26972, "PCS_NAD83_Illinois_West"},
+    {26973, "PCS_NAD83_Indiana_East"},
+    {26974, "PCS_NAD83_Indiana_West"},
+    {26975, "PCS_NAD83_Iowa_North"},
+    {26976, "PCS_NAD83_Iowa_South"},
+    {26977, "PCS_NAD83_Kansas_North"},
+    {26978, "PCS_NAD83_Kansas_South"},
+    {26979, "PCS_NAD83_Kentucky_North"},
+    {26980, "PCS_NAD83_Kentucky_South"},
+    {26981, "PCS_NAD83_Louisiana_North"},
+    {26982, "PCS_NAD83_Louisiana_South"},
+    {26983, "PCS_NAD83_Maine_East"},
+    {26984, "PCS_NAD83_Maine_West"},
+    {26985, "PCS_NAD83_Maryland"},
+    {26986, "PCS_NAD83_Massachusetts"},
+    {26987, "PCS_NAD83_Massachusetts_Is"},
+    {26988, "PCS_NAD83_Michigan_North"},
+    {26989, "PCS_NAD83_Michigan_Central"},
+    {26990, "PCS_NAD83_Michigan_South"},
+    {26991, "PCS_NAD83_Minnesota_North"},
+    {26992, "PCS_NAD83_Minnesota_Cent"},
+    {26993, "PCS_NAD83_Minnesota_South"},
+    {26994, "PCS_NAD83_Mississippi_East"},
+    {26995, "PCS_NAD83_Mississippi_West"},
+    {26996, "PCS_NAD83_Missouri_East"},
+    {26997, "PCS_NAD83_Missouri_Central"},
+    {26998, "PCS_NAD83_Missouri_West"},
+    {27038, "PCS_Nahrwan_1967_UTM_38N"},
+    {27039, "PCS_Nahrwan_1967_UTM_39N"},
+    {27040, "PCS_Nahrwan_1967_UTM_40N"},
+    {27120, "PCS_Naparima_UTM_20N"},
+    {27200, "PCS_GD49_NZ_Map_Grid"},
+    {27291, "PCS_GD49_North_Island_Grid"},
+    {27292, "PCS_GD49_South_Island_Grid"},
+    {27429, "PCS_Datum_73_UTM_zone_29N"},
+    {27500, "PCS_ATF_Nord_de_Guerre"},
+    {27581, "PCS_NTF_France_I"},
+    {27582, "PCS_NTF_France_II"},
+    {27583, "PCS_NTF_France_III"},
+    {27591, "PCS_NTF_Nord_France"},
+    {27592, "PCS_NTF_Centre_France"},
+    {27593, "PCS_NTF_Sud_France"},
+    {27700, "PCS_British_National_Grid"},
+    {28232, "PCS_Point_Noire_UTM_32S"},
+    {28348, "PCS_GDA94_MGA_zone_48"},
+    {28349, "PCS_GDA94_MGA_zone_49"},
+    {28350, "PCS_GDA94_MGA_zone_50"},
+    {28351, "PCS_GDA94_MGA_zone_51"},
+    {28352, "PCS_GDA94_MGA_zone_52"},
+    {28353, "PCS_GDA94_MGA_zone_53"},
+    {28354, "PCS_GDA94_MGA_zone_54"},
+    {28355, "PCS_GDA94_MGA_zone_55"},
+    {28356, "PCS_GDA94_MGA_zone_56"},
+    {28357, "PCS_GDA94_MGA_zone_57"},
+    {28358, "PCS_GDA94_MGA_zone_58"},
+    {28404, "PCS_Pulkovo_Gauss_zone_4"},
+    {28405, "PCS_Pulkovo_Gauss_zone_5"},
+    {28406, "PCS_Pulkovo_Gauss_zone_6"},
+    {28407, "PCS_Pulkovo_Gauss_zone_7"},
+    {28408, "PCS_Pulkovo_Gauss_zone_8"},
+    {28409, "PCS_Pulkovo_Gauss_zone_9"},
+    {28410, "PCS_Pulkovo_Gauss_zone_10"},
+    {28411, "PCS_Pulkovo_Gauss_zone_11"},
+    {28412, "PCS_Pulkovo_Gauss_zone_12"},
+    {28413, "PCS_Pulkovo_Gauss_zone_13"},
+    {28414, "PCS_Pulkovo_Gauss_zone_14"},
+    {28415, "PCS_Pulkovo_Gauss_zone_15"},
+    {28416, "PCS_Pulkovo_Gauss_zone_16"},
+    {28417, "PCS_Pulkovo_Gauss_zone_17"},
+    {28418, "PCS_Pulkovo_Gauss_zone_18"},
+    {28419, "PCS_Pulkovo_Gauss_zone_19"},
+    {28420, "PCS_Pulkovo_Gauss_zone_20"},
+    {28421, "PCS_Pulkovo_Gauss_zone_21"},
+    {28422, "PCS_Pulkovo_Gauss_zone_22"},
+    {28423, "PCS_Pulkovo_Gauss_zone_23"},
+    {28424, "PCS_Pulkovo_Gauss_zone_24"},
+    {28425, "PCS_Pulkovo_Gauss_zone_25"},
+    {28426, "PCS_Pulkovo_Gauss_zone_26"},
+    {28427, "PCS_Pulkovo_Gauss_zone_27"},
+    {28428, "PCS_Pulkovo_Gauss_zone_28"},
+    {28429, "PCS_Pulkovo_Gauss_zone_29"},
+    {28430, "PCS_Pulkovo_Gauss_zone_30"},
+    {28431, "PCS_Pulkovo_Gauss_zone_31"},
+    {28432, "PCS_Pulkovo_Gauss_zone_32"},
+    {28464, "PCS_Pulkovo_Gauss_4N"},
+    {28465, "PCS_Pulkovo_Gauss_5N"},
+    {28466, "PCS_Pulkovo_Gauss_6N"},
+    {28467, "PCS_Pulkovo_Gauss_7N"},
+    {28468, "PCS_Pulkovo_Gauss_8N"},
+    {28469, "PCS_Pulkovo_Gauss_9N"},
+    {28470, "PCS_Pulkovo_Gauss_10N"},
+    {28471, "PCS_Pulkovo_Gauss_11N"},
+    {28472, "PCS_Pulkovo_Gauss_12N"},
+    {28473, "PCS_Pulkovo_Gauss_13N"},
+    {28474, "PCS_Pulkovo_Gauss_14N"},
+    {28475, "PCS_Pulkovo_Gauss_15N"},
+    {28476, "PCS_Pulkovo_Gauss_16N"},
+    {28477, "PCS_Pulkovo_Gauss_17N"},
+    {28478, "PCS_Pulkovo_Gauss_18N"},
+    {28479, "PCS_Pulkovo_Gauss_19N"},
+    {28480, "PCS_Pulkovo_Gauss_20N"},
+    {28481, "PCS_Pulkovo_Gauss_21N"},
+    {28482, "PCS_Pulkovo_Gauss_22N"},
+    {28483, "PCS_Pulkovo_Gauss_23N"},
+    {28484, "PCS_Pulkovo_Gauss_24N"},
+    {28485, "PCS_Pulkovo_Gauss_25N"},
+    {28486, "PCS_Pulkovo_Gauss_26N"},
+    {28487, "PCS_Pulkovo_Gauss_27N"},
+    {28488, "PCS_Pulkovo_Gauss_28N"},
+    {28489, "PCS_Pulkovo_Gauss_29N"},
+    {28490, "PCS_Pulkovo_Gauss_30N"},
+    {28491, "PCS_Pulkovo_Gauss_31N"},
+    {28492, "PCS_Pulkovo_Gauss_32N"},
+    {28600, "PCS_Qatar_National_Grid"},
+    {28991, "PCS_RD_Netherlands_Old"},
+    {28992, "PCS_RD_Netherlands_New"},
+    {29118, "PCS_SAD69_UTM_zone_18N"},
+    {29119, "PCS_SAD69_UTM_zone_19N"},
+    {29120, "PCS_SAD69_UTM_zone_20N"},
+    {29121, "PCS_SAD69_UTM_zone_21N"},
+    {29122, "PCS_SAD69_UTM_zone_22N"},
+    {29177, "PCS_SAD69_UTM_zone_17S"},
+    {29178, "PCS_SAD69_UTM_zone_18S"},
+    {29179, "PCS_SAD69_UTM_zone_19S"},
+    {29180, "PCS_SAD69_UTM_zone_20S"},
+    {29181, "PCS_SAD69_UTM_zone_21S"},
+    {29182, "PCS_SAD69_UTM_zone_22S"},
+    {29183, "PCS_SAD69_UTM_zone_23S"},
+    {29184, "PCS_SAD69_UTM_zone_24S"},
+    {29185, "PCS_SAD69_UTM_zone_25S"},
+    {29220, "PCS_Sapper_Hill_UTM_20S"},
+    {29221, "PCS_Sapper_Hill_UTM_21S"},
+    {29333, "PCS_Schwarzeck_UTM_33S"},
+    {29635, "PCS_Sudan_UTM_zone_35N"},
+    {29636, "PCS_Sudan_UTM_zone_36N"},
+    {29700, "PCS_Tananarive_Laborde"},
+    {29738, "PCS_Tananarive_UTM_38S"},
+    {29739, "PCS_Tananarive_UTM_39S"},
+    {29800, "PCS_Timbalai_1948_Borneo"},
+    {29849, "PCS_Timbalai_1948_UTM_49N"},
+    {29850, "PCS_Timbalai_1948_UTM_50N"},
+    {29900, "PCS_TM65_Irish_Nat_Grid"},
+    {30200, "PCS_Trinidad_1903_Trinidad"},
+    {30339, "PCS_TC_1948_UTM_zone_39N"},
+    {30340, "PCS_TC_1948_UTM_zone_40N"},
+    {30491, "PCS_Voirol_N_Algerie_ancien"},
+    {30492, "PCS_Voirol_S_Algerie_ancien"},
+    {30591, "PCS_Voirol_Unifie_N_Algerie"},
+    {30592, "PCS_Voirol_Unifie_S_Algerie"},
+    {30600, "PCS_Bern_1938_Swiss_New"},
+    {30729, "PCS_Nord_Sahara_UTM_29N"},
+    {30730, "PCS_Nord_Sahara_UTM_30N"},
+    {30731, "PCS_Nord_Sahara_UTM_31N"},
+    {30732, "PCS_Nord_Sahara_UTM_32N"},
+    {31028, "PCS_Yoff_UTM_zone_28N"},
+    {31121, "PCS_Zanderij_UTM_zone_21N"},
+    {31291, "PCS_MGI_Austria_West"},
+    {31292, "PCS_MGI_Austria_Central"},
+    {31293, "PCS_MGI_Austria_East"},
+    {31300, "PCS_Belge_Lambert_72"},
+    {31491, "PCS_DHDN_Germany_zone_1"},
+    {31492, "PCS_DHDN_Germany_zone_2"},
+    {31493, "PCS_DHDN_Germany_zone_3"},
+    {31494, "PCS_DHDN_Germany_zone_4"},
+    {31495, "PCS_DHDN_Germany_zone_5"},
+    {32001, "PCS_NAD27_Montana_North"},
+    {32002, "PCS_NAD27_Montana_Central"},
+    {32003, "PCS_NAD27_Montana_South"},
+    {32005, "PCS_NAD27_Nebraska_North"},
+    {32006, "PCS_NAD27_Nebraska_South"},
+    {32007, "PCS_NAD27_Nevada_East"},
+    {32008, "PCS_NAD27_Nevada_Central"},
+    {32009, "PCS_NAD27_Nevada_West"},
+    {32010, "PCS_NAD27_New_Hampshire"},
+    {32011, "PCS_NAD27_New_Jersey"},
+    {32012, "PCS_NAD27_New_Mexico_East"},
+    {32013, "PCS_NAD27_New_Mexico_Cent"},
+    {32014, "PCS_NAD27_New_Mexico_West"},
+    {32015, "PCS_NAD27_New_York_East"},
+    {32016, "PCS_NAD27_New_York_Central"},
+    {32017, "PCS_NAD27_New_York_West"},
+    {32018, "PCS_NAD27_New_York_Long_Is"},
+    {32019, "PCS_NAD27_North_Carolina"},
+    {32020, "PCS_NAD27_North_Dakota_N"},
+    {32021, "PCS_NAD27_North_Dakota_S"},
+    {32022, "PCS_NAD27_Ohio_North"},
+    {32023, "PCS_NAD27_Ohio_South"},
+    {32024, "PCS_NAD27_Oklahoma_North"},
+    {32025, "PCS_NAD27_Oklahoma_South"},
+    {32026, "PCS_NAD27_Oregon_North"},
+    {32027, "PCS_NAD27_Oregon_South"},
+    {32028, "PCS_NAD27_Pennsylvania_N"},
+    {32029, "PCS_NAD27_Pennsylvania_S"},
+    {32030, "PCS_NAD27_Rhode_Island"},
+    {32031, "PCS_NAD27_South_Carolina_N"},
+    {32033, "PCS_NAD27_South_Carolina_S"},
+    {32034, "PCS_NAD27_South_Dakota_N"},
+    {32035, "PCS_NAD27_South_Dakota_S"},
+    {32036, "PCS_NAD27_Tennessee"},
+    {32037, "PCS_NAD27_Texas_North"},
+    {32038, "PCS_NAD27_Texas_North_Cen"},
+    {32039, "PCS_NAD27_Texas_Central"},
+    {32040, "PCS_NAD27_Texas_South_Cen"},
+    {32041, "PCS_NAD27_Texas_South"},
+    {32042, "PCS_NAD27_Utah_North"},
+    {32043, "PCS_NAD27_Utah_Central"},
+    {32044, "PCS_NAD27_Utah_South"},
+    {32045, "PCS_NAD27_Vermont"},
+    {32046, "PCS_NAD27_Virginia_North"},
+    {32047, "PCS_NAD27_Virginia_South"},
+    {32048, "PCS_NAD27_Washington_North"},
+    {32049, "PCS_NAD27_Washington_South"},
+    {32050, "PCS_NAD27_West_Virginia_N"},
+    {32051, "PCS_NAD27_West_Virginia_S"},
+    {32052, "PCS_NAD27_Wisconsin_North"},
+    {32053, "PCS_NAD27_Wisconsin_Cen"},
+    {32054, "PCS_NAD27_Wisconsin_South"},
+    {32055, "PCS_NAD27_Wyoming_East"},
+    {32056, "PCS_NAD27_Wyoming_E_Cen"},
+    {32057, "PCS_NAD27_Wyoming_W_Cen"},
+    {32058, "PCS_NAD27_Wyoming_West"},
+    {32059, "PCS_NAD27_Puerto_Rico"},
+    {32060, "PCS_NAD27_St_Croix"},
+    {32100, "PCS_NAD83_Montana"},
+    {32104, "PCS_NAD83_Nebraska"},
+    {32107, "PCS_NAD83_Nevada_East"},
+    {32108, "PCS_NAD83_Nevada_Central"},
+    {32109, "PCS_NAD83_Nevada_West"},
+    {32110, "PCS_NAD83_New_Hampshire"},
+    {32111, "PCS_NAD83_New_Jersey"},
+    {32112, "PCS_NAD83_New_Mexico_East"},
+    {32113, "PCS_NAD83_New_Mexico_Cent"},
+    {32114, "PCS_NAD83_New_Mexico_West"},
+    {32115, "PCS_NAD83_New_York_East"},
+    {32116, "PCS_NAD83_New_York_Central"},
+    {32117, "PCS_NAD83_New_York_West"},
+    {32118, "PCS_NAD83_New_York_Long_Is"},
+    {32119, "PCS_NAD83_North_Carolina"},
+    {32120, "PCS_NAD83_North_Dakota_N"},
+    {32121, "PCS_NAD83_North_Dakota_S"},
+    {32122, "PCS_NAD83_Ohio_North"},
+    {32123, "PCS_NAD83_Ohio_South"},
+    {32124, "PCS_NAD83_Oklahoma_North"},
+    {32125, "PCS_NAD83_Oklahoma_South"},
+    {32126, "PCS_NAD83_Oregon_North"},
+    {32127, "PCS_NAD83_Oregon_South"},
+    {32128, "PCS_NAD83_Pennsylvania_N"},
+    {32129, "PCS_NAD83_Pennsylvania_S"},
+    {32130, "PCS_NAD83_Rhode_Island"},
+    {32133, "PCS_NAD83_South_Carolina"},
+    {32134, "PCS_NAD83_South_Dakota_N"},
+    {32135, "PCS_NAD83_South_Dakota_S"},
+    {32136, "PCS_NAD83_Tennessee"},
+    {32137, "PCS_NAD83_Texas_North"},
+    {32138, "PCS_NAD83_Texas_North_Cen"},
+    {32139, "PCS_NAD83_Texas_Central"},
+    {32140, "PCS_NAD83_Texas_South_Cen"},
+    {32141, "PCS_NAD83_Texas_South"},
+    {32142, "PCS_NAD83_Utah_North"},
+    {32143, "PCS_NAD83_Utah_Central"},
+    {32144, "PCS_NAD83_Utah_South"},
+    {32145, "PCS_NAD83_Vermont"},
+    {32146, "PCS_NAD83_Virginia_North"},
+    {32147, "PCS_NAD83_Virginia_South"},
+    {32148, "PCS_NAD83_Washington_North"},
+    {32149, "PCS_NAD83_Washington_South"},
+    {32150, "PCS_NAD83_West_Virginia_N"},
+    {32151, "PCS_NAD83_West_Virginia_S"},
+    {32152, "PCS_NAD83_Wisconsin_North"},
+    {32153, "PCS_NAD83_Wisconsin_Cen"},
+    {32154, "PCS_NAD83_Wisconsin_South"},
+    {32155, "PCS_NAD83_Wyoming_East"},
+    {32156, "PCS_NAD83_Wyoming_E_Cen"},
+    {32157, "PCS_NAD83_Wyoming_W_Cen"},
+    {32158, "PCS_NAD83_Wyoming_West"},
+    {32161, "PCS_NAD83_Puerto_Rico_Virgin_Is"},
+    {32201, "PCS_WGS72_UTM_zone_1N"},
+    {32202, "PCS_WGS72_UTM_zone_2N"},
+    {32203, "PCS_WGS72_UTM_zone_3N"},
+    {32204, "PCS_WGS72_UTM_zone_4N"},
+    {32205, "PCS_WGS72_UTM_zone_5N"},
+    {32206, "PCS_WGS72_UTM_zone_6N"},
+    {32207, "PCS_WGS72_UTM_zone_7N"},
+    {32208, "PCS_WGS72_UTM_zone_8N"},
+    {32209, "PCS_WGS72_UTM_zone_9N"},
+    {32210, "PCS_WGS72_UTM_zone_10N"},
+    {32211, "PCS_WGS72_UTM_zone_11N"},
+    {32212, "PCS_WGS72_UTM_zone_12N"},
+    {32213, "PCS_WGS72_UTM_zone_13N"},
+    {32214, "PCS_WGS72_UTM_zone_14N"},
+    {32215, "PCS_WGS72_UTM_zone_15N"},
+    {32216, "PCS_WGS72_UTM_zone_16N"},
+    {32217, "PCS_WGS72_UTM_zone_17N"},
+    {32218, "PCS_WGS72_UTM_zone_18N"},
+    {32219, "PCS_WGS72_UTM_zone_19N"},
+    {32220, "PCS_WGS72_UTM_zone_20N"},
+    {32221, "PCS_WGS72_UTM_zone_21N"},
+    {32222, "PCS_WGS72_UTM_zone_22N"},
+    {32223, "PCS_WGS72_UTM_zone_23N"},
+    {32224, "PCS_WGS72_UTM_zone_24N"},
+    {32225, "PCS_WGS72_UTM_zone_25N"},
+    {32226, "PCS_WGS72_UTM_zone_26N"},
+    {32227, "PCS_WGS72_UTM_zone_27N"},
+    {32228, "PCS_WGS72_UTM_zone_28N"},
+    {32229, "PCS_WGS72_UTM_zone_29N"},
+    {32230, "PCS_WGS72_UTM_zone_30N"},
+    {32231, "PCS_WGS72_UTM_zone_31N"},
+    {32232, "PCS_WGS72_UTM_zone_32N"},
+    {32233, "PCS_WGS72_UTM_zone_33N"},
+    {32234, "PCS_WGS72_UTM_zone_34N"},
+    {32235, "PCS_WGS72_UTM_zone_35N"},
+    {32236, "PCS_WGS72_UTM_zone_36N"},
+    {32237, "PCS_WGS72_UTM_zone_37N"},
+    {32238, "PCS_WGS72_UTM_zone_38N"},
+    {32239, "PCS_WGS72_UTM_zone_39N"},
+    {32240, "PCS_WGS72_UTM_zone_40N"},
+    {32241, "PCS_WGS72_UTM_zone_41N"},
+    {32242, "PCS_WGS72_UTM_zone_42N"},
+    {32243, "PCS_WGS72_UTM_zone_43N"},
+    {32244, "PCS_WGS72_UTM_zone_44N"},
+    {32245, "PCS_WGS72_UTM_zone_45N"},
+    {32246, "PCS_WGS72_UTM_zone_46N"},
+    {32247, "PCS_WGS72_UTM_zone_47N"},
+    {32248, "PCS_WGS72_UTM_zone_48N"},
+    {32249, "PCS_WGS72_UTM_zone_49N"},
+    {32250, "PCS_WGS72_UTM_zone_50N"},
+    {32251, "PCS_WGS72_UTM_zone_51N"},
+    {32252, "PCS_WGS72_UTM_zone_52N"},
+    {32253, "PCS_WGS72_UTM_zone_53N"},
+    {32254, "PCS_WGS72_UTM_zone_54N"},
+    {32255, "PCS_WGS72_UTM_zone_55N"},
+    {32256, "PCS_WGS72_UTM_zone_56N"},
+    {32257, "PCS_WGS72_UTM_zone_57N"},
+    {32258, "PCS_WGS72_UTM_zone_58N"},
+    {32259, "PCS_WGS72_UTM_zone_59N"},
+    {32260, "PCS_WGS72_UTM_zone_60N"},
+    {32301, "PCS_WGS72_UTM_zone_1S"},
+    {32302, "PCS_WGS72_UTM_zone_2S"},
+    {32303, "PCS_WGS72_UTM_zone_3S"},
+    {32304, "PCS_WGS72_UTM_zone_4S"},
+    {32305, "PCS_WGS72_UTM_zone_5S"},
+    {32306, "PCS_WGS72_UTM_zone_6S"},
+    {32307, "PCS_WGS72_UTM_zone_7S"},
+    {32308, "PCS_WGS72_UTM_zone_8S"},
+    {32309, "PCS_WGS72_UTM_zone_9S"},
+    {32310, "PCS_WGS72_UTM_zone_10S"},
+    {32311, "PCS_WGS72_UTM_zone_11S"},
+    {32312, "PCS_WGS72_UTM_zone_12S"},
+    {32313, "PCS_WGS72_UTM_zone_13S"},
+    {32314, "PCS_WGS72_UTM_zone_14S"},
+    {32315, "PCS_WGS72_UTM_zone_15S"},
+    {32316, "PCS_WGS72_UTM_zone_16S"},
+    {32317, "PCS_WGS72_UTM_zone_17S"},
+    {32318, "PCS_WGS72_UTM_zone_18S"},
+    {32319, "PCS_WGS72_UTM_zone_19S"},
+    {32320, "PCS_WGS72_UTM_zone_20S"},
+    {32321, "PCS_WGS72_UTM_zone_21S"},
+    {32322, "PCS_WGS72_UTM_zone_22S"},
+    {32323, "PCS_WGS72_UTM_zone_23S"},
+    {32324, "PCS_WGS72_UTM_zone_24S"},
+    {32325, "PCS_WGS72_UTM_zone_25S"},
+    {32326, "PCS_WGS72_UTM_zone_26S"},
+    {32327, "PCS_WGS72_UTM_zone_27S"},
+    {32328, "PCS_WGS72_UTM_zone_28S"},
+    {32329, "PCS_WGS72_UTM_zone_29S"},
+    {32330, "PCS_WGS72_UTM_zone_30S"},
+    {32331, "PCS_WGS72_UTM_zone_31S"},
+    {32332, "PCS_WGS72_UTM_zone_32S"},
+    {32333, "PCS_WGS72_UTM_zone_33S"},
+    {32334, "PCS_WGS72_UTM_zone_34S"},
+    {32335, "PCS_WGS72_UTM_zone_35S"},
+    {32336, "PCS_WGS72_UTM_zone_36S"},
+    {32337, "PCS_WGS72_UTM_zone_37S"},
+    {32338, "PCS_WGS72_UTM_zone_38S"},
+    {32339, "PCS_WGS72_UTM_zone_39S"},
+    {32340, "PCS_WGS72_UTM_zone_40S"},
+    {32341, "PCS_WGS72_UTM_zone_41S"},
+    {32342, "PCS_WGS72_UTM_zone_42S"},
+    {32343, "PCS_WGS72_UTM_zone_43S"},
+    {32344, "PCS_WGS72_UTM_zone_44S"},
+    {32345, "PCS_WGS72_UTM_zone_45S"},
+    {32346, "PCS_WGS72_UTM_zone_46S"},
+    {32347, "PCS_WGS72_UTM_zone_47S"},
+    {32348, "PCS_WGS72_UTM_zone_48S"},
+    {32349, "PCS_WGS72_UTM_zone_49S"},
+    {32350, "PCS_WGS72_UTM_zone_50S"},
+    {32351, "PCS_WGS72_UTM_zone_51S"},
+    {32352, "PCS_WGS72_UTM_zone_52S"},
+    {32353, "PCS_WGS72_UTM_zone_53S"},
+    {32354, "PCS_WGS72_UTM_zone_54S"},
+    {32355, "PCS_WGS72_UTM_zone_55S"},
+    {32356, "PCS_WGS72_UTM_zone_56S"},
+    {32357, "PCS_WGS72_UTM_zone_57S"},
+    {32358, "PCS_WGS72_UTM_zone_58S"},
+    {32359, "PCS_WGS72_UTM_zone_59S"},
+    {32360, "PCS_WGS72_UTM_zone_60S"},
+    {32401, "PCS_WGS72BE_UTM_zone_1N"},
+    {32402, "PCS_WGS72BE_UTM_zone_2N"},
+    {32403, "PCS_WGS72BE_UTM_zone_3N"},
+    {32404, "PCS_WGS72BE_UTM_zone_4N"},
+    {32405, "PCS_WGS72BE_UTM_zone_5N"},
+    {32406, "PCS_WGS72BE_UTM_zone_6N"},
+    {32407, "PCS_WGS72BE_UTM_zone_7N"},
+    {32408, "PCS_WGS72BE_UTM_zone_8N"},
+    {32409, "PCS_WGS72BE_UTM_zone_9N"},
+    {32410, "PCS_WGS72BE_UTM_zone_10N"},
+    {32411, "PCS_WGS72BE_UTM_zone_11N"},
+    {32412, "PCS_WGS72BE_UTM_zone_12N"},
+    {32413, "PCS_WGS72BE_UTM_zone_13N"},
+    {32414, "PCS_WGS72BE_UTM_zone_14N"},
+    {32415, "PCS_WGS72BE_UTM_zone_15N"},
+    {32416, "PCS_WGS72BE_UTM_zone_16N"},
+    {32417, "PCS_WGS72BE_UTM_zone_17N"},
+    {32418, "PCS_WGS72BE_UTM_zone_18N"},
+    {32419, "PCS_WGS72BE_UTM_zone_19N"},
+    {32420, "PCS_WGS72BE_UTM_zone_20N"},
+    {32421, "PCS_WGS72BE_UTM_zone_21N"},
+    {32422, "PCS_WGS72BE_UTM_zone_22N"},
+    {32423, "PCS_WGS72BE_UTM_zone_23N"},
+    {32424, "PCS_WGS72BE_UTM_zone_24N"},
+    {32425, "PCS_WGS72BE_UTM_zone_25N"},
+    {32426, "PCS_WGS72BE_UTM_zone_26N"},
+    {32427, "PCS_WGS72BE_UTM_zone_27N"},
+    {32428, "PCS_WGS72BE_UTM_zone_28N"},
+    {32429, "PCS_WGS72BE_UTM_zone_29N"},
+    {32430, "PCS_WGS72BE_UTM_zone_30N"},
+    {32431, "PCS_WGS72BE_UTM_zone_31N"},
+    {32432, "PCS_WGS72BE_UTM_zone_32N"},
+    {32433, "PCS_WGS72BE_UTM_zone_33N"},
+    {32434, "PCS_WGS72BE_UTM_zone_34N"},
+    {32435, "PCS_WGS72BE_UTM_zone_35N"},
+    {32436, "PCS_WGS72BE_UTM_zone_36N"},
+    {32437, "PCS_WGS72BE_UTM_zone_37N"},
+    {32438, "PCS_WGS72BE_UTM_zone_38N"},
+    {32439, "PCS_WGS72BE_UTM_zone_39N"},
+    {32440, "PCS_WGS72BE_UTM_zone_40N"},
+    {32441, "PCS_WGS72BE_UTM_zone_41N"},
+    {32442, "PCS_WGS72BE_UTM_zone_42N"},
+    {32443, "PCS_WGS72BE_UTM_zone_43N"},
+    {32444, "PCS_WGS72BE_UTM_zone_44N"},
+    {32445, "PCS_WGS72BE_UTM_zone_45N"},
+    {32446, "PCS_WGS72BE_UTM_zone_46N"},
+    {32447, "PCS_WGS72BE_UTM_zone_47N"},
+    {32448, "PCS_WGS72BE_UTM_zone_48N"},
+    {32449, "PCS_WGS72BE_UTM_zone_49N"},
+    {32450, "PCS_WGS72BE_UTM_zone_50N"},
+    {32451, "PCS_WGS72BE_UTM_zone_51N"},
+    {32452, "PCS_WGS72BE_UTM_zone_52N"},
+    {32453, "PCS_WGS72BE_UTM_zone_53N"},
+    {32454, "PCS_WGS72BE_UTM_zone_54N"},
+    {32455, "PCS_WGS72BE_UTM_zone_55N"},
+    {32456, "PCS_WGS72BE_UTM_zone_56N"},
+    {32457, "PCS_WGS72BE_UTM_zone_57N"},
+    {32458, "PCS_WGS72BE_UTM_zone_58N"},
+    {32459, "PCS_WGS72BE_UTM_zone_59N"},
+    {32460, "PCS_WGS72BE_UTM_zone_60N"},
+    {32501, "PCS_WGS72BE_UTM_zone_1S"},
+    {32502, "PCS_WGS72BE_UTM_zone_2S"},
+    {32503, "PCS_WGS72BE_UTM_zone_3S"},
+    {32504, "PCS_WGS72BE_UTM_zone_4S"},
+    {32505, "PCS_WGS72BE_UTM_zone_5S"},
+    {32506, "PCS_WGS72BE_UTM_zone_6S"},
+    {32507, "PCS_WGS72BE_UTM_zone_7S"},
+    {32508, "PCS_WGS72BE_UTM_zone_8S"},
+    {32509, "PCS_WGS72BE_UTM_zone_9S"},
+    {32510, "PCS_WGS72BE_UTM_zone_10S"},
+    {32511, "PCS_WGS72BE_UTM_zone_11S"},
+    {32512, "PCS_WGS72BE_UTM_zone_12S"},
+    {32513, "PCS_WGS72BE_UTM_zone_13S"},
+    {32514, "PCS_WGS72BE_UTM_zone_14S"},
+    {32515, "PCS_WGS72BE_UTM_zone_15S"},
+    {32516, "PCS_WGS72BE_UTM_zone_16S"},
+    {32517, "PCS_WGS72BE_UTM_zone_17S"},
+    {32518, "PCS_WGS72BE_UTM_zone_18S"},
+    {32519, "PCS_WGS72BE_UTM_zone_19S"},
+    {32520, "PCS_WGS72BE_UTM_zone_20S"},
+    {32521, "PCS_WGS72BE_UTM_zone_21S"},
+    {32522, "PCS_WGS72BE_UTM_zone_22S"},
+    {32523, "PCS_WGS72BE_UTM_zone_23S"},
+    {32524, "PCS_WGS72BE_UTM_zone_24S"},
+    {32525, "PCS_WGS72BE_UTM_zone_25S"},
+    {32526, "PCS_WGS72BE_UTM_zone_26S"},
+    {32527, "PCS_WGS72BE_UTM_zone_27S"},
+    {32528, "PCS_WGS72BE_UTM_zone_28S"},
+    {32529, "PCS_WGS72BE_UTM_zone_29S"},
+    {32530, "PCS_WGS72BE_UTM_zone_30S"},
+    {32531, "PCS_WGS72BE_UTM_zone_31S"},
+    {32532, "PCS_WGS72BE_UTM_zone_32S"},
+    {32533, "PCS_WGS72BE_UTM_zone_33S"},
+    {32534, "PCS_WGS72BE_UTM_zone_34S"},
+    {32535, "PCS_WGS72BE_UTM_zone_35S"},
+    {32536, "PCS_WGS72BE_UTM_zone_36S"},
+    {32537, "PCS_WGS72BE_UTM_zone_37S"},
+    {32538, "PCS_WGS72BE_UTM_zone_38S"},
+    {32539, "PCS_WGS72BE_UTM_zone_39S"},
+    {32540, "PCS_WGS72BE_UTM_zone_40S"},
+    {32541, "PCS_WGS72BE_UTM_zone_41S"},
+    {32542, "PCS_WGS72BE_UTM_zone_42S"},
+    {32543, "PCS_WGS72BE_UTM_zone_43S"},
+    {32544, "PCS_WGS72BE_UTM_zone_44S"},
+    {32545, "PCS_WGS72BE_UTM_zone_45S"},
+    {32546, "PCS_WGS72BE_UTM_zone_46S"},
+    {32547, "PCS_WGS72BE_UTM_zone_47S"},
+    {32548, "PCS_WGS72BE_UTM_zone_48S"},
+    {32549, "PCS_WGS72BE_UTM_zone_49S"},
+    {32550, "PCS_WGS72BE_UTM_zone_50S"},
+    {32551, "PCS_WGS72BE_UTM_zone_51S"},
+    {32552, "PCS_WGS72BE_UTM_zone_52S"},
+    {32553, "PCS_WGS72BE_UTM_zone_53S"},
+    {32554, "PCS_WGS72BE_UTM_zone_54S"},
+    {32555, "PCS_WGS72BE_UTM_zone_55S"},
+    {32556, "PCS_WGS72BE_UTM_zone_56S"},
+    {32557, "PCS_WGS72BE_UTM_zone_57S"},
+    {32558, "PCS_WGS72BE_UTM_zone_58S"},
+    {32559, "PCS_WGS72BE_UTM_zone_59S"},
+    {32560, "PCS_WGS72BE_UTM_zone_60S"},
+    {32601, "PCS_WGS84_UTM_zone_1N"},
+    {32602, "PCS_WGS84_UTM_zone_2N"},
+    {32603, "PCS_WGS84_UTM_zone_3N"},
+    {32604, "PCS_WGS84_UTM_zone_4N"},
+    {32605, "PCS_WGS84_UTM_zone_5N"},
+    {32606, "PCS_WGS84_UTM_zone_6N"},
+    {32607, "PCS_WGS84_UTM_zone_7N"},
+    {32608, "PCS_WGS84_UTM_zone_8N"},
+    {32609, "PCS_WGS84_UTM_zone_9N"},
+    {32610, "PCS_WGS84_UTM_zone_10N"},
+    {32611, "PCS_WGS84_UTM_zone_11N"},
+    {32612, "PCS_WGS84_UTM_zone_12N"},
+    {32613, "PCS_WGS84_UTM_zone_13N"},
+    {32614, "PCS_WGS84_UTM_zone_14N"},
+    {32615, "PCS_WGS84_UTM_zone_15N"},
+    {32616, "PCS_WGS84_UTM_zone_16N"},
+    {32617, "PCS_WGS84_UTM_zone_17N"},
+    {32618, "PCS_WGS84_UTM_zone_18N"},
+    {32619, "PCS_WGS84_UTM_zone_19N"},
+    {32620, "PCS_WGS84_UTM_zone_20N"},
+    {32621, "PCS_WGS84_UTM_zone_21N"},
+    {32622, "PCS_WGS84_UTM_zone_22N"},
+    {32623, "PCS_WGS84_UTM_zone_23N"},
+    {32624, "PCS_WGS84_UTM_zone_24N"},
+    {32625, "PCS_WGS84_UTM_zone_25N"},
+    {32626, "PCS_WGS84_UTM_zone_26N"},
+    {32627, "PCS_WGS84_UTM_zone_27N"},
+    {32628, "PCS_WGS84_UTM_zone_28N"},
+    {32629, "PCS_WGS84_UTM_zone_29N"},
+    {32630, "PCS_WGS84_UTM_zone_30N"},
+    {32631, "PCS_WGS84_UTM_zone_31N"},
+    {32632, "PCS_WGS84_UTM_zone_32N"},
+    {32633, "PCS_WGS84_UTM_zone_33N"},
+    {32634, "PCS_WGS84_UTM_zone_34N"},
+    {32635, "PCS_WGS84_UTM_zone_35N"},
+    {32636, "PCS_WGS84_UTM_zone_36N"},
+    {32637, "PCS_WGS84_UTM_zone_37N"},
+    {32638, "PCS_WGS84_UTM_zone_38N"},
+    {32639, "PCS_WGS84_UTM_zone_39N"},
+    {32640, "PCS_WGS84_UTM_zone_40N"},
+    {32641, "PCS_WGS84_UTM_zone_41N"},
+    {32642, "PCS_WGS84_UTM_zone_42N"},
+    {32643, "PCS_WGS84_UTM_zone_43N"},
+    {32644, "PCS_WGS84_UTM_zone_44N"},
+    {32645, "PCS_WGS84_UTM_zone_45N"},
+    {32646, "PCS_WGS84_UTM_zone_46N"},
+    {32647, "PCS_WGS84_UTM_zone_47N"},
+    {32648, "PCS_WGS84_UTM_zone_48N"},
+    {32649, "PCS_WGS84_UTM_zone_49N"},
+    {32650, "PCS_WGS84_UTM_zone_50N"},
+    {32651, "PCS_WGS84_UTM_zone_51N"},
+    {32652, "PCS_WGS84_UTM_zone_52N"},
+    {32653, "PCS_WGS84_UTM_zone_53N"},
+    {32654, "PCS_WGS84_UTM_zone_54N"},
+    {32655, "PCS_WGS84_UTM_zone_55N"},
+    {32656, "PCS_WGS84_UTM_zone_56N"},
+    {32657, "PCS_WGS84_UTM_zone_57N"},
+    {32658, "PCS_WGS84_UTM_zone_58N"},
+    {32659, "PCS_WGS84_UTM_zone_59N"},
+    {32660, "PCS_WGS84_UTM_zone_60N"},
+    {32701, "PCS_WGS84_UTM_zone_1S"},
+    {32702, "PCS_WGS84_UTM_zone_2S"},
+    {32703, "PCS_WGS84_UTM_zone_3S"},
+    {32704, "PCS_WGS84_UTM_zone_4S"},
+    {32705, "PCS_WGS84_UTM_zone_5S"},
+    {32706, "PCS_WGS84_UTM_zone_6S"},
+    {32707, "PCS_WGS84_UTM_zone_7S"},
+    {32708, "PCS_WGS84_UTM_zone_8S"},
+    {32709, "PCS_WGS84_UTM_zone_9S"},
+    {32710, "PCS_WGS84_UTM_zone_10S"},
+    {32711, "PCS_WGS84_UTM_zone_11S"},
+    {32712, "PCS_WGS84_UTM_zone_12S"},
+    {32713, "PCS_WGS84_UTM_zone_13S"},
+    {32714, "PCS_WGS84_UTM_zone_14S"},
+    {32715, "PCS_WGS84_UTM_zone_15S"},
+    {32716, "PCS_WGS84_UTM_zone_16S"},
+    {32717, "PCS_WGS84_UTM_zone_17S"},
+    {32718, "PCS_WGS84_UTM_zone_18S"},
+    {32719, "PCS_WGS84_UTM_zone_19S"},
+    {32720, "PCS_WGS84_UTM_zone_20S"},
+    {32721, "PCS_WGS84_UTM_zone_21S"},
+    {32722, "PCS_WGS84_UTM_zone_22S"},
+    {32723, "PCS_WGS84_UTM_zone_23S"},
+    {32724, "PCS_WGS84_UTM_zone_24S"},
+    {32725, "PCS_WGS84_UTM_zone_25S"},
+    {32726, "PCS_WGS84_UTM_zone_26S"},
+    {32727, "PCS_WGS84_UTM_zone_27S"},
+    {32728, "PCS_WGS84_UTM_zone_28S"},
+    {32729, "PCS_WGS84_UTM_zone_29S"},
+    {32730, "PCS_WGS84_UTM_zone_30S"},
+    {32731, "PCS_WGS84_UTM_zone_31S"},
+    {32732, "PCS_WGS84_UTM_zone_32S"},
+    {32733, "PCS_WGS84_UTM_zone_33S"},
+    {32734, "PCS_WGS84_UTM_zone_34S"},
+    {32735, "PCS_WGS84_UTM_zone_35S"},
+    {32736, "PCS_WGS84_UTM_zone_36S"},
+    {32737, "PCS_WGS84_UTM_zone_37S"},
+    {32738, "PCS_WGS84_UTM_zone_38S"},
+    {32739, "PCS_WGS84_UTM_zone_39S"},
+    {32740, "PCS_WGS84_UTM_zone_40S"},
+    {32741, "PCS_WGS84_UTM_zone_41S"},
+    {32742, "PCS_WGS84_UTM_zone_42S"},
+    {32743, "PCS_WGS84_UTM_zone_43S"},
+    {32744, "PCS_WGS84_UTM_zone_44S"},
+    {32745, "PCS_WGS84_UTM_zone_45S"},
+    {32746, "PCS_WGS84_UTM_zone_46S"},
+    {32747, "PCS_WGS84_UTM_zone_47S"},
+    {32748, "PCS_WGS84_UTM_zone_48S"},
+    {32749, "PCS_WGS84_UTM_zone_49S"},
+    {32750, "PCS_WGS84_UTM_zone_50S"},
+    {32751, "PCS_WGS84_UTM_zone_51S"},
+    {32752, "PCS_WGS84_UTM_zone_52S"},
+    {32753, "PCS_WGS84_UTM_zone_53S"},
+    {32754, "PCS_WGS84_UTM_zone_54S"},
+    {32755, "PCS_WGS84_UTM_zone_55S"},
+    {32756, "PCS_WGS84_UTM_zone_56S"},
+    {32757, "PCS_WGS84_UTM_zone_57S"},
+    {32758, "PCS_WGS84_UTM_zone_58S"},
+    {32759, "PCS_WGS84_UTM_zone_59S"},
+    {32760, "PCS_WGS84_UTM_zone_60S"}
+};
+
+const TiffGeoTagKeyName ff_tiff_projection_codes[] = {
+    {10101, "Proj_Alabama_CS27_East"},
+    {10102, "Proj_Alabama_CS27_West"},
+    {10131, "Proj_Alabama_CS83_East"},
+    {10132, "Proj_Alabama_CS83_West"},
+    {10201, "Proj_Arizona_Coordinate_System_east"},
+    {10202, "Proj_Arizona_Coordinate_System_Central"},
+    {10203, "Proj_Arizona_Coordinate_System_west"},
+    {10231, "Proj_Arizona_CS83_east"},
+    {10232, "Proj_Arizona_CS83_Central"},
+    {10233, "Proj_Arizona_CS83_west"},
+    {10301, "Proj_Arkansas_CS27_North"},
+    {10302, "Proj_Arkansas_CS27_South"},
+    {10331, "Proj_Arkansas_CS83_North"},
+    {10332, "Proj_Arkansas_CS83_South"},
+    {10401, "Proj_California_CS27_I"},
+    {10402, "Proj_California_CS27_II"},
+    {10403, "Proj_California_CS27_III"},
+    {10404, "Proj_California_CS27_IV"},
+    {10405, "Proj_California_CS27_V"},
+    {10406, "Proj_California_CS27_VI"},
+    {10407, "Proj_California_CS27_VII"},
+    {10431, "Proj_California_CS83_1"},
+    {10432, "Proj_California_CS83_2"},
+    {10433, "Proj_California_CS83_3"},
+    {10434, "Proj_California_CS83_4"},
+    {10435, "Proj_California_CS83_5"},
+    {10436, "Proj_California_CS83_6"},
+    {10501, "Proj_Colorado_CS27_North"},
+    {10502, "Proj_Colorado_CS27_Central"},
+    {10503, "Proj_Colorado_CS27_South"},
+    {10531, "Proj_Colorado_CS83_North"},
+    {10532, "Proj_Colorado_CS83_Central"},
+    {10533, "Proj_Colorado_CS83_South"},
+    {10600, "Proj_Connecticut_CS27"},
+    {10630, "Proj_Connecticut_CS83"},
+    {10700, "Proj_Delaware_CS27"},
+    {10730, "Proj_Delaware_CS83"},
+    {10901, "Proj_Florida_CS27_East"},
+    {10902, "Proj_Florida_CS27_West"},
+    {10903, "Proj_Florida_CS27_North"},
+    {10931, "Proj_Florida_CS83_East"},
+    {10932, "Proj_Florida_CS83_West"},
+    {10933, "Proj_Florida_CS83_North"},
+    {11001, "Proj_Georgia_CS27_East"},
+    {11002, "Proj_Georgia_CS27_West"},
+    {11031, "Proj_Georgia_CS83_East"},
+    {11032, "Proj_Georgia_CS83_West"},
+    {11101, "Proj_Idaho_CS27_East"},
+    {11102, "Proj_Idaho_CS27_Central"},
+    {11103, "Proj_Idaho_CS27_West"},
+    {11131, "Proj_Idaho_CS83_East"},
+    {11132, "Proj_Idaho_CS83_Central"},
+    {11133, "Proj_Idaho_CS83_West"},
+    {11201, "Proj_Illinois_CS27_East"},
+    {11202, "Proj_Illinois_CS27_West"},
+    {11231, "Proj_Illinois_CS83_East"},
+    {11232, "Proj_Illinois_CS83_West"},
+    {11301, "Proj_Indiana_CS27_East"},
+    {11302, "Proj_Indiana_CS27_West"},
+    {11331, "Proj_Indiana_CS83_East"},
+    {11332, "Proj_Indiana_CS83_West"},
+    {11401, "Proj_Iowa_CS27_North"},
+    {11402, "Proj_Iowa_CS27_South"},
+    {11431, "Proj_Iowa_CS83_North"},
+    {11432, "Proj_Iowa_CS83_South"},
+    {11501, "Proj_Kansas_CS27_North"},
+    {11502, "Proj_Kansas_CS27_South"},
+    {11531, "Proj_Kansas_CS83_North"},
+    {11532, "Proj_Kansas_CS83_South"},
+    {11601, "Proj_Kentucky_CS27_North"},
+    {11602, "Proj_Kentucky_CS27_South"},
+    {11631, "Proj_Kentucky_CS83_North"},
+    {11632, "Proj_Kentucky_CS83_South"},
+    {11701, "Proj_Louisiana_CS27_North"},
+    {11702, "Proj_Louisiana_CS27_South"},
+    {11731, "Proj_Louisiana_CS83_North"},
+    {11732, "Proj_Louisiana_CS83_South"},
+    {11801, "Proj_Maine_CS27_East"},
+    {11802, "Proj_Maine_CS27_West"},
+    {11831, "Proj_Maine_CS83_East"},
+    {11832, "Proj_Maine_CS83_West"},
+    {11900, "Proj_Maryland_CS27"},
+    {11930, "Proj_Maryland_CS83"},
+    {12001, "Proj_Massachusetts_CS27_Mainland"},
+    {12002, "Proj_Massachusetts_CS27_Island"},
+    {12031, "Proj_Massachusetts_CS83_Mainland"},
+    {12032, "Proj_Massachusetts_CS83_Island"},
+    {12101, "Proj_Michigan_State_Plane_East"},
+    {12102, "Proj_Michigan_State_Plane_Old_Central"},
+    {12103, "Proj_Michigan_State_Plane_West"},
+    {12111, "Proj_Michigan_CS27_North"},
+    {12112, "Proj_Michigan_CS27_Central"},
+    {12113, "Proj_Michigan_CS27_South"},
+    {12141, "Proj_Michigan_CS83_North"},
+    {12142, "Proj_Michigan_CS83_Central"},
+    {12143, "Proj_Michigan_CS83_South"},
+    {12201, "Proj_Minnesota_CS27_North"},
+    {12202, "Proj_Minnesota_CS27_Central"},
+    {12203, "Proj_Minnesota_CS27_South"},
+    {12231, "Proj_Minnesota_CS83_North"},
+    {12232, "Proj_Minnesota_CS83_Central"},
+    {12233, "Proj_Minnesota_CS83_South"},
+    {12301, "Proj_Mississippi_CS27_East"},
+    {12302, "Proj_Mississippi_CS27_West"},
+    {12331, "Proj_Mississippi_CS83_East"},
+    {12332, "Proj_Mississippi_CS83_West"},
+    {12401, "Proj_Missouri_CS27_East"},
+    {12402, "Proj_Missouri_CS27_Central"},
+    {12403, "Proj_Missouri_CS27_West"},
+    {12431, "Proj_Missouri_CS83_East"},
+    {12432, "Proj_Missouri_CS83_Central"},
+    {12433, "Proj_Missouri_CS83_West"},
+    {12501, "Proj_Montana_CS27_North"},
+    {12502, "Proj_Montana_CS27_Central"},
+    {12503, "Proj_Montana_CS27_South"},
+    {12530, "Proj_Montana_CS83"},
+    {12601, "Proj_Nebraska_CS27_North"},
+    {12602, "Proj_Nebraska_CS27_South"},
+    {12630, "Proj_Nebraska_CS83"},
+    {12701, "Proj_Nevada_CS27_East"},
+    {12702, "Proj_Nevada_CS27_Central"},
+    {12703, "Proj_Nevada_CS27_West"},
+    {12731, "Proj_Nevada_CS83_East"},
+    {12732, "Proj_Nevada_CS83_Central"},
+    {12733, "Proj_Nevada_CS83_West"},
+    {12800, "Proj_New_Hampshire_CS27"},
+    {12830, "Proj_New_Hampshire_CS83"},
+    {12900, "Proj_New_Jersey_CS27"},
+    {12930, "Proj_New_Jersey_CS83"},
+    {13001, "Proj_New_Mexico_CS27_East"},
+    {13002, "Proj_New_Mexico_CS27_Central"},
+    {13003, "Proj_New_Mexico_CS27_West"},
+    {13031, "Proj_New_Mexico_CS83_East"},
+    {13032, "Proj_New_Mexico_CS83_Central"},
+    {13033, "Proj_New_Mexico_CS83_West"},
+    {13101, "Proj_New_York_CS27_East"},
+    {13102, "Proj_New_York_CS27_Central"},
+    {13103, "Proj_New_York_CS27_West"},
+    {13104, "Proj_New_York_CS27_Long_Island"},
+    {13131, "Proj_New_York_CS83_East"},
+    {13132, "Proj_New_York_CS83_Central"},
+    {13133, "Proj_New_York_CS83_West"},
+    {13134, "Proj_New_York_CS83_Long_Island"},
+    {13200, "Proj_North_Carolina_CS27"},
+    {13230, "Proj_North_Carolina_CS83"},
+    {13301, "Proj_North_Dakota_CS27_North"},
+    {13302, "Proj_North_Dakota_CS27_South"},
+    {13331, "Proj_North_Dakota_CS83_North"},
+    {13332, "Proj_North_Dakota_CS83_South"},
+    {13401, "Proj_Ohio_CS27_North"},
+    {13402, "Proj_Ohio_CS27_South"},
+    {13431, "Proj_Ohio_CS83_North"},
+    {13432, "Proj_Ohio_CS83_South"},
+    {13501, "Proj_Oklahoma_CS27_North"},
+    {13502, "Proj_Oklahoma_CS27_South"},
+    {13531, "Proj_Oklahoma_CS83_North"},
+    {13532, "Proj_Oklahoma_CS83_South"},
+    {13601, "Proj_Oregon_CS27_North"},
+    {13602, "Proj_Oregon_CS27_South"},
+    {13631, "Proj_Oregon_CS83_North"},
+    {13632, "Proj_Oregon_CS83_South"},
+    {13701, "Proj_Pennsylvania_CS27_North"},
+    {13702, "Proj_Pennsylvania_CS27_South"},
+    {13731, "Proj_Pennsylvania_CS83_North"},
+    {13732, "Proj_Pennsylvania_CS83_South"},
+    {13800, "Proj_Rhode_Island_CS27"},
+    {13830, "Proj_Rhode_Island_CS83"},
+    {13901, "Proj_South_Carolina_CS27_North"},
+    {13902, "Proj_South_Carolina_CS27_South"},
+    {13930, "Proj_South_Carolina_CS83"},
+    {14001, "Proj_South_Dakota_CS27_North"},
+    {14002, "Proj_South_Dakota_CS27_South"},
+    {14031, "Proj_South_Dakota_CS83_North"},
+    {14032, "Proj_South_Dakota_CS83_South"},
+    {14100, "Proj_Tennessee_CS27"},
+    {14130, "Proj_Tennessee_CS83"},
+    {14201, "Proj_Texas_CS27_North"},
+    {14202, "Proj_Texas_CS27_North_Central"},
+    {14203, "Proj_Texas_CS27_Central"},
+    {14204, "Proj_Texas_CS27_South_Central"},
+    {14205, "Proj_Texas_CS27_South"},
+    {14231, "Proj_Texas_CS83_North"},
+    {14232, "Proj_Texas_CS83_North_Central"},
+    {14233, "Proj_Texas_CS83_Central"},
+    {14234, "Proj_Texas_CS83_South_Central"},
+    {14235, "Proj_Texas_CS83_South"},
+    {14301, "Proj_Utah_CS27_North"},
+    {14302, "Proj_Utah_CS27_Central"},
+    {14303, "Proj_Utah_CS27_South"},
+    {14331, "Proj_Utah_CS83_North"},
+    {14332, "Proj_Utah_CS83_Central"},
+    {14333, "Proj_Utah_CS83_South"},
+    {14400, "Proj_Vermont_CS27"},
+    {14430, "Proj_Vermont_CS83"},
+    {14501, "Proj_Virginia_CS27_North"},
+    {14502, "Proj_Virginia_CS27_South"},
+    {14531, "Proj_Virginia_CS83_North"},
+    {14532, "Proj_Virginia_CS83_South"},
+    {14601, "Proj_Washington_CS27_North"},
+    {14602, "Proj_Washington_CS27_South"},
+    {14631, "Proj_Washington_CS83_North"},
+    {14632, "Proj_Washington_CS83_South"},
+    {14701, "Proj_West_Virginia_CS27_North"},
+    {14702, "Proj_West_Virginia_CS27_South"},
+    {14731, "Proj_West_Virginia_CS83_North"},
+    {14732, "Proj_West_Virginia_CS83_South"},
+    {14801, "Proj_Wisconsin_CS27_North"},
+    {14802, "Proj_Wisconsin_CS27_Central"},
+    {14803, "Proj_Wisconsin_CS27_South"},
+    {14831, "Proj_Wisconsin_CS83_North"},
+    {14832, "Proj_Wisconsin_CS83_Central"},
+    {14833, "Proj_Wisconsin_CS83_South"},
+    {14901, "Proj_Wyoming_CS27_East"},
+    {14902, "Proj_Wyoming_CS27_East_Central"},
+    {14903, "Proj_Wyoming_CS27_West_Central"},
+    {14904, "Proj_Wyoming_CS27_West"},
+    {14931, "Proj_Wyoming_CS83_East"},
+    {14932, "Proj_Wyoming_CS83_East_Central"},
+    {14933, "Proj_Wyoming_CS83_West_Central"},
+    {14934, "Proj_Wyoming_CS83_West"},
+    {15001, "Proj_Alaska_CS27_1"},
+    {15002, "Proj_Alaska_CS27_2"},
+    {15003, "Proj_Alaska_CS27_3"},
+    {15004, "Proj_Alaska_CS27_4"},
+    {15005, "Proj_Alaska_CS27_5"},
+    {15006, "Proj_Alaska_CS27_6"},
+    {15007, "Proj_Alaska_CS27_7"},
+    {15008, "Proj_Alaska_CS27_8"},
+    {15009, "Proj_Alaska_CS27_9"},
+    {15010, "Proj_Alaska_CS27_10"},
+    {15031, "Proj_Alaska_CS83_1"},
+    {15032, "Proj_Alaska_CS83_2"},
+    {15033, "Proj_Alaska_CS83_3"},
+    {15034, "Proj_Alaska_CS83_4"},
+    {15035, "Proj_Alaska_CS83_5"},
+    {15036, "Proj_Alaska_CS83_6"},
+    {15037, "Proj_Alaska_CS83_7"},
+    {15038, "Proj_Alaska_CS83_8"},
+    {15039, "Proj_Alaska_CS83_9"},
+    {15040, "Proj_Alaska_CS83_10"},
+    {15101, "Proj_Hawaii_CS27_1"},
+    {15102, "Proj_Hawaii_CS27_2"},
+    {15103, "Proj_Hawaii_CS27_3"},
+    {15104, "Proj_Hawaii_CS27_4"},
+    {15105, "Proj_Hawaii_CS27_5"},
+    {15131, "Proj_Hawaii_CS83_1"},
+    {15132, "Proj_Hawaii_CS83_2"},
+    {15133, "Proj_Hawaii_CS83_3"},
+    {15134, "Proj_Hawaii_CS83_4"},
+    {15135, "Proj_Hawaii_CS83_5"},
+    {15201, "Proj_Puerto_Rico_CS27"},
+    {15202, "Proj_St_Croix"},
+    {15230, "Proj_Puerto_Rico_Virgin_Is"},
+    {15914, "Proj_BLM_14N_feet"},
+    {15915, "Proj_BLM_15N_feet"},
+    {15916, "Proj_BLM_16N_feet"},
+    {15917, "Proj_BLM_17N_feet"},
+    {17348, "Proj_Map_Grid_of_Australia_48"},
+    {17349, "Proj_Map_Grid_of_Australia_49"},
+    {17350, "Proj_Map_Grid_of_Australia_50"},
+    {17351, "Proj_Map_Grid_of_Australia_51"},
+    {17352, "Proj_Map_Grid_of_Australia_52"},
+    {17353, "Proj_Map_Grid_of_Australia_53"},
+    {17354, "Proj_Map_Grid_of_Australia_54"},
+    {17355, "Proj_Map_Grid_of_Australia_55"},
+    {17356, "Proj_Map_Grid_of_Australia_56"},
+    {17357, "Proj_Map_Grid_of_Australia_57"},
+    {17358, "Proj_Map_Grid_of_Australia_58"},
+    {17448, "Proj_Australian_Map_Grid_48"},
+    {17449, "Proj_Australian_Map_Grid_49"},
+    {17450, "Proj_Australian_Map_Grid_50"},
+    {17451, "Proj_Australian_Map_Grid_51"},
+    {17452, "Proj_Australian_Map_Grid_52"},
+    {17453, "Proj_Australian_Map_Grid_53"},
+    {17454, "Proj_Australian_Map_Grid_54"},
+    {17455, "Proj_Australian_Map_Grid_55"},
+    {17456, "Proj_Australian_Map_Grid_56"},
+    {17457, "Proj_Australian_Map_Grid_57"},
+    {17458, "Proj_Australian_Map_Grid_58"},
+    {18031, "Proj_Argentina_1"},
+    {18032, "Proj_Argentina_2"},
+    {18033, "Proj_Argentina_3"},
+    {18034, "Proj_Argentina_4"},
+    {18035, "Proj_Argentina_5"},
+    {18036, "Proj_Argentina_6"},
+    {18037, "Proj_Argentina_7"},
+    {18051, "Proj_Colombia_3W"},
+    {18052, "Proj_Colombia_Bogota"},
+    {18053, "Proj_Colombia_3E"},
+    {18054, "Proj_Colombia_6E"},
+    {18072, "Proj_Egypt_Red_Belt"},
+    {18073, "Proj_Egypt_Purple_Belt"},
+    {18074, "Proj_Extended_Purple_Belt"},
+    {18141, "Proj_New_Zealand_North_Island_Nat_Grid"},
+    {18142, "Proj_New_Zealand_South_Island_Nat_Grid"},
+    {19900, "Proj_Bahrain_Grid"},
+    {19905, "Proj_Netherlands_E_Indies_Equatorial"},
+    {19912, "Proj_RSO_Borneo"}
+};
+
+const char *const ff_tiff_coord_trans_codes[] = {
+    "CT_TransverseMercator",
+    "CT_TransvMercator_Modified_Alaska",
+    "CT_ObliqueMercator",
+    "CT_ObliqueMercator_Laborde",
+    "CT_ObliqueMercator_Rosenmund",
+    "CT_ObliqueMercator_Spherical",
+    "CT_Mercator",
+    "CT_LambertConfConic_2SP",
+    "CT_LambertConfConic_Helmert",
+    "CT_LambertAzimEqualArea",
+    "CT_AlbersEqualArea",
+    "CT_AzimuthalEquidistant",
+    "CT_EquidistantConic",
+    "CT_Stereographic",
+    "CT_PolarStereographic",
+    "CT_ObliqueStereographic",
+    "CT_Equirectangular",
+    "CT_CassiniSoldner",
+    "CT_Gnomonic",
+    "CT_MillerCylindrical",
+    "CT_Orthographic",
+    "CT_Polyconic",
+    "CT_Robinson",
+    "CT_Sinusoidal",
+    "CT_VanDerGrinten",
+    "CT_NewZealandMapGrid",
+    "CT_TransvMercator_SouthOriented"
+};
+
+const char *const ff_tiff_vert_cs_codes[] = {
+    "VertCS_Airy_1830_ellipsoid",
+    "VertCS_Airy_Modified_1849_ellipsoid",
+    "VertCS_ANS_ellipsoid",
+    "VertCS_Bessel_1841_ellipsoid",
+    "VertCS_Bessel_Modified_ellipsoid",
+    "VertCS_Bessel_Namibia_ellipsoid",
+    "VertCS_Clarke_1858_ellipsoid",
+    "VertCS_Clarke_1866_ellipsoid",
+    "VertCS_Clarke_1880_Benoit_ellipsoid",
+    "VertCS_Clarke_1880_IGN_ellipsoid",
+    "VertCS_Clarke_1880_RGS_ellipsoid",
+    "VertCS_Clarke_1880_Arc_ellipsoid",
+    "VertCS_Clarke_1880_SGA_1922_ellipsoid",
+    "VertCS_Everest_1830_1937_Adjustment_ellipsoid",
+    "VertCS_Everest_1830_1967_Definition_ellipsoid",
+    "VertCS_Everest_1830_1975_Definition_ellipsoid",
+    "VertCS_Everest_1830_Modified_ellipsoid",
+    "VertCS_GRS_1980_ellipsoid",
+    "VertCS_Helmert_1906_ellipsoid",
+    "VertCS_INS_ellipsoid",
+    "VertCS_International_1924_ellipsoid",
+    "VertCS_International_1967_ellipsoid",
+    "VertCS_Krassowsky_1940_ellipsoid",
+    "VertCS_NWL_9D_ellipsoid",
+    "VertCS_NWL_10D_ellipsoid",
+    "VertCS_Plessis_1817_ellipsoid",
+    "VertCS_Struve_1860_ellipsoid",
+    "VertCS_War_Office_ellipsoid",
+    "VertCS_WGS_84_ellipsoid",
+    "VertCS_GEM_10C_ellipsoid",
+    "VertCS_OSU86F_ellipsoid",
+    "VertCS_OSU91A_ellipsoid"
+};
+
+const char *const ff_tiff_ortho_vert_cs_codes[] = {
+    "VertCS_Newlyn",
+    "VertCS_North_American_Vertical_Datum_1929",
+    "VertCS_North_American_Vertical_Datum_1988",
+    "VertCS_Yellow_Sea_1956",
+    "VertCS_Baltic_Sea",
+    "VertCS_Caspian_Sea"
+};
diff --git a/libavcodec/tiff_data.h b/libavcodec/tiff_data.h
index 9b123ca..57515f9 100644
--- a/libavcodec/tiff_data.h
+++ b/libavcodec/tiff_data.h
@@ -33,1863 +33,60 @@
 #include "tiff.h"
 
 #define TIFF_CONF_KEY_ID_OFFSET 1024
-static const TiffGeoTagNameType tiff_conf_name_type_map[] = {
-    {"GTModelTypeGeoKey",              GEOTIFF_SHORT },
-    {"GTRasterTypeGeoKey",             GEOTIFF_SHORT },
-    {"GTCitationGeoKey",               GEOTIFF_STRING}
-};
+extern const TiffGeoTagNameType ff_tiff_conf_name_type_map[3];
 
 #define TIFF_GEOG_KEY_ID_OFFSET 2048
-static const TiffGeoTagNameType tiff_geog_name_type_map[] = {
-    {"GeographicTypeGeoKey",           GEOTIFF_SHORT },
-    {"GeogCitationGeoKey",             GEOTIFF_STRING},
-    {"GeogGeodeticDatumGeoKey",        GEOTIFF_SHORT },
-    {"GeogPrimeMeridianGeoKey",        GEOTIFF_SHORT },
-    {"GeogLinearUnitsGeoKey",          GEOTIFF_SHORT },
-    {"GeogLinearUnitSizeGeoKey",       GEOTIFF_DOUBLE},
-    {"GeogAngularUnitsGeoKey",         GEOTIFF_SHORT },
-    {"GeogAngularUnitSizeGeoKey",      GEOTIFF_DOUBLE},
-    {"GeogEllipsoidGeoKey",            GEOTIFF_SHORT },
-    {"GeogSemiMajorAxisGeoKey",        GEOTIFF_DOUBLE},
-    {"GeogSemiMinorAxisGeoKey",        GEOTIFF_DOUBLE},
-    {"GeogInvFlatteningGeoKey",        GEOTIFF_DOUBLE},
-    {"GeogAzimuthUnitsGeoKey",         GEOTIFF_SHORT },
-    {"GeogPrimeMeridianLongGeoKey",    GEOTIFF_DOUBLE}
-};
+extern const TiffGeoTagNameType ff_tiff_geog_name_type_map[14];
 
 #define TIFF_PROJ_KEY_ID_OFFSET 3072
-static const TiffGeoTagNameType tiff_proj_name_type_map[] = {
-    {"ProjectedCSTypeGeoKey",          GEOTIFF_SHORT },
-    {"PCSCitationGeoKey",              GEOTIFF_STRING},
-    {"ProjectionGeoKey",               GEOTIFF_SHORT },
-    {"ProjCoordTransGeoKey",           GEOTIFF_SHORT },
-    {"ProjLinearUnitsGeoKey",          GEOTIFF_SHORT },
-    {"ProjLinearUnitSizeGeoKey",       GEOTIFF_DOUBLE},
-    {"ProjStdParallel1GeoKey",         GEOTIFF_DOUBLE},
-    {"ProjStdParallel2GeoKey",         GEOTIFF_DOUBLE},
-    {"ProjNatOriginLongGeoKey",        GEOTIFF_DOUBLE},
-    {"ProjNatOriginLatGeoKey",         GEOTIFF_DOUBLE},
-    {"ProjFalseEastingGeoKey",         GEOTIFF_DOUBLE},
-    {"ProjFalseNorthingGeoKey",        GEOTIFF_DOUBLE},
-    {"ProjFalseOriginLongGeoKey",      GEOTIFF_DOUBLE},
-    {"ProjFalseOriginLatGeoKey",       GEOTIFF_DOUBLE},
-    {"ProjFalseOriginEastingGeoKey",   GEOTIFF_DOUBLE},
-    {"ProjFalseOriginNorthingGeoKey",  GEOTIFF_DOUBLE},
-    {"ProjCenterLongGeoKey",           GEOTIFF_DOUBLE},
-    {"ProjCenterLatGeoKey",            GEOTIFF_DOUBLE},
-    {"ProjCenterEastingGeoKey",        GEOTIFF_DOUBLE},
-    {"ProjCenterNorthingGeoKey",       GEOTIFF_DOUBLE},
-    {"ProjScaleAtNatOriginGeoKey",     GEOTIFF_DOUBLE},
-    {"ProjScaleAtCenterGeoKey",        GEOTIFF_DOUBLE},
-    {"ProjAzimuthAngleGeoKey",         GEOTIFF_DOUBLE},
-    {"ProjStraightVertPoleLongGeoKey", GEOTIFF_DOUBLE}
-};
+extern const TiffGeoTagNameType ff_tiff_proj_name_type_map[24];
 
 #define TIFF_VERT_KEY_ID_OFFSET 4096
-static const TiffGeoTagNameType tiff_vert_name_type_map[] = {
-    {"VerticalCSTypeGeoKey",           GEOTIFF_SHORT },
-    {"VerticalCitationGeoKey",         GEOTIFF_STRING},
-    {"VerticalDatumGeoKey",            GEOTIFF_SHORT },
-    {"VerticalUnitsGeoKey",            GEOTIFF_SHORT }
-};
+extern const TiffGeoTagNameType ff_tiff_vert_name_type_map[4];
 
 #define TIFF_GEO_KEY_UNDEFINED    0
 #define TIFF_GEO_KEY_USER_DEFINED 32767
 
 #define TIFF_GT_MODEL_TYPE_OFFSET 1
-static const char *const tiff_gt_model_type_codes[] = {
-    "ModelTypeProjected",
-    "ModelTypeGeographic",
-    "ModelTypeGeocentric"
-};
+extern const char *const ff_tiff_gt_model_type_codes[3];
 
 #define TIFF_GT_RASTER_TYPE_OFFSET 1
-static const char *const tiff_gt_raster_type_codes[] = {
-    "RasterPixelIsArea",
-    "RasterPixelIsPoint"
-};
+extern const char *const ff_tiff_gt_raster_type_codes[2];
 
 #define TIFF_LINEAR_UNIT_OFFSET 9001
-static const char *const tiff_linear_unit_codes[] = {
-    "Linear_Meter",
-    "Linear_Foot",
-    "Linear_Foot_US_Survey",
-    "Linear_Foot_Modified_American",
-    "Linear_Foot_Clarke",
-    "Linear_Foot_Indian",
-    "Linear_Link",
-    "Linear_Link_Benoit",
-    "Linear_Link_Sears",
-    "Linear_Chain_Benoit",
-    "Linear_Chain_Sears",
-    "Linear_Yard_Sears",
-    "Linear_Yard_Indian",
-    "Linear_Fathom",
-    "Linear_Mile_International_Nautical"
-};
+extern const char *const ff_tiff_linear_unit_codes[15];
 
 #define TIFF_ANGULAR_UNIT_OFFSET 9101
-static const char *const tiff_angular_unit_codes[] = {
-    "Angular_Radian",
-    "Angular_Degree",
-    "Angular_Arc_Minute",
-    "Angular_Arc_Second",
-    "Angular_Grad",
-    "Angular_Gon",
-    "Angular_DMS",
-    "Angular_DMS_Hemisphere"
-};
+extern const char *const ff_tiff_angular_unit_codes[8];
 
 #define TIFF_GCS_TYPE_OFFSET 4201
-static const char *const tiff_gcs_type_codes[] = {
-    "GCS_Adindan",
-    "GCS_AGD66",
-    "GCS_AGD84",
-    "GCS_Ain_el_Abd",
-    "GCS_Afgooye",
-    "GCS_Agadez",
-    "GCS_Lisbon",
-    "GCS_Aratu",
-    "GCS_Arc_1950",
-    "GCS_Arc_1960",
-    "GCS_Batavia",
-    "GCS_Barbados",
-    "GCS_Beduaram",
-    "GCS_Beijing_1954",
-    "GCS_Belge_1950",
-    "GCS_Bermuda_1957",
-    "GCS_Bern_1898",
-    "GCS_Bogota",
-    "GCS_Bukit_Rimpah",
-    "GCS_Camacupa",
-    "GCS_Campo_Inchauspe",
-    "GCS_Cape",
-    "GCS_Carthage",
-    "GCS_Chua",
-    "GCS_Corrego_Alegre",
-    "GCS_Cote_d_Ivoire",
-    "GCS_Deir_ez_Zor",
-    "GCS_Douala",
-    "GCS_Egypt_1907",
-    "GCS_ED50",
-    "GCS_ED87",
-    "GCS_Fahud",
-    "GCS_Gandajika_1970",
-    "GCS_Garoua",
-    "GCS_Guyane_Francaise",
-    "GCS_Hu_Tzu_Shan",
-    "GCS_HD72",
-    "GCS_ID74",
-    "GCS_Indian_1954",
-    "GCS_Indian_1975",
-    "GCS_Jamaica_1875",
-    "GCS_JAD69",
-    "GCS_Kalianpur",
-    "GCS_Kandawala",
-    "GCS_Kertau",
-    "GCS_KOC",
-    "GCS_La_Canoa",
-    "GCS_PSAD56",
-    "GCS_Lake",
-    "GCS_Leigon",
-    "GCS_Liberia_1964",
-    "GCS_Lome",
-    "GCS_Luzon_1911",
-    "GCS_Hito_XVIII_1963",
-    "GCS_Herat_North",
-    "GCS_Mahe_1971",
-    "GCS_Makassar",
-    "GCS_EUREF89",
-    "GCS_Malongo_1987",
-    "GCS_Manoca",
-    "GCS_Merchich",
-    "GCS_Massawa",
-    "GCS_Minna",
-    "GCS_Mhast",
-    "GCS_Monte_Mario",
-    "GCS_M_poraloko",
-    "GCS_NAD27",
-    "GCS_NAD_Michigan",
-    "GCS_NAD83",
-    "GCS_Nahrwan_1967",
-    "GCS_Naparima_1972",
-    "GCS_GD49",
-    "GCS_NGO_1948",
-    "GCS_Datum_73",
-    "GCS_NTF",
-    "GCS_NSWC_9Z_2",
-    "GCS_OSGB_1936",
-    "GCS_OSGB70",
-    "GCS_OS_SN80",
-    "GCS_Padang",
-    "GCS_Palestine_1923",
-    "GCS_Pointe_Noire",
-    "GCS_GDA94",
-    "GCS_Pulkovo_1942",
-    "GCS_Qatar",
-    "GCS_Qatar_1948",
-    "GCS_Qornoq",
-    "GCS_Loma_Quintana",
-    "GCS_Amersfoort",
-    "GCS_RT38",
-    "GCS_SAD69",
-    "GCS_Sapper_Hill_1943",
-    "GCS_Schwarzeck",
-    "GCS_Segora",
-    "GCS_Serindung",
-    "GCS_Sudan",
-    "GCS_Tananarive",
-    "GCS_Timbalai_1948",
-    "GCS_TM65",
-    "GCS_TM75",
-    "GCS_Tokyo",
-    "GCS_Trinidad_1903",
-    "GCS_TC_1948",
-    "GCS_Voirol_1875",
-    "GCS_Voirol_Unifie",
-    "GCS_Bern_1938",
-    "GCS_Nord_Sahara_1959",
-    "GCS_Stockholm_1938",
-    "GCS_Yacare",
-    "GCS_Yoff",
-    "GCS_Zanderij",
-    "GCS_MGI",
-    "GCS_Belge_1972",
-    "GCS_DHDN",
-    "GCS_Conakry_1905",
-    "GCS_WGS_72",
-    "GCS_WGS_72BE",
-    "GCS_WGS_84",
-    "GCS_Bern_1898_Bern",
-    "GCS_Bogota_Bogota",
-    "GCS_Lisbon_Lisbon",
-    "GCS_Makassar_Jakarta",
-    "GCS_MGI_Ferro",
-    "GCS_Monte_Mario_Rome",
-    "GCS_NTF_Paris",
-    "GCS_Padang_Jakarta",
-    "GCS_Belge_1950_Brussels",
-    "GCS_Tananarive_Paris",
-    "GCS_Voirol_1875_Paris",
-    "GCS_Voirol_Unifie_Paris",
-    "GCS_Batavia_Jakarta",
-    "GCS_ATF_Paris",
-    "GCS_NDG_Paris"
-};
+extern const char *const ff_tiff_gcs_type_codes[133];
 
 #define TIFF_GCSE_TYPE_OFFSET 4001
-static const char *const tiff_gcse_type_codes[] = {
-    "GCSE_Airy1830",
-    "GCSE_AiryModified1849",
-    "GCSE_AustralianNationalSpheroid",
-    "GCSE_Bessel1841",
-    "GCSE_BesselModified",
-    "GCSE_BesselNamibia",
-    "GCSE_Clarke1858",
-    "GCSE_Clarke1866",
-    "GCSE_Clarke1866Michigan",
-    "GCSE_Clarke1880_Benoit",
-    "GCSE_Clarke1880_IGN",
-    "GCSE_Clarke1880_RGS",
-    "GCSE_Clarke1880_Arc",
-    "GCSE_Clarke1880_SGA1922",
-    "GCSE_Everest1830_1937Adjustment",
-    "GCSE_Everest1830_1967Definition",
-    "GCSE_Everest1830_1975Definition",
-    "GCSE_Everest1830Modified",
-    "GCSE_GRS1980",
-    "GCSE_Helmert1906",
-    "GCSE_IndonesianNationalSpheroid",
-    "GCSE_International1924",
-    "GCSE_International1967",
-    "GCSE_Krassowsky1940",
-    "GCSE_NWL9D",
-    "GCSE_NWL10D",
-    "GCSE_Plessis1817",
-    "GCSE_Struve1860",
-    "GCSE_WarOffice",
-    "GCSE_WGS84",
-    "GCSE_GEM10C",
-    "GCSE_OSU86F",
-    "GCSE_OSU91A",
-    "GCSE_Clarke1880",
-    "GCSE_Sphere"
-};
+extern const char *const ff_tiff_gcse_type_codes[35];
 
 #define TIFF_GEODETIC_DATUM_OFFSET 6201
-static const char *const tiff_geodetic_datum_codes[] = {
-    "Datum_Adindan",
-    "Datum_Australian_Geodetic_Datum_1966",
-    "Datum_Australian_Geodetic_Datum_1984",
-    "Datum_Ain_el_Abd_1970",
-    "Datum_Afgooye",
-    "Datum_Agadez",
-    "Datum_Lisbon",
-    "Datum_Aratu",
-    "Datum_Arc_1950",
-    "Datum_Arc_1960",
-    "Datum_Batavia",
-    "Datum_Barbados",
-    "Datum_Beduaram",
-    "Datum_Beijing_1954",
-    "Datum_Reseau_National_Belge_1950",
-    "Datum_Bermuda_1957",
-    "Datum_Bern_1898",
-    "Datum_Bogota",
-    "Datum_Bukit_Rimpah",
-    "Datum_Camacupa",
-    "Datum_Campo_Inchauspe",
-    "Datum_Cape",
-    "Datum_Carthage",
-    "Datum_Chua",
-    "Datum_Corrego_Alegre",
-    "Datum_Cote_d_Ivoire",
-    "Datum_Deir_ez_Zor",
-    "Datum_Douala",
-    "Datum_Egypt_1907",
-    "Datum_European_Datum_1950",
-    "Datum_European_Datum_1987",
-    "Datum_Fahud",
-    "Datum_Gandajika_1970",
-    "Datum_Garoua",
-    "Datum_Guyane_Francaise",
-    "Datum_Hu_Tzu_Shan",
-    "Datum_Hungarian_Datum_1972",
-    "Datum_Indonesian_Datum_1974",
-    "Datum_Indian_1954",
-    "Datum_Indian_1975",
-    "Datum_Jamaica_1875",
-    "Datum_Jamaica_1969",
-    "Datum_Kalianpur",
-    "Datum_Kandawala",
-    "Datum_Kertau",
-    "Datum_Kuwait_Oil_Company",
-    "Datum_La_Canoa",
-    "Datum_Provisional_S_American_Datum_1956",
-    "Datum_Lake",
-    "Datum_Leigon",
-    "Datum_Liberia_1964",
-    "Datum_Lome",
-    "Datum_Luzon_1911",
-    "Datum_Hito_XVIII_1963",
-    "Datum_Herat_North",
-    "Datum_Mahe_1971",
-    "Datum_Makassar",
-    "Datum_European_Reference_System_1989",
-    "Datum_Malongo_1987",
-    "Datum_Manoca",
-    "Datum_Merchich",
-    "Datum_Massawa",
-    "Datum_Minna",
-    "Datum_Mhast",
-    "Datum_Monte_Mario",
-    "Datum_M_poraloko",
-    "Datum_North_American_Datum_1927",
-    "Datum_NAD_Michigan",
-    "Datum_North_American_Datum_1983",
-    "Datum_Nahrwan_1967",
-    "Datum_Naparima_1972",
-    "Datum_New_Zealand_Geodetic_Datum_1949",
-    "Datum_NGO_1948",
-    "Datum_Datum_73",
-    "Datum_Nouvelle_Triangulation_Francaise",
-    "Datum_NSWC_9Z_2",
-    "Datum_OSGB_1936",
-    "Datum_OSGB_1970_SN",
-    "Datum_OS_SN_1980",
-    "Datum_Padang_1884",
-    "Datum_Palestine_1923",
-    "Datum_Pointe_Noire",
-    "Datum_Geocentric_Datum_of_Australia_1994",
-    "Datum_Pulkovo_1942",
-    "Datum_Qatar",
-    "Datum_Qatar_1948",
-    "Datum_Qornoq",
-    "Datum_Loma_Quintana",
-    "Datum_Amersfoort",
-    "Datum_RT38",
-    "Datum_South_American_Datum_1969",
-    "Datum_Sapper_Hill_1943",
-    "Datum_Schwarzeck",
-    "Datum_Segora",
-    "Datum_Serindung",
-    "Datum_Sudan",
-    "Datum_Tananarive_1925",
-    "Datum_Timbalai_1948",
-    "Datum_TM65",
-    "Datum_TM75",
-    "Datum_Tokyo",
-    "Datum_Trinidad_1903",
-    "Datum_Trucial_Coast_1948",
-    "Datum_Voirol_1875",
-    "Datum_Voirol_Unifie_1960",
-    "Datum_Bern_1938",
-    "Datum_Nord_Sahara_1959",
-    "Datum_Stockholm_1938",
-    "Datum_Yacare",
-    "Datum_Yoff",
-    "Datum_Zanderij",
-    "Datum_Militar_Geographische_Institut",
-    "Datum_Reseau_National_Belge_1972",
-    "Datum_Deutsche_Hauptdreiecksnetz",
-    "Datum_Conakry_1905",
-    "Datum_WGS72",
-    "Datum_WGS72_Transit_Broadcast_Ephemeris",
-    "Datum_WGS84",
-    "Datum_Ancienne_Triangulation_Francaise",
-    "Datum_Nord_de_Guerre"
-};
+extern const char *const ff_tiff_geodetic_datum_codes[120];
 
 #define TIFF_GEODETIC_DATUM_E_OFFSET 6001
-static const char *const tiff_geodetic_datum_e_codes[] = {
-    "DatumE_Airy1830",
-    "DatumE_AiryModified1849",
-    "DatumE_AustralianNationalSpheroid",
-    "DatumE_Bessel1841",
-    "DatumE_BesselModified",
-    "DatumE_BesselNamibia",
-    "DatumE_Clarke1858",
-    "DatumE_Clarke1866",
-    "DatumE_Clarke1866Michigan",
-    "DatumE_Clarke1880_Benoit",
-    "DatumE_Clarke1880_IGN",
-    "DatumE_Clarke1880_RGS",
-    "DatumE_Clarke1880_Arc",
-    "DatumE_Clarke1880_SGA1922",
-    "DatumE_Everest1830_1937Adjustment",
-    "DatumE_Everest1830_1967Definition",
-    "DatumE_Everest1830_1975Definition",
-    "DatumE_Everest1830Modified",
-    "DatumE_GRS1980",
-    "DatumE_Helmert1906",
-    "DatumE_IndonesianNationalSpheroid",
-    "DatumE_International1924",
-    "DatumE_International1967",
-    "DatumE_Krassowsky1960",
-    "DatumE_NWL9D",
-    "DatumE_NWL10D",
-    "DatumE_Plessis1817",
-    "DatumE_Struve1860",
-    "DatumE_WarOffice",
-    "DatumE_WGS84",
-    "DatumE_GEM10C",
-    "DatumE_OSU86F",
-    "DatumE_OSU91A",
-    "DatumE_Clarke1880",
-    "DatumE_Sphere"
-};
+extern const char *const ff_tiff_geodetic_datum_e_codes[35];
 
 #define TIFF_ELLIPSOID_OFFSET 7001
-static const char *const tiff_ellipsoid_codes[] = {
-    "Ellipse_Airy_1830",
-    "Ellipse_Airy_Modified_1849",
-    "Ellipse_Australian_National_Spheroid",
-    "Ellipse_Bessel_1841",
-    "Ellipse_Bessel_Modified",
-    "Ellipse_Bessel_Namibia",
-    "Ellipse_Clarke_1858",
-    "Ellipse_Clarke_1866",
-    "Ellipse_Clarke_1866_Michigan",
-    "Ellipse_Clarke_1880_Benoit",
-    "Ellipse_Clarke_1880_IGN",
-    "Ellipse_Clarke_1880_RGS",
-    "Ellipse_Clarke_1880_Arc",
-    "Ellipse_Clarke_1880_SGA_1922",
-    "Ellipse_Everest_1830_1937_Adjustment",
-    "Ellipse_Everest_1830_1967_Definition",
-    "Ellipse_Everest_1830_1975_Definition",
-    "Ellipse_Everest_1830_Modified",
-    "Ellipse_GRS_1980",
-    "Ellipse_Helmert_1906",
-    "Ellipse_Indonesian_National_Spheroid",
-    "Ellipse_International_1924",
-    "Ellipse_International_1967",
-    "Ellipse_Krassowsky_1940",
-    "Ellipse_NWL_9D",
-    "Ellipse_NWL_10D",
-    "Ellipse_Plessis_1817",
-    "Ellipse_Struve_1860",
-    "Ellipse_War_Office",
-    "Ellipse_WGS_84",
-    "Ellipse_GEM_10C",
-    "Ellipse_OSU86F",
-    "Ellipse_OSU91A",
-    "Ellipse_Clarke_1880",
-    "Ellipse_Sphere"
-};
+extern const char *const ff_tiff_ellipsoid_codes[35];
 
 #define TIFF_PRIME_MERIDIAN_OFFSET 8901
-static const char *const tiff_prime_meridian_codes[] = {
-    "PM_Greenwich",
-    "PM_Lisbon",
-    "PM_Paris",
-    "PM_Bogota",
-    "PM_Madrid",
-    "PM_Rome",
-    "PM_Bern",
-    "PM_Jakarta",
-    "PM_Ferro",
-    "PM_Brussels",
-    "PM_Stockholm"
-};
+extern const char *const ff_tiff_prime_meridian_codes[11];
 
-static const TiffGeoTagKeyName tiff_proj_cs_type_codes[] = {
-    {20137, "PCS_Adindan_UTM_zone_37N"},
-    {20138, "PCS_Adindan_UTM_zone_38N"},
-    {20248, "PCS_AGD66_AMG_zone_48"},
-    {20249, "PCS_AGD66_AMG_zone_49"},
-    {20250, "PCS_AGD66_AMG_zone_50"},
-    {20251, "PCS_AGD66_AMG_zone_51"},
-    {20252, "PCS_AGD66_AMG_zone_52"},
-    {20253, "PCS_AGD66_AMG_zone_53"},
-    {20254, "PCS_AGD66_AMG_zone_54"},
-    {20255, "PCS_AGD66_AMG_zone_55"},
-    {20256, "PCS_AGD66_AMG_zone_56"},
-    {20257, "PCS_AGD66_AMG_zone_57"},
-    {20258, "PCS_AGD66_AMG_zone_58"},
-    {20348, "PCS_AGD84_AMG_zone_48"},
-    {20349, "PCS_AGD84_AMG_zone_49"},
-    {20350, "PCS_AGD84_AMG_zone_50"},
-    {20351, "PCS_AGD84_AMG_zone_51"},
-    {20352, "PCS_AGD84_AMG_zone_52"},
-    {20353, "PCS_AGD84_AMG_zone_53"},
-    {20354, "PCS_AGD84_AMG_zone_54"},
-    {20355, "PCS_AGD84_AMG_zone_55"},
-    {20356, "PCS_AGD84_AMG_zone_56"},
-    {20357, "PCS_AGD84_AMG_zone_57"},
-    {20358, "PCS_AGD84_AMG_zone_58"},
-    {20437, "PCS_Ain_el_Abd_UTM_zone_37N"},
-    {20438, "PCS_Ain_el_Abd_UTM_zone_38N"},
-    {20439, "PCS_Ain_el_Abd_UTM_zone_39N"},
-    {20499, "PCS_Ain_el_Abd_Bahrain_Grid"},
-    {20538, "PCS_Afgooye_UTM_zone_38N"},
-    {20539, "PCS_Afgooye_UTM_zone_39N"},
-    {20700, "PCS_Lisbon_Portugese_Grid"},
-    {20822, "PCS_Aratu_UTM_zone_22S"},
-    {20823, "PCS_Aratu_UTM_zone_23S"},
-    {20824, "PCS_Aratu_UTM_zone_24S"},
-    {20973, "PCS_Arc_1950_Lo13"},
-    {20975, "PCS_Arc_1950_Lo15"},
-    {20977, "PCS_Arc_1950_Lo17"},
-    {20979, "PCS_Arc_1950_Lo19"},
-    {20981, "PCS_Arc_1950_Lo21"},
-    {20983, "PCS_Arc_1950_Lo23"},
-    {20985, "PCS_Arc_1950_Lo25"},
-    {20987, "PCS_Arc_1950_Lo27"},
-    {20989, "PCS_Arc_1950_Lo29"},
-    {20991, "PCS_Arc_1950_Lo31"},
-    {20993, "PCS_Arc_1950_Lo33"},
-    {20995, "PCS_Arc_1950_Lo35"},
-    {21100, "PCS_Batavia_NEIEZ"},
-    {21148, "PCS_Batavia_UTM_zone_48S"},
-    {21149, "PCS_Batavia_UTM_zone_49S"},
-    {21150, "PCS_Batavia_UTM_zone_50S"},
-    {21413, "PCS_Beijing_Gauss_zone_13"},
-    {21414, "PCS_Beijing_Gauss_zone_14"},
-    {21415, "PCS_Beijing_Gauss_zone_15"},
-    {21416, "PCS_Beijing_Gauss_zone_16"},
-    {21417, "PCS_Beijing_Gauss_zone_17"},
-    {21418, "PCS_Beijing_Gauss_zone_18"},
-    {21419, "PCS_Beijing_Gauss_zone_19"},
-    {21420, "PCS_Beijing_Gauss_zone_20"},
-    {21421, "PCS_Beijing_Gauss_zone_21"},
-    {21422, "PCS_Beijing_Gauss_zone_22"},
-    {21423, "PCS_Beijing_Gauss_zone_23"},
-    {21473, "PCS_Beijing_Gauss_13N"},
-    {21474, "PCS_Beijing_Gauss_14N"},
-    {21475, "PCS_Beijing_Gauss_15N"},
-    {21476, "PCS_Beijing_Gauss_16N"},
-    {21477, "PCS_Beijing_Gauss_17N"},
-    {21478, "PCS_Beijing_Gauss_18N"},
-    {21479, "PCS_Beijing_Gauss_19N"},
-    {21480, "PCS_Beijing_Gauss_20N"},
-    {21481, "PCS_Beijing_Gauss_21N"},
-    {21482, "PCS_Beijing_Gauss_22N"},
-    {21483, "PCS_Beijing_Gauss_23N"},
-    {21500, "PCS_Belge_Lambert_50"},
-    {21790, "PCS_Bern_1898_Swiss_Old"},
-    {21817, "PCS_Bogota_UTM_zone_17N"},
-    {21818, "PCS_Bogota_UTM_zone_18N"},
-    {21891, "PCS_Bogota_Colombia_3W"},
-    {21892, "PCS_Bogota_Colombia_Bogota"},
-    {21893, "PCS_Bogota_Colombia_3E"},
-    {21894, "PCS_Bogota_Colombia_6E"},
-    {22032, "PCS_Camacupa_UTM_32S"},
-    {22033, "PCS_Camacupa_UTM_33S"},
-    {22191, "PCS_C_Inchauspe_Argentina_1"},
-    {22192, "PCS_C_Inchauspe_Argentina_2"},
-    {22193, "PCS_C_Inchauspe_Argentina_3"},
-    {22194, "PCS_C_Inchauspe_Argentina_4"},
-    {22195, "PCS_C_Inchauspe_Argentina_5"},
-    {22196, "PCS_C_Inchauspe_Argentina_6"},
-    {22197, "PCS_C_Inchauspe_Argentina_7"},
-    {22332, "PCS_Carthage_UTM_zone_32N"},
-    {22391, "PCS_Carthage_Nord_Tunisie"},
-    {22392, "PCS_Carthage_Sud_Tunisie"},
-    {22523, "PCS_Corrego_Alegre_UTM_23S"},
-    {22524, "PCS_Corrego_Alegre_UTM_24S"},
-    {22832, "PCS_Douala_UTM_zone_32N"},
-    {22992, "PCS_Egypt_1907_Red_Belt"},
-    {22993, "PCS_Egypt_1907_Purple_Belt"},
-    {22994, "PCS_Egypt_1907_Ext_Purple"},
-    {23028, "PCS_ED50_UTM_zone_28N"},
-    {23029, "PCS_ED50_UTM_zone_29N"},
-    {23030, "PCS_ED50_UTM_zone_30N"},
-    {23031, "PCS_ED50_UTM_zone_31N"},
-    {23032, "PCS_ED50_UTM_zone_32N"},
-    {23033, "PCS_ED50_UTM_zone_33N"},
-    {23034, "PCS_ED50_UTM_zone_34N"},
-    {23035, "PCS_ED50_UTM_zone_35N"},
-    {23036, "PCS_ED50_UTM_zone_36N"},
-    {23037, "PCS_ED50_UTM_zone_37N"},
-    {23038, "PCS_ED50_UTM_zone_38N"},
-    {23239, "PCS_Fahud_UTM_zone_39N"},
-    {23240, "PCS_Fahud_UTM_zone_40N"},
-    {23433, "PCS_Garoua_UTM_zone_33N"},
-    {23846, "PCS_ID74_UTM_zone_46N"},
-    {23847, "PCS_ID74_UTM_zone_47N"},
-    {23848, "PCS_ID74_UTM_zone_48N"},
-    {23849, "PCS_ID74_UTM_zone_49N"},
-    {23850, "PCS_ID74_UTM_zone_50N"},
-    {23851, "PCS_ID74_UTM_zone_51N"},
-    {23852, "PCS_ID74_UTM_zone_52N"},
-    {23853, "PCS_ID74_UTM_zone_53N"},
-    {23886, "PCS_ID74_UTM_zone_46S"},
-    {23887, "PCS_ID74_UTM_zone_47S"},
-    {23888, "PCS_ID74_UTM_zone_48S"},
-    {23889, "PCS_ID74_UTM_zone_49S"},
-    {23890, "PCS_ID74_UTM_zone_50S"},
-    {23891, "PCS_ID74_UTM_zone_51S"},
-    {23892, "PCS_ID74_UTM_zone_52S"},
-    {23893, "PCS_ID74_UTM_zone_53S"},
-    {23894, "PCS_ID74_UTM_zone_54S"},
-    {23947, "PCS_Indian_1954_UTM_47N"},
-    {23948, "PCS_Indian_1954_UTM_48N"},
-    {24047, "PCS_Indian_1975_UTM_47N"},
-    {24048, "PCS_Indian_1975_UTM_48N"},
-    {24100, "PCS_Jamaica_1875_Old_Grid"},
-    {24200, "PCS_JAD69_Jamaica_Grid"},
-    {24370, "PCS_Kalianpur_India_0"},
-    {24371, "PCS_Kalianpur_India_I"},
-    {24372, "PCS_Kalianpur_India_IIa"},
-    {24373, "PCS_Kalianpur_India_IIIa"},
-    {24374, "PCS_Kalianpur_India_IVa"},
-    {24382, "PCS_Kalianpur_India_IIb"},
-    {24383, "PCS_Kalianpur_India_IIIb"},
-    {24384, "PCS_Kalianpur_India_IVb"},
-    {24500, "PCS_Kertau_Singapore_Grid"},
-    {24547, "PCS_Kertau_UTM_zone_47N"},
-    {24548, "PCS_Kertau_UTM_zone_48N"},
-    {24720, "PCS_La_Canoa_UTM_zone_20N"},
-    {24721, "PCS_La_Canoa_UTM_zone_21N"},
-    {24818, "PCS_PSAD56_UTM_zone_18N"},
-    {24819, "PCS_PSAD56_UTM_zone_19N"},
-    {24820, "PCS_PSAD56_UTM_zone_20N"},
-    {24821, "PCS_PSAD56_UTM_zone_21N"},
-    {24877, "PCS_PSAD56_UTM_zone_17S"},
-    {24878, "PCS_PSAD56_UTM_zone_18S"},
-    {24879, "PCS_PSAD56_UTM_zone_19S"},
-    {24880, "PCS_PSAD56_UTM_zone_20S"},
-    {24891, "PCS_PSAD56_Peru_west_zone"},
-    {24892, "PCS_PSAD56_Peru_central"},
-    {24893, "PCS_PSAD56_Peru_east_zone"},
-    {25000, "PCS_Leigon_Ghana_Grid"},
-    {25231, "PCS_Lome_UTM_zone_31N"},
-    {25391, "PCS_Luzon_Philippines_I"},
-    {25392, "PCS_Luzon_Philippines_II"},
-    {25393, "PCS_Luzon_Philippines_III"},
-    {25394, "PCS_Luzon_Philippines_IV"},
-    {25395, "PCS_Luzon_Philippines_V"},
-    {25700, "PCS_Makassar_NEIEZ"},
-    {25932, "PCS_Malongo_1987_UTM_32S"},
-    {26191, "PCS_Merchich_Nord_Maroc"},
-    {26192, "PCS_Merchich_Sud_Maroc"},
-    {26193, "PCS_Merchich_Sahara"},
-    {26237, "PCS_Massawa_UTM_zone_37N"},
-    {26331, "PCS_Minna_UTM_zone_31N"},
-    {26332, "PCS_Minna_UTM_zone_32N"},
-    {26391, "PCS_Minna_Nigeria_West"},
-    {26392, "PCS_Minna_Nigeria_Mid_Belt"},
-    {26393, "PCS_Minna_Nigeria_East"},
-    {26432, "PCS_Mhast_UTM_zone_32S"},
-    {26591, "PCS_Monte_Mario_Italy_1"},
-    {26592, "PCS_Monte_Mario_Italy_2"},
-    {26632, "PCS_M_poraloko_UTM_32N"},
-    {26692, "PCS_M_poraloko_UTM_32S"},
-    {26703, "PCS_NAD27_UTM_zone_3N"},
-    {26704, "PCS_NAD27_UTM_zone_4N"},
-    {26705, "PCS_NAD27_UTM_zone_5N"},
-    {26706, "PCS_NAD27_UTM_zone_6N"},
-    {26707, "PCS_NAD27_UTM_zone_7N"},
-    {26708, "PCS_NAD27_UTM_zone_8N"},
-    {26709, "PCS_NAD27_UTM_zone_9N"},
-    {26710, "PCS_NAD27_UTM_zone_10N"},
-    {26711, "PCS_NAD27_UTM_zone_11N"},
-    {26712, "PCS_NAD27_UTM_zone_12N"},
-    {26713, "PCS_NAD27_UTM_zone_13N"},
-    {26714, "PCS_NAD27_UTM_zone_14N"},
-    {26715, "PCS_NAD27_UTM_zone_15N"},
-    {26716, "PCS_NAD27_UTM_zone_16N"},
-    {26717, "PCS_NAD27_UTM_zone_17N"},
-    {26718, "PCS_NAD27_UTM_zone_18N"},
-    {26719, "PCS_NAD27_UTM_zone_19N"},
-    {26720, "PCS_NAD27_UTM_zone_20N"},
-    {26721, "PCS_NAD27_UTM_zone_21N"},
-    {26722, "PCS_NAD27_UTM_zone_22N"},
-    {26729, "PCS_NAD27_Alabama_East"},
-    {26730, "PCS_NAD27_Alabama_West"},
-    {26731, "PCS_NAD27_Alaska_zone_1"},
-    {26732, "PCS_NAD27_Alaska_zone_2"},
-    {26733, "PCS_NAD27_Alaska_zone_3"},
-    {26734, "PCS_NAD27_Alaska_zone_4"},
-    {26735, "PCS_NAD27_Alaska_zone_5"},
-    {26736, "PCS_NAD27_Alaska_zone_6"},
-    {26737, "PCS_NAD27_Alaska_zone_7"},
-    {26738, "PCS_NAD27_Alaska_zone_8"},
-    {26739, "PCS_NAD27_Alaska_zone_9"},
-    {26740, "PCS_NAD27_Alaska_zone_10"},
-    {26741, "PCS_NAD27_California_I"},
-    {26742, "PCS_NAD27_California_II"},
-    {26743, "PCS_NAD27_California_III"},
-    {26744, "PCS_NAD27_California_IV"},
-    {26745, "PCS_NAD27_California_V"},
-    {26746, "PCS_NAD27_California_VI"},
-    {26747, "PCS_NAD27_California_VII"},
-    {26748, "PCS_NAD27_Arizona_East"},
-    {26749, "PCS_NAD27_Arizona_Central"},
-    {26750, "PCS_NAD27_Arizona_West"},
-    {26751, "PCS_NAD27_Arkansas_North"},
-    {26752, "PCS_NAD27_Arkansas_South"},
-    {26753, "PCS_NAD27_Colorado_North"},
-    {26754, "PCS_NAD27_Colorado_Central"},
-    {26755, "PCS_NAD27_Colorado_South"},
-    {26756, "PCS_NAD27_Connecticut"},
-    {26757, "PCS_NAD27_Delaware"},
-    {26758, "PCS_NAD27_Florida_East"},
-    {26759, "PCS_NAD27_Florida_West"},
-    {26760, "PCS_NAD27_Florida_North"},
-    {26761, "PCS_NAD27_Hawaii_zone_1"},
-    {26762, "PCS_NAD27_Hawaii_zone_2"},
-    {26763, "PCS_NAD27_Hawaii_zone_3"},
-    {26764, "PCS_NAD27_Hawaii_zone_4"},
-    {26765, "PCS_NAD27_Hawaii_zone_5"},
-    {26766, "PCS_NAD27_Georgia_East"},
-    {26767, "PCS_NAD27_Georgia_West"},
-    {26768, "PCS_NAD27_Idaho_East"},
-    {26769, "PCS_NAD27_Idaho_Central"},
-    {26770, "PCS_NAD27_Idaho_West"},
-    {26771, "PCS_NAD27_Illinois_East"},
-    {26772, "PCS_NAD27_Illinois_West"},
-    {26773, "PCS_NAD27_Indiana_East"},
-    {26774, "PCS_NAD27_BLM_14N_feet"},
-    {26774, "PCS_NAD27_Indiana_West"},
-    {26775, "PCS_NAD27_BLM_15N_feet"},
-    {26775, "PCS_NAD27_Iowa_North"},
-    {26776, "PCS_NAD27_BLM_16N_feet"},
-    {26776, "PCS_NAD27_Iowa_South"},
-    {26777, "PCS_NAD27_BLM_17N_feet"},
-    {26777, "PCS_NAD27_Kansas_North"},
-    {26778, "PCS_NAD27_Kansas_South"},
-    {26779, "PCS_NAD27_Kentucky_North"},
-    {26780, "PCS_NAD27_Kentucky_South"},
-    {26781, "PCS_NAD27_Louisiana_North"},
-    {26782, "PCS_NAD27_Louisiana_South"},
-    {26783, "PCS_NAD27_Maine_East"},
-    {26784, "PCS_NAD27_Maine_West"},
-    {26785, "PCS_NAD27_Maryland"},
-    {26786, "PCS_NAD27_Massachusetts"},
-    {26787, "PCS_NAD27_Massachusetts_Is"},
-    {26788, "PCS_NAD27_Michigan_North"},
-    {26789, "PCS_NAD27_Michigan_Central"},
-    {26790, "PCS_NAD27_Michigan_South"},
-    {26791, "PCS_NAD27_Minnesota_North"},
-    {26792, "PCS_NAD27_Minnesota_Cent"},
-    {26793, "PCS_NAD27_Minnesota_South"},
-    {26794, "PCS_NAD27_Mississippi_East"},
-    {26795, "PCS_NAD27_Mississippi_West"},
-    {26796, "PCS_NAD27_Missouri_East"},
-    {26797, "PCS_NAD27_Missouri_Central"},
-    {26798, "PCS_NAD27_Missouri_West"},
-    {26801, "PCS_NAD_Michigan_Michigan_East"},
-    {26802, "PCS_NAD_Michigan_Michigan_Old_Central"},
-    {26803, "PCS_NAD_Michigan_Michigan_West"},
-    {26903, "PCS_NAD83_UTM_zone_3N"},
-    {26904, "PCS_NAD83_UTM_zone_4N"},
-    {26905, "PCS_NAD83_UTM_zone_5N"},
-    {26906, "PCS_NAD83_UTM_zone_6N"},
-    {26907, "PCS_NAD83_UTM_zone_7N"},
-    {26908, "PCS_NAD83_UTM_zone_8N"},
-    {26909, "PCS_NAD83_UTM_zone_9N"},
-    {26910, "PCS_NAD83_UTM_zone_10N"},
-    {26911, "PCS_NAD83_UTM_zone_11N"},
-    {26912, "PCS_NAD83_UTM_zone_12N"},
-    {26913, "PCS_NAD83_UTM_zone_13N"},
-    {26914, "PCS_NAD83_UTM_zone_14N"},
-    {26915, "PCS_NAD83_UTM_zone_15N"},
-    {26916, "PCS_NAD83_UTM_zone_16N"},
-    {26917, "PCS_NAD83_UTM_zone_17N"},
-    {26918, "PCS_NAD83_UTM_zone_18N"},
-    {26919, "PCS_NAD83_UTM_zone_19N"},
-    {26920, "PCS_NAD83_UTM_zone_20N"},
-    {26921, "PCS_NAD83_UTM_zone_21N"},
-    {26922, "PCS_NAD83_UTM_zone_22N"},
-    {26923, "PCS_NAD83_UTM_zone_23N"},
-    {26929, "PCS_NAD83_Alabama_East"},
-    {26930, "PCS_NAD83_Alabama_West"},
-    {26931, "PCS_NAD83_Alaska_zone_1"},
-    {26932, "PCS_NAD83_Alaska_zone_2"},
-    {26933, "PCS_NAD83_Alaska_zone_3"},
-    {26934, "PCS_NAD83_Alaska_zone_4"},
-    {26935, "PCS_NAD83_Alaska_zone_5"},
-    {26936, "PCS_NAD83_Alaska_zone_6"},
-    {26937, "PCS_NAD83_Alaska_zone_7"},
-    {26938, "PCS_NAD83_Alaska_zone_8"},
-    {26939, "PCS_NAD83_Alaska_zone_9"},
-    {26940, "PCS_NAD83_Alaska_zone_10"},
-    {26941, "PCS_NAD83_California_1"},
-    {26942, "PCS_NAD83_California_2"},
-    {26943, "PCS_NAD83_California_3"},
-    {26944, "PCS_NAD83_California_4"},
-    {26945, "PCS_NAD83_California_5"},
-    {26946, "PCS_NAD83_California_6"},
-    {26948, "PCS_NAD83_Arizona_East"},
-    {26949, "PCS_NAD83_Arizona_Central"},
-    {26950, "PCS_NAD83_Arizona_West"},
-    {26951, "PCS_NAD83_Arkansas_North"},
-    {26952, "PCS_NAD83_Arkansas_South"},
-    {26953, "PCS_NAD83_Colorado_North"},
-    {26954, "PCS_NAD83_Colorado_Central"},
-    {26955, "PCS_NAD83_Colorado_South"},
-    {26956, "PCS_NAD83_Connecticut"},
-    {26957, "PCS_NAD83_Delaware"},
-    {26958, "PCS_NAD83_Florida_East"},
-    {26959, "PCS_NAD83_Florida_West"},
-    {26960, "PCS_NAD83_Florida_North"},
-    {26961, "PCS_NAD83_Hawaii_zone_1"},
-    {26962, "PCS_NAD83_Hawaii_zone_2"},
-    {26963, "PCS_NAD83_Hawaii_zone_3"},
-    {26964, "PCS_NAD83_Hawaii_zone_4"},
-    {26965, "PCS_NAD83_Hawaii_zone_5"},
-    {26966, "PCS_NAD83_Georgia_East"},
-    {26967, "PCS_NAD83_Georgia_West"},
-    {26968, "PCS_NAD83_Idaho_East"},
-    {26969, "PCS_NAD83_Idaho_Central"},
-    {26970, "PCS_NAD83_Idaho_West"},
-    {26971, "PCS_NAD83_Illinois_East"},
-    {26972, "PCS_NAD83_Illinois_West"},
-    {26973, "PCS_NAD83_Indiana_East"},
-    {26974, "PCS_NAD83_Indiana_West"},
-    {26975, "PCS_NAD83_Iowa_North"},
-    {26976, "PCS_NAD83_Iowa_South"},
-    {26977, "PCS_NAD83_Kansas_North"},
-    {26978, "PCS_NAD83_Kansas_South"},
-    {26979, "PCS_NAD83_Kentucky_North"},
-    {26980, "PCS_NAD83_Kentucky_South"},
-    {26981, "PCS_NAD83_Louisiana_North"},
-    {26982, "PCS_NAD83_Louisiana_South"},
-    {26983, "PCS_NAD83_Maine_East"},
-    {26984, "PCS_NAD83_Maine_West"},
-    {26985, "PCS_NAD83_Maryland"},
-    {26986, "PCS_NAD83_Massachusetts"},
-    {26987, "PCS_NAD83_Massachusetts_Is"},
-    {26988, "PCS_NAD83_Michigan_North"},
-    {26989, "PCS_NAD83_Michigan_Central"},
-    {26990, "PCS_NAD83_Michigan_South"},
-    {26991, "PCS_NAD83_Minnesota_North"},
-    {26992, "PCS_NAD83_Minnesota_Cent"},
-    {26993, "PCS_NAD83_Minnesota_South"},
-    {26994, "PCS_NAD83_Mississippi_East"},
-    {26995, "PCS_NAD83_Mississippi_West"},
-    {26996, "PCS_NAD83_Missouri_East"},
-    {26997, "PCS_NAD83_Missouri_Central"},
-    {26998, "PCS_NAD83_Missouri_West"},
-    {27038, "PCS_Nahrwan_1967_UTM_38N"},
-    {27039, "PCS_Nahrwan_1967_UTM_39N"},
-    {27040, "PCS_Nahrwan_1967_UTM_40N"},
-    {27120, "PCS_Naparima_UTM_20N"},
-    {27200, "PCS_GD49_NZ_Map_Grid"},
-    {27291, "PCS_GD49_North_Island_Grid"},
-    {27292, "PCS_GD49_South_Island_Grid"},
-    {27429, "PCS_Datum_73_UTM_zone_29N"},
-    {27500, "PCS_ATF_Nord_de_Guerre"},
-    {27581, "PCS_NTF_France_I"},
-    {27582, "PCS_NTF_France_II"},
-    {27583, "PCS_NTF_France_III"},
-    {27591, "PCS_NTF_Nord_France"},
-    {27592, "PCS_NTF_Centre_France"},
-    {27593, "PCS_NTF_Sud_France"},
-    {27700, "PCS_British_National_Grid"},
-    {28232, "PCS_Point_Noire_UTM_32S"},
-    {28348, "PCS_GDA94_MGA_zone_48"},
-    {28349, "PCS_GDA94_MGA_zone_49"},
-    {28350, "PCS_GDA94_MGA_zone_50"},
-    {28351, "PCS_GDA94_MGA_zone_51"},
-    {28352, "PCS_GDA94_MGA_zone_52"},
-    {28353, "PCS_GDA94_MGA_zone_53"},
-    {28354, "PCS_GDA94_MGA_zone_54"},
-    {28355, "PCS_GDA94_MGA_zone_55"},
-    {28356, "PCS_GDA94_MGA_zone_56"},
-    {28357, "PCS_GDA94_MGA_zone_57"},
-    {28358, "PCS_GDA94_MGA_zone_58"},
-    {28404, "PCS_Pulkovo_Gauss_zone_4"},
-    {28405, "PCS_Pulkovo_Gauss_zone_5"},
-    {28406, "PCS_Pulkovo_Gauss_zone_6"},
-    {28407, "PCS_Pulkovo_Gauss_zone_7"},
-    {28408, "PCS_Pulkovo_Gauss_zone_8"},
-    {28409, "PCS_Pulkovo_Gauss_zone_9"},
-    {28410, "PCS_Pulkovo_Gauss_zone_10"},
-    {28411, "PCS_Pulkovo_Gauss_zone_11"},
-    {28412, "PCS_Pulkovo_Gauss_zone_12"},
-    {28413, "PCS_Pulkovo_Gauss_zone_13"},
-    {28414, "PCS_Pulkovo_Gauss_zone_14"},
-    {28415, "PCS_Pulkovo_Gauss_zone_15"},
-    {28416, "PCS_Pulkovo_Gauss_zone_16"},
-    {28417, "PCS_Pulkovo_Gauss_zone_17"},
-    {28418, "PCS_Pulkovo_Gauss_zone_18"},
-    {28419, "PCS_Pulkovo_Gauss_zone_19"},
-    {28420, "PCS_Pulkovo_Gauss_zone_20"},
-    {28421, "PCS_Pulkovo_Gauss_zone_21"},
-    {28422, "PCS_Pulkovo_Gauss_zone_22"},
-    {28423, "PCS_Pulkovo_Gauss_zone_23"},
-    {28424, "PCS_Pulkovo_Gauss_zone_24"},
-    {28425, "PCS_Pulkovo_Gauss_zone_25"},
-    {28426, "PCS_Pulkovo_Gauss_zone_26"},
-    {28427, "PCS_Pulkovo_Gauss_zone_27"},
-    {28428, "PCS_Pulkovo_Gauss_zone_28"},
-    {28429, "PCS_Pulkovo_Gauss_zone_29"},
-    {28430, "PCS_Pulkovo_Gauss_zone_30"},
-    {28431, "PCS_Pulkovo_Gauss_zone_31"},
-    {28432, "PCS_Pulkovo_Gauss_zone_32"},
-    {28464, "PCS_Pulkovo_Gauss_4N"},
-    {28465, "PCS_Pulkovo_Gauss_5N"},
-    {28466, "PCS_Pulkovo_Gauss_6N"},
-    {28467, "PCS_Pulkovo_Gauss_7N"},
-    {28468, "PCS_Pulkovo_Gauss_8N"},
-    {28469, "PCS_Pulkovo_Gauss_9N"},
-    {28470, "PCS_Pulkovo_Gauss_10N"},
-    {28471, "PCS_Pulkovo_Gauss_11N"},
-    {28472, "PCS_Pulkovo_Gauss_12N"},
-    {28473, "PCS_Pulkovo_Gauss_13N"},
-    {28474, "PCS_Pulkovo_Gauss_14N"},
-    {28475, "PCS_Pulkovo_Gauss_15N"},
-    {28476, "PCS_Pulkovo_Gauss_16N"},
-    {28477, "PCS_Pulkovo_Gauss_17N"},
-    {28478, "PCS_Pulkovo_Gauss_18N"},
-    {28479, "PCS_Pulkovo_Gauss_19N"},
-    {28480, "PCS_Pulkovo_Gauss_20N"},
-    {28481, "PCS_Pulkovo_Gauss_21N"},
-    {28482, "PCS_Pulkovo_Gauss_22N"},
-    {28483, "PCS_Pulkovo_Gauss_23N"},
-    {28484, "PCS_Pulkovo_Gauss_24N"},
-    {28485, "PCS_Pulkovo_Gauss_25N"},
-    {28486, "PCS_Pulkovo_Gauss_26N"},
-    {28487, "PCS_Pulkovo_Gauss_27N"},
-    {28488, "PCS_Pulkovo_Gauss_28N"},
-    {28489, "PCS_Pulkovo_Gauss_29N"},
-    {28490, "PCS_Pulkovo_Gauss_30N"},
-    {28491, "PCS_Pulkovo_Gauss_31N"},
-    {28492, "PCS_Pulkovo_Gauss_32N"},
-    {28600, "PCS_Qatar_National_Grid"},
-    {28991, "PCS_RD_Netherlands_Old"},
-    {28992, "PCS_RD_Netherlands_New"},
-    {29118, "PCS_SAD69_UTM_zone_18N"},
-    {29119, "PCS_SAD69_UTM_zone_19N"},
-    {29120, "PCS_SAD69_UTM_zone_20N"},
-    {29121, "PCS_SAD69_UTM_zone_21N"},
-    {29122, "PCS_SAD69_UTM_zone_22N"},
-    {29177, "PCS_SAD69_UTM_zone_17S"},
-    {29178, "PCS_SAD69_UTM_zone_18S"},
-    {29179, "PCS_SAD69_UTM_zone_19S"},
-    {29180, "PCS_SAD69_UTM_zone_20S"},
-    {29181, "PCS_SAD69_UTM_zone_21S"},
-    {29182, "PCS_SAD69_UTM_zone_22S"},
-    {29183, "PCS_SAD69_UTM_zone_23S"},
-    {29184, "PCS_SAD69_UTM_zone_24S"},
-    {29185, "PCS_SAD69_UTM_zone_25S"},
-    {29220, "PCS_Sapper_Hill_UTM_20S"},
-    {29221, "PCS_Sapper_Hill_UTM_21S"},
-    {29333, "PCS_Schwarzeck_UTM_33S"},
-    {29635, "PCS_Sudan_UTM_zone_35N"},
-    {29636, "PCS_Sudan_UTM_zone_36N"},
-    {29700, "PCS_Tananarive_Laborde"},
-    {29738, "PCS_Tananarive_UTM_38S"},
-    {29739, "PCS_Tananarive_UTM_39S"},
-    {29800, "PCS_Timbalai_1948_Borneo"},
-    {29849, "PCS_Timbalai_1948_UTM_49N"},
-    {29850, "PCS_Timbalai_1948_UTM_50N"},
-    {29900, "PCS_TM65_Irish_Nat_Grid"},
-    {30200, "PCS_Trinidad_1903_Trinidad"},
-    {30339, "PCS_TC_1948_UTM_zone_39N"},
-    {30340, "PCS_TC_1948_UTM_zone_40N"},
-    {30491, "PCS_Voirol_N_Algerie_ancien"},
-    {30492, "PCS_Voirol_S_Algerie_ancien"},
-    {30591, "PCS_Voirol_Unifie_N_Algerie"},
-    {30592, "PCS_Voirol_Unifie_S_Algerie"},
-    {30600, "PCS_Bern_1938_Swiss_New"},
-    {30729, "PCS_Nord_Sahara_UTM_29N"},
-    {30730, "PCS_Nord_Sahara_UTM_30N"},
-    {30731, "PCS_Nord_Sahara_UTM_31N"},
-    {30732, "PCS_Nord_Sahara_UTM_32N"},
-    {31028, "PCS_Yoff_UTM_zone_28N"},
-    {31121, "PCS_Zanderij_UTM_zone_21N"},
-    {31291, "PCS_MGI_Austria_West"},
-    {31292, "PCS_MGI_Austria_Central"},
-    {31293, "PCS_MGI_Austria_East"},
-    {31300, "PCS_Belge_Lambert_72"},
-    {31491, "PCS_DHDN_Germany_zone_1"},
-    {31492, "PCS_DHDN_Germany_zone_2"},
-    {31493, "PCS_DHDN_Germany_zone_3"},
-    {31494, "PCS_DHDN_Germany_zone_4"},
-    {31495, "PCS_DHDN_Germany_zone_5"},
-    {32001, "PCS_NAD27_Montana_North"},
-    {32002, "PCS_NAD27_Montana_Central"},
-    {32003, "PCS_NAD27_Montana_South"},
-    {32005, "PCS_NAD27_Nebraska_North"},
-    {32006, "PCS_NAD27_Nebraska_South"},
-    {32007, "PCS_NAD27_Nevada_East"},
-    {32008, "PCS_NAD27_Nevada_Central"},
-    {32009, "PCS_NAD27_Nevada_West"},
-    {32010, "PCS_NAD27_New_Hampshire"},
-    {32011, "PCS_NAD27_New_Jersey"},
-    {32012, "PCS_NAD27_New_Mexico_East"},
-    {32013, "PCS_NAD27_New_Mexico_Cent"},
-    {32014, "PCS_NAD27_New_Mexico_West"},
-    {32015, "PCS_NAD27_New_York_East"},
-    {32016, "PCS_NAD27_New_York_Central"},
-    {32017, "PCS_NAD27_New_York_West"},
-    {32018, "PCS_NAD27_New_York_Long_Is"},
-    {32019, "PCS_NAD27_North_Carolina"},
-    {32020, "PCS_NAD27_North_Dakota_N"},
-    {32021, "PCS_NAD27_North_Dakota_S"},
-    {32022, "PCS_NAD27_Ohio_North"},
-    {32023, "PCS_NAD27_Ohio_South"},
-    {32024, "PCS_NAD27_Oklahoma_North"},
-    {32025, "PCS_NAD27_Oklahoma_South"},
-    {32026, "PCS_NAD27_Oregon_North"},
-    {32027, "PCS_NAD27_Oregon_South"},
-    {32028, "PCS_NAD27_Pennsylvania_N"},
-    {32029, "PCS_NAD27_Pennsylvania_S"},
-    {32030, "PCS_NAD27_Rhode_Island"},
-    {32031, "PCS_NAD27_South_Carolina_N"},
-    {32033, "PCS_NAD27_South_Carolina_S"},
-    {32034, "PCS_NAD27_South_Dakota_N"},
-    {32035, "PCS_NAD27_South_Dakota_S"},
-    {32036, "PCS_NAD27_Tennessee"},
-    {32037, "PCS_NAD27_Texas_North"},
-    {32038, "PCS_NAD27_Texas_North_Cen"},
-    {32039, "PCS_NAD27_Texas_Central"},
-    {32040, "PCS_NAD27_Texas_South_Cen"},
-    {32041, "PCS_NAD27_Texas_South"},
-    {32042, "PCS_NAD27_Utah_North"},
-    {32043, "PCS_NAD27_Utah_Central"},
-    {32044, "PCS_NAD27_Utah_South"},
-    {32045, "PCS_NAD27_Vermont"},
-    {32046, "PCS_NAD27_Virginia_North"},
-    {32047, "PCS_NAD27_Virginia_South"},
-    {32048, "PCS_NAD27_Washington_North"},
-    {32049, "PCS_NAD27_Washington_South"},
-    {32050, "PCS_NAD27_West_Virginia_N"},
-    {32051, "PCS_NAD27_West_Virginia_S"},
-    {32052, "PCS_NAD27_Wisconsin_North"},
-    {32053, "PCS_NAD27_Wisconsin_Cen"},
-    {32054, "PCS_NAD27_Wisconsin_South"},
-    {32055, "PCS_NAD27_Wyoming_East"},
-    {32056, "PCS_NAD27_Wyoming_E_Cen"},
-    {32057, "PCS_NAD27_Wyoming_W_Cen"},
-    {32058, "PCS_NAD27_Wyoming_West"},
-    {32059, "PCS_NAD27_Puerto_Rico"},
-    {32060, "PCS_NAD27_St_Croix"},
-    {32100, "PCS_NAD83_Montana"},
-    {32104, "PCS_NAD83_Nebraska"},
-    {32107, "PCS_NAD83_Nevada_East"},
-    {32108, "PCS_NAD83_Nevada_Central"},
-    {32109, "PCS_NAD83_Nevada_West"},
-    {32110, "PCS_NAD83_New_Hampshire"},
-    {32111, "PCS_NAD83_New_Jersey"},
-    {32112, "PCS_NAD83_New_Mexico_East"},
-    {32113, "PCS_NAD83_New_Mexico_Cent"},
-    {32114, "PCS_NAD83_New_Mexico_West"},
-    {32115, "PCS_NAD83_New_York_East"},
-    {32116, "PCS_NAD83_New_York_Central"},
-    {32117, "PCS_NAD83_New_York_West"},
-    {32118, "PCS_NAD83_New_York_Long_Is"},
-    {32119, "PCS_NAD83_North_Carolina"},
-    {32120, "PCS_NAD83_North_Dakota_N"},
-    {32121, "PCS_NAD83_North_Dakota_S"},
-    {32122, "PCS_NAD83_Ohio_North"},
-    {32123, "PCS_NAD83_Ohio_South"},
-    {32124, "PCS_NAD83_Oklahoma_North"},
-    {32125, "PCS_NAD83_Oklahoma_South"},
-    {32126, "PCS_NAD83_Oregon_North"},
-    {32127, "PCS_NAD83_Oregon_South"},
-    {32128, "PCS_NAD83_Pennsylvania_N"},
-    {32129, "PCS_NAD83_Pennsylvania_S"},
-    {32130, "PCS_NAD83_Rhode_Island"},
-    {32133, "PCS_NAD83_South_Carolina"},
-    {32134, "PCS_NAD83_South_Dakota_N"},
-    {32135, "PCS_NAD83_South_Dakota_S"},
-    {32136, "PCS_NAD83_Tennessee"},
-    {32137, "PCS_NAD83_Texas_North"},
-    {32138, "PCS_NAD83_Texas_North_Cen"},
-    {32139, "PCS_NAD83_Texas_Central"},
-    {32140, "PCS_NAD83_Texas_South_Cen"},
-    {32141, "PCS_NAD83_Texas_South"},
-    {32142, "PCS_NAD83_Utah_North"},
-    {32143, "PCS_NAD83_Utah_Central"},
-    {32144, "PCS_NAD83_Utah_South"},
-    {32145, "PCS_NAD83_Vermont"},
-    {32146, "PCS_NAD83_Virginia_North"},
-    {32147, "PCS_NAD83_Virginia_South"},
-    {32148, "PCS_NAD83_Washington_North"},
-    {32149, "PCS_NAD83_Washington_South"},
-    {32150, "PCS_NAD83_West_Virginia_N"},
-    {32151, "PCS_NAD83_West_Virginia_S"},
-    {32152, "PCS_NAD83_Wisconsin_North"},
-    {32153, "PCS_NAD83_Wisconsin_Cen"},
-    {32154, "PCS_NAD83_Wisconsin_South"},
-    {32155, "PCS_NAD83_Wyoming_East"},
-    {32156, "PCS_NAD83_Wyoming_E_Cen"},
-    {32157, "PCS_NAD83_Wyoming_W_Cen"},
-    {32158, "PCS_NAD83_Wyoming_West"},
-    {32161, "PCS_NAD83_Puerto_Rico_Virgin_Is"},
-    {32201, "PCS_WGS72_UTM_zone_1N"},
-    {32202, "PCS_WGS72_UTM_zone_2N"},
-    {32203, "PCS_WGS72_UTM_zone_3N"},
-    {32204, "PCS_WGS72_UTM_zone_4N"},
-    {32205, "PCS_WGS72_UTM_zone_5N"},
-    {32206, "PCS_WGS72_UTM_zone_6N"},
-    {32207, "PCS_WGS72_UTM_zone_7N"},
-    {32208, "PCS_WGS72_UTM_zone_8N"},
-    {32209, "PCS_WGS72_UTM_zone_9N"},
-    {32210, "PCS_WGS72_UTM_zone_10N"},
-    {32211, "PCS_WGS72_UTM_zone_11N"},
-    {32212, "PCS_WGS72_UTM_zone_12N"},
-    {32213, "PCS_WGS72_UTM_zone_13N"},
-    {32214, "PCS_WGS72_UTM_zone_14N"},
-    {32215, "PCS_WGS72_UTM_zone_15N"},
-    {32216, "PCS_WGS72_UTM_zone_16N"},
-    {32217, "PCS_WGS72_UTM_zone_17N"},
-    {32218, "PCS_WGS72_UTM_zone_18N"},
-    {32219, "PCS_WGS72_UTM_zone_19N"},
-    {32220, "PCS_WGS72_UTM_zone_20N"},
-    {32221, "PCS_WGS72_UTM_zone_21N"},
-    {32222, "PCS_WGS72_UTM_zone_22N"},
-    {32223, "PCS_WGS72_UTM_zone_23N"},
-    {32224, "PCS_WGS72_UTM_zone_24N"},
-    {32225, "PCS_WGS72_UTM_zone_25N"},
-    {32226, "PCS_WGS72_UTM_zone_26N"},
-    {32227, "PCS_WGS72_UTM_zone_27N"},
-    {32228, "PCS_WGS72_UTM_zone_28N"},
-    {32229, "PCS_WGS72_UTM_zone_29N"},
-    {32230, "PCS_WGS72_UTM_zone_30N"},
-    {32231, "PCS_WGS72_UTM_zone_31N"},
-    {32232, "PCS_WGS72_UTM_zone_32N"},
-    {32233, "PCS_WGS72_UTM_zone_33N"},
-    {32234, "PCS_WGS72_UTM_zone_34N"},
-    {32235, "PCS_WGS72_UTM_zone_35N"},
-    {32236, "PCS_WGS72_UTM_zone_36N"},
-    {32237, "PCS_WGS72_UTM_zone_37N"},
-    {32238, "PCS_WGS72_UTM_zone_38N"},
-    {32239, "PCS_WGS72_UTM_zone_39N"},
-    {32240, "PCS_WGS72_UTM_zone_40N"},
-    {32241, "PCS_WGS72_UTM_zone_41N"},
-    {32242, "PCS_WGS72_UTM_zone_42N"},
-    {32243, "PCS_WGS72_UTM_zone_43N"},
-    {32244, "PCS_WGS72_UTM_zone_44N"},
-    {32245, "PCS_WGS72_UTM_zone_45N"},
-    {32246, "PCS_WGS72_UTM_zone_46N"},
-    {32247, "PCS_WGS72_UTM_zone_47N"},
-    {32248, "PCS_WGS72_UTM_zone_48N"},
-    {32249, "PCS_WGS72_UTM_zone_49N"},
-    {32250, "PCS_WGS72_UTM_zone_50N"},
-    {32251, "PCS_WGS72_UTM_zone_51N"},
-    {32252, "PCS_WGS72_UTM_zone_52N"},
-    {32253, "PCS_WGS72_UTM_zone_53N"},
-    {32254, "PCS_WGS72_UTM_zone_54N"},
-    {32255, "PCS_WGS72_UTM_zone_55N"},
-    {32256, "PCS_WGS72_UTM_zone_56N"},
-    {32257, "PCS_WGS72_UTM_zone_57N"},
-    {32258, "PCS_WGS72_UTM_zone_58N"},
-    {32259, "PCS_WGS72_UTM_zone_59N"},
-    {32260, "PCS_WGS72_UTM_zone_60N"},
-    {32301, "PCS_WGS72_UTM_zone_1S"},
-    {32302, "PCS_WGS72_UTM_zone_2S"},
-    {32303, "PCS_WGS72_UTM_zone_3S"},
-    {32304, "PCS_WGS72_UTM_zone_4S"},
-    {32305, "PCS_WGS72_UTM_zone_5S"},
-    {32306, "PCS_WGS72_UTM_zone_6S"},
-    {32307, "PCS_WGS72_UTM_zone_7S"},
-    {32308, "PCS_WGS72_UTM_zone_8S"},
-    {32309, "PCS_WGS72_UTM_zone_9S"},
-    {32310, "PCS_WGS72_UTM_zone_10S"},
-    {32311, "PCS_WGS72_UTM_zone_11S"},
-    {32312, "PCS_WGS72_UTM_zone_12S"},
-    {32313, "PCS_WGS72_UTM_zone_13S"},
-    {32314, "PCS_WGS72_UTM_zone_14S"},
-    {32315, "PCS_WGS72_UTM_zone_15S"},
-    {32316, "PCS_WGS72_UTM_zone_16S"},
-    {32317, "PCS_WGS72_UTM_zone_17S"},
-    {32318, "PCS_WGS72_UTM_zone_18S"},
-    {32319, "PCS_WGS72_UTM_zone_19S"},
-    {32320, "PCS_WGS72_UTM_zone_20S"},
-    {32321, "PCS_WGS72_UTM_zone_21S"},
-    {32322, "PCS_WGS72_UTM_zone_22S"},
-    {32323, "PCS_WGS72_UTM_zone_23S"},
-    {32324, "PCS_WGS72_UTM_zone_24S"},
-    {32325, "PCS_WGS72_UTM_zone_25S"},
-    {32326, "PCS_WGS72_UTM_zone_26S"},
-    {32327, "PCS_WGS72_UTM_zone_27S"},
-    {32328, "PCS_WGS72_UTM_zone_28S"},
-    {32329, "PCS_WGS72_UTM_zone_29S"},
-    {32330, "PCS_WGS72_UTM_zone_30S"},
-    {32331, "PCS_WGS72_UTM_zone_31S"},
-    {32332, "PCS_WGS72_UTM_zone_32S"},
-    {32333, "PCS_WGS72_UTM_zone_33S"},
-    {32334, "PCS_WGS72_UTM_zone_34S"},
-    {32335, "PCS_WGS72_UTM_zone_35S"},
-    {32336, "PCS_WGS72_UTM_zone_36S"},
-    {32337, "PCS_WGS72_UTM_zone_37S"},
-    {32338, "PCS_WGS72_UTM_zone_38S"},
-    {32339, "PCS_WGS72_UTM_zone_39S"},
-    {32340, "PCS_WGS72_UTM_zone_40S"},
-    {32341, "PCS_WGS72_UTM_zone_41S"},
-    {32342, "PCS_WGS72_UTM_zone_42S"},
-    {32343, "PCS_WGS72_UTM_zone_43S"},
-    {32344, "PCS_WGS72_UTM_zone_44S"},
-    {32345, "PCS_WGS72_UTM_zone_45S"},
-    {32346, "PCS_WGS72_UTM_zone_46S"},
-    {32347, "PCS_WGS72_UTM_zone_47S"},
-    {32348, "PCS_WGS72_UTM_zone_48S"},
-    {32349, "PCS_WGS72_UTM_zone_49S"},
-    {32350, "PCS_WGS72_UTM_zone_50S"},
-    {32351, "PCS_WGS72_UTM_zone_51S"},
-    {32352, "PCS_WGS72_UTM_zone_52S"},
-    {32353, "PCS_WGS72_UTM_zone_53S"},
-    {32354, "PCS_WGS72_UTM_zone_54S"},
-    {32355, "PCS_WGS72_UTM_zone_55S"},
-    {32356, "PCS_WGS72_UTM_zone_56S"},
-    {32357, "PCS_WGS72_UTM_zone_57S"},
-    {32358, "PCS_WGS72_UTM_zone_58S"},
-    {32359, "PCS_WGS72_UTM_zone_59S"},
-    {32360, "PCS_WGS72_UTM_zone_60S"},
-    {32401, "PCS_WGS72BE_UTM_zone_1N"},
-    {32402, "PCS_WGS72BE_UTM_zone_2N"},
-    {32403, "PCS_WGS72BE_UTM_zone_3N"},
-    {32404, "PCS_WGS72BE_UTM_zone_4N"},
-    {32405, "PCS_WGS72BE_UTM_zone_5N"},
-    {32406, "PCS_WGS72BE_UTM_zone_6N"},
-    {32407, "PCS_WGS72BE_UTM_zone_7N"},
-    {32408, "PCS_WGS72BE_UTM_zone_8N"},
-    {32409, "PCS_WGS72BE_UTM_zone_9N"},
-    {32410, "PCS_WGS72BE_UTM_zone_10N"},
-    {32411, "PCS_WGS72BE_UTM_zone_11N"},
-    {32412, "PCS_WGS72BE_UTM_zone_12N"},
-    {32413, "PCS_WGS72BE_UTM_zone_13N"},
-    {32414, "PCS_WGS72BE_UTM_zone_14N"},
-    {32415, "PCS_WGS72BE_UTM_zone_15N"},
-    {32416, "PCS_WGS72BE_UTM_zone_16N"},
-    {32417, "PCS_WGS72BE_UTM_zone_17N"},
-    {32418, "PCS_WGS72BE_UTM_zone_18N"},
-    {32419, "PCS_WGS72BE_UTM_zone_19N"},
-    {32420, "PCS_WGS72BE_UTM_zone_20N"},
-    {32421, "PCS_WGS72BE_UTM_zone_21N"},
-    {32422, "PCS_WGS72BE_UTM_zone_22N"},
-    {32423, "PCS_WGS72BE_UTM_zone_23N"},
-    {32424, "PCS_WGS72BE_UTM_zone_24N"},
-    {32425, "PCS_WGS72BE_UTM_zone_25N"},
-    {32426, "PCS_WGS72BE_UTM_zone_26N"},
-    {32427, "PCS_WGS72BE_UTM_zone_27N"},
-    {32428, "PCS_WGS72BE_UTM_zone_28N"},
-    {32429, "PCS_WGS72BE_UTM_zone_29N"},
-    {32430, "PCS_WGS72BE_UTM_zone_30N"},
-    {32431, "PCS_WGS72BE_UTM_zone_31N"},
-    {32432, "PCS_WGS72BE_UTM_zone_32N"},
-    {32433, "PCS_WGS72BE_UTM_zone_33N"},
-    {32434, "PCS_WGS72BE_UTM_zone_34N"},
-    {32435, "PCS_WGS72BE_UTM_zone_35N"},
-    {32436, "PCS_WGS72BE_UTM_zone_36N"},
-    {32437, "PCS_WGS72BE_UTM_zone_37N"},
-    {32438, "PCS_WGS72BE_UTM_zone_38N"},
-    {32439, "PCS_WGS72BE_UTM_zone_39N"},
-    {32440, "PCS_WGS72BE_UTM_zone_40N"},
-    {32441, "PCS_WGS72BE_UTM_zone_41N"},
-    {32442, "PCS_WGS72BE_UTM_zone_42N"},
-    {32443, "PCS_WGS72BE_UTM_zone_43N"},
-    {32444, "PCS_WGS72BE_UTM_zone_44N"},
-    {32445, "PCS_WGS72BE_UTM_zone_45N"},
-    {32446, "PCS_WGS72BE_UTM_zone_46N"},
-    {32447, "PCS_WGS72BE_UTM_zone_47N"},
-    {32448, "PCS_WGS72BE_UTM_zone_48N"},
-    {32449, "PCS_WGS72BE_UTM_zone_49N"},
-    {32450, "PCS_WGS72BE_UTM_zone_50N"},
-    {32451, "PCS_WGS72BE_UTM_zone_51N"},
-    {32452, "PCS_WGS72BE_UTM_zone_52N"},
-    {32453, "PCS_WGS72BE_UTM_zone_53N"},
-    {32454, "PCS_WGS72BE_UTM_zone_54N"},
-    {32455, "PCS_WGS72BE_UTM_zone_55N"},
-    {32456, "PCS_WGS72BE_UTM_zone_56N"},
-    {32457, "PCS_WGS72BE_UTM_zone_57N"},
-    {32458, "PCS_WGS72BE_UTM_zone_58N"},
-    {32459, "PCS_WGS72BE_UTM_zone_59N"},
-    {32460, "PCS_WGS72BE_UTM_zone_60N"},
-    {32501, "PCS_WGS72BE_UTM_zone_1S"},
-    {32502, "PCS_WGS72BE_UTM_zone_2S"},
-    {32503, "PCS_WGS72BE_UTM_zone_3S"},
-    {32504, "PCS_WGS72BE_UTM_zone_4S"},
-    {32505, "PCS_WGS72BE_UTM_zone_5S"},
-    {32506, "PCS_WGS72BE_UTM_zone_6S"},
-    {32507, "PCS_WGS72BE_UTM_zone_7S"},
-    {32508, "PCS_WGS72BE_UTM_zone_8S"},
-    {32509, "PCS_WGS72BE_UTM_zone_9S"},
-    {32510, "PCS_WGS72BE_UTM_zone_10S"},
-    {32511, "PCS_WGS72BE_UTM_zone_11S"},
-    {32512, "PCS_WGS72BE_UTM_zone_12S"},
-    {32513, "PCS_WGS72BE_UTM_zone_13S"},
-    {32514, "PCS_WGS72BE_UTM_zone_14S"},
-    {32515, "PCS_WGS72BE_UTM_zone_15S"},
-    {32516, "PCS_WGS72BE_UTM_zone_16S"},
-    {32517, "PCS_WGS72BE_UTM_zone_17S"},
-    {32518, "PCS_WGS72BE_UTM_zone_18S"},
-    {32519, "PCS_WGS72BE_UTM_zone_19S"},
-    {32520, "PCS_WGS72BE_UTM_zone_20S"},
-    {32521, "PCS_WGS72BE_UTM_zone_21S"},
-    {32522, "PCS_WGS72BE_UTM_zone_22S"},
-    {32523, "PCS_WGS72BE_UTM_zone_23S"},
-    {32524, "PCS_WGS72BE_UTM_zone_24S"},
-    {32525, "PCS_WGS72BE_UTM_zone_25S"},
-    {32526, "PCS_WGS72BE_UTM_zone_26S"},
-    {32527, "PCS_WGS72BE_UTM_zone_27S"},
-    {32528, "PCS_WGS72BE_UTM_zone_28S"},
-    {32529, "PCS_WGS72BE_UTM_zone_29S"},
-    {32530, "PCS_WGS72BE_UTM_zone_30S"},
-    {32531, "PCS_WGS72BE_UTM_zone_31S"},
-    {32532, "PCS_WGS72BE_UTM_zone_32S"},
-    {32533, "PCS_WGS72BE_UTM_zone_33S"},
-    {32534, "PCS_WGS72BE_UTM_zone_34S"},
-    {32535, "PCS_WGS72BE_UTM_zone_35S"},
-    {32536, "PCS_WGS72BE_UTM_zone_36S"},
-    {32537, "PCS_WGS72BE_UTM_zone_37S"},
-    {32538, "PCS_WGS72BE_UTM_zone_38S"},
-    {32539, "PCS_WGS72BE_UTM_zone_39S"},
-    {32540, "PCS_WGS72BE_UTM_zone_40S"},
-    {32541, "PCS_WGS72BE_UTM_zone_41S"},
-    {32542, "PCS_WGS72BE_UTM_zone_42S"},
-    {32543, "PCS_WGS72BE_UTM_zone_43S"},
-    {32544, "PCS_WGS72BE_UTM_zone_44S"},
-    {32545, "PCS_WGS72BE_UTM_zone_45S"},
-    {32546, "PCS_WGS72BE_UTM_zone_46S"},
-    {32547, "PCS_WGS72BE_UTM_zone_47S"},
-    {32548, "PCS_WGS72BE_UTM_zone_48S"},
-    {32549, "PCS_WGS72BE_UTM_zone_49S"},
-    {32550, "PCS_WGS72BE_UTM_zone_50S"},
-    {32551, "PCS_WGS72BE_UTM_zone_51S"},
-    {32552, "PCS_WGS72BE_UTM_zone_52S"},
-    {32553, "PCS_WGS72BE_UTM_zone_53S"},
-    {32554, "PCS_WGS72BE_UTM_zone_54S"},
-    {32555, "PCS_WGS72BE_UTM_zone_55S"},
-    {32556, "PCS_WGS72BE_UTM_zone_56S"},
-    {32557, "PCS_WGS72BE_UTM_zone_57S"},
-    {32558, "PCS_WGS72BE_UTM_zone_58S"},
-    {32559, "PCS_WGS72BE_UTM_zone_59S"},
-    {32560, "PCS_WGS72BE_UTM_zone_60S"},
-    {32601, "PCS_WGS84_UTM_zone_1N"},
-    {32602, "PCS_WGS84_UTM_zone_2N"},
-    {32603, "PCS_WGS84_UTM_zone_3N"},
-    {32604, "PCS_WGS84_UTM_zone_4N"},
-    {32605, "PCS_WGS84_UTM_zone_5N"},
-    {32606, "PCS_WGS84_UTM_zone_6N"},
-    {32607, "PCS_WGS84_UTM_zone_7N"},
-    {32608, "PCS_WGS84_UTM_zone_8N"},
-    {32609, "PCS_WGS84_UTM_zone_9N"},
-    {32610, "PCS_WGS84_UTM_zone_10N"},
-    {32611, "PCS_WGS84_UTM_zone_11N"},
-    {32612, "PCS_WGS84_UTM_zone_12N"},
-    {32613, "PCS_WGS84_UTM_zone_13N"},
-    {32614, "PCS_WGS84_UTM_zone_14N"},
-    {32615, "PCS_WGS84_UTM_zone_15N"},
-    {32616, "PCS_WGS84_UTM_zone_16N"},
-    {32617, "PCS_WGS84_UTM_zone_17N"},
-    {32618, "PCS_WGS84_UTM_zone_18N"},
-    {32619, "PCS_WGS84_UTM_zone_19N"},
-    {32620, "PCS_WGS84_UTM_zone_20N"},
-    {32621, "PCS_WGS84_UTM_zone_21N"},
-    {32622, "PCS_WGS84_UTM_zone_22N"},
-    {32623, "PCS_WGS84_UTM_zone_23N"},
-    {32624, "PCS_WGS84_UTM_zone_24N"},
-    {32625, "PCS_WGS84_UTM_zone_25N"},
-    {32626, "PCS_WGS84_UTM_zone_26N"},
-    {32627, "PCS_WGS84_UTM_zone_27N"},
-    {32628, "PCS_WGS84_UTM_zone_28N"},
-    {32629, "PCS_WGS84_UTM_zone_29N"},
-    {32630, "PCS_WGS84_UTM_zone_30N"},
-    {32631, "PCS_WGS84_UTM_zone_31N"},
-    {32632, "PCS_WGS84_UTM_zone_32N"},
-    {32633, "PCS_WGS84_UTM_zone_33N"},
-    {32634, "PCS_WGS84_UTM_zone_34N"},
-    {32635, "PCS_WGS84_UTM_zone_35N"},
-    {32636, "PCS_WGS84_UTM_zone_36N"},
-    {32637, "PCS_WGS84_UTM_zone_37N"},
-    {32638, "PCS_WGS84_UTM_zone_38N"},
-    {32639, "PCS_WGS84_UTM_zone_39N"},
-    {32640, "PCS_WGS84_UTM_zone_40N"},
-    {32641, "PCS_WGS84_UTM_zone_41N"},
-    {32642, "PCS_WGS84_UTM_zone_42N"},
-    {32643, "PCS_WGS84_UTM_zone_43N"},
-    {32644, "PCS_WGS84_UTM_zone_44N"},
-    {32645, "PCS_WGS84_UTM_zone_45N"},
-    {32646, "PCS_WGS84_UTM_zone_46N"},
-    {32647, "PCS_WGS84_UTM_zone_47N"},
-    {32648, "PCS_WGS84_UTM_zone_48N"},
-    {32649, "PCS_WGS84_UTM_zone_49N"},
-    {32650, "PCS_WGS84_UTM_zone_50N"},
-    {32651, "PCS_WGS84_UTM_zone_51N"},
-    {32652, "PCS_WGS84_UTM_zone_52N"},
-    {32653, "PCS_WGS84_UTM_zone_53N"},
-    {32654, "PCS_WGS84_UTM_zone_54N"},
-    {32655, "PCS_WGS84_UTM_zone_55N"},
-    {32656, "PCS_WGS84_UTM_zone_56N"},
-    {32657, "PCS_WGS84_UTM_zone_57N"},
-    {32658, "PCS_WGS84_UTM_zone_58N"},
-    {32659, "PCS_WGS84_UTM_zone_59N"},
-    {32660, "PCS_WGS84_UTM_zone_60N"},
-    {32701, "PCS_WGS84_UTM_zone_1S"},
-    {32702, "PCS_WGS84_UTM_zone_2S"},
-    {32703, "PCS_WGS84_UTM_zone_3S"},
-    {32704, "PCS_WGS84_UTM_zone_4S"},
-    {32705, "PCS_WGS84_UTM_zone_5S"},
-    {32706, "PCS_WGS84_UTM_zone_6S"},
-    {32707, "PCS_WGS84_UTM_zone_7S"},
-    {32708, "PCS_WGS84_UTM_zone_8S"},
-    {32709, "PCS_WGS84_UTM_zone_9S"},
-    {32710, "PCS_WGS84_UTM_zone_10S"},
-    {32711, "PCS_WGS84_UTM_zone_11S"},
-    {32712, "PCS_WGS84_UTM_zone_12S"},
-    {32713, "PCS_WGS84_UTM_zone_13S"},
-    {32714, "PCS_WGS84_UTM_zone_14S"},
-    {32715, "PCS_WGS84_UTM_zone_15S"},
-    {32716, "PCS_WGS84_UTM_zone_16S"},
-    {32717, "PCS_WGS84_UTM_zone_17S"},
-    {32718, "PCS_WGS84_UTM_zone_18S"},
-    {32719, "PCS_WGS84_UTM_zone_19S"},
-    {32720, "PCS_WGS84_UTM_zone_20S"},
-    {32721, "PCS_WGS84_UTM_zone_21S"},
-    {32722, "PCS_WGS84_UTM_zone_22S"},
-    {32723, "PCS_WGS84_UTM_zone_23S"},
-    {32724, "PCS_WGS84_UTM_zone_24S"},
-    {32725, "PCS_WGS84_UTM_zone_25S"},
-    {32726, "PCS_WGS84_UTM_zone_26S"},
-    {32727, "PCS_WGS84_UTM_zone_27S"},
-    {32728, "PCS_WGS84_UTM_zone_28S"},
-    {32729, "PCS_WGS84_UTM_zone_29S"},
-    {32730, "PCS_WGS84_UTM_zone_30S"},
-    {32731, "PCS_WGS84_UTM_zone_31S"},
-    {32732, "PCS_WGS84_UTM_zone_32S"},
-    {32733, "PCS_WGS84_UTM_zone_33S"},
-    {32734, "PCS_WGS84_UTM_zone_34S"},
-    {32735, "PCS_WGS84_UTM_zone_35S"},
-    {32736, "PCS_WGS84_UTM_zone_36S"},
-    {32737, "PCS_WGS84_UTM_zone_37S"},
-    {32738, "PCS_WGS84_UTM_zone_38S"},
-    {32739, "PCS_WGS84_UTM_zone_39S"},
-    {32740, "PCS_WGS84_UTM_zone_40S"},
-    {32741, "PCS_WGS84_UTM_zone_41S"},
-    {32742, "PCS_WGS84_UTM_zone_42S"},
-    {32743, "PCS_WGS84_UTM_zone_43S"},
-    {32744, "PCS_WGS84_UTM_zone_44S"},
-    {32745, "PCS_WGS84_UTM_zone_45S"},
-    {32746, "PCS_WGS84_UTM_zone_46S"},
-    {32747, "PCS_WGS84_UTM_zone_47S"},
-    {32748, "PCS_WGS84_UTM_zone_48S"},
-    {32749, "PCS_WGS84_UTM_zone_49S"},
-    {32750, "PCS_WGS84_UTM_zone_50S"},
-    {32751, "PCS_WGS84_UTM_zone_51S"},
-    {32752, "PCS_WGS84_UTM_zone_52S"},
-    {32753, "PCS_WGS84_UTM_zone_53S"},
-    {32754, "PCS_WGS84_UTM_zone_54S"},
-    {32755, "PCS_WGS84_UTM_zone_55S"},
-    {32756, "PCS_WGS84_UTM_zone_56S"},
-    {32757, "PCS_WGS84_UTM_zone_57S"},
-    {32758, "PCS_WGS84_UTM_zone_58S"},
-    {32759, "PCS_WGS84_UTM_zone_59S"},
-    {32760, "PCS_WGS84_UTM_zone_60S"}
-};
+extern const TiffGeoTagKeyName ff_tiff_proj_cs_type_codes[978];
 
-static const TiffGeoTagKeyName tiff_projection_codes[] = {
-    {10101, "Proj_Alabama_CS27_East"},
-    {10102, "Proj_Alabama_CS27_West"},
-    {10131, "Proj_Alabama_CS83_East"},
-    {10132, "Proj_Alabama_CS83_West"},
-    {10201, "Proj_Arizona_Coordinate_System_east"},
-    {10202, "Proj_Arizona_Coordinate_System_Central"},
-    {10203, "Proj_Arizona_Coordinate_System_west"},
-    {10231, "Proj_Arizona_CS83_east"},
-    {10232, "Proj_Arizona_CS83_Central"},
-    {10233, "Proj_Arizona_CS83_west"},
-    {10301, "Proj_Arkansas_CS27_North"},
-    {10302, "Proj_Arkansas_CS27_South"},
-    {10331, "Proj_Arkansas_CS83_North"},
-    {10332, "Proj_Arkansas_CS83_South"},
-    {10401, "Proj_California_CS27_I"},
-    {10402, "Proj_California_CS27_II"},
-    {10403, "Proj_California_CS27_III"},
-    {10404, "Proj_California_CS27_IV"},
-    {10405, "Proj_California_CS27_V"},
-    {10406, "Proj_California_CS27_VI"},
-    {10407, "Proj_California_CS27_VII"},
-    {10431, "Proj_California_CS83_1"},
-    {10432, "Proj_California_CS83_2"},
-    {10433, "Proj_California_CS83_3"},
-    {10434, "Proj_California_CS83_4"},
-    {10435, "Proj_California_CS83_5"},
-    {10436, "Proj_California_CS83_6"},
-    {10501, "Proj_Colorado_CS27_North"},
-    {10502, "Proj_Colorado_CS27_Central"},
-    {10503, "Proj_Colorado_CS27_South"},
-    {10531, "Proj_Colorado_CS83_North"},
-    {10532, "Proj_Colorado_CS83_Central"},
-    {10533, "Proj_Colorado_CS83_South"},
-    {10600, "Proj_Connecticut_CS27"},
-    {10630, "Proj_Connecticut_CS83"},
-    {10700, "Proj_Delaware_CS27"},
-    {10730, "Proj_Delaware_CS83"},
-    {10901, "Proj_Florida_CS27_East"},
-    {10902, "Proj_Florida_CS27_West"},
-    {10903, "Proj_Florida_CS27_North"},
-    {10931, "Proj_Florida_CS83_East"},
-    {10932, "Proj_Florida_CS83_West"},
-    {10933, "Proj_Florida_CS83_North"},
-    {11001, "Proj_Georgia_CS27_East"},
-    {11002, "Proj_Georgia_CS27_West"},
-    {11031, "Proj_Georgia_CS83_East"},
-    {11032, "Proj_Georgia_CS83_West"},
-    {11101, "Proj_Idaho_CS27_East"},
-    {11102, "Proj_Idaho_CS27_Central"},
-    {11103, "Proj_Idaho_CS27_West"},
-    {11131, "Proj_Idaho_CS83_East"},
-    {11132, "Proj_Idaho_CS83_Central"},
-    {11133, "Proj_Idaho_CS83_West"},
-    {11201, "Proj_Illinois_CS27_East"},
-    {11202, "Proj_Illinois_CS27_West"},
-    {11231, "Proj_Illinois_CS83_East"},
-    {11232, "Proj_Illinois_CS83_West"},
-    {11301, "Proj_Indiana_CS27_East"},
-    {11302, "Proj_Indiana_CS27_West"},
-    {11331, "Proj_Indiana_CS83_East"},
-    {11332, "Proj_Indiana_CS83_West"},
-    {11401, "Proj_Iowa_CS27_North"},
-    {11402, "Proj_Iowa_CS27_South"},
-    {11431, "Proj_Iowa_CS83_North"},
-    {11432, "Proj_Iowa_CS83_South"},
-    {11501, "Proj_Kansas_CS27_North"},
-    {11502, "Proj_Kansas_CS27_South"},
-    {11531, "Proj_Kansas_CS83_North"},
-    {11532, "Proj_Kansas_CS83_South"},
-    {11601, "Proj_Kentucky_CS27_North"},
-    {11602, "Proj_Kentucky_CS27_South"},
-    {11631, "Proj_Kentucky_CS83_North"},
-    {11632, "Proj_Kentucky_CS83_South"},
-    {11701, "Proj_Louisiana_CS27_North"},
-    {11702, "Proj_Louisiana_CS27_South"},
-    {11731, "Proj_Louisiana_CS83_North"},
-    {11732, "Proj_Louisiana_CS83_South"},
-    {11801, "Proj_Maine_CS27_East"},
-    {11802, "Proj_Maine_CS27_West"},
-    {11831, "Proj_Maine_CS83_East"},
-    {11832, "Proj_Maine_CS83_West"},
-    {11900, "Proj_Maryland_CS27"},
-    {11930, "Proj_Maryland_CS83"},
-    {12001, "Proj_Massachusetts_CS27_Mainland"},
-    {12002, "Proj_Massachusetts_CS27_Island"},
-    {12031, "Proj_Massachusetts_CS83_Mainland"},
-    {12032, "Proj_Massachusetts_CS83_Island"},
-    {12101, "Proj_Michigan_State_Plane_East"},
-    {12102, "Proj_Michigan_State_Plane_Old_Central"},
-    {12103, "Proj_Michigan_State_Plane_West"},
-    {12111, "Proj_Michigan_CS27_North"},
-    {12112, "Proj_Michigan_CS27_Central"},
-    {12113, "Proj_Michigan_CS27_South"},
-    {12141, "Proj_Michigan_CS83_North"},
-    {12142, "Proj_Michigan_CS83_Central"},
-    {12143, "Proj_Michigan_CS83_South"},
-    {12201, "Proj_Minnesota_CS27_North"},
-    {12202, "Proj_Minnesota_CS27_Central"},
-    {12203, "Proj_Minnesota_CS27_South"},
-    {12231, "Proj_Minnesota_CS83_North"},
-    {12232, "Proj_Minnesota_CS83_Central"},
-    {12233, "Proj_Minnesota_CS83_South"},
-    {12301, "Proj_Mississippi_CS27_East"},
-    {12302, "Proj_Mississippi_CS27_West"},
-    {12331, "Proj_Mississippi_CS83_East"},
-    {12332, "Proj_Mississippi_CS83_West"},
-    {12401, "Proj_Missouri_CS27_East"},
-    {12402, "Proj_Missouri_CS27_Central"},
-    {12403, "Proj_Missouri_CS27_West"},
-    {12431, "Proj_Missouri_CS83_East"},
-    {12432, "Proj_Missouri_CS83_Central"},
-    {12433, "Proj_Missouri_CS83_West"},
-    {12501, "Proj_Montana_CS27_North"},
-    {12502, "Proj_Montana_CS27_Central"},
-    {12503, "Proj_Montana_CS27_South"},
-    {12530, "Proj_Montana_CS83"},
-    {12601, "Proj_Nebraska_CS27_North"},
-    {12602, "Proj_Nebraska_CS27_South"},
-    {12630, "Proj_Nebraska_CS83"},
-    {12701, "Proj_Nevada_CS27_East"},
-    {12702, "Proj_Nevada_CS27_Central"},
-    {12703, "Proj_Nevada_CS27_West"},
-    {12731, "Proj_Nevada_CS83_East"},
-    {12732, "Proj_Nevada_CS83_Central"},
-    {12733, "Proj_Nevada_CS83_West"},
-    {12800, "Proj_New_Hampshire_CS27"},
-    {12830, "Proj_New_Hampshire_CS83"},
-    {12900, "Proj_New_Jersey_CS27"},
-    {12930, "Proj_New_Jersey_CS83"},
-    {13001, "Proj_New_Mexico_CS27_East"},
-    {13002, "Proj_New_Mexico_CS27_Central"},
-    {13003, "Proj_New_Mexico_CS27_West"},
-    {13031, "Proj_New_Mexico_CS83_East"},
-    {13032, "Proj_New_Mexico_CS83_Central"},
-    {13033, "Proj_New_Mexico_CS83_West"},
-    {13101, "Proj_New_York_CS27_East"},
-    {13102, "Proj_New_York_CS27_Central"},
-    {13103, "Proj_New_York_CS27_West"},
-    {13104, "Proj_New_York_CS27_Long_Island"},
-    {13131, "Proj_New_York_CS83_East"},
-    {13132, "Proj_New_York_CS83_Central"},
-    {13133, "Proj_New_York_CS83_West"},
-    {13134, "Proj_New_York_CS83_Long_Island"},
-    {13200, "Proj_North_Carolina_CS27"},
-    {13230, "Proj_North_Carolina_CS83"},
-    {13301, "Proj_North_Dakota_CS27_North"},
-    {13302, "Proj_North_Dakota_CS27_South"},
-    {13331, "Proj_North_Dakota_CS83_North"},
-    {13332, "Proj_North_Dakota_CS83_South"},
-    {13401, "Proj_Ohio_CS27_North"},
-    {13402, "Proj_Ohio_CS27_South"},
-    {13431, "Proj_Ohio_CS83_North"},
-    {13432, "Proj_Ohio_CS83_South"},
-    {13501, "Proj_Oklahoma_CS27_North"},
-    {13502, "Proj_Oklahoma_CS27_South"},
-    {13531, "Proj_Oklahoma_CS83_North"},
-    {13532, "Proj_Oklahoma_CS83_South"},
-    {13601, "Proj_Oregon_CS27_North"},
-    {13602, "Proj_Oregon_CS27_South"},
-    {13631, "Proj_Oregon_CS83_North"},
-    {13632, "Proj_Oregon_CS83_South"},
-    {13701, "Proj_Pennsylvania_CS27_North"},
-    {13702, "Proj_Pennsylvania_CS27_South"},
-    {13731, "Proj_Pennsylvania_CS83_North"},
-    {13732, "Proj_Pennsylvania_CS83_South"},
-    {13800, "Proj_Rhode_Island_CS27"},
-    {13830, "Proj_Rhode_Island_CS83"},
-    {13901, "Proj_South_Carolina_CS27_North"},
-    {13902, "Proj_South_Carolina_CS27_South"},
-    {13930, "Proj_South_Carolina_CS83"},
-    {14001, "Proj_South_Dakota_CS27_North"},
-    {14002, "Proj_South_Dakota_CS27_South"},
-    {14031, "Proj_South_Dakota_CS83_North"},
-    {14032, "Proj_South_Dakota_CS83_South"},
-    {14100, "Proj_Tennessee_CS27"},
-    {14130, "Proj_Tennessee_CS83"},
-    {14201, "Proj_Texas_CS27_North"},
-    {14202, "Proj_Texas_CS27_North_Central"},
-    {14203, "Proj_Texas_CS27_Central"},
-    {14204, "Proj_Texas_CS27_South_Central"},
-    {14205, "Proj_Texas_CS27_South"},
-    {14231, "Proj_Texas_CS83_North"},
-    {14232, "Proj_Texas_CS83_North_Central"},
-    {14233, "Proj_Texas_CS83_Central"},
-    {14234, "Proj_Texas_CS83_South_Central"},
-    {14235, "Proj_Texas_CS83_South"},
-    {14301, "Proj_Utah_CS27_North"},
-    {14302, "Proj_Utah_CS27_Central"},
-    {14303, "Proj_Utah_CS27_South"},
-    {14331, "Proj_Utah_CS83_North"},
-    {14332, "Proj_Utah_CS83_Central"},
-    {14333, "Proj_Utah_CS83_South"},
-    {14400, "Proj_Vermont_CS27"},
-    {14430, "Proj_Vermont_CS83"},
-    {14501, "Proj_Virginia_CS27_North"},
-    {14502, "Proj_Virginia_CS27_South"},
-    {14531, "Proj_Virginia_CS83_North"},
-    {14532, "Proj_Virginia_CS83_South"},
-    {14601, "Proj_Washington_CS27_North"},
-    {14602, "Proj_Washington_CS27_South"},
-    {14631, "Proj_Washington_CS83_North"},
-    {14632, "Proj_Washington_CS83_South"},
-    {14701, "Proj_West_Virginia_CS27_North"},
-    {14702, "Proj_West_Virginia_CS27_South"},
-    {14731, "Proj_West_Virginia_CS83_North"},
-    {14732, "Proj_West_Virginia_CS83_South"},
-    {14801, "Proj_Wisconsin_CS27_North"},
-    {14802, "Proj_Wisconsin_CS27_Central"},
-    {14803, "Proj_Wisconsin_CS27_South"},
-    {14831, "Proj_Wisconsin_CS83_North"},
-    {14832, "Proj_Wisconsin_CS83_Central"},
-    {14833, "Proj_Wisconsin_CS83_South"},
-    {14901, "Proj_Wyoming_CS27_East"},
-    {14902, "Proj_Wyoming_CS27_East_Central"},
-    {14903, "Proj_Wyoming_CS27_West_Central"},
-    {14904, "Proj_Wyoming_CS27_West"},
-    {14931, "Proj_Wyoming_CS83_East"},
-    {14932, "Proj_Wyoming_CS83_East_Central"},
-    {14933, "Proj_Wyoming_CS83_West_Central"},
-    {14934, "Proj_Wyoming_CS83_West"},
-    {15001, "Proj_Alaska_CS27_1"},
-    {15002, "Proj_Alaska_CS27_2"},
-    {15003, "Proj_Alaska_CS27_3"},
-    {15004, "Proj_Alaska_CS27_4"},
-    {15005, "Proj_Alaska_CS27_5"},
-    {15006, "Proj_Alaska_CS27_6"},
-    {15007, "Proj_Alaska_CS27_7"},
-    {15008, "Proj_Alaska_CS27_8"},
-    {15009, "Proj_Alaska_CS27_9"},
-    {15010, "Proj_Alaska_CS27_10"},
-    {15031, "Proj_Alaska_CS83_1"},
-    {15032, "Proj_Alaska_CS83_2"},
-    {15033, "Proj_Alaska_CS83_3"},
-    {15034, "Proj_Alaska_CS83_4"},
-    {15035, "Proj_Alaska_CS83_5"},
-    {15036, "Proj_Alaska_CS83_6"},
-    {15037, "Proj_Alaska_CS83_7"},
-    {15038, "Proj_Alaska_CS83_8"},
-    {15039, "Proj_Alaska_CS83_9"},
-    {15040, "Proj_Alaska_CS83_10"},
-    {15101, "Proj_Hawaii_CS27_1"},
-    {15102, "Proj_Hawaii_CS27_2"},
-    {15103, "Proj_Hawaii_CS27_3"},
-    {15104, "Proj_Hawaii_CS27_4"},
-    {15105, "Proj_Hawaii_CS27_5"},
-    {15131, "Proj_Hawaii_CS83_1"},
-    {15132, "Proj_Hawaii_CS83_2"},
-    {15133, "Proj_Hawaii_CS83_3"},
-    {15134, "Proj_Hawaii_CS83_4"},
-    {15135, "Proj_Hawaii_CS83_5"},
-    {15201, "Proj_Puerto_Rico_CS27"},
-    {15202, "Proj_St_Croix"},
-    {15230, "Proj_Puerto_Rico_Virgin_Is"},
-    {15914, "Proj_BLM_14N_feet"},
-    {15915, "Proj_BLM_15N_feet"},
-    {15916, "Proj_BLM_16N_feet"},
-    {15917, "Proj_BLM_17N_feet"},
-    {17348, "Proj_Map_Grid_of_Australia_48"},
-    {17349, "Proj_Map_Grid_of_Australia_49"},
-    {17350, "Proj_Map_Grid_of_Australia_50"},
-    {17351, "Proj_Map_Grid_of_Australia_51"},
-    {17352, "Proj_Map_Grid_of_Australia_52"},
-    {17353, "Proj_Map_Grid_of_Australia_53"},
-    {17354, "Proj_Map_Grid_of_Australia_54"},
-    {17355, "Proj_Map_Grid_of_Australia_55"},
-    {17356, "Proj_Map_Grid_of_Australia_56"},
-    {17357, "Proj_Map_Grid_of_Australia_57"},
-    {17358, "Proj_Map_Grid_of_Australia_58"},
-    {17448, "Proj_Australian_Map_Grid_48"},
-    {17449, "Proj_Australian_Map_Grid_49"},
-    {17450, "Proj_Australian_Map_Grid_50"},
-    {17451, "Proj_Australian_Map_Grid_51"},
-    {17452, "Proj_Australian_Map_Grid_52"},
-    {17453, "Proj_Australian_Map_Grid_53"},
-    {17454, "Proj_Australian_Map_Grid_54"},
-    {17455, "Proj_Australian_Map_Grid_55"},
-    {17456, "Proj_Australian_Map_Grid_56"},
-    {17457, "Proj_Australian_Map_Grid_57"},
-    {17458, "Proj_Australian_Map_Grid_58"},
-    {18031, "Proj_Argentina_1"},
-    {18032, "Proj_Argentina_2"},
-    {18033, "Proj_Argentina_3"},
-    {18034, "Proj_Argentina_4"},
-    {18035, "Proj_Argentina_5"},
-    {18036, "Proj_Argentina_6"},
-    {18037, "Proj_Argentina_7"},
-    {18051, "Proj_Colombia_3W"},
-    {18052, "Proj_Colombia_Bogota"},
-    {18053, "Proj_Colombia_3E"},
-    {18054, "Proj_Colombia_6E"},
-    {18072, "Proj_Egypt_Red_Belt"},
-    {18073, "Proj_Egypt_Purple_Belt"},
-    {18074, "Proj_Extended_Purple_Belt"},
-    {18141, "Proj_New_Zealand_North_Island_Nat_Grid"},
-    {18142, "Proj_New_Zealand_South_Island_Nat_Grid"},
-    {19900, "Proj_Bahrain_Grid"},
-    {19905, "Proj_Netherlands_E_Indies_Equatorial"},
-    {19912, "Proj_RSO_Borneo"}
-};
+extern const TiffGeoTagKeyName ff_tiff_projection_codes[298];
 
 #define TIFF_COORD_TRANS_OFFSET 1
-static const char *const tiff_coord_trans_codes[] = {
-    "CT_TransverseMercator",
-    "CT_TransvMercator_Modified_Alaska",
-    "CT_ObliqueMercator",
-    "CT_ObliqueMercator_Laborde",
-    "CT_ObliqueMercator_Rosenmund",
-    "CT_ObliqueMercator_Spherical",
-    "CT_Mercator",
-    "CT_LambertConfConic_2SP",
-    "CT_LambertConfConic_Helmert",
-    "CT_LambertAzimEqualArea",
-    "CT_AlbersEqualArea",
-    "CT_AzimuthalEquidistant",
-    "CT_EquidistantConic",
-    "CT_Stereographic",
-    "CT_PolarStereographic",
-    "CT_ObliqueStereographic",
-    "CT_Equirectangular",
-    "CT_CassiniSoldner",
-    "CT_Gnomonic",
-    "CT_MillerCylindrical",
-    "CT_Orthographic",
-    "CT_Polyconic",
-    "CT_Robinson",
-    "CT_Sinusoidal",
-    "CT_VanDerGrinten",
-    "CT_NewZealandMapGrid",
-    "CT_TransvMercator_SouthOriented"
-};
+extern const char *const ff_tiff_coord_trans_codes[27];
 
 #define TIFF_VERT_CS_OFFSET 5001
-static const char *const tiff_vert_cs_codes[] = {
-    "VertCS_Airy_1830_ellipsoid",
-    "VertCS_Airy_Modified_1849_ellipsoid",
-    "VertCS_ANS_ellipsoid",
-    "VertCS_Bessel_1841_ellipsoid",
-    "VertCS_Bessel_Modified_ellipsoid",
-    "VertCS_Bessel_Namibia_ellipsoid",
-    "VertCS_Clarke_1858_ellipsoid",
-    "VertCS_Clarke_1866_ellipsoid",
-    "VertCS_Clarke_1880_Benoit_ellipsoid",
-    "VertCS_Clarke_1880_IGN_ellipsoid",
-    "VertCS_Clarke_1880_RGS_ellipsoid",
-    "VertCS_Clarke_1880_Arc_ellipsoid",
-    "VertCS_Clarke_1880_SGA_1922_ellipsoid",
-    "VertCS_Everest_1830_1937_Adjustment_ellipsoid",
-    "VertCS_Everest_1830_1967_Definition_ellipsoid",
-    "VertCS_Everest_1830_1975_Definition_ellipsoid",
-    "VertCS_Everest_1830_Modified_ellipsoid",
-    "VertCS_GRS_1980_ellipsoid",
-    "VertCS_Helmert_1906_ellipsoid",
-    "VertCS_INS_ellipsoid",
-    "VertCS_International_1924_ellipsoid",
-    "VertCS_International_1967_ellipsoid",
-    "VertCS_Krassowsky_1940_ellipsoid",
-    "VertCS_NWL_9D_ellipsoid",
-    "VertCS_NWL_10D_ellipsoid",
-    "VertCS_Plessis_1817_ellipsoid",
-    "VertCS_Struve_1860_ellipsoid",
-    "VertCS_War_Office_ellipsoid",
-    "VertCS_WGS_84_ellipsoid",
-    "VertCS_GEM_10C_ellipsoid",
-    "VertCS_OSU86F_ellipsoid",
-    "VertCS_OSU91A_ellipsoid"
-};
+extern const char *const ff_tiff_vert_cs_codes[32];
 
 #define TIFF_ORTHO_VERT_CS_OFFSET 5101
-static const char *const tiff_ortho_vert_cs_codes[] = {
-    "VertCS_Newlyn",
-    "VertCS_North_American_Vertical_Datum_1929",
-    "VertCS_North_American_Vertical_Datum_1988",
-    "VertCS_Yellow_Sea_1956",
-    "VertCS_Baltic_Sea",
-    "VertCS_Caspian_Sea"
-};
-
+extern const char *const ff_tiff_ortho_vert_cs_codes[6];
 #endif
diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index 272fc43..3cdae8c 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -21,8 +21,6 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "get_bits.h"
diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
index d33639f..6d03081 100644
--- a/libavcodec/tscc.c
+++ b/libavcodec/tscc.c
@@ -72,7 +72,7 @@
     int palette_has_changed = 0;
 
     if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        buffer_size_t size;
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
 
         if (pal && size == AVPALETTE_SIZE) {
diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c
deleted file mode 100644
index 3972b43..0000000
--- a/libavcodec/ttmlenc.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * TTML subtitle encoder
- * Copyright (c) 2020 24i
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * TTML subtitle encoder
- * @see https://www.w3.org/TR/ttml1/
- * @see https://www.w3.org/TR/ttml2/
- * @see https://www.w3.org/TR/ttml-imsc/rec
- */
-
-#include "avcodec.h"
-#include "internal.h"
-#include "libavutil/avstring.h"
-#include "libavutil/bprint.h"
-#include "libavutil/internal.h"
-#include "ass_split.h"
-#include "ass.h"
-#include "ttmlenc.h"
-
-typedef struct {
-    AVCodecContext *avctx;
-    ASSSplitContext *ass_ctx;
-    AVBPrint buffer;
-} TTMLContext;
-
-static void ttml_text_cb(void *priv, const char *text, int len)
-{
-    TTMLContext *s = priv;
-    AVBPrint cur_line = { 0 };
-    AVBPrint *buffer = &s->buffer;
-
-    av_bprint_init(&cur_line, len, AV_BPRINT_SIZE_UNLIMITED);
-
-    av_bprint_append_data(&cur_line, text, len);
-    if (!av_bprint_is_complete(&cur_line)) {
-        av_log(s->avctx, AV_LOG_ERROR,
-               "Failed to move the current subtitle dialog to AVBPrint!\n");
-        av_bprint_finalize(&cur_line, NULL);
-        return;
-    }
-
-
-    av_bprint_escape(buffer, cur_line.str, NULL, AV_ESCAPE_MODE_XML,
-                     0);
-
-    av_bprint_finalize(&cur_line, NULL);
-}
-
-static void ttml_new_line_cb(void *priv, int forced)
-{
-    TTMLContext *s = priv;
-
-    av_bprintf(&s->buffer, "<br/>");
-}
-
-static const ASSCodesCallbacks ttml_callbacks = {
-    .text             = ttml_text_cb,
-    .new_line         = ttml_new_line_cb,
-};
-
-static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf,
-                             int bufsize, const AVSubtitle *sub)
-{
-    TTMLContext *s = avctx->priv_data;
-    ASSDialog *dialog;
-    int i;
-
-    av_bprint_clear(&s->buffer);
-
-    for (i=0; i<sub->num_rects; i++) {
-        const char *ass = sub->rects[i]->ass;
-
-        if (sub->rects[i]->type != SUBTITLE_ASS) {
-            av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
-            return AVERROR(EINVAL);
-        }
-
-#if FF_API_ASS_TIMING
-        if (!strncmp(ass, "Dialogue: ", 10)) {
-            int num;
-            dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num);
-
-            for (; dialog && num--; dialog++) {
-                int ret = ff_ass_split_override_codes(&ttml_callbacks, s,
-                                                      dialog->text);
-                int log_level = (ret != AVERROR_INVALIDDATA ||
-                                 avctx->err_recognition & AV_EF_EXPLODE) ?
-                                AV_LOG_ERROR : AV_LOG_WARNING;
-
-                if (ret < 0) {
-                    av_log(avctx, log_level,
-                           "Splitting received ASS dialog failed: %s\n",
-                           av_err2str(ret));
-
-                    if (log_level == AV_LOG_ERROR)
-                        return ret;
-                }
-            }
-        } else {
-#endif
-            dialog = ff_ass_split_dialog2(s->ass_ctx, ass);
-            if (!dialog)
-                return AVERROR(ENOMEM);
-
-            {
-                int ret = ff_ass_split_override_codes(&ttml_callbacks, s,
-                                                      dialog->text);
-                int log_level = (ret != AVERROR_INVALIDDATA ||
-                                 avctx->err_recognition & AV_EF_EXPLODE) ?
-                                AV_LOG_ERROR : AV_LOG_WARNING;
-
-                if (ret < 0) {
-                    av_log(avctx, log_level,
-                           "Splitting received ASS dialog text %s failed: %s\n",
-                           dialog->text,
-                           av_err2str(ret));
-
-                    if (log_level == AV_LOG_ERROR) {
-                        ff_ass_free_dialog(&dialog);
-                        return ret;
-                    }
-                }
-
-                ff_ass_free_dialog(&dialog);
-            }
-#if FF_API_ASS_TIMING
-        }
-#endif
-    }
-
-    if (!av_bprint_is_complete(&s->buffer))
-        return AVERROR(ENOMEM);
-    if (!s->buffer.len)
-        return 0;
-
-    // force null-termination, so in case our destination buffer is
-    // too small, the return value is larger than bufsize minus null.
-    if (av_strlcpy(buf, s->buffer.str, bufsize) > bufsize - 1) {
-        av_log(avctx, AV_LOG_ERROR, "Buffer too small for TTML event.\n");
-        return AVERROR_BUFFER_TOO_SMALL;
-    }
-
-    return s->buffer.len;
-}
-
-static av_cold int ttml_encode_close(AVCodecContext *avctx)
-{
-    TTMLContext *s = avctx->priv_data;
-
-    ff_ass_split_free(s->ass_ctx);
-
-    av_bprint_finalize(&s->buffer, NULL);
-
-    return 0;
-}
-
-static av_cold int ttml_encode_init(AVCodecContext *avctx)
-{
-    TTMLContext *s = avctx->priv_data;
-
-    s->avctx   = avctx;
-
-    if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) {
-        return AVERROR_INVALIDDATA;
-    }
-
-    if (!(avctx->extradata = av_mallocz(TTMLENC_EXTRADATA_SIGNATURE_SIZE +
-                                        1 + AV_INPUT_BUFFER_PADDING_SIZE))) {
-        return AVERROR(ENOMEM);
-    }
-
-    avctx->extradata_size = TTMLENC_EXTRADATA_SIGNATURE_SIZE;
-    memcpy(avctx->extradata, TTMLENC_EXTRADATA_SIGNATURE,
-           TTMLENC_EXTRADATA_SIGNATURE_SIZE);
-
-    av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
-
-    return 0;
-}
-
-AVCodec ff_ttml_encoder = {
-    .name           = "ttml",
-    .long_name      = NULL_IF_CONFIG_SMALL("TTML subtitle"),
-    .type           = AVMEDIA_TYPE_SUBTITLE,
-    .id             = AV_CODEC_ID_TTML,
-    .priv_data_size = sizeof(TTMLContext),
-    .init           = ttml_encode_init,
-    .encode_sub     = ttml_encode_frame,
-    .close          = ttml_encode_close,
-    .capabilities   = FF_CODEC_CAP_INIT_CLEANUP,
-};
diff --git a/libavcodec/twinvq_data.h b/libavcodec/twinvq_data.h
index 1d9678e..375acc2 100644
--- a/libavcodec/twinvq_data.h
+++ b/libavcodec/twinvq_data.h
@@ -135,6 +135,7 @@
  * without risking a segfault on malformed files.
  */
 static const struct twinvq_data {
+    float lsp08[504];
     int16_t fcb08l[640];
     int16_t fcb08m[320];
     int16_t fcb08s[320];
@@ -158,6 +159,7 @@
     int16_t fcb11m[320];
     int16_t fcb11s[320];
     int16_t shape11[1280];
+    float lsp11[1312];
 
     int16_t cb1110l0[1280];
     int16_t cb1110l1[1280];
@@ -170,6 +172,7 @@
     int16_t fcb16m[320];
     int16_t fcb16s[320];
     int16_t shape16[1920];
+    float lsp16[1400];
 
     int16_t cb1616l0[1024];
     int16_t cb1616l1[1024];
@@ -189,6 +192,7 @@
     int16_t fcb22m_1[640];
     int16_t fcb22s_1[640];
     int16_t shape22_1[1152];
+    float lsp22_1[1312];
 
     int16_t cb2224l0[960];
     int16_t cb2224l1[960];
@@ -221,6 +225,7 @@
     int16_t fcb44m[640];
     int16_t fcb44s[640];
     int16_t shape44[1152];
+    float lsp44[1640];
 
     int16_t cb4448l0[896];
     int16_t cb4448l1[896];
@@ -10031,6 +10036,584 @@
  -3976,    -66,   -594,   6181,   -110,    292,   1129,   -591
 },
 
+.lsp08 = {
+ 0.2702,  0.5096,  0.6437,  0.7672,  0.9639,  1.0696,  1.2625,  1.5789,
+ 1.9285,  2.2383,  2.5129,  2.8470,  0.1740,  0.3677,  0.6082,  0.8387,
+ 1.1084,  1.3721,  1.6362,  1.8733,  2.0640,  2.3442,  2.6087,  2.8548,
+ 0.1536,  0.3279,  0.5143,  0.6859,  0.9763,  1.2744,  1.5605,  1.8566,
+ 2.1007,  2.3450,  2.6075,  2.8850,  0.2075,  0.4533,  0.7709,  1.0377,
+ 1.2953,  1.5132,  1.7826,  2.0351,  2.2590,  2.4996,  2.6795,  2.8748,
+ 0.1393,  0.2453,  0.3754,  0.5453,  0.8148,  1.1289,  1.4389,  1.7592,
+ 2.0353,  2.3215,  2.5934,  2.8588,  0.1250,  0.3627,  0.7613,  1.1380,
+ 1.4163,  1.5565,  1.6920,  1.8130,  1.8678,  2.0427,  2.4318,  2.8544,
+ 0.2256,  0.4223,  0.6452,  0.8599,  1.0673,  1.3118,  1.5486,  1.8366,
+ 2.0759,  2.3026,  2.5284,  2.8030,  0.2304,  0.4404,  0.6891,  0.8964,
+ 1.1510,  1.4202,  1.6483,  1.8580,  2.1181,  2.3686,  2.6078,  2.9128,
+ 0.2230,  0.3816,  0.5520,  0.6062,  0.7909,  1.0988,  1.4330,  1.7846,
+ 2.0713,  2.3457,  2.6048,  2.8708,  0.2447,  0.5800,  0.8249,  0.9905,
+ 1.1721,  1.3990,  1.6694,  1.9064,  2.1307,  2.4255,  2.6815,  2.9117,
+ 0.1974,  0.3812,  0.5802,  0.7759,  0.9280,  1.1547,  1.4170,  1.6369,
+ 1.8890,  2.2587,  2.5626,  2.8239,  0.1209,  0.2510,  0.4841,  0.8048,
+ 1.1197,  1.3563,  1.6073,  1.8926,  2.1350,  2.3669,  2.6291,  2.8985,
+ 0.2352,  0.4347,  0.6582,  0.8178,  0.9548,  1.1654,  1.4942,  1.8812,
+ 2.1703,  2.3779,  2.6412,  2.8871,  0.2091,  0.4084,  0.6730,  0.9151,
+ 1.1259,  1.3262,  1.5937,  1.8129,  2.0237,  2.3317,  2.5778,  2.8620,
+ 0.1167,  0.2406,  0.4520,  0.7298,  0.9848,  1.2448,  1.5137,  1.7874,
+ 2.0280,  2.3020,  2.5914,  2.8794,  0.3003,  0.4966,  0.6520,  0.8505,
+ 1.1600,  1.3981,  1.5805,  1.8346,  2.0757,  2.3102,  2.5760,  2.8499,
+ 0.2451,  0.4163,  0.5960,  0.7805,  0.9507,  1.2438,  1.5587,  1.8581,
+ 2.0735,  2.3198,  2.5704,  2.8220,  0.3112,  0.5517,  0.7032,  0.8528,
+ 1.1489,  1.4257,  1.6848,  1.9388,  2.1577,  2.4265,  2.6678,  2.9051,
+ 0.2249,  0.3897,  0.5559,  0.7473,  1.0158,  1.3581,  1.6914,  1.9930,
+ 2.1843,  2.3534,  2.5512,  2.8065,  0.2600,  0.4574,  0.7349,  0.9691,
+ 1.1696,  1.3848,  1.6335,  1.9021,  2.1174,  2.3481,  2.5902,  2.8390,
+ 0.2246,  0.3372,  0.4560,  0.5249,  0.7056,  1.0273,  1.3810,  1.7132,
+ 1.9819,  2.2574,  2.5410,  2.8491,  0.1419,  0.4834,  0.8835,  1.1453,
+ 1.2839,  1.4224,  1.5593,  1.7877,  2.1285,  2.4070,  2.6043,  2.8511,
+ 0.1886,  0.3677,  0.5617,  0.8099,  1.1277,  1.3841,  1.5804,  1.8136,
+ 2.0307,  2.2805,  2.5399,  2.8322,  0.2351,  0.4151,  0.6675,  0.8713,
+ 1.0464,  1.3292,  1.6586,  1.9281,  2.1355,  2.3495,  2.6222,  2.8782,
+ 0.2700,  0.4489,  0.6206,  0.7121,  0.7737,  0.9848,  1.3658,  1.7433,
+ 2.0139,  2.2243,  2.4806,  2.8175,  0.2479,  0.4425,  0.6490,  0.8745,
+ 1.1161,  1.3849,  1.6773,  1.9566,  2.1491,  2.3624,  2.5685,  2.8114,
+ 0.2035,  0.3701,  0.5567,  0.7953,  1.0082,  1.2758,  1.5373,  1.7822,
+ 2.0175,  2.2601,  2.4759,  2.7771,  0.1856,  0.3461,  0.5998,  0.9041,
+ 1.2383,  1.4612,  1.6667,  1.9305,  2.1617,  2.4107,  2.6477,  2.8656,
+ 0.2107,  0.3715,  0.5289,  0.6651,  0.8420,  1.1168,  1.4401,  1.7230,
+ 1.9901,  2.2687,  2.5452,  2.8655,  0.1218,  0.2999,  0.6348,  0.9482,
+ 1.2745,  1.5876,  1.9129,  2.2348,  2.4020,  2.4922,  2.6351,  2.8357,
+ 0.1617,  0.3483,  0.5869,  0.8163,  1.0366,  1.2344,  1.4609,  1.7029,
+ 1.9476,  2.2337,  2.5258,  2.8442,  0.2505,  0.4894,  0.7510,  0.9152,
+ 1.0845,  1.3657,  1.6528,  1.8346,  2.0160,  2.2811,  2.5338,  2.8136,
+ 0.0947,  0.1158,  0.0578, -0.0337, -0.0066,  0.0104, -0.0447, -0.0505,
+-0.0778, -0.0293,  0.0251, -0.0143,  0.0349, -0.0227, -0.0909,  0.0523,
+ 0.0325, -0.0410, -0.1045, -0.0899, -0.0009,  0.0075, -0.0575, -0.0855,
+-0.0129,  0.0575,  0.0597,  0.0391,  0.0371, -0.0184, -0.0083,  0.0287,
+ 0.0143,  0.0167,  0.0120, -0.0168,  0.0452,  0.0223, -0.0352,  0.0119,
+-0.0496, -0.0965, -0.0661, -0.0072,  0.1099,  0.0843, -0.0087, -0.0478,
+-0.0128, -0.0120, -0.0004,  0.0731,  0.1047,  0.0630,  0.0196, -0.0103,
+-0.0399, -0.0986, -0.0912, -0.0390, -0.0247, -0.0694, -0.0749, -0.0066,
+ 0.0223,  0.0634,  0.0343, -0.0134,  0.0727,  0.0241,  0.0066,  0.0437,
+ 0.0610,  0.0364,  0.0248, -0.0358, -0.0686, -0.0104,  0.0426,  0.0088,
+-0.0137, -0.0165,  0.0671,  0.0815, -0.0863, -0.0644, -0.0088,  0.0023,
+ 0.0482,  0.1174,  0.1270,  0.0594,  0.0165,  0.0949,  0.1098,  0.0137,
+ 0.4951,  0.4999,  0.4958,  0.4907,  0.4984,  0.4965,  0.4958,  0.4996,
+ 0.4987,  0.4958,  0.4986,  0.4977,  0.2841,  0.2186,  0.1474,  0.1687,
+ 0.2217,  0.2632,  0.2706,  0.2624,  0.2162,  0.2453,  0.2460,  0.2531
+},
+
+.lsp11 = {
+ 0.1103,  0.3862,  0.6863,  0.8447,  0.9231,  1.0261,  1.1248,  1.4057,
+ 1.6621,  1.8010,  1.8692,  2.0704,  2.3490,  2.6060,  2.7539,  2.8977,
+ 0.1273,  0.2407,  0.3812,  0.6004,  0.7767,  0.9383,  1.1344,  1.3351,
+ 1.5233,  1.7262,  1.9466,  2.1739,  2.3495,  2.5162,  2.7164,  2.9202,
+ 0.2010,  0.3330,  0.4488,  0.6465,  0.8046,  0.9889,  1.1479,  1.2964,
+ 1.4770,  1.6606,  1.8789,  2.1155,  2.3287,  2.5199,  2.7101,  2.9119,
+ 0.1168,  0.2197,  0.3279,  0.4691,  0.6268,  0.8251,  1.0533,  1.2714,
+ 1.4712,  1.6762,  1.8831,  2.1114,  2.3230,  2.5297,  2.7365,  2.9270,
+ 0.1405,  0.3109,  0.4986,  0.6891,  0.8634,  1.0583,  1.2594,  1.4349,
+ 1.6232,  1.8116,  1.9905,  2.1935,  2.3799,  2.5656,  2.7661,  2.9486,
+ 0.1703,  0.3057,  0.4403,  0.5225,  0.5969,  0.8110,  1.0729,  1.3215,
+ 1.5407,  1.7381,  1.9477,  2.1680,  2.3586,  2.5612,  2.7630,  2.9410,
+ 0.1128,  0.2628,  0.4523,  0.6495,  0.8176,  0.9816,  1.1746,  1.3710,
+ 1.5568,  1.7518,  1.9497,  2.1452,  2.3346,  2.5389,  2.7362,  2.9264,
+ 0.1809,  0.3287,  0.5205,  0.7264,  0.9298,  1.1217,  1.2970,  1.4894,
+ 1.6874,  1.8493,  2.0576,  2.2382,  2.4097,  2.6041,  2.7796,  2.9389,
+ 0.2502,  0.4709,  0.6892,  0.8346,  0.9209,  1.0455,  1.2399,  1.4616,
+ 1.6463,  1.8380,  2.0475,  2.2397,  2.4665,  2.6550,  2.7701,  2.8895,
+ 0.1040,  0.2340,  0.3964,  0.5740,  0.7764,  0.9941,  1.2000,  1.4014,
+ 1.6024,  1.7974,  1.9939,  2.1959,  2.3783,  2.5663,  2.7613,  2.9484,
+ 0.1912,  0.3393,  0.4743,  0.6313,  0.8014,  0.9879,  1.1855,  1.3922,
+ 1.5678,  1.7289,  1.9271,  2.1165,  2.3089,  2.5414,  2.7448,  2.9269,
+ 0.0965,  0.2025,  0.3398,  0.4990,  0.6934,  0.9386,  1.1730,  1.3766,
+ 1.5783,  1.7783,  1.9790,  2.1831,  2.3670,  2.5578,  2.7641,  2.9516,
+ 0.2126,  0.3652,  0.5545,  0.7170,  0.8674,  1.0640,  1.2558,  1.4061,
+ 1.5904,  1.8095,  1.9760,  2.1505,  2.3549,  2.5575,  2.7023,  2.8877,
+ 0.1827,  0.3426,  0.4894,  0.6488,  0.7960,  0.9535,  1.1217,  1.2798,
+ 1.4566,  1.6453,  1.8044,  2.0042,  2.2379,  2.4611,  2.6697,  2.8966,
+ 0.2034,  0.3822,  0.5231,  0.6960,  0.9200,  1.0394,  1.1616,  1.3772,
+ 1.5493,  1.7330,  1.9646,  2.1233,  2.3334,  2.5361,  2.7087,  2.9470,
+ 0.1050,  0.2060,  0.3705,  0.5998,  0.8337,  1.0577,  1.2559,  1.4327,
+ 1.6334,  1.8165,  1.9853,  2.2058,  2.4063,  2.5818,  2.7625,  2.9458,
+ 0.1419,  0.4053,  0.6660,  0.8911,  1.0405,  1.1547,  1.2506,  1.3926,
+ 1.5669,  1.7527,  1.9694,  2.2054,  2.3889,  2.5743,  2.7586,  2.9174,
+ 0.1514,  0.2825,  0.4309,  0.5772,  0.7470,  0.9703,  1.1462,  1.3316,
+ 1.5321,  1.7259,  1.9282,  2.1266,  2.3106,  2.5064,  2.7067,  2.9094,
+ 0.1693,  0.3156,  0.4878,  0.6635,  0.8206,  0.9569,  1.1154,  1.3064,
+ 1.5109,  1.7184,  1.9179,  2.1036,  2.2763,  2.4820,  2.6949,  2.9105,
+ 0.1432,  0.2718,  0.4241,  0.5564,  0.6939,  0.9011,  1.1582,  1.3948,
+ 1.6181,  1.8024,  1.9814,  2.1740,  2.3459,  2.5456,  2.7491,  2.9307,
+ 0.2294,  0.3857,  0.5590,  0.7434,  0.9189,  1.0941,  1.2740,  1.4456,
+ 1.6178,  1.7994,  1.9689,  2.1644,  2.3525,  2.5385,  2.7468,  2.9405,
+ 0.1667,  0.3109,  0.4612,  0.6032,  0.7375,  0.8866,  1.0840,  1.3053,
+ 1.4982,  1.7044,  1.9146,  2.1117,  2.2942,  2.4983,  2.7084,  2.9132,
+ 0.1810,  0.3205,  0.4696,  0.6231,  0.7641,  0.9959,  1.2427,  1.4361,
+ 1.5889,  1.7544,  1.9083,  2.0733,  2.2457,  2.4461,  2.6793,  2.9098,
+ 0.1164,  0.3753,  0.6068,  0.7503,  1.0100,  1.2131,  1.3793,  1.5302,
+ 1.6300,  1.7950,  1.9057,  2.1031,  2.3830,  2.5745,  2.6949,  2.8779,
+ 0.1571,  0.4378,  0.6735,  0.8312,  0.8944,  0.9818,  1.1622,  1.4094,
+ 1.6423,  1.8066,  1.9258,  2.1838,  2.4363,  2.6279,  2.7358,  2.8790,
+ 0.1398,  0.2686,  0.4248,  0.6156,  0.7870,  1.0035,  1.2012,  1.3689,
+ 1.5363,  1.7398,  1.9604,  2.1619,  2.3345,  2.5097,  2.7271,  2.9368,
+ 0.1913,  0.3338,  0.4987,  0.6446,  0.7852,  1.0163,  1.1886,  1.3610,
+ 1.5379,  1.7230,  1.8880,  2.0862,  2.2960,  2.4928,  2.7122,  2.9151,
+ 0.0908,  0.1752,  0.2899,  0.5365,  0.7761,  1.0100,  1.2124,  1.4060,
+ 1.6019,  1.8010,  1.9774,  2.1905,  2.3733,  2.5623,  2.7660,  2.9565,
+ 0.1773,  0.3179,  0.4925,  0.6864,  0.8452,  0.9897,  1.1860,  1.3722,
+ 1.5515,  1.7658,  1.9802,  2.1819,  2.3620,  2.5442,  2.7250,  2.9220,
+ 0.1286,  0.2341,  0.3689,  0.5364,  0.7176,  0.9350,  1.1083,  1.2943,
+ 1.4974,  1.7059,  1.9047,  2.1145,  2.3242,  2.5361,  2.7453,  2.9329,
+ 0.2273,  0.3834,  0.5565,  0.7192,  0.8431,  0.9962,  1.1763,  1.3571,
+ 1.5774,  1.7419,  1.9202,  2.1131,  2.2919,  2.4898,  2.6895,  2.9180,
+ 0.1775,  0.3058,  0.4274,  0.6023,  0.8151,  1.0734,  1.3211,  1.5178,
+ 1.6706,  1.8154,  1.9686,  2.1537,  2.3461,  2.5276,  2.7181,  2.9121,
+ 0.1653,  0.4304,  0.6361,  0.7824,  0.9183,  1.0452,  1.2071,  1.4077,
+ 1.6206,  1.8299,  2.0089,  2.1948,  2.3900,  2.5982,  2.7844,  2.9487,
+ 0.1492,  0.2609,  0.3820,  0.5485,  0.7243,  0.9319,  1.1538,  1.3579,
+ 1.5266,  1.7002,  1.8873,  2.1016,  2.3175,  2.5221,  2.7241,  2.9243,
+ 0.2074,  0.3781,  0.5209,  0.6869,  0.8577,  0.9875,  1.1849,  1.3568,
+ 1.4907,  1.7335,  1.8902,  2.1224,  2.3099,  2.4918,  2.7023,  2.8765,
+ 0.1359,  0.2254,  0.3286,  0.4432,  0.6586,  0.8964,  1.1125,  1.3523,
+ 1.5626,  1.7579,  1.9846,  2.1905,  2.3548,  2.5542,  2.7663,  2.9346,
+ 0.1430,  0.2966,  0.4685,  0.6493,  0.8315,  1.0304,  1.2220,  1.4082,
+ 1.5995,  1.7888,  1.9774,  2.1737,  2.3607,  2.5577,  2.7558,  2.9405,
+ 0.1477,  0.2694,  0.4056,  0.5626,  0.7051,  0.8647,  1.0491,  1.2488,
+ 1.4814,  1.7072,  1.9150,  2.1147,  2.3038,  2.5144,  2.7184,  2.9202,
+ 0.1690,  0.3033,  0.4580,  0.6686,  0.8536,  1.0293,  1.2124,  1.3998,
+ 1.5718,  1.7607,  1.9580,  2.1245,  2.2971,  2.4762,  2.6896,  2.9177,
+ 0.1092,  0.2779,  0.4853,  0.6880,  0.9011,  1.0953,  1.2752,  1.4618,
+ 1.6623,  1.8484,  2.0264,  2.2152,  2.4017,  2.5835,  2.7671,  2.9436,
+ 0.1497,  0.3637,  0.6014,  0.8032,  0.9963,  1.1835,  1.3741,  1.5698,
+ 1.7382,  1.9094,  2.0710,  2.2392,  2.4082,  2.5926,  2.7762,  2.9536,
+ 0.1434,  0.2492,  0.3966,  0.5934,  0.8033,  1.0657,  1.2796,  1.4276,
+ 1.5745,  1.7833,  1.9288,  2.1247,  2.3543,  2.5412,  2.7049,  2.8872,
+ 0.1612,  0.2926,  0.4574,  0.6387,  0.8265,  1.0180,  1.1808,  1.3526,
+ 1.5564,  1.7536,  1.9187,  2.1192,  2.3149,  2.5006,  2.7101,  2.9217,
+ 0.0828,  0.1863,  0.3235,  0.5050,  0.7250,  0.9867,  1.2093,  1.3941,
+ 1.5980,  1.7932,  1.9809,  2.1894,  2.3918,  2.5773,  2.7540,  2.9329,
+ 0.2001,  0.3655,  0.5290,  0.6761,  0.8027,  0.9972,  1.2090,  1.4255,
+ 1.6085,  1.7825,  1.9804,  2.1681,  2.3457,  2.5325,  2.7319,  2.9196,
+ 0.1505,  0.2767,  0.4254,  0.6054,  0.7821,  0.9567,  1.1294,  1.3080,
+ 1.4984,  1.6954,  1.8666,  2.0736,  2.2875,  2.4969,  2.7072,  2.9163,
+ 0.1589,  0.4151,  0.5749,  0.6651,  0.8061,  1.0470,  1.2616,  1.3690,
+ 1.4985,  1.7808,  1.9825,  2.1068,  2.2751,  2.5448,  2.7133,  2.8689,
+ 0.0916,  0.1846,  0.3788,  0.6329,  0.8774,  1.0687,  1.2653,  1.4561,
+ 1.6573,  1.8449,  2.0402,  2.2254,  2.3968,  2.5861,  2.7792,  2.9508,
+ 0.2282,  0.4159,  0.5834,  0.6899,  0.8108,  1.0321,  1.2795,  1.5262,
+ 1.6936,  1.8469,  2.0922,  2.2607,  2.3795,  2.5301,  2.7386,  2.9530,
+ 0.1651,  0.3004,  0.4555,  0.6179,  0.7891,  0.9584,  1.1372,  1.3707,
+ 1.5951,  1.7880,  1.9434,  2.1465,  2.3311,  2.5081,  2.6977,  2.8970,
+ 0.1279,  0.3828,  0.6330,  0.8323,  0.9652,  1.1175,  1.2319,  1.3511,
+ 1.5115,  1.6392,  1.7835,  1.9558,  2.2008,  2.4635,  2.6910,  2.9058,
+ 0.1193,  0.2185,  0.3521,  0.5311,  0.7378,  0.9239,  1.1105,  1.3217,
+ 1.5362,  1.7504,  1.9536,  2.1627,  2.3560,  2.5506,  2.7548,  2.9453,
+ 0.1806,  0.3432,  0.4981,  0.6948,  0.8928,  1.0527,  1.2467,  1.4140,
+ 1.6326,  1.7950,  1.9935,  2.1969,  2.3512,  2.5682,  2.7445,  2.9277,
+ 0.1846,  0.3112,  0.4568,  0.5891,  0.7317,  0.8493,  1.0204,  1.2022,
+ 1.3688,  1.6020,  1.8428,  2.0710,  2.2725,  2.4879,  2.7057,  2.9160,
+ 0.0880,  0.2514,  0.5332,  0.7272,  0.8906,  1.1354,  1.3199,  1.4941,
+ 1.6010,  1.7151,  1.8712,  2.0643,  2.2755,  2.5375,  2.7054,  2.8891,
+ 0.1382,  0.2833,  0.4658,  0.6897,  0.9071,  1.0716,  1.2469,  1.4143,
+ 1.5910,  1.7947,  1.9805,  2.1581,  2.3338,  2.5215,  2.7292,  2.9211,
+ 0.1061,  0.3494,  0.6327,  0.8570,  0.9748,  1.0560,  1.1529,  1.3250,
+ 1.6032,  1.8340,  1.9711,  2.1157,  2.3011,  2.5464,  2.8078,  2.9803,
+ 0.1603,  0.2839,  0.4307,  0.5980,  0.7980,  1.0399,  1.1971,  1.3524,
+ 1.5715,  1.7838,  1.9468,  2.1498,  2.3627,  2.5514,  2.7327,  2.9148,
+ 0.1691,  0.3117,  0.4796,  0.6895,  0.8732,  1.0164,  1.1916,  1.3707,
+ 1.5384,  1.7202,  1.8857,  2.0672,  2.2487,  2.4593,  2.6789,  2.8940,
+ 0.0965,  0.1702,  0.3191,  0.5721,  0.8100,  1.0241,  1.2272,  1.4196,
+ 1.6093,  1.8057,  1.9884,  2.2037,  2.3925,  2.5805,  2.7578,  2.9366,
+ 0.1950,  0.3519,  0.5272,  0.6973,  0.8732,  1.0656,  1.2112,  1.3959,
+ 1.6116,  1.7821,  1.9445,  2.1592,  2.3348,  2.5142,  2.7440,  2.9297,
+ 0.1388,  0.2557,  0.4120,  0.5727,  0.7354,  0.9196,  1.0985,  1.2805,
+ 1.4643,  1.6535,  1.8340,  2.0546,  2.2758,  2.4778,  2.6921,  2.9122,
+ 0.1823,  0.3336,  0.4957,  0.6771,  0.8563,  1.0137,  1.2299,  1.3849,
+ 1.5718,  1.7667,  1.9193,  2.1326,  2.3135,  2.5268,  2.7133,  2.8998,
+ 0.0790,  0.1901,  0.4083,  0.6456,  0.8463,  1.0285,  1.2297,  1.4181,
+ 1.6159,  1.8056,  1.9971,  2.1912,  2.3816,  2.5746,  2.7692,  2.9497,
+ 0.0049,  0.0116,  0.0045,  0.0039, -0.0010, -0.0122, -0.0205, -0.0034,
+-0.0140, -0.0041,  0.0191, -0.0322,  0.0002, -0.0124, -0.0269,  0.0059,
+ 0.0586,  0.0339, -0.0389, -0.0319, -0.0079, -0.0205, -0.0363, -0.0211,
+ 0.0241,  0.0595,  0.0469,  0.0283,  0.0176, -0.0183, -0.0173, -0.0004,
+ 0.0024,  0.0145,  0.0534,  0.0197, -0.0065, -0.0067,  0.0133,  0.0358,
+-0.0104, -0.0386, -0.0109, -0.0078,  0.0275,  0.0565,  0.0251, -0.0027,
+-0.0053,  0.0171,  0.0088,  0.0495,  0.0141,  0.0039, -0.0445, -0.0426,
+-0.0184, -0.0280, -0.0223,  0.0039, -0.0171, -0.0606, -0.0786, -0.0430,
+ 0.0544,  0.0595,  0.0320, -0.0012,  0.0108,  0.0185,  0.0066,  0.0408,
+ 0.0552, -0.0073, -0.0247, -0.0480, -0.0288,  0.0186,  0.0212, -0.0013,
+ 0.0403,  0.0598,  0.0690,  0.0516, -0.0298, -0.0177,  0.0278,  0.0168,
+-0.0106,  0.0251,  0.0386,  0.0331, -0.0052,  0.0133,  0.0291, -0.0158,
+-0.0329, -0.0367,  0.0287,  0.0462, -0.0176,  0.0049,  0.0242, -0.0034,
+ 0.0135,  0.0086, -0.0149,  0.0241,  0.0504,  0.0246, -0.0273, -0.0369,
+-0.0108, -0.0449, -0.0625, -0.0414, -0.0292, -0.0571, -0.0440, -0.0088,
+ 0.0098,  0.0009, -0.0004,  0.0007, -0.0314, -0.0208, -0.0138, -0.0277,
+-0.0044,  0.0522,  0.0315, -0.0270, -0.0277, -0.0256, -0.0103, -0.0201,
+-0.0287, -0.0279, -0.0182,  0.0472,  0.0613,  0.0450,  0.0413,  0.0333,
+ 0.0444,  0.0223,  0.0061,  0.0316,  0.0321,  0.0501,  0.0460,  0.0250,
+ 0.0227,  0.0235,  0.0099,  0.0185, -0.0347, -0.0684, -0.0189,  0.0242,
+-0.0190, -0.0273, -0.0012, -0.0253,  0.0293, -0.0231, -0.0219, -0.0010,
+ 0.0153,  0.0128, -0.0166, -0.0435, -0.0417, -0.0121, -0.0351, -0.0390,
+ 0.0077, -0.0278, -0.0355,  0.0092, -0.0063,  0.0005,  0.0216,  0.0461,
+ 0.0538,  0.0451,  0.0298, -0.0130,  0.0058,  0.0206,  0.0471,  0.0499,
+ 0.0280,  0.0086, -0.0007, -0.0317,  0.0259,  0.0176,  0.0043,  0.0212,
+ 0.0138,  0.0106,  0.0220, -0.0025,  0.0050,  0.0122, -0.0051, -0.0086,
+-0.0472, -0.0005,  0.0193,  0.0032,  0.0246,  0.0222,  0.0090, -0.0320,
+-0.0713, -0.0526, -0.0151, -0.0440, -0.0648, -0.0466, -0.0092,  0.0115,
+-0.0129,  0.0053, -0.0344, -0.0385,  0.0392,  0.0599,  0.0414,  0.0165,
+-0.0098, -0.0320, -0.0261, -0.0055, -0.0139, -0.0110,  0.0084,  0.0172,
+-0.0492, -0.0537, -0.0320, -0.0036,  0.0265,  0.0385,  0.0064, -0.0280,
+-0.0230,  0.0134,  0.0241,  0.0106,  0.0387,  0.0105,  0.0068,  0.0260,
+ 0.4940,  0.4911,  0.4849,  0.4820,  0.4837,  0.4839,  0.4824,  0.4799,
+ 0.4812,  0.4782,  0.4788,  0.4711,  0.4706,  0.4671,  0.4601,  0.4578,
+ 0.2954,  0.2121,  0.1859,  0.1958,  0.1474,  0.1086,  0.1351,  0.1362,
+ 0.1486,  0.1342,  0.1215,  0.1423,  0.1634,  0.1588,  0.1539,  0.1857
+},
+
+.lsp16 = {
+ 0.1813,  0.3911,  0.6301,  0.8012,  1.0057,  1.2041,  1.4271,  1.6943,
+ 1.9402,  2.1733,  2.3521,  2.4989,  2.5839,  2.6846,  2.7634,  2.8950,
+ 0.1311,  0.3183,  0.4659,  0.5601,  0.6658,  0.7828,  1.0065,  1.2717,
+ 1.5185,  1.7339,  1.9530,  2.2189,  2.3739,  2.4991,  2.6984,  2.9256,
+ 0.1627,  0.4519,  0.6323,  0.7012,  0.7848,  0.9801,  1.1810,  1.3222,
+ 1.5413,  1.8129,  1.9338,  2.0809,  2.3180,  2.5189,  2.7066,  2.9514,
+ 0.1475,  0.2447,  0.4240,  0.5669,  0.7872,  0.9838,  1.1823,  1.3814,
+ 1.5358,  1.6820,  1.8794,  2.1419,  2.4132,  2.6112,  2.7911,  2.9511,
+ 0.1224,  0.2876,  0.5013,  0.6985,  0.8902,  1.0901,  1.2835,  1.4768,
+ 1.6596,  1.8538,  2.0467,  2.2304,  2.4124,  2.5942,  2.7729,  2.9531,
+ 0.1741,  0.3034,  0.4677,  0.5879,  0.7258,  0.9648,  1.1417,  1.3220,
+ 1.5081,  1.7151,  1.9212,  2.1286,  2.3208,  2.4938,  2.6765,  2.8891,
+ 0.1657,  0.3174,  0.4907,  0.6559,  0.8295,  1.0254,  1.2071,  1.3880,
+ 1.5737,  1.7845,  1.9027,  2.1139,  2.3323,  2.5157,  2.7323,  2.9015,
+ 0.1592,  0.2758,  0.4417,  0.6315,  0.8257,  0.9873,  1.1277,  1.2830,
+ 1.4337,  1.6315,  1.8899,  2.1356,  2.3572,  2.5632,  2.7468,  2.9420,
+ 0.1524,  0.4325,  0.5931,  0.7036,  0.7696,  0.8923,  1.1739,  1.4773,
+ 1.6609,  1.7911,  1.9666,  2.1972,  2.3754,  2.5045,  2.6613,  2.8882,
+ 0.2130,  0.3013,  0.3721,  0.4257,  0.5079,  0.7015,  0.9815,  1.2554,
+ 1.4648,  1.6966,  1.9138,  2.1075,  2.3318,  2.5292,  2.7453,  2.9347,
+ 0.1142,  0.3748,  0.6205,  0.7642,  0.8121,  0.9022,  0.9843,  1.1558,
+ 1.4467,  1.7422,  1.9574,  2.1302,  2.3812,  2.5898,  2.7720,  2.9583,
+ 0.1255,  0.2339,  0.3570,  0.5323,  0.7458,  1.0003,  1.1729,  1.3567,
+ 1.5217,  1.6977,  1.8924,  2.0942,  2.3145,  2.5408,  2.7553,  2.9337,
+ 0.1316,  0.2289,  0.4327,  0.6663,  0.8509,  0.9994,  1.1697,  1.3804,
+ 1.5609,  1.6903,  1.8572,  2.1019,  2.3687,  2.5789,  2.7715,  2.9472,
+ 0.1502,  0.2546,  0.3883,  0.5333,  0.6976,  0.9163,  1.1071,  1.3364,
+ 1.5420,  1.7525,  1.8948,  2.0839,  2.2819,  2.4651,  2.6875,  2.8987,
+ 0.1593,  0.3014,  0.4573,  0.6354,  0.8157,  0.9805,  1.1783,  1.3747,
+ 1.5678,  1.7326,  1.9286,  2.1340,  2.3253,  2.5280,  2.7180,  2.9298,
+ 0.1811,  0.3167,  0.4655,  0.6507,  0.8198,  1.0075,  1.1892,  1.3743,
+ 1.5227,  1.7090,  1.8849,  2.0743,  2.2750,  2.4830,  2.6896,  2.8953,
+ 0.1846,  0.3577,  0.5315,  0.7290,  0.9176,  1.1016,  1.2654,  1.4525,
+ 1.6315,  1.8268,  2.0238,  2.1934,  2.3868,  2.5753,  2.7682,  2.9469,
+ 0.0876,  0.1439,  0.2048,  0.3654,  0.6281,  0.8853,  1.0907,  1.2992,
+ 1.5227,  1.7373,  1.9395,  2.1419,  2.3488,  2.5486,  2.7466,  2.9348,
+ 0.1391,  0.4170,  0.6561,  0.7953,  0.8734,  0.9986,  1.1870,  1.4520,
+ 1.6042,  1.7910,  2.0135,  2.1870,  2.3358,  2.5066,  2.7409,  2.9955,
+ 0.0804,  0.1355,  0.2599,  0.4998,  0.7408,  0.9474,  1.1276,  1.3428,
+ 1.5556,  1.7712,  1.9699,  2.1535,  2.3605,  2.5548,  2.7489,  2.9325,
+ 0.1304,  0.3087,  0.4979,  0.6584,  0.8414,  1.0329,  1.2244,  1.4189,
+ 1.6118,  1.8200,  1.9985,  2.1893,  2.3915,  2.5794,  2.7647,  2.9344,
+ 0.1895,  0.2849,  0.3705,  0.4126,  0.6265,  0.9207,  1.1774,  1.3762,
+ 1.5757,  1.7728,  1.9568,  2.1662,  2.3615,  2.5575,  2.7561,  2.9416,
+ 0.1800,  0.3078,  0.4805,  0.6796,  0.8503,  1.0046,  1.1703,  1.3269,
+ 1.4862,  1.6502,  1.8454,  2.0873,  2.3175,  2.5356,  2.7516,  2.9469,
+ 0.1950,  0.3233,  0.4568,  0.5940,  0.7589,  0.9978,  1.1701,  1.3383,
+ 1.5017,  1.6565,  1.8243,  2.0605,  2.2938,  2.5147,  2.7419,  2.9396,
+ 0.2531,  0.4391,  0.5790,  0.7170,  0.8998,  1.1430,  1.3577,  1.5326,
+ 1.6328,  1.7627,  1.9726,  2.1762,  2.3563,  2.5478,  2.7385,  2.9067,
+ 0.1805,  0.2788,  0.3591,  0.3881,  0.5441,  0.8055,  1.0766,  1.3165,
+ 1.5316,  1.7508,  1.9477,  2.1374,  2.3438,  2.5484,  2.7501,  2.9410,
+ 0.2044,  0.3671,  0.5396,  0.7042,  0.8582,  0.9831,  1.1261,  1.3194,
+ 1.4769,  1.6979,  1.8717,  2.0463,  2.2620,  2.4739,  2.7054,  2.9208,
+ 0.1048,  0.2175,  0.4206,  0.5923,  0.7483,  0.9400,  1.1356,  1.3799,
+ 1.5958,  1.7320,  1.8984,  2.1296,  2.3594,  2.5492,  2.7387,  2.9305,
+ 0.0842,  0.1729,  0.3951,  0.6447,  0.8688,  1.0605,  1.2472,  1.4330,
+ 1.6232,  1.8144,  2.0216,  2.1915,  2.3878,  2.5763,  2.7685,  2.9464,
+ 0.1461,  0.2593,  0.4105,  0.5677,  0.7328,  0.8919,  1.0484,  1.2302,
+ 1.4386,  1.6635,  1.8873,  2.1024,  2.3116,  2.5268,  2.7273,  2.9269,
+ 0.1503,  0.3108,  0.4756,  0.6731,  0.8600,  1.0233,  1.2115,  1.3971,
+ 1.5915,  1.7892,  1.9517,  2.1603,  2.3487,  2.5460,  2.7308,  2.8998,
+ 0.2163,  0.3669,  0.5125,  0.6709,  0.8143,  0.9930,  1.2095,  1.4205,
+ 1.6176,  1.7112,  1.8398,  2.0896,  2.3513,  2.5290,  2.6667,  2.8960,
+ 0.2133,  0.4382,  0.6287,  0.8702,  1.1088,  1.3749,  1.6062,  1.7446,
+ 1.8333,  1.9122,  1.9614,  2.0669,  2.1789,  2.3449,  2.6038,  2.8849,
+ 0.1598,  0.2719,  0.3877,  0.4815,  0.5926,  0.7795,  1.0449,  1.3045,
+ 1.5210,  1.7391,  1.9462,  2.1397,  2.3553,  2.5458,  2.7540,  2.9392,
+ 0.2918,  0.5607,  0.6801,  0.7404,  0.8285,  0.9431,  1.1579,  1.4080,
+ 1.6332,  1.8472,  1.9738,  2.0771,  2.2890,  2.5178,  2.7445,  2.9830,
+ 0.1664,  0.2842,  0.3965,  0.5463,  0.8162,  1.0346,  1.1849,  1.3446,
+ 1.5122,  1.7563,  1.9960,  2.2002,  2.3796,  2.5689,  2.7712,  2.9550,
+ 0.0911,  0.2397,  0.5052,  0.7868,  1.0299,  1.1311,  1.2244,  1.3333,
+ 1.4395,  1.6790,  1.9369,  2.1717,  2.3689,  2.5538,  2.7340,  2.9326,
+ 0.1647,  0.2931,  0.3836,  0.4978,  0.6255,  0.9243,  1.1339,  1.3001,
+ 1.5269,  1.8010,  1.9715,  2.1419,  2.3784,  2.5503,  2.6719,  2.8745,
+ 0.2440,  0.3802,  0.4756,  0.6613,  0.8627,  1.0292,  1.2291,  1.4060,
+ 1.5198,  1.7354,  1.9044,  2.1010,  2.3147,  2.4996,  2.7171,  2.9041,
+ 0.1590,  0.2876,  0.4572,  0.5996,  0.7713,  0.9490,  1.1205,  1.2815,
+ 1.4516,  1.6385,  1.8179,  2.0457,  2.2759,  2.4785,  2.6861,  2.9080,
+ 0.2297,  0.4309,  0.5712,  0.6717,  0.8138,  1.0463,  1.2492,  1.4560,
+ 1.6796,  1.8458,  1.9642,  2.1452,  2.3636,  2.5395,  2.7456,  2.9495,
+ 0.2975,  0.4678,  0.4996,  0.5809,  0.6279,  0.6884,  0.8606,  1.1386,
+ 1.4412,  1.6876,  1.8760,  2.0932,  2.3178,  2.5166,  2.7345,  2.9280,
+ 0.1278,  0.3737,  0.6004,  0.7069,  0.8147,  1.0180,  1.2581,  1.3812,
+ 1.4855,  1.7268,  1.9970,  2.1258,  2.2936,  2.5702,  2.7563,  2.8983,
+ 0.1314,  0.2508,  0.3999,  0.5680,  0.7424,  0.9367,  1.1286,  1.3175,
+ 1.5336,  1.7404,  1.9317,  2.1404,  2.3514,  2.5562,  2.7510,  2.9402,
+ 0.1043,  0.2367,  0.4293,  0.6376,  0.8160,  0.9836,  1.1779,  1.3850,
+ 1.5835,  1.7875,  1.9765,  2.1593,  2.3654,  2.5577,  2.7465,  2.9398,
+ 0.1529,  0.2515,  0.3454,  0.4374,  0.7011,  0.9015,  1.0744,  1.3532,
+ 1.5699,  1.7545,  2.0021,  2.1259,  2.2278,  2.4546,  2.7264,  2.9425,
+ 0.1429,  0.2808,  0.4395,  0.6334,  0.8069,  0.9705,  1.1520,  1.3250,
+ 1.5109,  1.7285,  1.9356,  2.1469,  2.3479,  2.5554,  2.7512,  2.9348,
+ 0.1625,  0.3022,  0.4756,  0.6315,  0.8032,  0.9924,  1.1596,  1.3204,
+ 1.4994,  1.6929,  1.8955,  2.1090,  2.3025,  2.5018,  2.6908,  2.8980,
+ 0.1692,  0.3427,  0.5228,  0.7756,  0.9688,  1.0950,  1.3056,  1.4360,
+ 1.5675,  1.8049,  1.9376,  2.1151,  2.3407,  2.5012,  2.7192,  2.9258,
+ 0.0474,  0.1251,  0.1939,  0.3841,  0.6501,  0.9231,  1.1153,  1.3240,
+ 1.5478,  1.7599,  1.9651,  2.1510,  2.3645,  2.5552,  2.7542,  2.9393,
+ 0.2196,  0.4656,  0.7492,  0.9922,  1.1678,  1.2489,  1.3112,  1.3657,
+ 1.4223,  1.5302,  1.7212,  1.9996,  2.2523,  2.4844,  2.7036,  2.9145,
+ 0.1128,  0.2368,  0.3704,  0.5476,  0.7723,  0.9968,  1.1930,  1.3992,
+ 1.6013,  1.7957,  1.9888,  2.1857,  2.3825,  2.5705,  2.7616,  2.9434,
+ 0.1341,  0.2768,  0.4510,  0.6359,  0.8332,  1.0335,  1.2004,  1.3952,
+ 1.5762,  1.7681,  1.9815,  2.1735,  2.3657,  2.5552,  2.7514,  2.9498,
+ 0.1247,  0.2559,  0.3516,  0.4726,  0.6861,  0.9483,  1.1852,  1.3858,
+ 1.5851,  1.7815,  1.9778,  2.1737,  2.3729,  2.5664,  2.7620,  2.9429,
+ 0.1988,  0.3320,  0.4777,  0.6737,  0.8425,  1.0265,  1.1694,  1.3655,
+ 1.5463,  1.7135,  1.9385,  2.1650,  2.3529,  2.5367,  2.7545,  2.9585,
+ 0.1376,  0.2620,  0.4273,  0.6169,  0.7755,  0.9441,  1.1169,  1.3157,
+ 1.5179,  1.7020,  1.8931,  2.1059,  2.3112,  2.5136,  2.7169,  2.9198,
+ 0.2112,  0.4385,  0.6091,  0.7618,  0.9553,  1.1543,  1.3445,  1.5396,
+ 1.7153,  1.9192,  2.1263,  2.3593,  2.5958,  2.8171,  2.9394,  3.0409,
+ 0.1347,  0.2099,  0.2646,  0.3453,  0.5266,  0.7869,  1.0513,  1.2795,
+ 1.4880,  1.7181,  1.9294,  2.1332,  2.3362,  2.5442,  2.7433,  2.9362,
+ 0.3141,  0.5935,  0.7517,  0.8313,  0.8568,  0.9570,  1.0250,  1.1275,
+ 1.3422,  1.6303,  1.8577,  2.0705,  2.2957,  2.5095,  2.7244,  2.9262,
+ 0.0962,  0.2116,  0.3961,  0.5641,  0.7122,  0.8883,  1.1023,  1.3481,
+ 1.5623,  1.7554,  1.9618,  2.1675,  2.3706,  2.5556,  2.7430,  2.9337,
+ 0.0898,  0.1510,  0.3060,  0.5820,  0.8221,  1.0388,  1.2261,  1.4289,
+ 1.6054,  1.8103,  1.9941,  2.1844,  2.3742,  2.5711,  2.7632,  2.9474,
+ 0.1326,  0.2316,  0.3761,  0.5177,  0.6782,  0.8761,  1.0952,  1.3175,
+ 1.5078,  1.7034,  1.9051,  2.1245,  2.3424,  2.5484,  2.7444,  2.9389,
+ 0.1740,  0.3293,  0.5174,  0.6824,  0.8394,  1.0372,  1.2046,  1.3723,
+ 1.5656,  1.7444,  1.9442,  2.1386,  2.3139,  2.4960,  2.7071,  2.9297,
+ 0.2304,  0.3775,  0.4865,  0.6182,  0.7842,  0.9208,  1.1151,  1.2843,
+ 1.4641,  1.6988,  1.9209,  2.1260,  2.3099,  2.5229,  2.7414,  2.9276,
+ 0.0094,  0.0261, -0.0037,  0.0041, -0.0092, -0.0044, -0.0232, -0.0073,
+-0.0047, -0.0021,  0.0250, -0.0580, -0.0140, -0.0342, -0.0586,  0.0020,
+ 0.0449,  0.0155, -0.0523, -0.0279,  0.0299, -0.0183, -0.0736, -0.0639,
+-0.0017,  0.0336,  0.0209,  0.0046,  0.0077, -0.0148, -0.0114, -0.0120,
+ 0.0115, -0.0050,  0.0445,  0.0048,  0.0188, -0.0137, -0.0080,  0.0239,
+-0.0184, -0.0524, -0.0195, -0.0126,  0.0284,  0.0632,  0.0141, -0.0093,
+-0.0096,  0.0196,  0.0230,  0.0379,  0.0308,  0.0237, -0.0224, -0.0600,
+-0.0755, -0.1074, -0.0988, -0.0606, -0.1038, -0.1552, -0.1480, -0.0672,
+ 0.0504,  0.0676,  0.0336, -0.0042,  0.0729,  0.1013,  0.0868,  0.0846,
+ 0.0954,  0.0515, -0.0066, -0.0851, -0.0485,  0.0294,  0.0395,  0.0087,
+ 0.0078,  0.0446,  0.0881,  0.0672, -0.0384, -0.0025,  0.0415,  0.0353,
+ 0.0080,  0.0052,  0.0190,  0.0182,  0.0069,  0.0168,  0.0374,  0.0037,
+-0.0292, -0.0429,  0.0302,  0.0681, -0.0233, -0.0238, -0.0003, -0.0043,
+ 0.0054, -0.0029, -0.0149,  0.0642,  0.0622,  0.0341, -0.0232, -0.0461,
+-0.0082, -0.0469, -0.0618, -0.0326, -0.0452, -0.0649, -0.0597, -0.0398,
+-0.0318, -0.0116,  0.0011,  0.0009, -0.0384, -0.0384, -0.0156, -0.0260,
+-0.0007,  0.0473,  0.0111, -0.0358, -0.0484, -0.0204, -0.0029, -0.0090,
+-0.0285, -0.0495, -0.0376,  0.0917,  0.1192,  0.1026,  0.0745,  0.0397,
+ 0.0463,  0.0253,  0.0025,  0.0465,  0.0100,  0.0488,  0.0416,  0.0223,
+ 0.0263,  0.0072, -0.0053,  0.0595,  0.0060, -0.0518, -0.0316, -0.0043,
+-0.0133, -0.0233, -0.0075, -0.0251,  0.0277, -0.0067, -0.0136, -0.0004,
+ 0.0235,  0.0112, -0.0182, -0.0324, -0.0210, -0.0035, -0.0395, -0.0384,
+ 0.0005, -0.0150, -0.0356,  0.0127, -0.0033, -0.0034,  0.0205,  0.0747,
+ 0.1138,  0.1015,  0.0995, -0.0161, -0.0045,  0.0129,  0.0472,  0.0575,
+ 0.0222,  0.0091,  0.0037, -0.0471,  0.0371,  0.0132,  0.0208,  0.0247,
+ 0.0117,  0.0164,  0.0225,  0.0124, -0.0023,  0.0088, -0.0046,  0.0047,
+-0.0393,  0.0018,  0.0148,  0.0020,  0.0044,  0.0165,  0.0229, -0.0208,
+-0.0477, -0.0310, -0.0164, -0.0390, -0.0764, -0.0525, -0.0094,  0.0075,
+-0.0102, -0.0045, -0.0504, -0.0709,  0.0822,  0.0710,  0.0426,  0.0014,
+-0.0371, -0.0400, -0.0157, -0.0155, -0.0173, -0.0138, -0.0015,  0.0134,
+-0.0418, -0.0682, -0.0256,  0.0050,  0.0360,  0.0354,  0.0074, -0.0396,
+-0.0235,  0.0284,  0.0494,  0.0153,  0.0448,  0.0025, -0.0061,  0.0252,
+ 0.1000,  0.2260,  0.2158,  0.2116,  0.2198,  0.2055,  0.2110,  0.1873,
+ 0.1907,  0.2071,  0.2164,  0.2009,  0.2059,  0.2124,  0.2141,  0.2093,
+ 0.0875,  0.0981,  0.1177,  0.1071,  0.1033,  0.1248,  0.1048,  0.1238,
+ 0.1166,  0.1008,  0.1062,  0.0992,  0.0994,  0.1067,  0.0999,  0.1187,
+ 0.0750,  0.0794,  0.0828,  0.0854,  0.0859,  0.0801,  0.0891,  0.0933,
+ 0.0969,  0.0920,  0.0915,  0.0862,  0.0868,  0.0891,  0.0842,  0.0824,
+ 0.0625,  0.0930,  0.0815,  0.0853,  0.0898,  0.0828,  0.0822,  0.0910,
+ 0.0873,  0.0906,  0.0856,  0.0840,  0.0774,  0.0785,  0.0684,  0.0711,
+ 0.3319,  0.4219,  0.4588,  0.4090,  0.4092,  0.4014,  0.3548,  0.3353,
+ 0.3708,  0.3352,  0.3720,  0.3538,  0.4084,  0.4289,  0.4060,  0.4210,
+ 0.0588,  0.0209, -0.0082, -0.0115, -0.0343, -0.0621, -0.0541, -0.0346,
+-0.0346, -0.0366, -0.0220, -0.0265, -0.0102,  0.0374,  0.0306,  0.0404,
+ 0.0306,  0.0090, -0.0054,  0.0333,  0.0047,  0.0238,  0.0141,  0.0165,
+ 0.0306,  0.0420,  0.0159,  0.0124,  0.0414,  0.0158, -0.0237,  0.0141,
+ 0.0765,  0.0057, -0.0260, -0.0426, -0.0395, -0.0126, -0.0579, -0.0417
+},
+
+.lsp22_1 = {
+ 0.0664,  0.1875,  0.4300,  0.6730,  0.8793,  1.0640,  1.2563,  1.4433,
+ 1.6394,  1.8176,  2.0029,  2.1921,  2.3796,  2.5671,  2.7595,  2.9536,
+ 0.2128,  0.4052,  0.5311,  0.6404,  0.7875,  0.8775,  1.0974,  1.3261,
+ 1.5563,  1.6790,  1.8339,  2.1195,  2.3226,  2.4609,  2.6440,  2.8947,
+ 0.2024,  0.3362,  0.4834,  0.6784,  0.9088,  1.0850,  1.2188,  1.4054,
+ 1.6102,  1.7767,  1.9679,  2.1436,  2.3445,  2.5467,  2.7429,  2.9320,
+ 0.1181,  0.2279,  0.4413,  0.6114,  0.7710,  0.9427,  1.1142,  1.2707,
+ 1.4892,  1.7416,  1.9526,  2.1466,  2.3629,  2.5445,  2.7293,  2.9205,
+ 0.1155,  0.2720,  0.4886,  0.6812,  0.8594,  1.0422,  1.2315,  1.4116,
+ 1.6137,  1.8020,  1.9758,  2.1743,  2.3602,  2.5568,  2.7472,  2.9374,
+ 0.1110,  0.3312,  0.4735,  0.5612,  0.7129,  0.8146,  1.0233,  1.3155,
+ 1.5765,  1.7746,  1.9574,  2.1416,  2.3220,  2.5384,  2.7334,  2.9318,
+ 0.1656,  0.3350,  0.4215,  0.5609,  0.6759,  0.8503,  1.1405,  1.4094,
+ 1.6057,  1.6860,  1.7639,  2.0031,  2.2680,  2.5076,  2.7263,  2.9368,
+ 0.1466,  0.3638,  0.4587,  0.5674,  0.7381,  0.8669,  0.9619,  1.1658,
+ 1.4667,  1.7440,  1.9335,  2.1018,  2.3022,  2.5281,  2.7359,  2.9261,
+ 0.1061,  0.2566,  0.4739,  0.6751,  0.8711,  1.0704,  1.2720,  1.4655,
+ 1.6605,  1.8494,  2.0290,  2.2197,  2.4008,  2.5912,  2.7772,  2.9513,
+ 0.1116,  0.2364,  0.3971,  0.6316,  0.8583,  1.0335,  1.1686,  1.3302,
+ 1.5612,  1.7877,  1.9829,  2.2052,  2.3596,  2.5460,  2.7341,  2.9290,
+ 0.2661,  0.4186,  0.5126,  0.6477,  0.8818,  1.1045,  1.2852,  1.4128,
+ 1.5851,  1.7593,  1.9399,  2.1757,  2.3684,  2.5136,  2.6927,  2.9064,
+ 0.1495,  0.2749,  0.4391,  0.6304,  0.8239,  1.0181,  1.1995,  1.3759,
+ 1.5669,  1.7722,  1.9671,  2.1635,  2.3586,  2.5528,  2.7445,  2.9311,
+ 0.0912,  0.1759,  0.3066,  0.5660,  0.8005,  0.9568,  1.1832,  1.4504,
+ 1.6259,  1.7948,  2.0113,  2.2002,  2.3654,  2.5583,  2.7929,  2.9735,
+ 0.1353,  0.2747,  0.4078,  0.5977,  0.7658,  0.9124,  1.1081,  1.3630,
+ 1.5875,  1.7847,  1.9323,  2.1181,  2.3321,  2.5046,  2.7183,  2.9225,
+ 0.1938,  0.4063,  0.4982,  0.6002,  0.7702,  0.9071,  1.1631,  1.3885,
+ 1.6043,  1.8118,  1.9306,  2.0893,  2.2724,  2.4609,  2.6283,  2.8802,
+ 0.1857,  0.3351,  0.4381,  0.6101,  0.7561,  0.8555,  1.0384,  1.3171,
+ 1.5667,  1.6904,  1.7552,  1.9689,  2.2597,  2.5260,  2.7272,  2.9337,
+ 0.1037,  0.2159,  0.4188,  0.6174,  0.8035,  1.0285,  1.2256,  1.4230,
+ 1.6400,  1.8322,  2.0144,  2.1988,  2.3810,  2.5682,  2.7613,  2.9438,
+ 0.1625,  0.2776,  0.4225,  0.6001,  0.7879,  0.9087,  1.0801,  1.2759,
+ 1.4899,  1.7448,  1.9911,  2.1770,  2.3723,  2.5777,  2.7971,  2.9444,
+ 0.2111,  0.3640,  0.5839,  0.7290,  0.8051,  1.0023,  1.2315,  1.4143,
+ 1.5878,  1.7755,  1.9804,  2.1498,  2.3312,  2.5350,  2.7613,  2.9472,
+ 0.1423,  0.2646,  0.4136,  0.6350,  0.8070,  0.9514,  1.1168,  1.3213,
+ 1.5776,  1.7721,  1.9404,  2.1545,  2.3385,  2.5137,  2.7396,  2.9553,
+ 0.1132,  0.2386,  0.4103,  0.5931,  0.7808,  0.9881,  1.1840,  1.3860,
+ 1.6021,  1.7990,  1.9922,  2.1885,  2.3852,  2.5717,  2.7640,  2.9510,
+ 0.1267,  0.2602,  0.3913,  0.5944,  0.7598,  0.9198,  1.0781,  1.2715,
+ 1.5299,  1.7573,  1.9308,  2.1346,  2.3267,  2.5419,  2.7466,  2.9320,
+ 0.2023,  0.3417,  0.4392,  0.6141,  0.7439,  0.8593,  1.1096,  1.3543,
+ 1.5185,  1.6553,  1.7862,  2.0341,  2.2718,  2.4834,  2.7103,  2.9466,
+ 0.1113,  0.2470,  0.3677,  0.5686,  0.7700,  0.9356,  1.0806,  1.2452,
+ 1.4830,  1.7344,  1.9268,  2.1404,  2.3371,  2.5169,  2.7329,  2.9012,
+ 0.1664,  0.3554,  0.5573,  0.7471,  0.9245,  1.0998,  1.2787,  1.4655,
+ 1.6654,  1.8346,  2.0179,  2.2159,  2.4096,  2.5946,  2.7790,  2.9530,
+ 0.1313,  0.2625,  0.4731,  0.6444,  0.8110,  0.9878,  1.1493,  1.3212,
+ 1.5719,  1.8138,  1.9861,  2.1943,  2.3714,  2.5578,  2.7346,  2.9296,
+ 0.1186,  0.3035,  0.5049,  0.6860,  0.8670,  0.9975,  1.1364,  1.3471,
+ 1.5695,  1.7412,  1.9346,  2.1506,  2.3413,  2.5531,  2.7794,  2.9627,
+ 0.1108,  0.2697,  0.4787,  0.6344,  0.7909,  0.9586,  1.1440,  1.3511,
+ 1.5686,  1.7601,  1.9246,  2.1241,  2.3293,  2.5390,  2.7315,  2.9333,
+ 0.0985,  0.2302,  0.3544,  0.5759,  0.7620,  0.9651,  1.1497,  1.3080,
+ 1.5500,  1.7845,  1.9518,  2.1734,  2.3565,  2.5665,  2.7605,  2.9102,
+ 0.1208,  0.2727,  0.4381,  0.5736,  0.7382,  0.8390,  1.0102,  1.2648,
+ 1.5100,  1.7440,  1.9619,  2.1430,  2.3307,  2.5159,  2.7264,  2.9211,
+ 0.1582,  0.2777,  0.4475,  0.6551,  0.8591,  1.0084,  1.1414,  1.3291,
+ 1.5902,  1.7826,  1.9543,  2.1659,  2.3233,  2.5044,  2.6935,  2.9199,
+ 0.1360,  0.2873,  0.4585,  0.6295,  0.7592,  0.9089,  1.0492,  1.2733,
+ 1.5391,  1.7768,  1.9372,  2.1329,  2.3168,  2.5015,  2.6857,  2.8837,
+ 0.0886,  0.1829,  0.3696,  0.6126,  0.8334,  1.0135,  1.2303,  1.4674,
+ 1.6743,  1.8564,  2.0530,  2.2370,  2.3960,  2.5787,  2.7756,  2.9377,
+ 0.2005,  0.3537,  0.4700,  0.6249,  0.7385,  0.9097,  1.1759,  1.3811,
+ 1.5314,  1.6705,  1.8546,  2.1229,  2.3292,  2.5251,  2.7951,  2.9646,
+ 0.1999,  0.3112,  0.4722,  0.7146,  0.8908,  1.0028,  1.1831,  1.3903,
+ 1.6125,  1.7514,  1.9083,  2.1248,  2.3271,  2.5339,  2.6945,  2.8918,
+ 0.1243,  0.2606,  0.4382,  0.5850,  0.7705,  0.9727,  1.1214,  1.3059,
+ 1.5218,  1.7406,  1.9137,  2.1353,  2.3354,  2.5299,  2.7287,  2.9068,
+ 0.1039,  0.2426,  0.4265,  0.6284,  0.8152,  0.9941,  1.2004,  1.4038,
+ 1.5912,  1.7763,  1.9650,  2.1598,  2.3474,  2.5488,  2.7419,  2.9322,
+ 0.1364,  0.2420,  0.3886,  0.5864,  0.7663,  0.8844,  1.0860,  1.3242,
+ 1.5518,  1.7893,  2.0004,  2.1562,  2.3619,  2.5516,  2.7687,  2.9181,
+ 0.1483,  0.2851,  0.4479,  0.6312,  0.7924,  0.9821,  1.1705,  1.3386,
+ 1.5375,  1.7226,  1.9053,  2.0991,  2.2898,  2.4953,  2.7000,  2.9146,
+ 0.2332,  0.4561,  0.5407,  0.6212,  0.7524,  0.8215,  0.9522,  1.1685,
+ 1.5216,  1.7132,  1.8291,  2.0647,  2.2811,  2.4857,  2.7071,  2.9281,
+ 0.1348,  0.3126,  0.5179,  0.7192,  0.9227,  1.1363,  1.3223,  1.4756,
+ 1.6509,  1.8191,  1.9991,  2.1976,  2.3877,  2.5768,  2.7590,  2.9386,
+ 0.1093,  0.2211,  0.4763,  0.6703,  0.8282,  0.9536,  1.1202,  1.3796,
+ 1.6043,  1.8031,  1.9832,  2.1604,  2.3578,  2.5856,  2.7650,  2.9291,
+ 0.1865,  0.3027,  0.4580,  0.6719,  0.8400,  1.0082,  1.1901,  1.3782,
+ 1.5448,  1.6885,  1.9477,  2.1381,  2.2797,  2.5113,  2.7465,  2.9414,
+ 0.1575,  0.3124,  0.4649,  0.6262,  0.8095,  0.9858,  1.1676,  1.3602,
+ 1.5646,  1.7582,  1.9550,  2.1671,  2.3628,  2.5734,  2.7670,  2.9519,
+ 0.1174,  0.2777,  0.4663,  0.6333,  0.8169,  1.0096,  1.1885,  1.3847,
+ 1.5803,  1.7571,  1.9380,  2.1398,  2.3414,  2.5407,  2.7360,  2.9375,
+ 0.1073,  0.2264,  0.4083,  0.5973,  0.7474,  0.9514,  1.1349,  1.3337,
+ 1.5433,  1.7348,  1.9380,  2.1436,  2.3441,  2.5438,  2.7457,  2.9383,
+ 0.1472,  0.2880,  0.4793,  0.6268,  0.8015,  1.0063,  1.1715,  1.3644,
+ 1.5525,  1.7410,  1.9258,  2.1227,  2.3214,  2.5149,  2.7148,  2.9196,
+ 0.1414,  0.2565,  0.4349,  0.6111,  0.7695,  0.9496,  1.1212,  1.3265,
+ 1.5218,  1.7209,  1.9015,  2.0887,  2.3158,  2.5077,  2.7233,  2.9421,
+ 0.1252,  0.2667,  0.4454,  0.6431,  0.8371,  1.0124,  1.2110,  1.4160,
+ 1.6240,  1.8242,  2.0047,  2.1974,  2.3902,  2.5778,  2.7637,  2.9481,
+ 0.1321,  0.2565,  0.3846,  0.5847,  0.7578,  0.9259,  1.0637,  1.2239,
+ 1.4690,  1.7346,  1.9750,  2.1882,  2.3712,  2.5509,  2.7280,  2.8885,
+ 0.1437,  0.2930,  0.4428,  0.6156,  0.8045,  0.9638,  1.1450,  1.3138,
+ 1.5144,  1.7355,  1.9469,  2.1534,  2.3414,  2.5452,  2.7353,  2.9334,
+ 0.1692,  0.2770,  0.3831,  0.6100,  0.7825,  0.9302,  1.0690,  1.2481,
+ 1.4615,  1.6799,  1.9165,  2.1739,  2.3435,  2.5349,  2.7520,  2.9163,
+ 0.1235,  0.2489,  0.4354,  0.6343,  0.8236,  1.0066,  1.1908,  1.3474,
+ 1.5656,  1.8275,  2.0620,  2.2548,  2.4135,  2.5913,  2.7639,  2.9334,
+ 0.1090,  0.1961,  0.3854,  0.5701,  0.7024,  0.8843,  1.1393,  1.3785,
+ 1.5940,  1.7797,  1.9442,  2.1740,  2.3853,  2.5773,  2.7727,  2.9406,
+ 0.1560,  0.3477,  0.5011,  0.6287,  0.7612,  0.9896,  1.1510,  1.3420,
+ 1.5435,  1.6816,  1.8731,  2.0651,  2.2613,  2.4999,  2.7027,  2.8971,
+ 0.1459,  0.2416,  0.3833,  0.5450,  0.7916,  0.9223,  1.0662,  1.1953,
+ 1.4029,  1.6616,  1.9320,  2.1459,  2.3386,  2.5081,  2.6799,  2.9195,
+ 0.1546,  0.3854,  0.6184,  0.8460,  1.0599,  1.2428,  1.3906,  1.5550,
+ 1.7388,  1.8945,  2.0757,  2.2386,  2.4014,  2.5705,  2.7574,  2.9400,
+ 0.1080,  0.2307,  0.4112,  0.6067,  0.7725,  0.9467,  1.1285,  1.3205,
+ 1.5348,  1.7609,  1.9937,  2.1878,  2.3583,  2.5515,  2.7199,  2.9049,
+ 0.1482,  0.3178,  0.4983,  0.6342,  0.7783,  0.9880,  1.2019,  1.3404,
+ 1.5223,  1.7296,  1.9211,  2.0943,  2.2928,  2.5008,  2.7136,  2.9224,
+ 0.1145,  0.2910,  0.4891,  0.6492,  0.8126,  0.9530,  1.1180,  1.3155,
+ 1.5054,  1.6893,  1.8899,  2.1188,  2.3389,  2.5512,  2.7313,  2.9224,
+ 0.0939,  0.1689,  0.3250,  0.5792,  0.7698,  0.9245,  1.1574,  1.3865,
+ 1.5959,  1.7977,  1.9821,  2.1528,  2.3326,  2.5540,  2.7553,  2.9179,
+ 0.1243,  0.2474,  0.3923,  0.6199,  0.7908,  0.9379,  1.1497,  1.3734,
+ 1.5582,  1.7420,  1.9539,  2.1385,  2.3240,  2.5277,  2.7311,  2.9178,
+ 0.1961,  0.3748,  0.5176,  0.6387,  0.8169,  1.0477,  1.2124,  1.3869,
+ 1.5604,  1.7225,  1.8770,  2.0837,  2.2960,  2.5103,  2.6945,  2.8862,
+ 0.1295,  0.2403,  0.4149,  0.6189,  0.7913,  0.9130,  1.0832,  1.2787,
+ 1.4860,  1.7112,  1.9502,  2.1348,  2.2776,  2.4982,  2.7431,  2.9522,
+ 0.0160,  0.0362,  0.0097,  0.0057, -0.0014, -0.0073, -0.0046, -0.0064,
+-0.0121,  0.0019,  0.0149, -0.0440, -0.0479, -0.0382, -0.0480, -0.0182,
+ 0.0170,  0.0114, -0.0298, -0.0175, -0.0033, -0.0354, -0.0510, -0.0025,
+ 0.0307,  0.0351,  0.0338,  0.0420,  0.0138, -0.0175, -0.0102,  0.0053,
+ 0.0084, -0.0003,  0.0412, -0.0027,  0.0145, -0.0039,  0.0083,  0.0400,
+ 0.0001, -0.0262,  0.0055, -0.0082,  0.0348,  0.0433,  0.0137, -0.0024,
+-0.0055,  0.0262,  0.0521,  0.0349,  0.0185,  0.0076, -0.0319, -0.0561,
+-0.0460, -0.0253, -0.0097,  0.0163,  0.0184, -0.0037, -0.0480, -0.0371,
+ 0.0628,  0.0665,  0.0296, -0.0057,  0.0253,  0.0227,  0.0350,  0.0692,
+ 0.0545,  0.0218,  0.0094, -0.0449, -0.0372,  0.0005,  0.0258,  0.0118,
+ 0.0285,  0.0760,  0.0822,  0.0527, -0.0299, -0.0049,  0.0170,  0.0195,
+ 0.0136,  0.0286,  0.0289,  0.0139,  0.0054,  0.0152,  0.0244,  0.0028,
+-0.0056, -0.0260,  0.0307,  0.0572, -0.0087,  0.0088,  0.0062,  0.0000,
+ 0.0125,  0.0000, -0.0292,  0.0820,  0.0872,  0.0646,  0.0346,  0.0076,
+-0.0022, -0.0253, -0.0567, -0.0188, -0.0336, -0.0673, -0.0549, -0.0166,
+-0.0259, -0.0140,  0.0040, -0.0029, -0.0430, -0.0531, -0.0253, -0.0019,
+-0.0071,  0.0393,  0.0072, -0.0327, -0.0236, -0.0235, -0.0177, -0.0186,
+-0.0280, -0.0201, -0.0077,  0.0383,  0.0418,  0.0321,  0.0294,  0.0169,
+ 0.0468,  0.0301,  0.0133,  0.0363,  0.0516,  0.0937,  0.1240,  0.1404,
+ 0.1325,  0.1178,  0.0999,  0.0251, -0.0037, -0.0495, -0.0703, -0.0219,
+-0.0261, -0.0304, -0.0204, -0.0372,  0.0355,  0.0131, -0.0093, -0.0099,
+-0.0069, -0.0034, -0.0065, -0.0208, -0.0231, -0.0117, -0.0211, -0.0243,
+ 0.0046, -0.0107, -0.0070,  0.0123,  0.0230,  0.0152,  0.0164,  0.0412,
+ 0.0619,  0.0858,  0.0862, -0.0056,  0.0125,  0.0182,  0.0347,  0.0388,
+ 0.0456,  0.0407, -0.0249, -0.0460,  0.0206,  0.0299,  0.0253,  0.0207,
+ 0.0177,  0.0238,  0.0253,  0.0030,  0.0042,  0.0020, -0.0081, -0.0136,
+-0.0290, -0.0042,  0.0122,  0.0051,  0.0107,  0.0228,  0.0211, -0.0068,
+-0.0436, -0.0299, -0.0078, -0.0779, -0.1157, -0.0679,  0.0172,  0.0150,
+-0.0051,  0.0081, -0.0512, -0.0616,  0.0576,  0.0799,  0.0803,  0.0336,
+ 0.0001, -0.0298, -0.0747, -0.0115, -0.0101, -0.0170, -0.0050,  0.0174,
+-0.0290, -0.0601, -0.0150,  0.0121,  0.0165,  0.0230,  0.0028, -0.0317,
+-0.0165,  0.0356,  0.0451,  0.0120,  0.0321,  0.0084, -0.0058,  0.0122,
+ 0.1935,  0.1802,  0.2195,  0.2410,  0.2201,  0.1915,  0.1840,  0.1935,
+ 0.2213,  0.2079,  0.1858,  0.1974,  0.2239,  0.2173,  0.1840,  0.2120,
+ 0.4912,  0.4777,  0.4607,  0.4395,  0.4426,  0.4388,  0.4416,  0.4345,
+ 0.4239,  0.4331,  0.4522,  0.4423,  0.4475,  0.4387,  0.4525,  0.4446
+},
+
 .lsp22_2 = {
  0.0712,  0.1830,  0.4167,  0.6669,  0.8738,  1.0696,  1.2555,  1.4426,
  1.6427,  1.8138,  1.9966,  2.1925,  2.3872,  2.5748,  2.7713,  2.9597,
@@ -10198,6 +10781,213 @@
  0.4938,  0.4951,  0.4994,  0.4971,  0.4981,  0.4983,  0.4967,  0.4789
 },
 
+.lsp44 = {
+ 0.0927,  0.2291,  0.4059,  0.5779,  0.7288,  0.8821,  1.0377,  1.1915,
+ 1.3433,  1.4931,  1.6475,  1.7989,  1.9381,  2.0858,  2.2321,  2.3765,
+ 2.5187,  2.6530,  2.7895,  2.9354,  0.0944,  0.1974,  0.3046,  0.4714,
+ 0.6116,  0.7829,  0.9027,  1.0375,  1.1869,  1.3488,  1.5036,  1.6781,
+ 1.8276,  1.9983,  2.1449,  2.3089,  2.4534,  2.6113,  2.7553,  2.9062,
+ 0.1168,  0.2843,  0.4907,  0.6706,  0.8100,  0.9417,  1.0753,  1.2014,
+ 1.3151,  1.4496,  1.5832,  1.7379,  1.8642,  2.0230,  2.1681,  2.3250,
+ 2.4676,  2.6242,  2.7602,  2.9066,  0.1353,  0.2335,  0.3370,  0.4380,
+ 0.5819,  0.7353,  0.8671,  1.0160,  1.1435,  1.2977,  1.4860,  1.6739,
+ 1.8412,  2.0028,  2.1537,  2.3124,  2.4741,  2.6272,  2.7862,  2.9536,
+ 0.1003,  0.2226,  0.3584,  0.4971,  0.6291,  0.7710,  0.9157,  1.0669,
+ 1.2143,  1.3624,  1.5104,  1.6681,  1.8164,  1.9823,  2.1394,  2.3082,
+ 2.4677,  2.6306,  2.7909,  2.9382,  0.1056,  0.2027,  0.2956,  0.4005,
+ 0.5215,  0.6708,  0.8545,  1.0557,  1.2344,  1.4023,  1.5676,  1.7278,
+ 1.8808,  2.0381,  2.1846,  2.3376,  2.4887,  2.6377,  2.7878,  2.9504,
+ 0.1015,  0.2462,  0.4122,  0.5783,  0.7233,  0.8833,  1.0377,  1.1903,
+ 1.3341,  1.4727,  1.6138,  1.7582,  1.8912,  2.0370,  2.1701,  2.3125,
+ 2.4500,  2.6006,  2.7507,  2.9166,  0.1787,  0.2418,  0.3265,  0.5379,
+ 0.6584,  0.7681,  0.9545,  1.1050,  1.2125,  1.3528,  1.4763,  1.6705,
+ 1.8136,  1.9594,  2.0936,  2.2724,  2.4394,  2.5919,  2.7037,  2.8747,
+ 0.0859,  0.1600,  0.2980,  0.4933,  0.6696,  0.8285,  0.9958,  1.1545,
+ 1.3107,  1.4591,  1.6127,  1.7652,  1.9143,  2.0680,  2.2171,  2.3643,
+ 2.5141,  2.6611,  2.8143,  2.9691,  0.0910,  0.2110,  0.3364,  0.4718,
+ 0.5856,  0.7298,  0.8910,  1.0514,  1.1988,  1.3572,  1.5178,  1.6861,
+ 1.8399,  2.0099,  2.1639,  2.3225,  2.4774,  2.6321,  2.7863,  2.9412,
+ 0.1904,  0.2874,  0.3681,  0.4981,  0.6248,  0.7880,  0.9121,  1.0750,
+ 1.2185,  1.3809,  1.5296,  1.7007,  1.8592,  2.0470,  2.1913,  2.3250,
+ 2.4519,  2.5984,  2.7408,  2.9023,  0.0917,  0.2067,  0.3246,  0.4961,
+ 0.6310,  0.8024,  0.9438,  1.1008,  1.2362,  1.3892,  1.5407,  1.7033,
+ 1.8427,  2.0061,  2.1498,  2.3117,  2.4550,  2.6053,  2.7462,  2.9029,
+ 0.0989,  0.2193,  0.3756,  0.5410,  0.6929,  0.8368,  0.9801,  1.1250,
+ 1.2677,  1.4184,  1.5677,  1.7292,  1.8770,  2.0311,  2.1803,  2.3306,
+ 2.4836,  2.6339,  2.7943,  2.9549,  0.0861,  0.1943,  0.3057,  0.4867,
+ 0.6194,  0.7592,  0.9184,  1.1052,  1.2486,  1.4064,  1.5609,  1.7273,
+ 1.8703,  2.0291,  2.1686,  2.3225,  2.4628,  2.6115,  2.7471,  2.9005,
+ 0.0932,  0.2110,  0.3737,  0.5479,  0.7120,  0.8570,  0.9975,  1.1364,
+ 1.2772,  1.4220,  1.5612,  1.7089,  1.8410,  1.9827,  2.1263,  2.2859,
+ 2.4459,  2.6172,  2.7788,  2.9395,  0.1193,  0.2341,  0.3523,  0.5029,
+ 0.6437,  0.7803,  0.9367,  1.1007,  1.2392,  1.3869,  1.5425,  1.7168,
+ 1.8709,  2.0248,  2.1584,  2.2949,  2.4308,  2.5823,  2.7235,  2.9034,
+ 0.0834,  0.1988,  0.3557,  0.5261,  0.6767,  0.8427,  1.0029,  1.1683,
+ 1.3138,  1.4527,  1.6046,  1.7583,  1.9011,  2.0517,  2.1928,  2.3397,
+ 2.4839,  2.6291,  2.7771,  2.9329,  0.0938,  0.1967,  0.3213,  0.4675,
+ 0.6068,  0.7664,  0.9418,  1.1120,  1.2535,  1.3932,  1.5243,  1.6801,
+ 1.8346,  1.9931,  2.1376,  2.3035,  2.4636,  2.6244,  2.7829,  2.9371,
+ 0.1017,  0.2552,  0.4327,  0.6017,  0.7467,  0.8797,  1.0097,  1.1442,
+ 1.2628,  1.4049,  1.5541,  1.7090,  1.8461,  1.9982,  2.1486,  2.3029,
+ 2.4513,  2.6075,  2.7594,  2.9209,  0.1031,  0.2295,  0.3747,  0.5122,
+ 0.6596,  0.7935,  0.9345,  1.1050,  1.2384,  1.3543,  1.4739,  1.6136,
+ 1.7447,  1.8914,  2.0434,  2.1916,  2.3557,  2.5396,  2.7419,  2.9401,
+ 0.1007,  0.2374,  0.3715,  0.5173,  0.6465,  0.8069,  0.9553,  1.1145,
+ 1.2594,  1.4143,  1.5617,  1.7166,  1.8457,  2.0012,  2.1462,  2.2864,
+ 2.4258,  2.5910,  2.7372,  2.9018,  0.0808,  0.1726,  0.2849,  0.4592,
+ 0.6118,  0.7853,  0.9588,  1.1256,  1.2751,  1.4392,  1.5898,  1.7514,
+ 1.8977,  2.0554,  2.1937,  2.3430,  2.4831,  2.6249,  2.7601,  2.9155,
+ 0.1669,  0.2574,  0.3694,  0.5569,  0.6773,  0.8061,  1.0160,  1.1667,
+ 1.2791,  1.4041,  1.5452,  1.7207,  1.8524,  2.0038,  2.1414,  2.3338,
+ 2.4747,  2.6157,  2.7303,  2.8848,  0.1598,  0.2521,  0.3416,  0.5149,
+ 0.6703,  0.7941,  0.9408,  1.1164,  1.2017,  1.3293,  1.4908,  1.6783,
+ 1.8438,  1.9927,  2.1149,  2.2698,  2.4420,  2.6193,  2.7583,  2.9103,
+ 0.0902,  0.1978,  0.3265,  0.4578,  0.5878,  0.7439,  0.9110,  1.0906,
+ 1.2556,  1.4125,  1.5688,  1.7295,  1.8829,  2.0472,  2.2058,  2.3537,
+ 2.5075,  2.6548,  2.8058,  2.9538,  0.0818,  0.1695,  0.2794,  0.4470,
+ 0.6069,  0.7641,  0.9313,  1.0946,  1.2411,  1.4072,  1.5640,  1.7186,
+ 1.8651,  2.0254,  2.1726,  2.3286,  2.4784,  2.6287,  2.7750,  2.9339,
+ 0.1980,  0.3134,  0.4099,  0.4975,  0.6491,  0.8376,  0.9441,  1.0298,
+ 1.1795,  1.3866,  1.5784,  1.7209,  1.8137,  1.9271,  2.0863,  2.2930,
+ 2.4696,  2.6184,  2.7587,  2.9251,  0.1338,  0.2341,  0.3566,  0.4797,
+ 0.6129,  0.7580,  0.9093,  1.0491,  1.1911,  1.3313,  1.4841,  1.6503,
+ 1.8035,  1.9685,  2.1128,  2.2694,  2.4093,  2.5728,  2.7206,  2.8994,
+ 0.0937,  0.2034,  0.3447,  0.5032,  0.6370,  0.7993,  0.9674,  1.1323,
+ 1.2830,  1.4199,  1.5492,  1.7010,  1.8513,  2.0087,  2.1550,  2.3115,
+ 2.4643,  2.6237,  2.7812,  2.9392,  0.1085,  0.2152,  0.3126,  0.4569,
+ 0.5718,  0.7213,  0.8837,  1.0604,  1.2053,  1.3755,  1.5397,  1.7001,
+ 1.8409,  2.0039,  2.1498,  2.3080,  2.4535,  2.6063,  2.7505,  2.9110,
+ 0.0562,  0.2066,  0.4034,  0.5490,  0.6682,  0.7924,  0.9495,  1.0800,
+ 1.1869,  1.3156,  1.4834,  1.6619,  1.8404,  2.0199,  2.1509,  2.2755,
+ 2.4072,  2.5580,  2.6993,  2.8913,  0.0939,  0.2303,  0.3742,  0.5260,
+ 0.6662,  0.8294,  0.9769,  1.1315,  1.2792,  1.4153,  1.5436,  1.6701,
+ 1.8215,  1.9920,  2.1310,  2.3005,  2.4534,  2.5786,  2.7204,  2.9068,
+ 0.1005,  0.2442,  0.3898,  0.5398,  0.6958,  0.8474,  1.0008,  1.1556,
+ 1.3020,  1.4456,  1.5954,  1.7470,  1.8922,  2.0500,  2.2019,  2.3492,
+ 2.4963,  2.6412,  2.7890,  2.9423,  0.1022,  0.2031,  0.3213,  0.4402,
+ 0.5637,  0.7117,  0.8673,  1.0242,  1.1727,  1.3206,  1.4846,  1.6465,
+ 1.8015,  1.9655,  2.1233,  2.2873,  2.4464,  2.6074,  2.7685,  2.9409,
+ 0.1985,  0.3497,  0.4622,  0.5982,  0.7489,  0.8752,  0.9925,  1.1679,
+ 1.3288,  1.4606,  1.5820,  1.7492,  1.8922,  2.0511,  2.1780,  2.3373,
+ 2.4760,  2.6233,  2.7466,  2.8978,  0.1284,  0.2433,  0.3630,  0.4852,
+ 0.6117,  0.7460,  0.8904,  1.0360,  1.1738,  1.3142,  1.4696,  1.6185,
+ 1.7719,  1.9318,  2.0961,  2.2697,  2.4408,  2.6046,  2.7681,  2.9451,
+ 0.1042,  0.2286,  0.3598,  0.5064,  0.6438,  0.7899,  0.9350,  1.0891,
+ 1.2323,  1.3807,  1.5225,  1.6747,  1.8153,  1.9669,  2.1145,  2.2832,
+ 2.4430,  2.6085,  2.7748,  2.9346,  0.0780,  0.1724,  0.2440,  0.3489,
+ 0.5280,  0.7426,  0.9272,  1.0914,  1.2562,  1.4188,  1.5804,  1.7376,
+ 1.8909,  2.0473,  2.1946,  2.3457,  2.4950,  2.6424,  2.7926,  2.9549,
+ 0.1103,  0.2608,  0.4087,  0.5538,  0.6923,  0.8418,  0.9940,  1.1507,
+ 1.2919,  1.4406,  1.5802,  1.7262,  1.8638,  2.0085,  2.1572,  2.2975,
+ 2.4329,  2.5866,  2.7380,  2.9107,  0.1297,  0.2532,  0.4003,  0.5329,
+ 0.6733,  0.7950,  0.9557,  1.0859,  1.2235,  1.3538,  1.5037,  1.6389,
+ 1.7964,  1.9285,  2.0898,  2.2541,  2.4231,  2.5711,  2.6875,  2.8947,
+ 0.0871,  0.1968,  0.3425,  0.4949,  0.6424,  0.7959,  0.9534,  1.1132,
+ 1.2656,  1.4229,  1.5785,  1.7271,  1.8729,  2.0355,  2.1998,  2.3562,
+ 2.5151,  2.6663,  2.8145,  2.9534,  0.1038,  0.2204,  0.3248,  0.4566,
+ 0.5947,  0.7443,  0.8811,  1.0379,  1.2031,  1.3772,  1.5430,  1.7092,
+ 1.8625,  2.0322,  2.1904,  2.3417,  2.4960,  2.6458,  2.7979,  2.9485,
+ 0.1329,  0.2763,  0.3943,  0.5147,  0.6512,  0.8071,  0.9410,  1.0879,
+ 1.2298,  1.3850,  1.5282,  1.6674,  1.8137,  1.9993,  2.1344,  2.2749,
+ 2.4257,  2.5863,  2.7410,  2.9184,  0.1052,  0.2142,  0.3584,  0.5033,
+ 0.6387,  0.7804,  0.9320,  1.0780,  1.2172,  1.3764,  1.5421,  1.6887,
+ 1.8246,  1.9833,  2.1245,  2.2797,  2.4237,  2.5779,  2.7257,  2.9097,
+ 0.1092,  0.2676,  0.4071,  0.5355,  0.6661,  0.8142,  0.9621,  1.1173,
+ 1.2628,  1.4185,  1.5696,  1.7220,  1.8595,  2.0178,  2.1720,  2.3221,
+ 2.4718,  2.6259,  2.7775,  2.9334,  0.0929,  0.2017,  0.3073,  0.4570,
+ 0.5775,  0.7635,  0.9299,  1.0832,  1.2334,  1.3935,  1.5420,  1.7112,
+ 1.8601,  2.0309,  2.1735,  2.3230,  2.4543,  2.6034,  2.7418,  2.8988,
+ 0.0775,  0.2005,  0.3490,  0.5200,  0.6747,  0.8383,  0.9885,  1.1738,
+ 1.3141,  1.4236,  1.5892,  1.7402,  1.8474,  2.0210,  2.1593,  2.2730,
+ 2.4235,  2.5604,  2.7128,  2.9005,  0.1104,  0.2292,  0.3353,  0.4732,
+ 0.6152,  0.7675,  0.9164,  1.0907,  1.2594,  1.4064,  1.5218,  1.6426,
+ 1.8018,  1.9937,  2.1362,  2.2961,  2.4523,  2.6083,  2.7613,  2.9202,
+ 0.0826,  0.2000,  0.3384,  0.5144,  0.6694,  0.8377,  0.9870,  1.1461,
+ 1.2950,  1.4495,  1.5872,  1.7387,  1.8793,  2.0329,  2.1723,  2.3114,
+ 2.4415,  2.5908,  2.7354,  2.9028,  0.1063,  0.2268,  0.3442,  0.4735,
+ 0.6116,  0.7507,  0.9028,  1.0768,  1.2426,  1.4052,  1.5566,  1.7015,
+ 1.8243,  1.9742,  2.1276,  2.2824,  2.4262,  2.5953,  2.7627,  2.9290,
+ 0.1150,  0.2814,  0.4543,  0.6095,  0.7373,  0.8592,  0.9908,  1.1108,
+ 1.2339,  1.3590,  1.4864,  1.6168,  1.7392,  1.8752,  2.0212,  2.1688,
+ 2.3128,  2.4869,  2.7019,  2.9239,  0.0948,  0.2074,  0.3433,  0.4943,
+ 0.6346,  0.7645,  0.8809,  1.0610,  1.2307,  1.3487,  1.4655,  1.6186,
+ 1.7534,  1.8859,  2.0486,  2.2200,  2.3835,  2.5581,  2.7565,  2.9502,
+ 0.1062,  0.2239,  0.3683,  0.5197,  0.6704,  0.8184,  0.9642,  1.1127,
+ 1.2556,  1.3976,  1.5405,  1.6940,  1.8375,  1.9888,  2.1377,  2.2980,
+ 2.4555,  2.6184,  2.7849,  2.9452,  0.0888,  0.2005,  0.2847,  0.4322,
+ 0.5763,  0.7577,  0.9262,  1.1095,  1.2719,  1.4331,  1.5843,  1.7452,
+ 1.8845,  2.0385,  2.1805,  2.3345,  2.4750,  2.6217,  2.7555,  2.9013,
+ 0.1713,  0.2617,  0.3868,  0.5859,  0.7073,  0.8535,  1.0593,  1.1778,
+ 1.3109,  1.4508,  1.5910,  1.7463,  1.8911,  2.0651,  2.2035,  2.3355,
+ 2.4947,  2.6440,  2.7424,  2.8943,  0.1346,  0.2549,  0.4089,  0.5488,
+ 0.6949,  0.8394,  0.9810,  1.1145,  1.2528,  1.4044,  1.5423,  1.6872,
+ 1.8274,  1.9726,  2.1403,  2.2809,  2.4128,  2.5564,  2.6887,  2.8895,
+ 0.0776,  0.1621,  0.2553,  0.4191,  0.5988,  0.7921,  0.9651,  1.1350,
+ 1.2930,  1.4475,  1.6011,  1.7585,  1.9068,  2.0638,  2.2102,  2.3594,
+ 2.5096,  2.6581,  2.8099,  2.9654,  0.0864,  0.1778,  0.2854,  0.4235,
+ 0.5568,  0.7220,  0.8963,  1.0609,  1.2217,  1.3830,  1.5422,  1.7018,
+ 1.8551,  2.0206,  2.1783,  2.3328,  2.4869,  2.6366,  2.7923,  2.9539,
+ 0.1144,  0.2576,  0.4186,  0.5594,  0.6875,  0.8221,  0.9598,  1.0944,
+ 1.2273,  1.3713,  1.5152,  1.6628,  1.8070,  1.9525,  2.0965,  2.2535,
+ 2.4132,  2.5725,  2.7250,  2.9150,  0.1079,  0.2221,  0.3334,  0.4845,
+ 0.6083,  0.7516,  0.9018,  1.0594,  1.2060,  1.3673,  1.5212,  1.6880,
+ 1.8208,  1.9831,  2.1269,  2.2909,  2.4366,  2.6027,  2.7339,  2.8924,
+ 0.0994,  0.2233,  0.3634,  0.5145,  0.6568,  0.8131,  0.9746,  1.1296,
+ 1.2666,  1.4116,  1.5748,  1.7264,  1.8649,  2.0217,  2.1716,  2.3293,
+ 2.4900,  2.6455,  2.7818,  2.9362,  0.1120,  0.2079,  0.3128,  0.4124,
+ 0.5291,  0.6816,  0.8478,  1.0150,  1.1772,  1.3456,  1.5208,  1.6882,
+ 1.8458,  2.0078,  2.1627,  2.3198,  2.4733,  2.6251,  2.7796,  2.9489,
+ 0.0853,  0.2030,  0.3669,  0.5326,  0.6678,  0.8086,  0.9526,  1.1142,
+ 1.2551,  1.4158,  1.5694,  1.7073,  1.8431,  1.9686,  2.1153,  2.2376,
+ 2.3686,  2.5591,  2.7320,  2.9104,  0.0905,  0.2166,  0.3539,  0.5201,
+ 0.6700,  0.8346,  0.9883,  1.1457,  1.2714,  1.3845,  1.5172,  1.6688,
+ 1.8008,  1.9535,  2.1019,  2.2708,  2.4135,  2.5974,  2.7486,  2.9033,
+ 0.0084,  0.0374,  0.0164, -0.0153,  0.0288,  0.0107, -0.0255, -0.0242,
+ 0.0000, -0.0055, -0.0081, -0.0075, -0.0022, -0.0052, -0.0069, -0.0017,
+ 0.0003,  0.0091,  0.0028, -0.0027,  0.0085,  0.0043, -0.0235, -0.0411,
+ 0.0202,  0.0359,  0.0376,  0.0321,  0.0306, -0.0358, -0.0276, -0.0090,
+ 0.0032,  0.0048,  0.0309,  0.0332,  0.0284,  0.0237,  0.0051, -0.0101,
+-0.0233, -0.0428, -0.0585, -0.0387,  0.0039,  0.0081,  0.0029, -0.0017,
+-0.0006, -0.0068,  0.0044,  0.0182,  0.0376,  0.0387, -0.0334, -0.0269,
+-0.0182, -0.0069, -0.0026,  0.0035, -0.0049, -0.0212, -0.0408, -0.0245,
+ 0.0186,  0.0189,  0.0153,  0.0120,  0.0157,  0.0055, -0.0046,  0.0179,
+ 0.0284, -0.0032, -0.0261, -0.0205, -0.0039,  0.0174,  0.0299,  0.0207,
+ 0.0012, -0.0056,  0.0010,  0.0141, -0.0119,  0.0190,  0.0315,  0.0033,
+-0.0128,  0.0300,  0.0328,  0.0308,  0.0353,  0.0266,  0.0066, -0.0328,
+-0.0273,  0.0054,  0.0145,  0.0175,  0.0015, -0.0171,  0.0062, -0.0164,
+ 0.0045, -0.0071,  0.0025,  0.0278,  0.0283,  0.0117, -0.0026, -0.0285,
+-0.0408, -0.0366, -0.0059, -0.0208, -0.0354, -0.0334, -0.0263, -0.0064,
+ 0.0072, -0.0006, -0.0235, -0.0037, -0.0307, -0.0294, -0.0163, -0.0197,
+-0.0235,  0.0192,  0.0013, -0.0219, -0.0123, -0.0004, -0.0081, -0.0096,
+-0.0123, -0.0101,  0.0021,  0.0151,  0.0106,  0.0151,  0.0292,  0.0033,
+ 0.0283,  0.0124,  0.0058, -0.0017, -0.0038,  0.0152,  0.0141,  0.0132,
+ 0.0178,  0.0157,  0.0073,  0.0176,  0.0141,  0.0097, -0.0092, -0.0163,
+-0.0230, -0.0134, -0.0099, -0.0147,  0.0040, -0.0183, -0.0175, -0.0080,
+-0.0083, -0.0290, -0.0417, -0.0398, -0.0269, -0.0199, -0.0143, -0.0053,
+-0.0099, -0.0054, -0.0199, -0.0219, -0.0170,  0.0107,  0.0194,  0.0035,
+ 0.0437,  0.0406,  0.0215,  0.0120,  0.0053, -0.0028,  0.0238,  0.0337,
+ 0.0217,  0.0011,  0.0227,  0.0244,  0.0327,  0.0378,  0.0437,  0.0356,
+-0.0033,  0.0113,  0.0407,  0.0334, -0.0125, -0.0003, -0.0141, -0.0273,
+-0.0137, -0.0079, -0.0145, -0.0071,  0.0114,  0.0181,  0.0150,  0.0085,
+-0.0077, -0.0038, -0.0219, -0.0263, -0.0187, -0.0233,  0.0133,  0.0265,
+-0.0156, -0.0091, -0.0110, -0.0016,  0.0143,  0.0177,  0.0240,  0.0082,
+-0.0143, -0.0257, -0.0014,  0.0002,  0.0082,  0.0180,  0.0325,  0.0340,
+-0.0153, -0.0389, -0.0240,  0.0082,  0.0140,  0.0046, -0.0138, -0.0378,
+-0.0366,  0.0297,  0.0252,  0.0078,  0.0063,  0.0006,  0.0044,  0.0074,
+ 0.0094,  0.0113,  0.0105,  0.0137,  0.0438,  0.0262, -0.0078, -0.0185,
+-0.0215, -0.0407, -0.0435, -0.0208, -0.0004, -0.0144, -0.0205, -0.0248,
+-0.0159, -0.0069, -0.0153,  0.0132,  0.0355,  0.0298,  0.0120,  0.0072,
+ 0.0236,  0.0526,  0.0479,  0.0233, -0.0133, -0.0283, -0.0468, -0.0549,
+-0.0370,  0.0032,  0.0056,  0.0023,  0.0050,  0.0024,  0.0279,  0.0116,
+-0.0045, -0.0012,  0.0107,  0.0190,  0.0253,  0.0191,  0.0043,  0.0193,
+-0.0348, -0.0246,  0.0123,  0.0210,  0.0135, -0.0096, -0.0109, -0.0076,
+-0.0156, -0.0290,  0.0160,  0.0194,  0.0219,  0.0259,  0.0250,  0.0195,
+ 0.4948,  0.4961,  0.4940,  0.4878,  0.4849,  0.4727,  0.4571,  0.4551,
+ 0.4534,  0.4468,  0.4412,  0.4354,  0.4298,  0.4272,  0.4498,  0.4506,
+ 0.4560,  0.4592,  0.4758,  0.4941,  0.2476,  0.1771,  0.1974,  0.1881,
+ 0.1667,  0.1826,  0.2067,  0.2031,  0.1734,  0.1534,  0.1415,  0.1761,
+ 0.1897,  0.1772,  0.1651,  0.1247,  0.1041,  0.1231,  0.1809,  0.2234
+    },
 };
 
 static const uint8_t tab7[][35] = {
diff --git a/libavcodec/twinvqdec.c b/libavcodec/twinvqdec.c
index 0c1782e..b13f8a0 100644
--- a/libavcodec/twinvqdec.c
+++ b/libavcodec/twinvqdec.c
@@ -27,7 +27,6 @@
 #include "get_bits.h"
 #include "internal.h"
 #include "twinvq.h"
-#include "metasound_data.h"
 #include "twinvq_data.h"
 
 static const TwinVQModeTab mode_08_08 = {
@@ -36,7 +35,7 @@
         { 2, bark_tab_m08_256, 20, tab.fcb08m, 2, 5, tab.cb0808m0, tab.cb0808m1, 16 },
         { 1, bark_tab_l08_512, 30, tab.fcb08l, 3, 6, tab.cb0808l0, tab.cb0808l1, 17 }
     },
-    512, 12, ff_metasound_lsp8, 1, 5, 3, 3, tab.shape08, 8, 28, 20, 6, 40
+    512, 12, tab.lsp08, 1, 5, 3, 3, tab.shape08, 8, 28, 20, 6, 40
 };
 
 static const TwinVQModeTab mode_11_08 = {
@@ -45,7 +44,7 @@
         { 2, bark_tab_m11_256, 20, tab.fcb11m, 2, 5, tab.cb1108m0, tab.cb1108m1, 24 },
         { 1, bark_tab_l11_512, 30, tab.fcb11l, 3, 6, tab.cb1108l0, tab.cb1108l1, 27 }
     },
-    512, 16, ff_metasound_lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
+    512, 16, tab.lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
 };
 
 static const TwinVQModeTab mode_11_10 = {
@@ -54,7 +53,7 @@
         { 2, bark_tab_m11_256, 20, tab.fcb11m, 2, 5, tab.cb1110m0, tab.cb1110m1, 18 },
         { 1, bark_tab_l11_512, 30, tab.fcb11l, 3, 6, tab.cb1110l0, tab.cb1110l1, 20 }
     },
-    512, 16, ff_metasound_lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
+    512, 16, tab.lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
 };
 
 static const TwinVQModeTab mode_16_16 = {
@@ -63,7 +62,7 @@
         { 2, bark_tab_m16_512,  20, tab.fcb16m, 2, 5, tab.cb1616m0, tab.cb1616m1, 15 },
         { 1, bark_tab_l16_1024, 30, tab.fcb16l, 3, 6, tab.cb1616l0, tab.cb1616l1, 16 }
     },
-    1024, 16, ff_metasound_lsp16, 1, 6, 4, 3, tab.shape16, 9, 56, 60, 7, 180
+    1024, 16, tab.lsp16, 1, 6, 4, 3, tab.shape16, 9, 56, 60, 7, 180
 };
 
 static const TwinVQModeTab mode_22_20 = {
@@ -72,7 +71,7 @@
         { 2, bark_tab_m22_512,  20, tab.fcb22m_1, 2, 6, tab.cb2220m0, tab.cb2220m1, 17 },
         { 1, bark_tab_l22_1024, 32, tab.fcb22l_1, 4, 6, tab.cb2220l0, tab.cb2220l1, 18 }
     },
-    1024, 16, ff_metasound_lsp22, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
+    1024, 16, tab.lsp22_1, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
 };
 
 static const TwinVQModeTab mode_22_24 = {
@@ -81,7 +80,7 @@
         { 2, bark_tab_m22_512,  20, tab.fcb22m_1, 2, 6, tab.cb2224m0, tab.cb2224m1, 14 },
         { 1, bark_tab_l22_1024, 32, tab.fcb22l_1, 4, 6, tab.cb2224l0, tab.cb2224l1, 15 }
     },
-    1024, 16, ff_metasound_lsp22, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
+    1024, 16, tab.lsp22_1, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
 };
 
 static const TwinVQModeTab mode_22_32 = {
@@ -99,7 +98,7 @@
         { 4,  bark_tab_m44_512,  20, tab.fcb44m, 2, 6, tab.cb4440m0, tab.cb4440m1, 17 },
         { 1,  bark_tab_l44_2048, 40, tab.fcb44l, 4, 6, tab.cb4440l0, tab.cb4440l1, 17 }
     },
-    2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
+    2048, 20, tab.lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
 };
 
 static const TwinVQModeTab mode_44_48 = {
@@ -108,7 +107,7 @@
         { 4,  bark_tab_m44_512,  20, tab.fcb44m, 2, 6, tab.cb4448m0, tab.cb4448m1, 14 },
         { 1,  bark_tab_l44_2048, 40, tab.fcb44l, 4, 6, tab.cb4448l0, tab.cb4448l1, 14 }
     },
-    2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
+    2048, 20, tab.lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
 };
 
 /**
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b8a8c0a..0226e36 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -50,6 +50,7 @@
 #include "thread.h"
 #include "frame_thread_encoder.h"
 #include "internal.h"
+#include "packet_internal.h"
 #include "put_bits.h"
 #include "raw.h"
 #include "bytestream.h"
@@ -512,14 +513,7 @@
         break;
     case AVMEDIA_TYPE_AUDIO:
         bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
-        if (bits_per_sample) {
-            bit_rate = ctx->sample_rate * (int64_t)ctx->channels;
-            if (bit_rate > INT64_MAX / bits_per_sample) {
-                bit_rate = 0;
-            } else
-                bit_rate *= bits_per_sample;
-        } else
-            bit_rate = ctx->bit_rate;
+        bit_rate = bits_per_sample ? ctx->sample_rate * (int64_t)ctx->channels * bits_per_sample : ctx->bit_rate;
         break;
     default:
         bit_rate = 0;
@@ -579,24 +573,18 @@
     }
     avctx->internal = avci;
 
-#if FF_API_OLD_ENCDEC
     avci->to_free = av_frame_alloc();
     avci->compat_decode_frame = av_frame_alloc();
     avci->compat_encode_packet = av_packet_alloc();
-    if (!avci->to_free || !avci->compat_decode_frame || !avci->compat_encode_packet) {
-        ret = AVERROR(ENOMEM);
-        goto free_and_end;
-    }
-#endif
     avci->buffer_frame = av_frame_alloc();
     avci->buffer_pkt = av_packet_alloc();
     avci->es.in_frame = av_frame_alloc();
     avci->ds.in_pkt = av_packet_alloc();
     avci->last_pkt_props = av_packet_alloc();
-    avci->pkt_props = av_fifo_alloc(sizeof(*avci->last_pkt_props));
-    if (!avci->buffer_frame || !avci->buffer_pkt          ||
+    if (!avci->compat_decode_frame || !avci->compat_encode_packet ||
+        !avci->buffer_frame || !avci->buffer_pkt          ||
         !avci->es.in_frame  || !avci->ds.in_pkt           ||
-        !avci->last_pkt_props || !avci->pkt_props) {
+        !avci->to_free      || !avci->last_pkt_props) {
         ret = AVERROR(ENOMEM);
         goto free_and_end;
     }
@@ -1070,15 +1058,12 @@
     av_freep(&avctx->priv_data);
     av_freep(&avctx->subtitle_header);
 
-#if FF_API_OLD_ENCDEC
     av_frame_free(&avci->to_free);
     av_frame_free(&avci->compat_decode_frame);
-    av_packet_free(&avci->compat_encode_packet);
-#endif
     av_frame_free(&avci->buffer_frame);
+    av_packet_free(&avci->compat_encode_packet);
     av_packet_free(&avci->buffer_pkt);
     av_packet_free(&avci->last_pkt_props);
-    av_fifo_freep(&avci->pkt_props);
 
     av_packet_free(&avci->ds.in_pkt);
     av_frame_free(&avci->es.in_frame);
@@ -1114,20 +1099,13 @@
     avci->draining_done = 0;
     avci->nb_draining_errors = 0;
     av_frame_unref(avci->buffer_frame);
-#if FF_API_OLD_ENCDEC
     av_frame_unref(avci->compat_decode_frame);
     av_packet_unref(avci->compat_encode_packet);
-#endif
     av_packet_unref(avci->buffer_pkt);
 
     av_packet_unref(avci->last_pkt_props);
-    while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) {
-        av_fifo_generic_read(avci->pkt_props,
-                             avci->last_pkt_props, sizeof(*avci->last_pkt_props),
-                             NULL);
-        av_packet_unref(avci->last_pkt_props);
-    }
-    av_fifo_reset(avci->pkt_props);
+    avpriv_packet_list_free(&avci->pkt_props,
+                            &avci->pkt_props_tail);
 
     av_frame_unref(avci->es.in_frame);
     av_packet_unref(avci->ds.in_pkt);
@@ -1143,12 +1121,8 @@
     if (av_codec_is_decoder(avctx->codec))
         av_bsf_flush(avci->bsf);
 
-#if FF_API_OLD_ENCDEC
-FF_DISABLE_DEPRECATION_WARNINGS
     if (!avctx->refcounted_frames)
         av_frame_unref(avci->to_free);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 }
 
 void avsubtitle_free(AVSubtitle *sub)
@@ -1188,24 +1162,14 @@
             avctx->codec->close(avctx);
         avctx->internal->byte_buffer_size = 0;
         av_freep(&avctx->internal->byte_buffer);
-#if FF_API_OLD_ENCDEC
         av_frame_free(&avctx->internal->to_free);
         av_frame_free(&avctx->internal->compat_decode_frame);
-        av_packet_free(&avctx->internal->compat_encode_packet);
-#endif
         av_frame_free(&avctx->internal->buffer_frame);
+        av_packet_free(&avctx->internal->compat_encode_packet);
         av_packet_free(&avctx->internal->buffer_pkt);
-        av_packet_unref(avctx->internal->last_pkt_props);
-        while (av_fifo_size(avctx->internal->pkt_props) >=
-               sizeof(*avctx->internal->last_pkt_props)) {
-            av_fifo_generic_read(avctx->internal->pkt_props,
-                                 avctx->internal->last_pkt_props,
-                                 sizeof(*avctx->internal->last_pkt_props),
-                                 NULL);
-            av_packet_unref(avctx->internal->last_pkt_props);
-        }
         av_packet_free(&avctx->internal->last_pkt_props);
-        av_fifo_freep(&avctx->internal->pkt_props);
+        avpriv_packet_list_free(&avctx->internal->pkt_props,
+                                &avctx->internal->pkt_props_tail);
 
         av_packet_free(&avctx->internal->ds.in_pkt);
         av_frame_free(&avctx->internal->es.in_frame);
@@ -1561,7 +1525,6 @@
     case AV_CODEC_ID_PCM_VIDC:
     case AV_CODEC_ID_PCM_S8:
     case AV_CODEC_ID_PCM_S8_PLANAR:
-    case AV_CODEC_ID_PCM_SGA:
     case AV_CODEC_ID_PCM_U8:
     case AV_CODEC_ID_SDX2_DPCM:
     case AV_CODEC_ID_DERF_DPCM:
@@ -1683,10 +1646,14 @@
             return 256 * sr / 245;
         else if (id == AV_CODEC_ID_DST)
             return 588 * sr / 44100;
-        else if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
-            if (sr / 22050 > 22)
-                return 0;
-            return (480 << (sr / 22050));
+
+        if (ch > 0) {
+            /* calc from sample rate and channels */
+            if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
+                if (sr / 22050 > 22)
+                    return 0;
+                return (480 << (sr / 22050)) / ch;
+            }
         }
 
         if (id == AV_CODEC_ID_MP3)
@@ -1736,10 +1703,7 @@
                 return frame_bytes / (9 * ch) * 16;
             case AV_CODEC_ID_ADPCM_PSX:
             case AV_CODEC_ID_ADPCM_DTK:
-                frame_bytes /= 16 * ch;
-                if (frame_bytes > INT_MAX / 28)
-                    return 0;
-                return frame_bytes * 28;
+                return frame_bytes / (16 * ch) * 28;
             case AV_CODEC_ID_ADPCM_4XM:
             case AV_CODEC_ID_ADPCM_IMA_DAT4:
             case AV_CODEC_ID_ADPCM_IMA_ISS:
diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
index 1809b48..b76e217 100644
--- a/libavcodec/vaapi_av1.c
+++ b/libavcodec/vaapi_av1.c
@@ -61,7 +61,6 @@
     VADecPictureParameterBufferAV1 pic_param;
     int8_t bit_depth_idx;
     int err = 0;
-    int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain;
     uint8_t remap_lr_type[4] = {AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ};
 
     pic->output_surface = vaapi_av1_surface_id(&s->cur_frame);
@@ -108,8 +107,7 @@
             .subsampling_x              = seq->color_config.subsampling_x,
             .subsampling_y              = seq->color_config.subsampling_y,
             .chroma_sample_position     = seq->color_config.chroma_sample_position,
-            .film_grain_params_present  = seq->film_grain_params_present &&
-                                          !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN),
+            .film_grain_params_present  = seq->film_grain_params_present,
         },
         .seg_info.segment_info_fields.bits = {
             .enabled         = frame_header->segmentation_enabled,
@@ -119,7 +117,7 @@
         },
         .film_grain_info = {
             .film_grain_info_fields.bits = {
-                .apply_grain              = apply_grain,
+                .apply_grain              = film_grain->apply_grain,
                 .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
                 .grain_scaling_minus_8    = film_grain->grain_scaling_minus_8,
                 .ar_coeff_lag             = film_grain->ar_coeff_lag,
@@ -217,7 +215,7 @@
         for (int j = 0; j < 6; j++)
             pic_param.wm[i - 1].wmmat[j] = s->cur_frame.gm_params[i][j];
     }
-    if (apply_grain) {
+    if (film_grain->apply_grain) {
         for (int i = 0; i < film_grain->num_y_points; i++) {
             pic_param.film_grain_info.point_y_value[i] =
                 film_grain->point_y_value[i];
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3c57c07..518e5b2 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
-#include "libavutil/internal.h"
 #include "libavutil/log.h"
 #include "libavutil/pixdesc.h"
 
@@ -2235,7 +2234,7 @@
 }
 
 static AVBufferRef *vaapi_encode_alloc_output_buffer(void *opaque,
-                                                     buffer_size_t size)
+                                                     int size)
 {
     AVCodecContext   *avctx = opaque;
     VAAPIEncodeContext *ctx = avctx->priv_data;
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index ce73e26..e52a0e3 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -90,12 +90,13 @@
     H264RawAUD   raw_aud;
     H264RawSPS   raw_sps;
     H264RawPPS   raw_pps;
+    H264RawSEI   raw_sei;
     H264RawSlice raw_slice;
 
     H264RawSEIBufferingPeriod      sei_buffering_period;
     H264RawSEIPicTiming            sei_pic_timing;
     H264RawSEIRecoveryPoint        sei_recovery_point;
-    SEIRawUserDataUnregistered     sei_identifier;
+    H264RawSEIUserDataUnregistered sei_identifier;
     char                          *sei_identifier_string;
 
     int aud_needed;
@@ -209,9 +210,11 @@
 {
     VAAPIEncodeH264Context *priv = avctx->priv_data;
     CodedBitstreamFragment   *au = &priv->current_access_unit;
-    int err;
+    int err, i;
 
     if (priv->sei_needed) {
+        H264RawSEI *sei = &priv->raw_sei;
+
         if (priv->aud_needed) {
             err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
             if (err < 0)
@@ -219,35 +222,41 @@
             priv->aud_needed = 0;
         }
 
+        *sei = (H264RawSEI) {
+            .nal_unit_header = {
+                .nal_unit_type = H264_NAL_SEI,
+            },
+        };
+
+        i = 0;
+
         if (priv->sei_needed & SEI_IDENTIFIER) {
-            err = ff_cbs_sei_add_message(priv->cbc, au, 1,
-                                         SEI_TYPE_USER_DATA_UNREGISTERED,
-                                         &priv->sei_identifier, NULL);
-            if (err < 0)
-                goto fail;
+            sei->payload[i].payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED;
+            sei->payload[i].payload.user_data_unregistered = priv->sei_identifier;
+            ++i;
         }
         if (priv->sei_needed & SEI_TIMING) {
             if (pic->type == PICTURE_TYPE_IDR) {
-                err = ff_cbs_sei_add_message(priv->cbc, au, 1,
-                                             SEI_TYPE_BUFFERING_PERIOD,
-                                             &priv->sei_buffering_period, NULL);
-                if (err < 0)
-                    goto fail;
+                sei->payload[i].payload_type = H264_SEI_TYPE_BUFFERING_PERIOD;
+                sei->payload[i].payload.buffering_period = priv->sei_buffering_period;
+                ++i;
             }
-            err = ff_cbs_sei_add_message(priv->cbc, au, 1,
-                                         SEI_TYPE_PIC_TIMING,
-                                         &priv->sei_pic_timing, NULL);
-            if (err < 0)
-                goto fail;
+            sei->payload[i].payload_type = H264_SEI_TYPE_PIC_TIMING;
+            sei->payload[i].payload.pic_timing = priv->sei_pic_timing;
+            ++i;
         }
         if (priv->sei_needed & SEI_RECOVERY_POINT) {
-            err = ff_cbs_sei_add_message(priv->cbc, au, 1,
-                                         SEI_TYPE_RECOVERY_POINT,
-                                         &priv->sei_recovery_point, NULL);
-            if (err < 0)
-                goto fail;
+            sei->payload[i].payload_type = H264_SEI_TYPE_RECOVERY_POINT;
+            sei->payload[i].payload.recovery_point = priv->sei_recovery_point;
+            ++i;
         }
 
+        sei->payload_count = i;
+        av_assert0(sei->payload_count > 0);
+
+        err = vaapi_encode_h264_add_nal(avctx, au, sei);
+        if (err < 0)
+            goto fail;
         priv->sei_needed = 0;
 
         err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 2c356fb..3e0af17 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -73,10 +73,11 @@
     H265RawVPS   raw_vps;
     H265RawSPS   raw_sps;
     H265RawPPS   raw_pps;
+    H265RawSEI   raw_sei;
     H265RawSlice raw_slice;
 
-    SEIRawMasteringDisplayColourVolume sei_mastering_display;
-    SEIRawContentLightLevelInfo        sei_content_light_level;
+    H265RawSEIMasteringDisplayColourVolume sei_mastering_display;
+    H265RawSEIContentLightLevelInfo        sei_content_light_level;
 
     CodedBitstreamContext *cbc;
     CodedBitstreamFragment current_access_unit;
@@ -194,9 +195,11 @@
 {
     VAAPIEncodeH265Context *priv = avctx->priv_data;
     CodedBitstreamFragment   *au = &priv->current_access_unit;
-    int err;
+    int err, i;
 
     if (priv->sei_needed) {
+        H265RawSEI *sei = &priv->raw_sei;
+
         if (priv->aud_needed) {
             err = vaapi_encode_h265_add_nal(avctx, au, &priv->aud);
             if (err < 0)
@@ -204,22 +207,34 @@
             priv->aud_needed = 0;
         }
 
+        *sei = (H265RawSEI) {
+            .nal_unit_header = {
+                .nal_unit_type         = HEVC_NAL_SEI_PREFIX,
+                .nuh_layer_id          = 0,
+                .nuh_temporal_id_plus1 = 1,
+            },
+        };
+
+        i = 0;
+
         if (priv->sei_needed & SEI_MASTERING_DISPLAY) {
-            err = ff_cbs_sei_add_message(priv->cbc, au, 1,
-                                         SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME,
-                                         &priv->sei_mastering_display, NULL);
-            if (err < 0)
-                goto fail;
+            sei->payload[i].payload_type = HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO;
+            sei->payload[i].payload.mastering_display = priv->sei_mastering_display;
+            ++i;
         }
 
         if (priv->sei_needed & SEI_CONTENT_LIGHT_LEVEL) {
-            err = ff_cbs_sei_add_message(priv->cbc, au, 1,
-                                         SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO,
-                                         &priv->sei_content_light_level, NULL);
-            if (err < 0)
-                goto fail;
+            sei->payload[i].payload_type = HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO;
+            sei->payload[i].payload.content_light_level = priv->sei_content_light_level;
+            ++i;
         }
 
+        sei->payload_count = i;
+        av_assert0(sei->payload_count > 0);
+
+        err = vaapi_encode_h265_add_nal(avctx, au, sei);
+        if (err < 0)
+            goto fail;
         priv->sei_needed = 0;
 
         err = vaapi_encode_h265_write_access_unit(avctx, data, data_len, au);
@@ -766,7 +781,7 @@
 
             // SEI is needed when both the primaries and luminance are set
             if (mdm->has_primaries && mdm->has_luminance) {
-                SEIRawMasteringDisplayColourVolume *mdcv =
+                H265RawSEIMasteringDisplayColourVolume *mdcv =
                     &priv->sei_mastering_display;
                 const int mapping[3] = {1, 2, 0};
                 const int chroma_den = 50000;
@@ -811,7 +826,7 @@
         if (sd) {
             AVContentLightMetadata *clm =
                 (AVContentLightMetadata *)sd->data;
-            SEIRawContentLightLevelInfo *clli =
+            H265RawSEIContentLightLevelInfo *clli =
                 &priv->sei_content_light_level;
 
             clli->max_content_light_level     = FFMIN(clm->MaxCLL,  65535);
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index b6ace37..5c33170 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -592,6 +592,10 @@
     } else {
         dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     }
+    if (dcdiff < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
+        return -1;
+    }
     if (dcdiff) {
         const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0;
         if (dcdiff == 119 /* ESC index value */) {
@@ -736,6 +740,10 @@
     } else {
         dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     }
+    if (dcdiff < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
+        return -1;
+    }
     if (dcdiff) {
         const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
         if (dcdiff == 119 /* ESC index value */) {
@@ -936,6 +944,10 @@
     } else {
         dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     }
+    if (dcdiff < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
+        return -1;
+    }
     if (dcdiff) {
         const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
         if (dcdiff == 119 /* ESC index value */) {
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 47940fb..7809234 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1217,7 +1217,7 @@
     .flush          = ff_mpeg_flush,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
     .pix_fmts       = vc1_hwaccel_pixfmt_list_420,
-    .hw_configs     = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs     = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_VC1_DXVA2_HWACCEL
                         HWACCEL_DXVA2(vc1),
 #endif
@@ -1254,7 +1254,7 @@
     .flush          = ff_mpeg_flush,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
     .pix_fmts       = vc1_hwaccel_pixfmt_list_420,
-    .hw_configs     = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs     = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_WMV3_DXVA2_HWACCEL
                         HWACCEL_DXVA2(wmv3),
 #endif
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 7bd2e4c..bab9d0f 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -423,7 +423,7 @@
 }
 
 /* 1st idx = LL, second - vertical, third - horizontal, fourth - total */
-static const uint8_t vc2_qm_col_tab[][4] = {
+const uint8_t vc2_qm_col_tab[][4] = {
     {20,  9, 15,  4},
     { 0,  6,  6,  4},
     { 0,  3,  3,  5},
@@ -431,7 +431,7 @@
     { 0, 11, 10, 11}
 };
 
-static const uint8_t vc2_qm_flat_tab[][4] = {
+const uint8_t vc2_qm_flat_tab[][4] = {
     { 0,  0,  0,  0},
     { 0,  0,  0,  0},
     { 0,  0,  0,  0},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3124ec8..5b92afe 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR 130
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MINOR 115
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
@@ -51,6 +51,12 @@
  * at once through the bump. This improves the git bisect-ability of the change.
  */
 
+#ifndef FF_API_LOWRES
+#define FF_API_LOWRES            (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_DEBUG_MV
+#define FF_API_DEBUG_MV          (LIBAVCODEC_VERSION_MAJOR < 58)
+#endif
 #ifndef FF_API_AVCTX_TIMEBASE
 #define FF_API_AVCTX_TIMEBASE    (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
@@ -141,26 +147,8 @@
 #ifndef FF_API_AVPRIV_PUT_BITS
 #define FF_API_AVPRIV_PUT_BITS     (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
-#ifndef FF_API_OLD_ENCDEC
-#define FF_API_OLD_ENCDEC          (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
-#ifndef FF_API_AVCODEC_PIX_FMT
-#define FF_API_AVCODEC_PIX_FMT     (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
-#ifndef FF_API_MPV_RC_STRATEGY
-#define FF_API_MPV_RC_STRATEGY     (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
-#ifndef FF_API_PARSER_CHANGE
-#define FF_API_PARSER_CHANGE       (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
 #ifndef FF_API_THREAD_SAFE_CALLBACKS
 #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
 #endif
-#ifndef FF_API_DEBUG_MV
-#define FF_API_DEBUG_MV          (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_GET_FRAME_CLASS
-#define FF_API_GET_FRAME_CLASS     (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 49e726a..8773de3 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -1088,13 +1088,7 @@
     vtctx->vt_ctx->cv_pix_fmt_type =
         av_map_videotoolbox_format_from_pixfmt2(hw_frames->sw_format, full_range);
     if (!vtctx->vt_ctx->cv_pix_fmt_type) {
-        const AVPixFmtDescriptor *attempted_format =
-            av_pix_fmt_desc_get(hw_frames->sw_format);
-        av_log(avctx, AV_LOG_ERROR,
-               "Failed to map underlying FFmpeg pixel format %s (%s range) to "
-               "a VideoToolbox format!\n",
-               attempted_format ? attempted_format->name : "<unknown>",
-               av_color_range_name(avctx->color_range));
+        av_log(avctx, AV_LOG_ERROR, "Unknown sw_format.\n");
         err = AVERROR(EINVAL);
         goto fail;
     }
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index c487d2d..4004015 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1751,7 +1751,7 @@
             remaining_dst_size--;
 
             wrote_bytes = write_sei(sei,
-                                    SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35,
+                                    H264_SEI_TYPE_USER_DATA_REGISTERED,
                                     dst_data,
                                     remaining_dst_size);
 
@@ -1807,7 +1807,7 @@
                 return status;
 
             wrote_bytes = write_sei(sei,
-                                    SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35,
+                                    H264_SEI_TYPE_USER_DATA_REGISTERED,
                                     new_sei,
                                     remaining_dst_size - old_sei_length);
             if (wrote_bytes < 0)
@@ -1903,7 +1903,7 @@
 
     if (sei) {
         size_t msg_size = get_sei_msg_bytes(sei,
-                                            SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35);
+                                            H264_SEI_TYPE_USER_DATA_REGISTERED);
 
         sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1;
     }
diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h
index 69ddbd2..98dd14f 100644
--- a/libavcodec/vorbis.h
+++ b/libavcodec/vorbis.h
@@ -26,6 +26,7 @@
 extern const float ff_vorbis_floor1_inverse_db_table[256];
 extern const float * const ff_vorbis_vwin[8];
 extern const uint8_t ff_vorbis_channel_layout_offsets[8][8];
+extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8];
 extern const uint64_t ff_vorbis_channel_layouts[9];
 
 typedef struct vorbis_floor1_entry {
diff --git a/libavcodec/vorbis_data.c b/libavcodec/vorbis_data.c
index fd7e291..063a075 100644
--- a/libavcodec/vorbis_data.c
+++ b/libavcodec/vorbis_data.c
@@ -19,8 +19,7 @@
  */
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem_internal.h"
-
+#include "libavutil/mem.h"
 #include "vorbis.h"
 
 const uint8_t ff_vorbis_channel_layout_offsets[8][8] = {
@@ -34,6 +33,17 @@
     { 0, 2, 1, 7, 5, 6, 3, 4 },
 };
 
+const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8] = {
+    { 0 },
+    { 0, 1 },
+    { 0, 2, 1 },
+    { 0, 1, 2, 3 },
+    { 0, 2, 1, 3, 4 },
+    { 0, 2, 1, 4, 5, 3 },
+    { 0, 2, 1, 5, 6, 4, 3 },
+    { 0, 2, 1, 6, 7, 4, 5, 3 },
+};
+
 const uint64_t ff_vorbis_channel_layouts[9] = {
     AV_CH_LAYOUT_MONO,
     AV_CH_LAYOUT_STEREO,
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 57c6eb1..cf64a8c 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -35,7 +35,6 @@
 #include <string.h>
 
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
@@ -2875,9 +2874,6 @@
     int ret;
     AVRational fps, aspect;
 
-    if (get_bits_left(gb) < 206)
-        return AVERROR_INVALIDDATA;
-
     s->theora_header = 0;
     s->theora = get_bits(gb, 24);
     av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
diff --git a/libavcodec/vp3data.h b/libavcodec/vp3data.h
index 272af4e..1fbeac7 100644
--- a/libavcodec/vp3data.h
+++ b/libavcodec/vp3data.h
@@ -179,7 +179,8 @@
 static const int16_t coeff_table_token_16[2] = { 6, -6 };
 
 static const int16_t coeff_table_token_23_24_25_26_27_28_29[2] = { 1, -1 };
-static const int16_t coeff_table_token_30_31[4] = { 2, 3, -2, -3 };
+static const int16_t coeff_table_token_30[4] = { 2, 3, -2, -3 };
+static const int16_t coeff_table_token_31[4] = { 2, 3, -2, -3 };
 
 static const int16_t coeff_table_token_17[4] = {
     7, 8, -7, -8
@@ -376,8 +377,8 @@
     coeff_table_token_23_24_25_26_27_28_29,
     coeff_table_token_23_24_25_26_27_28_29,
     coeff_table_token_23_24_25_26_27_28_29,
-    coeff_table_token_30_31,
-    coeff_table_token_30_31
+    coeff_table_token_30,
+    coeff_table_token_31
 };
 
 static const uint8_t vp3_bias[5 * 16][32][2] = {
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h
index 46090f2..65cf468 100644
--- a/libavcodec/vp56.h
+++ b/libavcodec/vp56.h
@@ -26,8 +26,6 @@
 #ifndef AVCODEC_VP56_H
 #define AVCODEC_VP56_H
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "get_bits.h"
 #include "hpeldsp.h"
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index d16e7b6..d5d1335 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -25,7 +25,6 @@
  */
 
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "hwconfig.h"
@@ -2293,10 +2292,10 @@
         s->mv_bounds.mv_min.x = -MARGIN;
         s->mv_bounds.mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
 
+        if (vpX_rac_is_end(&s->c)) {
+            return AVERROR_INVALIDDATA;
+        }
         for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
-            if (vpX_rac_is_end(&s->c)) {
-                return AVERROR_INVALIDDATA;
-            }
             if (mb_y == 0)
                 AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,
                          DC_PRED * 0x01010101);
@@ -2622,7 +2621,7 @@
 
 static av_always_inline
 int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
-                      const AVPacket *avpkt, int is_vp7)
+                      AVPacket *avpkt, int is_vp7)
 {
     VP8Context *s = avctx->priv_data;
     int ret, i, referenced, num_jobs;
@@ -2966,7 +2965,7 @@
                              AV_CODEC_CAP_SLICE_THREADS,
     .flush                 = vp8_decode_flush,
     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context),
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_VP8_VAAPI_HWACCEL
                                HWACCEL_VAAPI(vp8),
 #endif
diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h
index e6091df..70d21e3 100644
--- a/libavcodec/vp8.h
+++ b/libavcodec/vp8.h
@@ -29,7 +29,6 @@
 #include <stdatomic.h>
 
 #include "libavutil/buffer.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "h264pred.h"
diff --git a/libavcodec/vp8data.h b/libavcodec/vp8data.h
index 1fcce13..5e6dea7 100644
--- a/libavcodec/vp8data.h
+++ b/libavcodec/vp8data.h
@@ -316,6 +316,12 @@
     },
 };
 
+static const int8_t vp8_segmentid_tree[][2] = {
+    {  1,  2 },
+    { -0, -1 }, // '00', '01'
+    { -2, -3 }, // '10', '11'
+};
+
 static const uint8_t vp8_coeff_band[16] = {
     0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7
 };
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 4659f94..294059f 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -1894,7 +1894,7 @@
     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context),
     .profiles              = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),
     .bsfs                  = "vp9_superframe_split",
-    .hw_configs            = (const AVCodecHWConfigInternal *const []) {
+    .hw_configs            = (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_VP9_DXVA2_HWACCEL
                                HWACCEL_DXVA2(vp9),
 #endif
diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c
index d904a00..00a5580 100644
--- a/libavcodec/vp9_metadata_bsf.c
+++ b/libavcodec/vp9_metadata_bsf.c
@@ -21,12 +21,15 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
-#include "cbs_bsf.h"
 #include "cbs_vp9.h"
 
 typedef struct VP9MetadataContext {
-    CBSBSFContext common;
+    const AVClass *class;
+
+    CodedBitstreamContext *cbc;
+    CodedBitstreamFragment fragment;
 
     int color_space;
     int color_range;
@@ -35,11 +38,21 @@
 } VP9MetadataContext;
 
 
-static int vp9_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
-                                        CodedBitstreamFragment *frag)
+static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
 {
     VP9MetadataContext *ctx = bsf->priv_data;
-    int i;
+    CodedBitstreamFragment *frag = &ctx->fragment;
+    int err, i;
+
+    err = ff_bsf_get_packet_ref(bsf, pkt);
+    if (err < 0)
+        return err;
+
+    err = ff_cbs_read_packet(ctx->cbc, frag, pkt);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+        goto fail;
+    }
 
     for (i = 0; i < frag->nb_units; i++) {
         VP9RawFrame *frame = frag->units[i].content;
@@ -77,19 +90,35 @@
         }
     }
 
-    return 0;
-}
+    err = ff_cbs_write_packet(ctx->cbc, pkt, frag);
+    if (err < 0) {
+        av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+        goto fail;
+    }
 
-static const CBSBSFType vp9_metadata_type = {
-    .codec_id        = AV_CODEC_ID_VP9,
-    .fragment_name   = "superframe",
-    .unit_name       = "frame",
-    .update_fragment = &vp9_metadata_update_fragment,
-};
+    err = 0;
+fail:
+    ff_cbs_fragment_reset(frag);
+
+    if (err < 0)
+        av_packet_unref(pkt);
+
+    return err;
+}
 
 static int vp9_metadata_init(AVBSFContext *bsf)
 {
-    return ff_cbs_bsf_generic_init(bsf, &vp9_metadata_type);
+    VP9MetadataContext *ctx = bsf->priv_data;
+
+    return ff_cbs_init(&ctx->cbc, AV_CODEC_ID_VP9, bsf);
+}
+
+static void vp9_metadata_close(AVBSFContext *bsf)
+{
+    VP9MetadataContext *ctx = bsf->priv_data;
+
+    ff_cbs_fragment_free(&ctx->fragment);
+    ff_cbs_close(&ctx->cbc);
 }
 
 #define OFFSET(x) offsetof(VP9MetadataContext, x)
@@ -140,7 +169,7 @@
     .priv_data_size = sizeof(VP9MetadataContext),
     .priv_class     = &vp9_metadata_class,
     .init           = &vp9_metadata_init,
-    .close          = &ff_cbs_bsf_generic_close,
-    .filter         = &ff_cbs_bsf_generic_filter,
+    .close          = &vp9_metadata_close,
+    .filter         = &vp9_metadata_filter,
     .codec_ids      = vp9_metadata_codec_ids,
 };
diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h
index d82b258..cc2440b 100644
--- a/libavcodec/vp9dec.h
+++ b/libavcodec/vp9dec.h
@@ -29,7 +29,6 @@
 #include <stdatomic.h>
 
 #include "libavutil/buffer.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "libavutil/internal.h"
 
diff --git a/libavcodec/vp9dsp.c b/libavcodec/vp9dsp.c
index 41b8ad1..f6d73f7 100644
--- a/libavcodec/vp9dsp.c
+++ b/libavcodec/vp9dsp.c
@@ -23,8 +23,6 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
-
 #include "vp9dsp.h"
 
 const DECLARE_ALIGNED(16, int16_t, ff_vp9_subpel_filters)[3][16][8] = {
diff --git a/libavcodec/vp9dsp_template.c b/libavcodec/vp9dsp_template.c
index 9b11661..3acf94c 100644
--- a/libavcodec/vp9dsp_template.c
+++ b/libavcodec/vp9dsp_template.c
@@ -1138,7 +1138,7 @@
             for (j = 0; j < sz; j++) \
                 dst[j * stride] = av_clip_pixel(dst[j * stride] + \
                                                 (bits ? \
-                                                 (int)(t + (1U << (bits - 1))) >> bits : \
+                                                 (t + (1 << (bits - 1))) >> bits : \
                                                  t)); \
             dst++; \
         } \
@@ -1153,7 +1153,7 @@
         for (j = 0; j < sz; j++) \
             dst[j * stride] = av_clip_pixel(dst[j * stride] + \
                                             (bits ? \
-                                             (int)(out[j] + (1U << (bits - 1))) >> bits : \
+                                             (out[j] + (1 << (bits - 1))) >> bits : \
                                              out[j])); \
         dst++; \
     } \
diff --git a/libavcodec/vp9recon.c b/libavcodec/vp9recon.c
index e38cf99..9a4e7c7 100644
--- a/libavcodec/vp9recon.c
+++ b/libavcodec/vp9recon.c
@@ -22,7 +22,6 @@
  */
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/wavpack.h b/libavcodec/wavpack.h
index 7e7dfce..43aaac8 100644
--- a/libavcodec/wavpack.h
+++ b/libavcodec/wavpack.h
@@ -124,8 +124,43 @@
 };
 
 // exponent table copied from WavPack source
-extern const uint8_t ff_wp_exp2_table[256];
-extern const uint8_t ff_wp_log2_table[256];
+static const uint8_t wp_exp2_table[256] = {
+    0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b,
+    0x0b, 0x0c, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x16,
+    0x17, 0x18, 0x19, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1f, 0x20, 0x20, 0x21, 0x22, 0x23,
+    0x24, 0x24, 0x25, 0x26, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
+    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3a, 0x3b, 0x3c, 0x3d,
+    0x3e, 0x3f, 0x40, 0x41, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b,
+    0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
+    0x5b, 0x5c, 0x5d, 0x5e, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+    0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+    0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x87, 0x88, 0x89, 0x8a,
+    0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
+    0x9c, 0x9d, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad,
+    0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
+    0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc8, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf, 0xd0, 0xd2, 0xd3, 0xd4,
+    0xd6, 0xd7, 0xd8, 0xd9, 0xdb, 0xdc, 0xdd, 0xde, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe8, 0xe9,
+    0xea, 0xec, 0xed, 0xee, 0xf0, 0xf1, 0xf2, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfc, 0xfd, 0xff
+};
+
+static const uint8_t wp_log2_table [] = {
+    0x00, 0x01, 0x03, 0x04, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14, 0x15,
+    0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a,
+    0x2c, 0x2d, 0x2e, 0x2f, 0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3b, 0x3c, 0x3d, 0x3e,
+    0x3f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
+    0x52, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63,
+    0x64, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x74, 0x75,
+    0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85,
+    0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95,
+    0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4,
+    0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb2,
+    0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc0,
+    0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xce,
+    0xcf, 0xd0, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd8, 0xd9, 0xda, 0xdb,
+    0xdc, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe4, 0xe5, 0xe6, 0xe7, 0xe7,
+    0xe8, 0xe9, 0xea, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xee, 0xef, 0xf0, 0xf1, 0xf1, 0xf2, 0xf3, 0xf4,
+    0xf4, 0xf5, 0xf6, 0xf7, 0xf7, 0xf8, 0xf9, 0xf9, 0xfa, 0xfb, 0xfc, 0xfc, 0xfd, 0xfe, 0xff, 0xff
+};
 
 static av_always_inline int wp_exp2(int16_t val)
 {
@@ -136,7 +171,7 @@
         neg = 1;
     }
 
-    res   = ff_wp_exp2_table[val & 0xFF] | 0x100;
+    res   = wp_exp2_table[val & 0xFF] | 0x100;
     val >>= 8;
     if (val > 31U)
         return INT_MIN;
@@ -155,9 +190,9 @@
     val += val >> 9;
     bits = av_log2(val) + 1;
     if (bits < 9)
-        return (bits << 8) + ff_wp_log2_table[(val << (9 - bits)) & 0xFF];
+        return (bits << 8) + wp_log2_table[(val << (9 - bits)) & 0xFF];
     else
-        return (bits << 8) + ff_wp_log2_table[(val >> (bits - 9)) & 0xFF];
+        return (bits << 8) + wp_log2_table[(val >> (bits - 9)) & 0xFF];
 }
 
 #endif /* AVCODEC_WAVPACK_H */
diff --git a/libavcodec/wavpackdata.c b/libavcodec/wavpackdata.c
deleted file mode 100644
index 1c777af..0000000
--- a/libavcodec/wavpackdata.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * WavPack decoder/encoder common data
- * Copyright (c) 2006,2011 Konstantin Shishkov
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "wavpack.h"
-
-const uint8_t ff_wp_exp2_table[256] = {
-    0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b,
-    0x0b, 0x0c, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x16,
-    0x17, 0x18, 0x19, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1f, 0x20, 0x20, 0x21, 0x22, 0x23,
-    0x24, 0x24, 0x25, 0x26, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
-    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3a, 0x3b, 0x3c, 0x3d,
-    0x3e, 0x3f, 0x40, 0x41, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b,
-    0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
-    0x5b, 0x5c, 0x5d, 0x5e, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
-    0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
-    0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x87, 0x88, 0x89, 0x8a,
-    0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
-    0x9c, 0x9d, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad,
-    0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
-    0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc8, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf, 0xd0, 0xd2, 0xd3, 0xd4,
-    0xd6, 0xd7, 0xd8, 0xd9, 0xdb, 0xdc, 0xdd, 0xde, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe8, 0xe9,
-    0xea, 0xec, 0xed, 0xee, 0xf0, 0xf1, 0xf2, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfc, 0xfd, 0xff
-};
-
-const uint8_t ff_wp_log2_table[256] = {
-    0x00, 0x01, 0x03, 0x04, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14, 0x15,
-    0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a,
-    0x2c, 0x2d, 0x2e, 0x2f, 0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3b, 0x3c, 0x3d, 0x3e,
-    0x3f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
-    0x52, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63,
-    0x64, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x74, 0x75,
-    0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85,
-    0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95,
-    0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4,
-    0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb2,
-    0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc0,
-    0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xce,
-    0xcf, 0xd0, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd8, 0xd9, 0xda, 0xdb,
-    0xdc, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe4, 0xe5, 0xe6, 0xe7, 0xe7,
-    0xe8, 0xe9, 0xea, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xee, 0xef, 0xf0, 0xf1, 0xf1, 0xf2, 0xf3, 0xf4,
-    0xf4, 0xf5, 0xf6, 0xf7, 0xf7, 0xf8, 0xf9, 0xf9, 0xfa, 0xfb, 0xfc, 0xfc, 0xfd, 0xfe, 0xff, 0xff
-};
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 0a79843..0c85fbe 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -644,9 +644,9 @@
     uint32_t dbits = count_bits(v);
 
     if ((v += v >> 9) < (1 << 8)) {
-        *result += (dbits << 8) + ff_wp_log2_table[(v << (9 - dbits)) & 0xff];
+        *result += (dbits << 8) + wp_log2_table[(v << (9 - dbits)) & 0xff];
     } else {
-        *result += dbits = (dbits << 8) + ff_wp_log2_table[(v >> (dbits - 9)) & 0xff];
+        *result += dbits = (dbits << 8) + wp_log2_table[(v >> (dbits - 9)) & 0xff];
 
         if (limit && dbits >= limit)
             return 1;
diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index aea7ba2..7935bcd 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -23,7 +23,6 @@
 #define AVCODEC_WMA_H
 
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "fft.h"
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index e1fcf8a..a8fd997 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -26,7 +26,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
-#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 8024ce1..63e7680 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -92,8 +92,6 @@
 #include "libavutil/float_dsp.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
@@ -1721,12 +1719,6 @@
         }
     } else {
         int frame_size;
-
-        if (avpkt->size < s->next_packet_start) {
-            s->packet_loss = 1;
-            return AVERROR_INVALIDDATA;
-        }
-
         s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
         init_get_bits(gb, avpkt->data, s->buf_bit_size);
         skip_bits(gb, s->packet_offset);
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index fbdb865..a588bb6 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -29,7 +29,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h
index f425332..0f459ae 100644
--- a/libavcodec/wmv2.h
+++ b/libavcodec/wmv2.h
@@ -21,8 +21,6 @@
 #ifndef AVCODEC_WMV2_H
 #define AVCODEC_WMV2_H
 
-#include "libavutil/mem_internal.h"
-
 #include "avcodec.h"
 #include "intrax8.h"
 #include "mpegvideo.h"
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 7aae115..a16c446 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -278,16 +278,22 @@
     return 0;
 }
 
-static inline void wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
+static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
 {
     MpegEncContext *const s = &w->s;
+    int ret;
 
-    ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
+    ret = ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
+
+    if (ret < 0)
+        return ret;
 
     if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
         w->hshift = get_bits1(&s->gb);
     else
         w->hshift = 0;
+
+    return 0;
 }
 
 static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py)
@@ -403,6 +409,8 @@
 
         code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
                         MB_NON_INTRA_VLC_BITS, 3);
+        if (code < 0)
+            return AVERROR_INVALIDDATA;
         s->mb_intra = (~code & 0x40) >> 6;
 
         cbp = code & 0x3f;
@@ -411,6 +419,11 @@
         if (get_bits_left(&s->gb) <= 0)
             return AVERROR_INVALIDDATA;
         code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
+        if (code < 0) {
+            av_log(s->avctx, AV_LOG_ERROR,
+                   "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
+            return AVERROR_INVALIDDATA;
+        }
         /* predict coded block pattern */
         cbp = 0;
         for (i = 0; i < 6; i++) {
@@ -443,7 +456,8 @@
                 w->per_block_abt = 0;
         }
 
-        wmv2_decode_motion(w, &mx, &my);
+        if ((ret = wmv2_decode_motion(w, &mx, &my)) < 0)
+            return ret;
 
         s->mv_dir      = MV_DIR_FORWARD;
         s->mv_type     = MV_TYPE_16X16;
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 6361161..884dc0c 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -51,7 +51,6 @@
 OBJS-$(CONFIG_APNG_DECODER)            += x86/pngdsp_init.o
 OBJS-$(CONFIG_CAVS_DECODER)            += x86/cavsdsp.o
 OBJS-$(CONFIG_CFHD_DECODER)            += x86/cfhddsp_init.o
-OBJS-$(CONFIG_CFHD_ENCODER)            += x86/cfhdencdsp_init.o
 OBJS-$(CONFIG_DCA_DECODER)             += x86/dcadsp_init.o x86/synth_filter_init.o
 OBJS-$(CONFIG_DNXHD_ENCODER)           += x86/dnxhdenc_init.o
 OBJS-$(CONFIG_EXR_DECODER)             += x86/exrdsp_init.o
@@ -155,7 +154,6 @@
 X86ASM-OBJS-$(CONFIG_ALAC_DECODER)     += x86/alacdsp.o
 X86ASM-OBJS-$(CONFIG_APNG_DECODER)     += x86/pngdsp.o
 X86ASM-OBJS-$(CONFIG_CAVS_DECODER)     += x86/cavsidct.o
-X86ASM-OBJS-$(CONFIG_CFHD_ENCODER)     += x86/cfhdencdsp.o
 X86ASM-OBJS-$(CONFIG_CFHD_DECODER)     += x86/cfhddsp.o
 X86ASM-OBJS-$(CONFIG_DCA_DECODER)      += x86/dcadsp.o x86/synth_filter.o
 X86ASM-OBJS-$(CONFIG_DIRAC_DECODER)    += x86/diracdsp.o                \
diff --git a/libavcodec/x86/ac3dsp.asm b/libavcodec/x86/ac3dsp.asm
index 4ddaa94..675ade3 100644
--- a/libavcodec/x86/ac3dsp.asm
+++ b/libavcodec/x86/ac3dsp.asm
@@ -35,6 +35,10 @@
 cextern pd_1
 pd_151: times 4 dd 151
 
+; used in ff_apply_window_int16()
+pb_revwords: SHUFFLE_MASK_W 7, 6, 5, 4, 3, 2, 1, 0
+pd_16384: times 4 dd 16384
+
 SECTION .text
 
 ;-----------------------------------------------------------------------------
@@ -78,6 +82,133 @@
 %undef LOOP_ALIGN
 
 ;-----------------------------------------------------------------------------
+; int ff_ac3_max_msb_abs_int16(const int16_t *src, int len)
+;
+; This function uses 2 different methods to calculate a valid result.
+; 1) logical 'or' of abs of each element
+;        This is used for ssse3 because of the pabsw instruction.
+;        It is also used for mmx because of the lack of min/max instructions.
+; 2) calculate min/max for the array, then or(abs(min),abs(max))
+;        This is used for mmxext and sse2 because they have pminsw/pmaxsw.
+;-----------------------------------------------------------------------------
+
+; logical 'or' of 4 or 8 words in an mmx or xmm register into the low word
+%macro OR_WORDS_HORIZ 2 ; src, tmp
+%if cpuflag(sse2)
+    movhlps     %2, %1
+    por         %1, %2
+    pshuflw     %2, %1, q0032
+    por         %1, %2
+    pshuflw     %2, %1, q0001
+    por         %1, %2
+%elif cpuflag(mmxext)
+    pshufw      %2, %1, q0032
+    por         %1, %2
+    pshufw      %2, %1, q0001
+    por         %1, %2
+%else ; mmx
+    movq        %2, %1
+    psrlq       %2, 32
+    por         %1, %2
+    movq        %2, %1
+    psrlq       %2, 16
+    por         %1, %2
+%endif
+%endmacro
+
+%macro AC3_MAX_MSB_ABS_INT16 1
+cglobal ac3_max_msb_abs_int16, 2,2,5, src, len
+    pxor        m2, m2
+    pxor        m3, m3
+.loop:
+%ifidn %1, min_max
+    mova        m0, [srcq]
+    mova        m1, [srcq+mmsize]
+    pminsw      m2, m0
+    pminsw      m2, m1
+    pmaxsw      m3, m0
+    pmaxsw      m3, m1
+%else ; or_abs
+%if notcpuflag(ssse3)
+    mova        m0, [srcq]
+    mova        m1, [srcq+mmsize]
+    ABS2        m0, m1, m3, m4
+%else ; ssse3
+    ; using memory args is faster for ssse3
+    pabsw       m0, [srcq]
+    pabsw       m1, [srcq+mmsize]
+%endif
+    por         m2, m0
+    por         m2, m1
+%endif
+    add       srcq, mmsize*2
+    sub       lend, mmsize
+    ja .loop
+%ifidn %1, min_max
+    ABS2        m2, m3, m0, m1
+    por         m2, m3
+%endif
+    OR_WORDS_HORIZ m2, m0
+    movd       eax, m2
+    and        eax, 0xFFFF
+    RET
+%endmacro
+
+INIT_MMX mmx
+AC3_MAX_MSB_ABS_INT16 or_abs
+INIT_MMX mmxext
+AC3_MAX_MSB_ABS_INT16 min_max
+INIT_XMM sse2
+AC3_MAX_MSB_ABS_INT16 min_max
+INIT_XMM ssse3
+AC3_MAX_MSB_ABS_INT16 or_abs
+
+;-----------------------------------------------------------------------------
+; macro used for ff_ac3_lshift_int16() and ff_ac3_rshift_int32()
+;-----------------------------------------------------------------------------
+
+%macro AC3_SHIFT 3 ; l/r, 16/32, shift instruction, instruction set
+cglobal ac3_%1shift_int%2, 3, 3, 5, src, len, shift
+    movd      m0, shiftd
+.loop:
+    mova      m1, [srcq         ]
+    mova      m2, [srcq+mmsize  ]
+    mova      m3, [srcq+mmsize*2]
+    mova      m4, [srcq+mmsize*3]
+    %3        m1, m0
+    %3        m2, m0
+    %3        m3, m0
+    %3        m4, m0
+    mova  [srcq         ], m1
+    mova  [srcq+mmsize  ], m2
+    mova  [srcq+mmsize*2], m3
+    mova  [srcq+mmsize*3], m4
+    add     srcq, mmsize*4
+    sub     lend, mmsize*32/%2
+    ja .loop
+.end:
+    REP_RET
+%endmacro
+
+;-----------------------------------------------------------------------------
+; void ff_ac3_lshift_int16(int16_t *src, unsigned int len, unsigned int shift)
+;-----------------------------------------------------------------------------
+
+INIT_MMX mmx
+AC3_SHIFT l, 16, psllw
+INIT_XMM sse2
+AC3_SHIFT l, 16, psllw
+
+;-----------------------------------------------------------------------------
+; void ff_ac3_rshift_int32(int32_t *src, unsigned int len, unsigned int shift)
+;-----------------------------------------------------------------------------
+
+INIT_MMX mmx
+AC3_SHIFT r, 32, psrad
+INIT_XMM sse2
+AC3_SHIFT r, 32, psrad
+
+;-----------------------------------------------------------------------------
 ; void ff_float_to_fixed24(int32_t *dst, const float *src, unsigned int len)
 ;-----------------------------------------------------------------------------
 
@@ -292,3 +423,130 @@
 INIT_XMM ssse3
 AC3_EXTRACT_EXPONENTS
 %endif
+
+;-----------------------------------------------------------------------------
+; void ff_apply_window_int16(int16_t *output, const int16_t *input,
+;                            const int16_t *window, unsigned int len)
+;-----------------------------------------------------------------------------
+
+%macro REVERSE_WORDS 1-2
+%if cpuflag(ssse3) && notcpuflag(atom)
+    pshufb  %1, %2
+%elif cpuflag(sse2)
+    pshuflw  %1, %1, 0x1B
+    pshufhw  %1, %1, 0x1B
+    pshufd   %1, %1, 0x4E
+%elif cpuflag(mmxext)
+    pshufw   %1, %1, 0x1B
+%endif
+%endmacro
+
+%macro MUL16FIXED 3
+%if cpuflag(ssse3) ; dst, src, unused
+; dst = ((dst * src) + (1<<14)) >> 15
+    pmulhrsw   %1, %2
+%elif cpuflag(mmxext) ; dst, src, temp
+; dst = (dst * src) >> 15
+; pmulhw cuts off the bottom bit, so we have to lshift by 1 and add it back
+; in from the pmullw result.
+    mova    %3, %1
+    pmulhw  %1, %2
+    pmullw  %3, %2
+    psrlw   %3, 15
+    psllw   %1, 1
+    por     %1, %3
+%endif
+%endmacro
+
+%macro APPLY_WINDOW_INT16 1 ; %1 bitexact version
+%if %1
+cglobal apply_window_int16, 4,5,6, output, input, window, offset, offset2
+%else
+cglobal apply_window_int16_round, 4,5,6, output, input, window, offset, offset2
+%endif
+    lea     offset2q, [offsetq-mmsize]
+%if cpuflag(ssse3) && notcpuflag(atom)
+    mova          m5, [pb_revwords]
+    ALIGN 16
+%elif %1
+    mova          m5, [pd_16384]
+%endif
+.loop:
+%if cpuflag(ssse3)
+    ; This version does the 16x16->16 multiplication in-place without expanding
+    ; to 32-bit. The ssse3 version is bit-identical.
+    mova          m0, [windowq+offset2q]
+    mova          m1, [ inputq+offset2q]
+    pmulhrsw      m1, m0
+    REVERSE_WORDS m0, m5
+    pmulhrsw      m0, [ inputq+offsetq ]
+    mova  [outputq+offset2q], m1
+    mova  [outputq+offsetq ], m0
+%elif %1
+    ; This version expands 16-bit to 32-bit, multiplies by the window,
+    ; adds 16384 for rounding, right shifts 15, then repacks back to words to
+    ; save to the output. The window is reversed for the second half.
+    mova          m3, [windowq+offset2q]
+    mova          m4, [ inputq+offset2q]
+    pxor          m0, m0
+    punpcklwd     m0, m3
+    punpcklwd     m1, m4
+    pmaddwd       m0, m1
+    paddd         m0, m5
+    psrad         m0, 15
+    pxor          m2, m2
+    punpckhwd     m2, m3
+    punpckhwd     m1, m4
+    pmaddwd       m2, m1
+    paddd         m2, m5
+    psrad         m2, 15
+    packssdw      m0, m2
+    mova  [outputq+offset2q], m0
+    REVERSE_WORDS m3
+    mova          m4, [ inputq+offsetq]
+    pxor          m0, m0
+    punpcklwd     m0, m3
+    punpcklwd     m1, m4
+    pmaddwd       m0, m1
+    paddd         m0, m5
+    psrad         m0, 15
+    pxor          m2, m2
+    punpckhwd     m2, m3
+    punpckhwd     m1, m4
+    pmaddwd       m2, m1
+    paddd         m2, m5
+    psrad         m2, 15
+    packssdw      m0, m2
+    mova  [outputq+offsetq], m0
+%else
+    ; This version does the 16x16->16 multiplication in-place without expanding
+    ; to 32-bit. The mmxext and sse2 versions do not use rounding, and
+    ; therefore are not bit-identical to the C version.
+    mova          m0, [windowq+offset2q]
+    mova          m1, [ inputq+offset2q]
+    mova          m2, [ inputq+offsetq ]
+    MUL16FIXED    m1, m0, m3
+    REVERSE_WORDS m0
+    MUL16FIXED    m2, m0, m3
+    mova  [outputq+offset2q], m1
+    mova  [outputq+offsetq ], m2
+%endif
+    add      offsetd, mmsize
+    sub     offset2d, mmsize
+    jae .loop
+    REP_RET
+%endmacro
+
+INIT_MMX mmxext
+APPLY_WINDOW_INT16 0
+INIT_XMM sse2
+APPLY_WINDOW_INT16 0
+
+INIT_MMX mmxext
+APPLY_WINDOW_INT16 1
+INIT_XMM sse2
+APPLY_WINDOW_INT16 1
+INIT_XMM ssse3
+APPLY_WINDOW_INT16 1
+INIT_XMM ssse3, atom
+APPLY_WINDOW_INT16 1
diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c
index 2ae762a..2e7e2fb 100644
--- a/libavcodec/x86/ac3dsp_init.c
+++ b/libavcodec/x86/ac3dsp_init.c
@@ -30,6 +30,17 @@
 void ff_ac3_exponent_min_mmxext(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
 void ff_ac3_exponent_min_sse2  (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
 
+int ff_ac3_max_msb_abs_int16_mmx  (const int16_t *src, int len);
+int ff_ac3_max_msb_abs_int16_mmxext(const int16_t *src, int len);
+int ff_ac3_max_msb_abs_int16_sse2 (const int16_t *src, int len);
+int ff_ac3_max_msb_abs_int16_ssse3(const int16_t *src, int len);
+
+void ff_ac3_lshift_int16_mmx (int16_t *src, unsigned int len, unsigned int shift);
+void ff_ac3_lshift_int16_sse2(int16_t *src, unsigned int len, unsigned int shift);
+
+void ff_ac3_rshift_int32_mmx (int32_t *src, unsigned int len, unsigned int shift);
+void ff_ac3_rshift_int32_sse2(int32_t *src, unsigned int len, unsigned int shift);
+
 void ff_float_to_fixed24_3dnow(int32_t *dst, const float *src, unsigned int len);
 void ff_float_to_fixed24_sse  (int32_t *dst, const float *src, unsigned int len);
 void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, unsigned int len);
@@ -39,12 +50,28 @@
 void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
 void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
 
+void ff_apply_window_int16_round_mmxext(int16_t *output, const int16_t *input,
+                                        const int16_t *window, unsigned int len);
+void ff_apply_window_int16_round_sse2(int16_t *output, const int16_t *input,
+                                      const int16_t *window, unsigned int len);
+void ff_apply_window_int16_mmxext(int16_t *output, const int16_t *input,
+                                  const int16_t *window, unsigned int len);
+void ff_apply_window_int16_sse2(int16_t *output, const int16_t *input,
+                                const int16_t *window, unsigned int len);
+void ff_apply_window_int16_ssse3(int16_t *output, const int16_t *input,
+                                 const int16_t *window, unsigned int len);
+void ff_apply_window_int16_ssse3_atom(int16_t *output, const int16_t *input,
+                                      const int16_t *window, unsigned int len);
+
 av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
 {
     int cpu_flags = av_get_cpu_flags();
 
     if (EXTERNAL_MMX(cpu_flags)) {
         c->ac3_exponent_min = ff_ac3_exponent_min_mmx;
+        c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx;
+        c->ac3_lshift_int16 = ff_ac3_lshift_int16_mmx;
+        c->ac3_rshift_int32 = ff_ac3_rshift_int32_mmx;
     }
     if (EXTERNAL_AMD3DNOW(cpu_flags)) {
         if (!bit_exact) {
@@ -53,20 +80,43 @@
     }
     if (EXTERNAL_MMXEXT(cpu_flags)) {
         c->ac3_exponent_min = ff_ac3_exponent_min_mmxext;
+        c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmxext;
+        if (bit_exact) {
+            c->apply_window_int16 = ff_apply_window_int16_mmxext;
+        } else {
+            c->apply_window_int16 = ff_apply_window_int16_round_mmxext;
+        }
     }
     if (EXTERNAL_SSE(cpu_flags)) {
         c->float_to_fixed24 = ff_float_to_fixed24_sse;
     }
     if (EXTERNAL_SSE2(cpu_flags)) {
         c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
+        c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_sse2;
         c->float_to_fixed24 = ff_float_to_fixed24_sse2;
         c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
         c->extract_exponents = ff_ac3_extract_exponents_sse2;
+        if (bit_exact) {
+            c->apply_window_int16 = ff_apply_window_int16_sse2;
+        }
+    }
+
+    if (EXTERNAL_SSE2_FAST(cpu_flags)) {
+        c->ac3_lshift_int16 = ff_ac3_lshift_int16_sse2;
+        c->ac3_rshift_int32 = ff_ac3_rshift_int32_sse2;
+        if (!bit_exact) {
+            c->apply_window_int16 = ff_apply_window_int16_round_sse2;
+        }
     }
 
     if (EXTERNAL_SSSE3(cpu_flags)) {
-        if (!(cpu_flags & AV_CPU_FLAG_ATOM))
+        c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3;
+        if (cpu_flags & AV_CPU_FLAG_ATOM) {
+            c->apply_window_int16 = ff_apply_window_int16_ssse3_atom;
+        } else {
             c->extract_exponents = ff_ac3_extract_exponents_ssse3;
+            c->apply_window_int16 = ff_apply_window_int16_ssse3;
+        }
     }
 }
 
diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h
index 53d74c5..cfd3b75 100644
--- a/libavcodec/x86/cabac.h
+++ b/libavcodec/x86/cabac.h
@@ -21,8 +21,6 @@
 #ifndef AVCODEC_X86_CABAC_H
 #define AVCODEC_X86_CABAC_H
 
-#include <stddef.h>
-
 #include "libavcodec/cabac.h"
 #include "libavutil/attributes.h"
 #include "libavutil/macros.h"
diff --git a/libavcodec/x86/cavsdsp.c b/libavcodec/x86/cavsdsp.c
index f974f93..becb3a4 100644
--- a/libavcodec/x86/cavsdsp.c
+++ b/libavcodec/x86/cavsdsp.c
@@ -25,7 +25,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/cavsdsp.h"
diff --git a/libavcodec/x86/cfhdencdsp.asm b/libavcodec/x86/cfhdencdsp.asm
deleted file mode 100644
index 4aaeb56..0000000
--- a/libavcodec/x86/cfhdencdsp.asm
+++ /dev/null
@@ -1,432 +0,0 @@
-;******************************************************************************
-;* x86-optimized functions for the CFHD encoder
-;* Copyright (c) 2021 Paul B Mahol
-;*
-;* This file is part of FFmpeg.
-;*
-;* FFmpeg is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* FFmpeg is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with FFmpeg; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-pw_p1_n1:  dw  1, -1, 1, -1, 1, -1, 1, -1
-pw_n1_p1:  dw  -1, 1, -1, 1, -1, 1, -1, 1
-pw_p5_n11: dw  5, -11, 5, -11, 5, -11, 5, -11
-pw_n5_p11: dw -5, 11, -5, 11, -5, 11, -5, 11
-pw_p11_n5: dw 11, -5, 11, -5, 11, -5, 11, -5
-pw_n11_p5: dw -11, 5, -11, 5, -11, 5, -11, 5
-pd_4:  times 4 dd  4
-pw_n4: times 8 dw -4
-cextern pw_m1
-cextern pw_1
-cextern pw_4
-
-SECTION .text
-
-%if ARCH_X86_64
-INIT_XMM sse2
-cglobal cfhdenc_horiz_filter, 8, 10, 11, input, low, high, istride, lwidth, hwidth, width, y, x, temp
-    shl  istrideq, 1
-    shl   lwidthq, 1
-    shl   hwidthq, 1
-    mova       m7, [pd_4]
-    mova       m8, [pw_1]
-    mova       m9, [pw_m1]
-    mova       m10,[pw_p1_n1]
-    movsxdifnidn yq, yd
-    movsxdifnidn widthq, widthd
-    neg        yq
-.looph:
-    movsx          xq, word [inputq]
-
-    movsx       tempq, word [inputq + 2]
-    add         tempq, xq
-
-    movd          xm0, tempd
-    packssdw       m0, m0
-    movd        tempd, m0
-    mov   word [lowq], tempw
-
-    movsx          xq, word [inputq]
-    imul           xq, 5
-    movsx       tempq, word [inputq + 2]
-    imul        tempq, -11
-    add         tempq, xq
-
-    movsx          xq, word [inputq + 4]
-    imul           xq, 4
-    add         tempq, xq
-
-    movsx          xq, word [inputq + 6]
-    imul           xq, 4
-    add         tempq, xq
-
-    movsx          xq, word [inputq + 8]
-    imul           xq, -1
-    add         tempq, xq
-
-    movsx          xq, word [inputq + 10]
-    imul           xq, -1
-    add         tempq, xq
-
-    add         tempq, 4
-    sar         tempq, 3
-
-    movd          xm0, tempd
-    packssdw       m0, m0
-    movd        tempd, m0
-    mov  word [highq], tempw
-
-    mov            xq, 2
-
-.loopw:
-    movu           m0, [inputq + xq * 2]
-    movu           m1, [inputq + xq * 2 + mmsize]
-
-    pmaddwd        m0, m8
-    pmaddwd        m1, m8
-
-    packssdw       m0, m1
-    movu    [lowq+xq], m0
-
-    movu           m2, [inputq + xq * 2 - 4]
-    movu           m3, [inputq + xq * 2 - 4 + mmsize]
-
-    pmaddwd        m2, m9
-    pmaddwd        m3, m9
-
-    movu           m0, [inputq + xq * 2 + 4]
-    movu           m1, [inputq + xq * 2 + 4 + mmsize]
-
-    pmaddwd        m0, m8
-    pmaddwd        m1, m8
-
-    paddd          m0, m2
-    paddd          m1, m3
-
-    paddd          m0, m7
-    paddd          m1, m7
-
-    psrad          m0, 3
-    psrad          m1, 3
-
-    movu           m5, [inputq + xq * 2 + 0]
-    movu           m6, [inputq + xq * 2 + mmsize]
-
-    pmaddwd        m5, m10
-    pmaddwd        m6, m10
-
-    paddd          m0, m5
-    paddd          m1, m6
-
-    packssdw       m0, m1
-    movu   [highq+xq], m0
-
-    add            xq, mmsize
-    cmp            xq, widthq
-    jl .loopw
-
-    add          lowq, widthq
-    add         highq, widthq
-    lea        inputq, [inputq + widthq * 2]
-
-    movsx          xq, word [inputq - 4]
-    movsx       tempq, word [inputq - 2]
-    add         tempq, xq
-
-    movd          xm0, tempd
-    packssdw       m0, m0
-    movd        tempd, m0
-    mov word [lowq-2], tempw
-
-    movsx       tempq, word [inputq - 4]
-    imul        tempq, 11
-    movsx          xq, word [inputq - 2]
-    imul           xq, -5
-    add         tempq, xq
-
-    movsx          xq, word [inputq - 6]
-    imul           xq, -4
-    add         tempq, xq
-
-    movsx          xq, word [inputq - 8]
-    imul           xq, -4
-    add         tempq, xq
-
-    movsx          xq, word [inputq - 10]
-    add         tempq, xq
-
-    movsx          xq, word [inputq - 12]
-    add         tempq, xq
-
-    add         tempq, 4
-    sar         tempq, 3
-
-    movd          xm0, tempd
-    packssdw       m0, m0
-    movd        tempd, m0
-    mov word [highq-2], tempw
-
-    sub        inputq, widthq
-    sub        inputq, widthq
-    sub         highq, widthq
-    sub          lowq, widthq
-
-    add          lowq, lwidthq
-    add         highq, hwidthq
-    add        inputq, istrideq
-    add            yq, 1
-    jl .looph
-
-    RET
-%endif
-
-%if ARCH_X86_64
-INIT_XMM sse2
-cglobal cfhdenc_vert_filter, 8, 11, 14, input, low, high, istride, lwidth, hwidth, width, height, x, y, pos
-    shl  istrideq, 1
-
-    shl    widthd, 1
-    sub   heightd, 2
-
-    xor        xq, xq
-
-    mova       m7, [pd_4]
-    mova       m8, [pw_1]
-    mova       m9, [pw_m1]
-    mova       m10,[pw_p1_n1]
-    mova       m11,[pw_n1_p1]
-    mova       m12,[pw_4]
-    mova       m13,[pw_n4]
-.loopw:
-    mov        yq, 2
-
-    mov      posq, xq
-    movu       m0, [inputq + posq]
-    add      posq, istrideq
-    movu       m1, [inputq + posq]
-
-    paddsw     m0, m1
-
-    movu    [lowq + xq], m0
-
-    mov      posq, xq
-
-    movu       m0, [inputq + posq]
-    add      posq, istrideq
-    movu       m1, [inputq + posq]
-    add      posq, istrideq
-    movu       m2, [inputq + posq]
-    add      posq, istrideq
-    movu       m3, [inputq + posq]
-    add      posq, istrideq
-    movu       m4, [inputq + posq]
-    add      posq, istrideq
-    movu       m5, [inputq + posq]
-
-    mova       m6, m0
-    punpcklwd  m0, m1
-    punpckhwd  m1, m6
-
-    mova       m6, m2
-    punpcklwd  m2, m3
-    punpckhwd  m3, m6
-
-    mova       m6, m4
-    punpcklwd  m4, m5
-    punpckhwd  m5, m6
-
-    pmaddwd    m0, [pw_p5_n11]
-    pmaddwd    m1, [pw_n11_p5]
-    pmaddwd    m2, m12
-    pmaddwd    m3, m12
-    pmaddwd    m4, m9
-    pmaddwd    m5, m9
-
-    paddd      m0, m2
-    paddd      m1, m3
-    paddd      m0, m4
-    paddd      m1, m5
-
-    paddd      m0, m7
-    paddd      m1, m7
-
-    psrad      m0, 3
-    psrad      m1, 3
-    packssdw   m0, m1
-
-    movu   [highq + xq], m0
-
-.looph:
-
-    mov      posq, istrideq
-    imul     posq, yq
-    add      posq, xq
-
-    movu       m0, [inputq + posq]
-
-    add      posq, istrideq
-    movu       m1, [inputq + posq]
-
-    paddsw     m0, m1
-
-    mov      posq, lwidthq
-    imul     posq, yq
-    add      posq, xq
-
-    movu    [lowq + posq], m0
-
-    add        yq, -2
-
-    mov      posq, istrideq
-    imul     posq, yq
-    add      posq, xq
-
-    movu       m0, [inputq + posq]
-    add      posq, istrideq
-    movu       m1, [inputq + posq]
-    add      posq, istrideq
-    movu       m2, [inputq + posq]
-    add      posq, istrideq
-    movu       m3, [inputq + posq]
-    add      posq, istrideq
-    movu       m4, [inputq + posq]
-    add      posq, istrideq
-    movu       m5, [inputq + posq]
-
-    add        yq, 2
-
-    mova       m6, m0
-    punpcklwd  m0, m1
-    punpckhwd  m1, m6
-
-    mova       m6, m2
-    punpcklwd  m2, m3
-    punpckhwd  m3, m6
-
-    mova       m6, m4
-    punpcklwd  m4, m5
-    punpckhwd  m5, m6
-
-    pmaddwd    m0, m9
-    pmaddwd    m1, m9
-    pmaddwd    m2, m10
-    pmaddwd    m3, m11
-    pmaddwd    m4, m8
-    pmaddwd    m5, m8
-
-    paddd      m0, m4
-    paddd      m1, m5
-
-    paddd      m0, m7
-    paddd      m1, m7
-
-    psrad      m0, 3
-    psrad      m1, 3
-    paddd      m0, m2
-    paddd      m1, m3
-    packssdw   m0, m1
-
-    mov      posq, hwidthq
-    imul     posq, yq
-    add      posq, xq
-
-    movu   [highq + posq], m0
-
-    add        yq, 2
-    cmp        yq, heightq
-    jl .looph
-
-    mov      posq, istrideq
-    imul     posq, yq
-    add      posq, xq
-
-    movu       m0, [inputq + posq]
-    add      posq, istrideq
-    movu       m1, [inputq + posq]
-
-    paddsw     m0, m1
-
-    mov      posq, lwidthq
-    imul     posq, yq
-    add      posq, xq
-
-    movu    [lowq + posq], m0
-
-    sub        yq, 4
-
-    mov      posq, istrideq
-    imul     posq, yq
-    add      posq, xq
-
-    movu       m0, [inputq + posq]
-    add      posq, istrideq
-    movu       m1, [inputq + posq]
-    add      posq, istrideq
-    movu       m2, [inputq + posq]
-    add      posq, istrideq
-    movu       m3, [inputq + posq]
-    add      posq, istrideq
-    movu       m4, [inputq + posq]
-    add      posq, istrideq
-    movu       m5, [inputq + posq]
-
-    add        yq, 4
-
-    mova       m6, m0
-    punpcklwd  m0, m1
-    punpckhwd  m1, m6
-
-    mova       m6, m2
-    punpcklwd  m2, m3
-    punpckhwd  m3, m6
-
-    mova       m6, m4
-    punpcklwd  m4, m5
-    punpckhwd  m5, m6
-
-    pmaddwd    m0, m8
-    pmaddwd    m1, m8
-    pmaddwd    m2, m13
-    pmaddwd    m3, m13
-    pmaddwd    m4, [pw_p11_n5]
-    pmaddwd    m5, [pw_n5_p11]
-
-    paddd      m4, m2
-    paddd      m5, m3
-
-    paddd      m4, m0
-    paddd      m5, m1
-
-    paddd      m4, m7
-    paddd      m5, m7
-
-    psrad      m4, 3
-    psrad      m5, 3
-    packssdw   m4, m5
-
-    mov      posq, hwidthq
-    imul     posq, yq
-    add      posq, xq
-
-    movu   [highq + posq], m4
-
-    add        xq, mmsize
-    cmp        xq, widthq
-    jl .loopw
-    RET
-%endif
diff --git a/libavcodec/x86/cfhdencdsp_init.c b/libavcodec/x86/cfhdencdsp_init.c
deleted file mode 100644
index 28f1dd5..0000000
--- a/libavcodec/x86/cfhdencdsp_init.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/cfhdencdsp.h"
-
-void ff_cfhdenc_horiz_filter_sse2(int16_t *input, int16_t *low, int16_t *high,
-                                  ptrdiff_t in_stride, ptrdiff_t low_stride,
-                                  ptrdiff_t high_stride,
-                                  int width, int height);
-void ff_cfhdenc_vert_filter_sse2(int16_t *input, int16_t *low, int16_t *high,
-                                 ptrdiff_t in_stride, ptrdiff_t low_stride,
-                                 ptrdiff_t high_stride,
-                                 int width, int height);
-
-av_cold void ff_cfhdencdsp_init_x86(CFHDEncDSPContext *c)
-{
-    int cpu_flags = av_get_cpu_flags();
-
-#if ARCH_X86_64
-    if (EXTERNAL_SSE2(cpu_flags)) {
-        c->horiz_filter = ff_cfhdenc_horiz_filter_sse2;
-        c->vert_filter = ff_cfhdenc_vert_filter_sse2;
-    }
-#endif
-}
diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c
index bc7f2b1..4bfb78c 100644
--- a/libavcodec/x86/constants.c
+++ b/libavcodec/x86/constants.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h" // for xmm_reg
 #include "constants.h"
 
@@ -34,6 +34,7 @@
 DECLARE_ASM_ALIGNED(16, const xmm_reg,  ff_pw_9)    = { 0x0009000900090009ULL, 0x0009000900090009ULL };
 DECLARE_ALIGNED(8,  const uint64_t, ff_pw_15)   =   0x000F000F000F000FULL;
 DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_16)   = { 0x0010001000100010ULL, 0x0010001000100010ULL };
+DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_17)   = { 0x0011001100110011ULL, 0x0011001100110011ULL };
 DECLARE_ASM_ALIGNED(16, const xmm_reg,  ff_pw_18)   = { 0x0012001200120012ULL, 0x0012001200120012ULL };
 DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_20)   = { 0x0014001400140014ULL, 0x0014001400140014ULL };
 DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_32)   = { 0x0020002000200020ULL, 0x0020002000200020ULL };
diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c
index 8baacf3..8cb84eb 100644
--- a/libavcodec/x86/diracdsp_init.c
+++ b/libavcodec/x86/diracdsp_init.c
@@ -22,6 +22,15 @@
 #include "libavcodec/diracdsp.h"
 #include "fpel.h"
 
+DECL_DIRAC_PIXOP(put, mmx);
+DECL_DIRAC_PIXOP(avg, mmx);
+DECL_DIRAC_PIXOP(avg, mmxext);
+
+void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
+void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
+void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
+void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
+
 void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
 void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
 
@@ -63,47 +72,89 @@
     }
 
 #define PIXFUNC(PFX, IDX, EXT)                                                   \
-    /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = PFX ## _dirac_pixels8_ ## EXT;*/  \
-    c->PFX ## _dirac_pixels_tab[1][IDX] = PFX ## _dirac_pixels16_ ## EXT; \
-    c->PFX ## _dirac_pixels_tab[2][IDX] = PFX ## _dirac_pixels32_ ## EXT
+    /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## _dirac_pixels8_ ## EXT;*/  \
+    c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## EXT; \
+    c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
 
-#define DIRAC_PIXOP(OPNAME, EXT)\
-static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], \
-                                              int stride, int h) \
+#define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
+void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 {\
     if (h&3)\
-        ff_ ## OPNAME ## _dirac_pixels16_c(dst, src, stride, h);\
+        ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\
     else\
-        ff_ ## OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
+        OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
 }\
-static void OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], \
-                                              int stride, int h) \
+void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
+{\
+    if (h&3)\
+        ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\
+    else\
+        OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
+}\
+void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 {\
     if (h&3) {\
-        ff_ ## OPNAME ## _dirac_pixels32_c(dst, src, stride, h);\
+        ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\
     } else {\
-        ff_ ## OPNAME ## _pixels16_ ## EXT(dst   , src[0]   , stride, h);\
-        ff_ ## OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
+        OPNAME ## _pixels16_ ## EXT(dst   , src[0]   , stride, h);\
+        OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
     }\
 }
 
-DIRAC_PIXOP(put, mmx)
-DIRAC_PIXOP(avg, mmx)
-DIRAC_PIXOP(avg, mmxext)
+DIRAC_PIXOP(put, ff_put, mmx)
+DIRAC_PIXOP(avg, ff_avg, mmx)
+DIRAC_PIXOP(avg, ff_avg, mmxext)
 
-DIRAC_PIXOP(put, sse2)
-DIRAC_PIXOP(avg, sse2)
+void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
+{
+    if (h&3)
+        ff_put_dirac_pixels16_c(dst, src, stride, h);
+    else
+        ff_put_pixels16_sse2(dst, src[0], stride, h);
+}
+void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
+{
+    if (h&3)
+        ff_avg_dirac_pixels16_c(dst, src, stride, h);
+    else
+        ff_avg_pixels16_sse2(dst, src[0], stride, h);
+}
+void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
+{
+    if (h&3) {
+        ff_put_dirac_pixels32_c(dst, src, stride, h);
+    } else {
+        ff_put_pixels16_sse2(dst   , src[0]   , stride, h);
+        ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h);
+    }
+}
+void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
+{
+    if (h&3) {
+        ff_avg_dirac_pixels32_c(dst, src, stride, h);
+    } else {
+        ff_avg_pixels16_sse2(dst   , src[0]   , stride, h);
+        ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
+    }
+}
+
+#else // HAVE_X86ASM
+
+#define HPEL_FILTER(MMSIZE, EXT)                                                     \
+    void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,              \
+                                   const uint8_t *src, int stride, int width, int height);
+
+#define PIXFUNC(PFX, IDX, EXT) do {} while (0)
+
+#endif // HAVE_X86ASM
 
 #if !ARCH_X86_64
 HPEL_FILTER(8, mmx)
 #endif
 HPEL_FILTER(16, sse2)
 
-#endif // HAVE_X86ASM
-
 void ff_diracdsp_init_x86(DiracDSPContext* c)
 {
-#if HAVE_X86ASM
     int mm_flags = av_get_cpu_flags();
 
     if (EXTERNAL_MMX(mm_flags)) {
@@ -131,15 +182,14 @@
         c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
         c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
 
-        c->put_dirac_pixels_tab[1][0] = put_dirac_pixels16_sse2;
-        c->avg_dirac_pixels_tab[1][0] = avg_dirac_pixels16_sse2;
-        c->put_dirac_pixels_tab[2][0] = put_dirac_pixels32_sse2;
-        c->avg_dirac_pixels_tab[2][0] = avg_dirac_pixels32_sse2;
+        c->put_dirac_pixels_tab[1][0] = ff_put_dirac_pixels16_sse2;
+        c->avg_dirac_pixels_tab[1][0] = ff_avg_dirac_pixels16_sse2;
+        c->put_dirac_pixels_tab[2][0] = ff_put_dirac_pixels32_sse2;
+        c->avg_dirac_pixels_tab[2][0] = ff_avg_dirac_pixels32_sse2;
     }
 
     if (EXTERNAL_SSE4(mm_flags)) {
         c->dequant_subband[1]         = ff_dequant_subband_32_sse4;
         c->put_signed_rect_clamped[1] = ff_put_signed_rect_clamped_10_sse4;
     }
-#endif
 }
diff --git a/libavcodec/x86/fdct.c b/libavcodec/x86/fdct.c
index d77f60c..112566d 100644
--- a/libavcodec/x86/fdct.c
+++ b/libavcodec/x86/fdct.c
@@ -31,7 +31,6 @@
  */
 
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "fdct.h"
 
diff --git a/libavcodec/x86/h264_intrapred.asm b/libavcodec/x86/h264_intrapred.asm
index b36c198..f3aa317 100644
--- a/libavcodec/x86/h264_intrapred.asm
+++ b/libavcodec/x86/h264_intrapred.asm
@@ -42,7 +42,11 @@
 cextern pb_1
 cextern pb_3
 cextern pw_4
+cextern pw_5
 cextern pw_8
+cextern pw_16
+cextern pw_17
+cextern pw_32
 
 ;-----------------------------------------------------------------------------
 ; void ff_pred16x16_vertical_8(uint8_t *src, ptrdiff_t stride)
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index a2d8a64..0d3dbba 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/h264dec.h"
diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
index 8a3fa27..17cd233 100644
--- a/libavcodec/x86/hevcdsp_init.c
+++ b/libavcodec/x86/hevcdsp_init.c
@@ -22,7 +22,6 @@
 #include "config.h"
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/get_bits.h" /* required for hevcdsp.h GetBitContext */
diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c
index 701eb1a..6aec93e 100644
--- a/libavcodec/x86/me_cmp_init.c
+++ b/libavcodec/x86/me_cmp_init.c
@@ -24,7 +24,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/me_cmp.h"
diff --git a/libavcodec/x86/mpegaudiodsp.c b/libavcodec/x86/mpegaudiodsp.c
index 50692f2..d646c6d 100644
--- a/libavcodec/x86/mpegaudiodsp.c
+++ b/libavcodec/x86/mpegaudiodsp.c
@@ -22,7 +22,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/mpegaudiodsp.h"
diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index 4bad6a8..c884cf1 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/avcodec.h"
diff --git a/libavcodec/x86/mpegvideoenc_template.c b/libavcodec/x86/mpegvideoenc_template.c
index b32b1b0..1201be5 100644
--- a/libavcodec/x86/mpegvideoenc_template.c
+++ b/libavcodec/x86/mpegvideoenc_template.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavcodec/mpegutils.h"
 #include "libavcodec/mpegvideo.h"
diff --git a/libavcodec/x86/rv40dsp_init.c b/libavcodec/x86/rv40dsp_init.c
index 79a617f..b57a3fc 100644
--- a/libavcodec/x86/rv40dsp_init.c
+++ b/libavcodec/x86/rv40dsp_init.c
@@ -29,7 +29,6 @@
 #include "libavcodec/rv34dsp.h"
 #include "libavutil/attributes.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/cpu.h"
 #include "hpeldsp.h"
 
diff --git a/libavcodec/x86/vc1dsp_mmx.c b/libavcodec/x86/vc1dsp_mmx.c
index 6541dda..45c8a68 100644
--- a/libavcodec/x86/vc1dsp_mmx.c
+++ b/libavcodec/x86/vc1dsp_mmx.c
@@ -26,7 +26,6 @@
 
 #include "libavutil/cpu.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/vc1dsp.h"
diff --git a/libavcodec/x86/vp8dsp_init.c b/libavcodec/x86/vp8dsp_init.c
index dffa7a2..397b251 100644
--- a/libavcodec/x86/vp8dsp_init.c
+++ b/libavcodec/x86/vp8dsp_init.c
@@ -23,7 +23,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/vp8dsp.h"
 
diff --git a/libavcodec/x86/vp9dsp_init.h b/libavcodec/x86/vp9dsp_init.h
index ebe7ca8..e410cab 100644
--- a/libavcodec/x86/vp9dsp_init.h
+++ b/libavcodec/x86/vp9dsp_init.h
@@ -23,8 +23,6 @@
 #ifndef AVCODEC_X86_VP9DSP_INIT_H
 #define AVCODEC_X86_VP9DSP_INIT_H
 
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/vp9dsp.h"
 
 // hack to force-expand BPC
diff --git a/libavcodec/x86/w64xmmtest.c b/libavcodec/x86/w64xmmtest.c
index d0782b9..8f2b8a6 100644
--- a/libavcodec/x86/w64xmmtest.c
+++ b/libavcodec/x86/w64xmmtest.c
@@ -29,7 +29,6 @@
     testxmmclobbers(avcodec_open2, avctx, codec, options);
 }
 
-#if FF_API_OLD_ENCDEC
 wrap(avcodec_decode_audio4(AVCodecContext *avctx,
                            AVFrame *frame,
                            int *got_frame_ptr,
@@ -48,22 +47,6 @@
                     got_picture_ptr, avpkt);
 }
 
-wrap(avcodec_encode_audio2(AVCodecContext *avctx,
-                           AVPacket *avpkt,
-                           const AVFrame *frame,
-                           int *got_packet_ptr))
-{
-    testxmmclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
-                    got_packet_ptr);
-}
-
-wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                           const AVFrame *frame, int *got_packet_ptr))
-{
-    testxmmclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
-}
-#endif
-
 wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
                               AVSubtitle *sub,
                               int *got_sub_ptr,
@@ -73,6 +56,15 @@
                     got_sub_ptr, avpkt);
 }
 
+wrap(avcodec_encode_audio2(AVCodecContext *avctx,
+                           AVPacket *avpkt,
+                           const AVFrame *frame,
+                           int *got_packet_ptr))
+{
+    testxmmclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
+                    got_packet_ptr);
+}
+
 wrap(avcodec_encode_subtitle(AVCodecContext *avctx,
                              uint8_t *buf, int buf_size,
                              const AVSubtitle *sub))
@@ -80,6 +72,12 @@
     testxmmclobbers(avcodec_encode_subtitle, avctx, buf, buf_size, sub);
 }
 
+wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
+                           const AVFrame *frame, int *got_packet_ptr))
+{
+    testxmmclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
+}
+
 wrap(avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt))
 {
     testxmmclobbers(avcodec_send_packet, avctx, avpkt);
diff --git a/libavcodec/xbm_parser.c b/libavcodec/xbm_parser.c
deleted file mode 100644
index 6b0eea6..0000000
--- a/libavcodec/xbm_parser.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * XBM parser
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * XBM parser
- */
-
-#include "libavutil/common.h"
-
-#include "parser.h"
-
-typedef struct XBMParseContext {
-    ParseContext pc;
-    uint16_t state16;
-    int count;
-} XBMParseContext;
-
-#define KEY (((uint64_t)'\n' << 56) | ((uint64_t)'#' << 48) | \
-             ((uint64_t)'d' << 40)  | ((uint64_t)'e' << 32) | \
-             ((uint64_t)'f' << 24) | ('i' << 16) | ('n' << 8) | \
-             ('e' << 0))
-
-#define END ((';' << 8) | ('\n' << 0))
-
-static int xbm_init(AVCodecParserContext *s)
-{
-    XBMParseContext *bpc = s->priv_data;
-
-    bpc->count = 1;
-
-    return 0;
-}
-
-static int xbm_parse(AVCodecParserContext *s, AVCodecContext *avctx,
-                     const uint8_t **poutbuf, int *poutbuf_size,
-                     const uint8_t *buf, int buf_size)
-{
-    XBMParseContext *bpc = s->priv_data;
-    uint64_t state = bpc->pc.state64;
-    uint16_t state16 = bpc->state16;
-    int next = END_NOT_FOUND, i = 0;
-
-    s->pict_type = AV_PICTURE_TYPE_I;
-    s->key_frame = 1;
-    s->duration  = 1;
-
-    *poutbuf_size = 0;
-    *poutbuf = NULL;
-
-    for (; i < buf_size; i++) {
-        state = (state << 8) | buf[i];
-        state16 = (state16 << 8) | buf[i];
-
-        if (state == KEY)
-            bpc->count++;
-
-        if ((state == KEY && bpc->count == 1)) {
-            next = i - 6;
-            break;
-        } else if (state16 == END) {
-            next = i + 1;
-            bpc->count = 0;
-            break;
-        }
-    }
-
-    bpc->pc.state64 = state;
-    bpc->state16 = state16;
-    if (ff_combine_frame(&bpc->pc, next, &buf, &buf_size) < 0) {
-        *poutbuf = NULL;
-        *poutbuf_size = 0;
-        return buf_size;
-    }
-
-    *poutbuf      = buf;
-    *poutbuf_size = buf_size;
-
-    return next;
-}
-
-AVCodecParser ff_xbm_parser = {
-    .codec_ids      = { AV_CODEC_ID_XBM },
-    .priv_data_size = sizeof(XBMParseContext),
-    .parser_init    = xbm_init,
-    .parser_parse   = xbm_parse,
-    .parser_close   = ff_parse_close,
-};
diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c
index c1fc6cb..d19bdae 100644
--- a/libavcodec/xbmdec.c
+++ b/libavcodec/xbmdec.c
@@ -26,31 +26,26 @@
 #include "internal.h"
 #include "mathops.h"
 
-static int get_nibble(uint8_t x)
+static int convert(uint8_t x)
 {
-    int ret = 255;
-
-    if (x <= '9') {
-        if (x >= '0')
-            ret = x - '0';
-    } else if (x >= 'a') {
-        if (x <= 'f')
-            ret = x - ('a' - 10);
-    } else if (x >= 'A' && x <= 'F')
-        ret = x - ('A' - 10);
-    return ret;
+    if (x >= 'a')
+        x -= 87;
+    else if (x >= 'A')
+        x -= 55;
+    else
+        x -= '0';
+    return x;
 }
 
-static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key)
+static int parse_str_int(const uint8_t *p, int len, const uint8_t *key)
 {
-    int keylen = strlen(key);
-    const uint8_t *e = end - keylen;
+    const uint8_t *end = p + len;
 
-    for(; p < e; p++) {
-        if (!memcmp(p, key, keylen))
+    for(; p<end - strlen(key); p++) {
+        if (!memcmp(p, key, strlen(key)))
             break;
     }
-    p += keylen;
+    p += strlen(key);
     if (p >= end)
         return INT_MIN;
 
@@ -77,8 +72,8 @@
     avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
     end = avpkt->data + avpkt->size;
 
-    width  = parse_str_int(avpkt->data, end, "_width");
-    height = parse_str_int(avpkt->data, end, "_height");
+    width  = parse_str_int(avpkt->data, avpkt->size, "_width");
+    height = parse_str_int(avpkt->data, avpkt->size, "_height");
 
     if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
         return ret;
@@ -98,26 +93,22 @@
     for (i = 0; i < avctx->height; i++) {
         dst = p->data[0] + i * p->linesize[0];
         for (j = 0; j < linesize; j++) {
-            uint8_t nib, val;
+            uint8_t val;
 
             while (ptr < end && *ptr != 'x' && *ptr != '$')
                 ptr++;
 
             ptr ++;
-            if (ptr < end && (val = get_nibble(*ptr)) <= 15) {
-                ptr++;
-                if ((nib = get_nibble(*ptr)) <= 15) {
-                    val = (val << 4) + nib;
-                    ptr++;
-                }
+            if (ptr < end && av_isxdigit(*ptr)) {
+                val = convert(*ptr++);
+                if (av_isxdigit(*ptr))
+                    val = (val << 4) + convert(*ptr++);
                 *dst++ = ff_reverse[val];
-                if ((val = get_nibble(*ptr)) <= 15 && j+1 < linesize) {
+                if (av_isxdigit(*ptr) && j+1 < linesize) {
                     j++;
-                    ptr++;
-                    if ((nib = get_nibble(*ptr)) <= 15) {
-                        val = (val << 4) + nib;
-                        ptr++;
-                    }
+                    val = convert(*ptr++);
+                    if (av_isxdigit(*ptr))
+                        val = (val << 4) + convert(*ptr++);
                     *dst++ = ff_reverse[val];
                 }
             } else {
diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index 1cf13f6..b25615f 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -24,25 +24,14 @@
 #include "internal.h"
 #include "mathops.h"
 
-#define ANSI_MIN_READLINE 509
-
 static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                             const AVFrame *p, int *got_packet)
 {
-    int i, j, l, commas, ret, size, linesize, lineout, rowsout;
+    int i, j, ret, size, linesize;
     uint8_t *ptr, *buf;
 
-    linesize = lineout = (avctx->width + 7) / 8;
-    commas   = avctx->height * linesize;
-
-    /* ANSI worst case minimum readline is 509 chars. */
-    rowsout  = avctx->height;
-    if (lineout > (ANSI_MIN_READLINE / 6)) {
-        lineout = ANSI_MIN_READLINE / 6;
-        rowsout = (commas + lineout - 1) / lineout;
-    }
-
-    size     = rowsout * (lineout * 6 + 1) + 106;
+    linesize = (avctx->width + 7) / 8;
+    size     = avctx->height * (linesize * 7 + 2) + 110;
     if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0)
         return ret;
 
@@ -51,21 +40,12 @@
 
     buf += snprintf(buf, 32, "#define image_width %u\n", avctx->width);
     buf += snprintf(buf, 33, "#define image_height %u\n", avctx->height);
-    buf += snprintf(buf, 39, "static unsigned char image_bits[] = {\n");
-    for (i = 0, l = lineout; i < avctx->height; i++) {
-        for (j = 0; j < linesize; j++) {
-            buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]);
-            if (--commas <= 0) {
-                buf += snprintf(buf, 2, "\n");
-                break;
-            }
-            buf += snprintf(buf, 2, ",");
-            if (--l <= 0) {
-                buf += snprintf(buf, 2, "\n");
-                l = lineout;
-            }
-        }
+    buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n");
+    for (i = 0; i < avctx->height; i++) {
+        for (j = 0; j < linesize; j++)
+            buf += snprintf(buf, 7, " 0x%02X,", ff_reverse[*ptr++]);
         ptr += p->linesize[0] - linesize;
+        buf += snprintf(buf, 2, "\n");
     }
     buf += snprintf(buf, 5, " };\n");
 
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
index ab1f895..f68fcf0 100644
--- a/libavcodec/ylc.c
+++ b/libavcodec/ylc.c
@@ -38,9 +38,11 @@
 
 typedef struct YLCContext {
     VLC vlc[4];
-    uint32_t table[256];
-    uint8_t *buffer;
-    int buffer_size;
+    uint32_t table[1024];
+    uint8_t *table_bits;
+    uint8_t *bitstream_bits;
+    int table_bits_size;
+    int bitstream_bits_size;
     BswapDSPContext bdsp;
 } YLCContext;
 
@@ -56,6 +58,7 @@
 
 typedef struct Node {
     int16_t  sym;
+    int16_t  n0;
     uint32_t count;
     int16_t  l, r;
 } Node;
@@ -96,6 +99,7 @@
     for (i = 0; i < 256; i++) {
         nodes[i].count = table[i];
         nodes[i].sym   = i;
+        nodes[i].n0    = -2;
         nodes[i].l     = i;
         nodes[i].r     = i;
     }
@@ -137,6 +141,7 @@
             }
             nodes[cur_node].count = nd + st;
             nodes[cur_node].sym = -1;
+            nodes[cur_node].n0 = cur_node;
             nodes[cur_node].l = first_node;
             nodes[cur_node].r = second_node;
             cur_node++;
@@ -310,39 +315,50 @@
     if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
         return ret;
 
-    av_fast_malloc(&s->buffer, &s->buffer_size,
-                   FFMAX(boffset - toffset, avpkt->size - boffset)
-                       + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!s->buffer)
+    av_fast_malloc(&s->table_bits, &s->table_bits_size,
+                   boffset - toffset + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!s->table_bits)
         return AVERROR(ENOMEM);
 
-    memcpy(s->buffer, avpkt->data + toffset, boffset - toffset);
-    memset(s->buffer + boffset - toffset, 0, AV_INPUT_BUFFER_PADDING_SIZE);
-    s->bdsp.bswap_buf((uint32_t *) s->buffer,
-                      (uint32_t *) s->buffer,
+    memcpy(s->table_bits, avpkt->data + toffset, boffset - toffset);
+    memset(s->table_bits + boffset - toffset, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+    s->bdsp.bswap_buf((uint32_t *) s->table_bits,
+                      (uint32_t *) s->table_bits,
                       (boffset - toffset + 3) >> 2);
-    if ((ret = init_get_bits8(&gb, s->buffer, boffset - toffset)) < 0)
+    if ((ret = init_get_bits8(&gb, s->table_bits, boffset - toffset)) < 0)
         return ret;
 
-    for (int i = 0; i < 4; i++) {
-        for (x = 0; x < 256; x++) {
-            unsigned len = get_unary(&gb, 1, 31);
-            uint32_t val = ((1U << len) - 1) + get_bits_long(&gb, len);
+    for (x = 0; x < 1024; x++) {
+        unsigned len = get_unary(&gb, 1, 31);
+        uint32_t val = ((1U << len) - 1) + get_bits_long(&gb, len);
 
-            s->table[x] = val;
-        }
-
-        ret = build_vlc(avctx, &s->vlc[i], s->table);
-        if (ret < 0)
-            return ret;
+        s->table[x] = val;
     }
 
-    memcpy(s->buffer, avpkt->data + boffset, avpkt->size - boffset);
-    memset(s->buffer + avpkt->size - boffset, 0, AV_INPUT_BUFFER_PADDING_SIZE);
-    s->bdsp.bswap_buf((uint32_t *) s->buffer,
-                      (uint32_t *) s->buffer,
+    ret = build_vlc(avctx, &s->vlc[0], &s->table[0  ]);
+    if (ret < 0)
+        return ret;
+    ret = build_vlc(avctx, &s->vlc[1], &s->table[256]);
+    if (ret < 0)
+        return ret;
+    ret = build_vlc(avctx, &s->vlc[2], &s->table[512]);
+    if (ret < 0)
+        return ret;
+    ret = build_vlc(avctx, &s->vlc[3], &s->table[768]);
+    if (ret < 0)
+        return ret;
+
+    av_fast_malloc(&s->bitstream_bits, &s->bitstream_bits_size,
+                   avpkt->size - boffset + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!s->bitstream_bits)
+        return AVERROR(ENOMEM);
+
+    memcpy(s->bitstream_bits, avpkt->data + boffset, avpkt->size - boffset);
+    memset(s->bitstream_bits + avpkt->size - boffset, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+    s->bdsp.bswap_buf((uint32_t *) s->bitstream_bits,
+                      (uint32_t *) s->bitstream_bits,
                       (avpkt->size - boffset) >> 2);
-    if ((ret = init_get_bits8(&gb, s->buffer, avpkt->size - boffset)) < 0)
+    if ((ret = init_get_bits8(&gb, s->bitstream_bits, avpkt->size - boffset)) < 0)
         return ret;
 
     dst = p->data[0];
@@ -444,10 +460,14 @@
 {
     YLCContext *s = avctx->priv_data;
 
-    for (int i = 0; i < FF_ARRAY_ELEMS(s->vlc); i++)
-        ff_free_vlc(&s->vlc[i]);
-    av_freep(&s->buffer);
-    s->buffer_size = 0;
+    ff_free_vlc(&s->vlc[0]);
+    ff_free_vlc(&s->vlc[1]);
+    ff_free_vlc(&s->vlc[2]);
+    ff_free_vlc(&s->vlc[3]);
+    av_freep(&s->table_bits);
+    s->table_bits_size = 0;
+    av_freep(&s->bitstream_bits);
+    s->bitstream_bits_size = 0;
 
     return 0;
 }
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 554debc..ec84d3b 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -27,11 +27,39 @@
 #include "libavutil/ffversion.h"
 const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
-#if FF_API_DEVICE_CAPABILITIES
+#define E AV_OPT_FLAG_ENCODING_PARAM
+#define D AV_OPT_FLAG_DECODING_PARAM
+#define A AV_OPT_FLAG_AUDIO_PARAM
+#define V AV_OPT_FLAG_VIDEO_PARAM
+#define OFFSET(x) offsetof(AVDeviceCapabilitiesQuery, x)
+
 const AVOption av_device_capabilities[] = {
+    { "codec", "codec", OFFSET(codec), AV_OPT_TYPE_INT,
+        {.i64 = AV_CODEC_ID_NONE}, AV_CODEC_ID_NONE, INT_MAX, E|D|A|V },
+    { "sample_format", "sample format", OFFSET(sample_format), AV_OPT_TYPE_SAMPLE_FMT,
+        {.i64 = AV_SAMPLE_FMT_NONE}, AV_SAMPLE_FMT_NONE, INT_MAX, E|D|A },
+    { "sample_rate", "sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT,
+        {.i64 = -1}, -1, INT_MAX, E|D|A },
+    { "channels", "channels", OFFSET(channels), AV_OPT_TYPE_INT,
+        {.i64 = -1}, -1, INT_MAX, E|D|A },
+    { "channel_layout", "channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT,
+        {.i64 = -1}, -1, INT_MAX, E|D|A },
+    { "pixel_format", "pixel format", OFFSET(pixel_format), AV_OPT_TYPE_PIXEL_FMT,
+        {.i64 = AV_PIX_FMT_NONE}, AV_PIX_FMT_NONE, INT_MAX, E|D|V },
+    { "window_size", "window size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE,
+        {.str = NULL}, -1, INT_MAX, E|D|V },
+    { "frame_size", "frame size", OFFSET(frame_width), AV_OPT_TYPE_IMAGE_SIZE,
+        {.str = NULL}, -1, INT_MAX, E|D|V },
+    { "fps", "fps", OFFSET(fps), AV_OPT_TYPE_RATIONAL,
+        {.dbl = -1}, -1, INT_MAX, E|D|V },
     { NULL }
 };
-#endif
+
+#undef E
+#undef D
+#undef A
+#undef V
+#undef OFFSET
 
 unsigned avdevice_version(void)
 {
@@ -66,18 +94,49 @@
     return s->control_message_cb(s, type, data, data_size);
 }
 
-#if FF_API_DEVICE_CAPABILITIES
 int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
                                  AVDictionary **device_options)
 {
-    return AVERROR(ENOSYS);
+    int ret;
+    av_assert0(s && caps);
+    av_assert0(s->iformat || s->oformat);
+    if ((s->oformat && !s->oformat->create_device_capabilities) ||
+        (s->iformat && !s->iformat->create_device_capabilities))
+        return AVERROR(ENOSYS);
+    *caps = av_mallocz(sizeof(**caps));
+    if (!(*caps))
+        return AVERROR(ENOMEM);
+    (*caps)->device_context = s;
+    if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0))
+        goto fail;
+    if (s->iformat) {
+        if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0)
+            goto fail;
+    } else {
+        if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0)
+            goto fail;
+    }
+    av_opt_set_defaults(*caps);
+    return 0;
+  fail:
+    av_freep(caps);
+    return ret;
 }
 
 void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s)
 {
-    return;
+    if (!s || !caps || !(*caps))
+        return;
+    av_assert0(s->iformat || s->oformat);
+    if (s->iformat) {
+        if (s->iformat->free_device_capabilities)
+            s->iformat->free_device_capabilities(s, *caps);
+    } else {
+        if (s->oformat->free_device_capabilities)
+            s->oformat->free_device_capabilities(s, *caps);
+    }
+    av_freep(caps);
 }
-#endif
 
 int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
 {
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 85a4dcc..ee94624 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -321,7 +321,6 @@
                                         enum AVDevToAppMessageType type,
                                         void *data, size_t data_size);
 
-#if FF_API_DEVICE_CAPABILITIES
 /**
  * Following API allows user to probe device capabilities (supported codecs,
  * pixel formats, sample formats, resolutions, channel counts, etc).
@@ -417,7 +416,6 @@
 /**
  * AVOption table used by devices to implement device capabilities API. Should not be used by a user.
  */
-attribute_deprecated
 extern const AVOption av_device_capabilities[];
 
 /**
@@ -437,7 +435,6 @@
  *
  * @return >= 0 on success, negative otherwise.
  */
-attribute_deprecated
 int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
                                  AVDictionary **device_options);
 
@@ -447,9 +444,7 @@
  * @param caps Device capabilities data to be freed.
  * @param s    Context of the device.
  */
-attribute_deprecated
 void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s);
-#endif
 
 /**
  * Structure describes basic parameters of the device.
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 0688028..2601adb 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -225,14 +225,14 @@
 {
     uint64_t curtime;
 
-    curtime = av_gettime_relative();
+    curtime = av_gettime();
     if (!last_frame_time
         || ((last_frame_time + per_frame) > curtime)) {
         if (!usleep(last_frame_time + per_frame + per_frame / 8 - curtime)) {
             if (!nsignals)
                 av_log(NULL, AV_LOG_INFO,
                        "SLEPT NO signals - %d microseconds late\n",
-                       (int)(av_gettime_relative() - last_frame_time - per_frame));
+                       (int)(av_gettime() - last_frame_time - per_frame));
         }
     }
     nsignals = 0;
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 6c0a338..d56d31e 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -789,7 +789,7 @@
     return pts;
 }
 
-static int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame *videoFrame)
+int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame *videoFrame)
 {
     IDeckLinkTimecode *timecode;
     int ret = AVERROR(ENOENT);
@@ -811,7 +811,7 @@
     return ret;
 }
 
-static int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimecode *tc, IDeckLinkVideoInputFrame *videoFrame)
+int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimecode *tc, IDeckLinkVideoInputFrame *videoFrame)
 {
     AVRational frame_rate = ctx->video_st->r_frame_rate;
     int ret;
@@ -1320,26 +1320,34 @@
     switch(ctx->raw_format) {
     case bmdFormat8BitYUV:
         st->codecpar->codec_id    = AV_CODEC_ID_RAWVIDEO;
+        st->codecpar->codec_tag   = MKTAG('U', 'Y', 'V', 'Y');
         st->codecpar->format      = AV_PIX_FMT_UYVY422;
         st->codecpar->bit_rate    = av_rescale(ctx->bmd_width * ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
         break;
     case bmdFormat10BitYUV:
         st->codecpar->codec_id    = AV_CODEC_ID_V210;
+        st->codecpar->codec_tag   = MKTAG('V','2','1','0');
         st->codecpar->bit_rate    = av_rescale(ctx->bmd_width * ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
+        st->codecpar->bits_per_coded_sample = 10;
         break;
     case bmdFormat8BitARGB:
         st->codecpar->codec_id    = AV_CODEC_ID_RAWVIDEO;
         st->codecpar->format      = AV_PIX_FMT_0RGB;
+        st->codecpar->codec_tag   = avcodec_pix_fmt_to_codec_tag((enum AVPixelFormat)st->codecpar->format);
         st->codecpar->bit_rate    = av_rescale(ctx->bmd_width * ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
         break;
     case bmdFormat8BitBGRA:
         st->codecpar->codec_id    = AV_CODEC_ID_RAWVIDEO;
         st->codecpar->format      = AV_PIX_FMT_BGR0;
+        st->codecpar->codec_tag   = avcodec_pix_fmt_to_codec_tag((enum AVPixelFormat)st->codecpar->format);
         st->codecpar->bit_rate    = av_rescale(ctx->bmd_width * ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
         break;
     case bmdFormat10BitRGB:
         st->codecpar->codec_id    = AV_CODEC_ID_R210;
+        st->codecpar->codec_tag   = MKTAG('R','2','1','0');
+        st->codecpar->format      = AV_PIX_FMT_RGB48LE;
         st->codecpar->bit_rate    = av_rescale(ctx->bmd_width * ctx->bmd_height * 30, st->time_base.den, st->time_base.num);
+        st->codecpar->bits_per_coded_sample = 10;
         break;
     default:
         char fourcc_str[AV_FOURCC_MAX_STRING_SIZE] = {0};
@@ -1437,7 +1445,7 @@
     avpacket_queue_get(&ctx->queue, pkt, 1);
 
     if (ctx->tc_format && !(av_dict_get(ctx->video_st->metadata, "timecode", NULL, 0))) {
-        buffer_size_t size;
+        int size;
         const uint8_t *side_metadata = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &size);
         if (side_metadata) {
            if (av_packet_unpack_dictionary(side_metadata, size, &ctx->video_st->metadata) < 0)
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index df901b0..6c73968 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -312,8 +312,7 @@
     uint16_t *cdp_words;
     uint16_t len;
     uint8_t cc_count;
-    buffer_size_t size;
-    int ret, i;
+    int size, ret, i;
 
     const uint8_t *data = av_packet_get_side_data(pkt, AV_PKT_DATA_A53_CC, &size);
     if (!data)
diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index a16764d..d7f5bd7 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -87,13 +87,13 @@
     }
 
     if (ctx->capture_pin[VideoDevice])
-        ff_dshow_pin_Release(ctx->capture_pin[VideoDevice]);
+        libAVPin_Release(ctx->capture_pin[VideoDevice]);
     if (ctx->capture_pin[AudioDevice])
-        ff_dshow_pin_Release(ctx->capture_pin[AudioDevice]);
+        libAVPin_Release(ctx->capture_pin[AudioDevice]);
     if (ctx->capture_filter[VideoDevice])
-        ff_dshow_filter_Release(ctx->capture_filter[VideoDevice]);
+        libAVFilter_Release(ctx->capture_filter[VideoDevice]);
     if (ctx->capture_filter[AudioDevice])
-        ff_dshow_filter_Release(ctx->capture_filter[AudioDevice]);
+        libAVFilter_Release(ctx->capture_filter[AudioDevice]);
 
     if (ctx->device_pin[VideoDevice])
         IPin_Release(ctx->device_pin[VideoDevice]);
@@ -510,7 +510,7 @@
  * Pops up a user dialog allowing them to adjust properties for the given filter, if possible.
  */
 void
-ff_dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) {
+dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) {
     ISpecifyPropertyPages *property_pages = NULL;
     IUnknown *device_filter_iunknown = NULL;
     HRESULT hr;
@@ -582,7 +582,7 @@
     int should_show_properties = (devtype == VideoDevice) ? ctx->show_video_device_dialog : ctx->show_audio_device_dialog;
 
     if (should_show_properties)
-        ff_dshow_show_filter_properties(device_filter, avctx);
+        dshow_show_filter_properties(device_filter, avctx);
 
     r = IBaseFilter_EnumPins(device_filter, &pins);
     if (r != S_OK) {
@@ -731,8 +731,8 @@
     char *device_filter_unique_name = NULL;
     IGraphBuilder *graph = ctx->graph;
     IPin *device_pin = NULL;
-    DShowPin *capture_pin = NULL;
-    DShowFilter *capture_filter = NULL;
+    libAVPin *capture_pin = NULL;
+    libAVFilter *capture_filter = NULL;
     ICaptureGraphBuilder2 *graph_builder2 = NULL;
     int ret = AVERROR(EIO);
     int r;
@@ -807,7 +807,7 @@
 
     ctx->device_pin[devtype] = device_pin;
 
-    capture_filter = ff_dshow_filter_Create(avctx, callback, devtype);
+    capture_filter = libAVFilter_Create(avctx, callback, devtype);
     if (!capture_filter) {
         av_log(avctx, AV_LOG_ERROR, "Could not create grabber filter.\n");
         goto error;
@@ -863,7 +863,7 @@
         goto error;
     }
 
-    ff_dshow_pin_AddRef(capture_filter->pin);
+    libAVPin_AddRef(capture_filter->pin);
     capture_pin = capture_filter->pin;
     ctx->capture_pin[devtype] = capture_pin;
 
@@ -887,7 +887,7 @@
         goto error;
     }
 
-    r = ff_dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx);
+    r = dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx);
 
     if (r != S_OK) {
         av_log(avctx, AV_LOG_ERROR, "Could not setup CrossBar\n");
@@ -953,7 +953,7 @@
 
     ctx->capture_filter[devtype]->stream_index = st->index;
 
-    ff_dshow_pin_ConnectionMediaType(ctx->capture_pin[devtype], &type);
+    libAVPin_ConnectionMediaType(ctx->capture_pin[devtype], &type);
 
     par = st->codecpar;
     if (devtype == VideoDevice) {
diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index 710b65c..475d62b 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -68,20 +68,20 @@
     AudioSourceDevice = 1,
 };
 
-#define DECLARE_QUERYINTERFACE(prefix, class, ...)                           \
-long                                                                         \
-ff_dshow_##prefix##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
+#define DECLARE_QUERYINTERFACE(class, ...)                                   \
+long WINAPI                                                                  \
+class##_QueryInterface(class *this, const GUID *riid, void **ppvObject)      \
 {                                                                            \
     struct GUIDoffset ifaces[] = __VA_ARGS__;                                \
     int i;                                                                   \
-    dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \
+    dshowdebug(AV_STRINGIFY(class)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \
     ff_printGUID(riid);                                                      \
     if (!ppvObject)                                                          \
         return E_POINTER;                                                    \
     for (i = 0; i < sizeof(ifaces)/sizeof(ifaces[0]); i++) {                 \
         if (IsEqualGUID(riid, ifaces[i].iid)) {                              \
             void *obj = (void *) ((uint8_t *) this + ifaces[i].offset);      \
-            ff_dshow_##prefix##_AddRef(this);                                \
+            class##_AddRef(this);                                            \
             dshowdebug("\tfound %d with offset %d\n", i, ifaces[i].offset);  \
             *ppvObject = (void *) obj;                                       \
             return S_OK;                                                     \
@@ -91,28 +91,28 @@
     *ppvObject = NULL;                                                       \
     return E_NOINTERFACE;                                                    \
 }
-#define DECLARE_ADDREF(prefix, class)                                        \
-unsigned long                                                                \
-ff_dshow_##prefix##_AddRef(class *this)                                      \
+#define DECLARE_ADDREF(class)                                                \
+unsigned long WINAPI                                                         \
+class##_AddRef(class *this)                                                  \
 {                                                                            \
-    dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_AddRef(%p)\t%ld\n", this, this->ref+1); \
+    dshowdebug(AV_STRINGIFY(class)"_AddRef(%p)\t%ld\n", this, this->ref+1);  \
     return InterlockedIncrement(&this->ref);                                 \
 }
-#define DECLARE_RELEASE(prefix, class)                                       \
-unsigned long                                                                \
-ff_dshow_##prefix##_Release(class *this)                                     \
+#define DECLARE_RELEASE(class)                                               \
+unsigned long WINAPI                                                         \
+class##_Release(class *this)                                                 \
 {                                                                            \
     long ref = InterlockedDecrement(&this->ref);                             \
-    dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Release(%p)\t%ld\n", this, ref); \
+    dshowdebug(AV_STRINGIFY(class)"_Release(%p)\t%ld\n", this, ref);         \
     if (!ref)                                                                \
-        ff_dshow_##prefix##_Destroy(this);                                   \
+        class##_Destroy(this);                                               \
     return ref;                                                              \
 }
 
-#define DECLARE_DESTROY(prefix, class, func)                                 \
-void ff_dshow_##prefix##_Destroy(class *this)                                \
+#define DECLARE_DESTROY(class, func)                                         \
+void class##_Destroy(class *this)                                            \
 {                                                                            \
-    dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Destroy(%p)\n", this);       \
+    dshowdebug(AV_STRINGIFY(class)"_Destroy(%p)\n", this);                   \
     func(this);                                                              \
     if (this) {                                                              \
         if (this->vtbl)                                                      \
@@ -120,12 +120,12 @@
         CoTaskMemFree(this);                                                 \
     }                                                                        \
 }
-#define DECLARE_CREATE(prefix, class, setup, ...)                            \
-class *ff_dshow_##prefix##_Create(__VA_ARGS__)                               \
+#define DECLARE_CREATE(class, setup, ...)                                    \
+class *class##_Create(__VA_ARGS__)                                           \
 {                                                                            \
     class *this = CoTaskMemAlloc(sizeof(class));                             \
     void  *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl));                       \
-    dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Create(%p)\n", this);        \
+    dshowdebug(AV_STRINGIFY(class)"_Create(%p)\n", this);                    \
     if (!this || !vtbl)                                                      \
         goto fail;                                                           \
     ZeroMemory(this, sizeof(class));                                         \
@@ -134,123 +134,123 @@
     this->vtbl = vtbl;                                                       \
     if (!setup)                                                              \
         goto fail;                                                           \
-    dshowdebug("created ff_dshow_"AV_STRINGIFY(prefix)" %p\n", this);        \
+    dshowdebug("created "AV_STRINGIFY(class)" %p\n", this);                  \
     return this;                                                             \
 fail:                                                                        \
-    ff_dshow_##prefix##_Destroy(this);                                       \
-    dshowdebug("could not create ff_dshow_"AV_STRINGIFY(prefix)"\n");        \
+    class##_Destroy(this);                                                   \
+    dshowdebug("could not create "AV_STRINGIFY(class)"\n");                  \
     return NULL;                                                             \
 }
 
-#define SETVTBL(vtbl, prefix, fn) \
-    do { (vtbl)->fn = (void *) ff_dshow_##prefix##_##fn; } while(0)
+#define SETVTBL(vtbl, class, fn) \
+    do { (vtbl)->fn = (void *) class##_##fn; } while(0)
 
 /*****************************************************************************
  * Forward Declarations
  ****************************************************************************/
-typedef struct DShowPin DShowPin;
-typedef struct DShowMemInputPin DShowMemInputPin;
-typedef struct DShowEnumPins DShowEnumPins;
-typedef struct DShowEnumMediaTypes DShowEnumMediaTypes;
-typedef struct DShowFilter DShowFilter;
+typedef struct libAVPin libAVPin;
+typedef struct libAVMemInputPin libAVMemInputPin;
+typedef struct libAVEnumPins libAVEnumPins;
+typedef struct libAVEnumMediaTypes libAVEnumMediaTypes;
+typedef struct libAVFilter libAVFilter;
 
 /*****************************************************************************
- * DShowPin
+ * libAVPin
  ****************************************************************************/
-struct DShowPin {
+struct libAVPin {
     IPinVtbl *vtbl;
     long ref;
-    DShowFilter *filter;
+    libAVFilter *filter;
     IPin *connectedto;
     AM_MEDIA_TYPE type;
     IMemInputPinVtbl *imemvtbl;
 };
 
-long          ff_dshow_pin_QueryInterface          (DShowPin *, const GUID *, void **);
-unsigned long ff_dshow_pin_AddRef                  (DShowPin *);
-unsigned long ff_dshow_pin_Release                 (DShowPin *);
-long          ff_dshow_pin_Connect                 (DShowPin *, IPin *, const AM_MEDIA_TYPE *);
-long          ff_dshow_pin_ReceiveConnection       (DShowPin *, IPin *, const AM_MEDIA_TYPE *);
-long          ff_dshow_pin_Disconnect              (DShowPin *);
-long          ff_dshow_pin_ConnectedTo             (DShowPin *, IPin **);
-long          ff_dshow_pin_ConnectionMediaType     (DShowPin *, AM_MEDIA_TYPE *);
-long          ff_dshow_pin_QueryPinInfo            (DShowPin *, PIN_INFO *);
-long          ff_dshow_pin_QueryDirection          (DShowPin *, PIN_DIRECTION *);
-long          ff_dshow_pin_QueryId                 (DShowPin *, wchar_t **);
-long          ff_dshow_pin_QueryAccept             (DShowPin *, const AM_MEDIA_TYPE *);
-long          ff_dshow_pin_EnumMediaTypes          (DShowPin *, IEnumMediaTypes **);
-long          ff_dshow_pin_QueryInternalConnections(DShowPin *, IPin **, unsigned long *);
-long          ff_dshow_pin_EndOfStream             (DShowPin *);
-long          ff_dshow_pin_BeginFlush              (DShowPin *);
-long          ff_dshow_pin_EndFlush                (DShowPin *);
-long          ff_dshow_pin_NewSegment              (DShowPin *, REFERENCE_TIME, REFERENCE_TIME, double);
+long          WINAPI libAVPin_QueryInterface          (libAVPin *, const GUID *, void **);
+unsigned long WINAPI libAVPin_AddRef                  (libAVPin *);
+unsigned long WINAPI libAVPin_Release                 (libAVPin *);
+long          WINAPI libAVPin_Connect                 (libAVPin *, IPin *, const AM_MEDIA_TYPE *);
+long          WINAPI libAVPin_ReceiveConnection       (libAVPin *, IPin *, const AM_MEDIA_TYPE *);
+long          WINAPI libAVPin_Disconnect              (libAVPin *);
+long          WINAPI libAVPin_ConnectedTo             (libAVPin *, IPin **);
+long          WINAPI libAVPin_ConnectionMediaType     (libAVPin *, AM_MEDIA_TYPE *);
+long          WINAPI libAVPin_QueryPinInfo            (libAVPin *, PIN_INFO *);
+long          WINAPI libAVPin_QueryDirection          (libAVPin *, PIN_DIRECTION *);
+long          WINAPI libAVPin_QueryId                 (libAVPin *, wchar_t **);
+long          WINAPI libAVPin_QueryAccept             (libAVPin *, const AM_MEDIA_TYPE *);
+long          WINAPI libAVPin_EnumMediaTypes          (libAVPin *, IEnumMediaTypes **);
+long          WINAPI libAVPin_QueryInternalConnections(libAVPin *, IPin **, unsigned long *);
+long          WINAPI libAVPin_EndOfStream             (libAVPin *);
+long          WINAPI libAVPin_BeginFlush              (libAVPin *);
+long          WINAPI libAVPin_EndFlush                (libAVPin *);
+long          WINAPI libAVPin_NewSegment              (libAVPin *, REFERENCE_TIME, REFERENCE_TIME, double);
 
-long          ff_dshow_meminputpin_QueryInterface          (DShowMemInputPin *, const GUID *, void **);
-unsigned long ff_dshow_meminputpin_AddRef                  (DShowMemInputPin *);
-unsigned long ff_dshow_meminputpin_Release                 (DShowMemInputPin *);
-long          ff_dshow_meminputpin_GetAllocator            (DShowMemInputPin *, IMemAllocator **);
-long          ff_dshow_meminputpin_NotifyAllocator         (DShowMemInputPin *, IMemAllocator *, BOOL);
-long          ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *, ALLOCATOR_PROPERTIES *);
-long          ff_dshow_meminputpin_Receive                 (DShowMemInputPin *, IMediaSample *);
-long          ff_dshow_meminputpin_ReceiveMultiple         (DShowMemInputPin *, IMediaSample **, long, long *);
-long          ff_dshow_meminputpin_ReceiveCanBlock         (DShowMemInputPin *);
+long          WINAPI libAVMemInputPin_QueryInterface          (libAVMemInputPin *, const GUID *, void **);
+unsigned long WINAPI libAVMemInputPin_AddRef                  (libAVMemInputPin *);
+unsigned long WINAPI libAVMemInputPin_Release                 (libAVMemInputPin *);
+long          WINAPI libAVMemInputPin_GetAllocator            (libAVMemInputPin *, IMemAllocator **);
+long          WINAPI libAVMemInputPin_NotifyAllocator         (libAVMemInputPin *, IMemAllocator *, BOOL);
+long          WINAPI libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *, ALLOCATOR_PROPERTIES *);
+long          WINAPI libAVMemInputPin_Receive                 (libAVMemInputPin *, IMediaSample *);
+long          WINAPI libAVMemInputPin_ReceiveMultiple         (libAVMemInputPin *, IMediaSample **, long, long *);
+long          WINAPI libAVMemInputPin_ReceiveCanBlock         (libAVMemInputPin *);
 
-void                 ff_dshow_pin_Destroy(DShowPin *);
-DShowPin            *ff_dshow_pin_Create (DShowFilter *filter);
+void                 libAVPin_Destroy(libAVPin *);
+libAVPin            *libAVPin_Create (libAVFilter *filter);
 
-void                 ff_dshow_meminputpin_Destroy(DShowMemInputPin *);
+void                 libAVMemInputPin_Destroy(libAVMemInputPin *);
 
 /*****************************************************************************
- * DShowEnumPins
+ * libAVEnumPins
  ****************************************************************************/
-struct DShowEnumPins {
+struct libAVEnumPins {
     IEnumPinsVtbl *vtbl;
     long ref;
     int pos;
-    DShowPin *pin;
-    DShowFilter *filter;
+    libAVPin *pin;
+    libAVFilter *filter;
 };
 
-long          ff_dshow_enumpins_QueryInterface(DShowEnumPins *, const GUID *, void **);
-unsigned long ff_dshow_enumpins_AddRef        (DShowEnumPins *);
-unsigned long ff_dshow_enumpins_Release       (DShowEnumPins *);
-long          ff_dshow_enumpins_Next          (DShowEnumPins *, unsigned long, IPin **, unsigned long *);
-long          ff_dshow_enumpins_Skip          (DShowEnumPins *, unsigned long);
-long          ff_dshow_enumpins_Reset         (DShowEnumPins *);
-long          ff_dshow_enumpins_Clone         (DShowEnumPins *, DShowEnumPins **);
+long          WINAPI libAVEnumPins_QueryInterface(libAVEnumPins *, const GUID *, void **);
+unsigned long WINAPI libAVEnumPins_AddRef        (libAVEnumPins *);
+unsigned long WINAPI libAVEnumPins_Release       (libAVEnumPins *);
+long          WINAPI libAVEnumPins_Next          (libAVEnumPins *, unsigned long, IPin **, unsigned long *);
+long          WINAPI libAVEnumPins_Skip          (libAVEnumPins *, unsigned long);
+long          WINAPI libAVEnumPins_Reset         (libAVEnumPins *);
+long          WINAPI libAVEnumPins_Clone         (libAVEnumPins *, libAVEnumPins **);
 
-void                 ff_dshow_enumpins_Destroy(DShowEnumPins *);
-DShowEnumPins       *ff_dshow_enumpins_Create (DShowPin *pin, DShowFilter *filter);
+void                 libAVEnumPins_Destroy(libAVEnumPins *);
+libAVEnumPins       *libAVEnumPins_Create (libAVPin *pin, libAVFilter *filter);
 
 /*****************************************************************************
- * DShowEnumMediaTypes
+ * libAVEnumMediaTypes
  ****************************************************************************/
-struct DShowEnumMediaTypes {
+struct libAVEnumMediaTypes {
     IEnumMediaTypesVtbl *vtbl;
     long ref;
     int pos;
     AM_MEDIA_TYPE type;
 };
 
-long          ff_dshow_enummediatypes_QueryInterface(DShowEnumMediaTypes *, const GUID *, void **);
-unsigned long ff_dshow_enummediatypes_AddRef        (DShowEnumMediaTypes *);
-unsigned long ff_dshow_enummediatypes_Release       (DShowEnumMediaTypes *);
-long          ff_dshow_enummediatypes_Next          (DShowEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *);
-long          ff_dshow_enummediatypes_Skip          (DShowEnumMediaTypes *, unsigned long);
-long          ff_dshow_enummediatypes_Reset         (DShowEnumMediaTypes *);
-long          ff_dshow_enummediatypes_Clone         (DShowEnumMediaTypes *, DShowEnumMediaTypes **);
+long          WINAPI libAVEnumMediaTypes_QueryInterface(libAVEnumMediaTypes *, const GUID *, void **);
+unsigned long WINAPI libAVEnumMediaTypes_AddRef        (libAVEnumMediaTypes *);
+unsigned long WINAPI libAVEnumMediaTypes_Release       (libAVEnumMediaTypes *);
+long          WINAPI libAVEnumMediaTypes_Next          (libAVEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *);
+long          WINAPI libAVEnumMediaTypes_Skip          (libAVEnumMediaTypes *, unsigned long);
+long          WINAPI libAVEnumMediaTypes_Reset         (libAVEnumMediaTypes *);
+long          WINAPI libAVEnumMediaTypes_Clone         (libAVEnumMediaTypes *, libAVEnumMediaTypes **);
 
-void                 ff_dshow_enummediatypes_Destroy(DShowEnumMediaTypes *);
-DShowEnumMediaTypes *ff_dshow_enummediatypes_Create(const AM_MEDIA_TYPE *type);
+void                 libAVEnumMediaTypes_Destroy(libAVEnumMediaTypes *);
+libAVEnumMediaTypes *libAVEnumMediaTypes_Create(const AM_MEDIA_TYPE *type);
 
 /*****************************************************************************
- * DShowFilter
+ * libAVFilter
  ****************************************************************************/
-struct DShowFilter {
+struct libAVFilter {
     IBaseFilterVtbl *vtbl;
     long ref;
     const wchar_t *name;
-    DShowPin *pin;
+    libAVPin *pin;
     FILTER_INFO info;
     FILTER_STATE state;
     IReferenceClock *clock;
@@ -261,24 +261,24 @@
     void (*callback)(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType type);
 };
 
-long          ff_dshow_filter_QueryInterface (DShowFilter *, const GUID *, void **);
-unsigned long ff_dshow_filter_AddRef         (DShowFilter *);
-unsigned long ff_dshow_filter_Release        (DShowFilter *);
-long          ff_dshow_filter_GetClassID     (DShowFilter *, CLSID *);
-long          ff_dshow_filter_Stop           (DShowFilter *);
-long          ff_dshow_filter_Pause          (DShowFilter *);
-long          ff_dshow_filter_Run            (DShowFilter *, REFERENCE_TIME);
-long          ff_dshow_filter_GetState       (DShowFilter *, DWORD, FILTER_STATE *);
-long          ff_dshow_filter_SetSyncSource  (DShowFilter *, IReferenceClock *);
-long          ff_dshow_filter_GetSyncSource  (DShowFilter *, IReferenceClock **);
-long          ff_dshow_filter_EnumPins       (DShowFilter *, IEnumPins **);
-long          ff_dshow_filter_FindPin        (DShowFilter *, const wchar_t *, IPin **);
-long          ff_dshow_filter_QueryFilterInfo(DShowFilter *, FILTER_INFO *);
-long          ff_dshow_filter_JoinFilterGraph(DShowFilter *, IFilterGraph *, const wchar_t *);
-long          ff_dshow_filter_QueryVendorInfo(DShowFilter *, wchar_t **);
+long          WINAPI libAVFilter_QueryInterface (libAVFilter *, const GUID *, void **);
+unsigned long WINAPI libAVFilter_AddRef         (libAVFilter *);
+unsigned long WINAPI libAVFilter_Release        (libAVFilter *);
+long          WINAPI libAVFilter_GetClassID     (libAVFilter *, CLSID *);
+long          WINAPI libAVFilter_Stop           (libAVFilter *);
+long          WINAPI libAVFilter_Pause          (libAVFilter *);
+long          WINAPI libAVFilter_Run            (libAVFilter *, REFERENCE_TIME);
+long          WINAPI libAVFilter_GetState       (libAVFilter *, DWORD, FILTER_STATE *);
+long          WINAPI libAVFilter_SetSyncSource  (libAVFilter *, IReferenceClock *);
+long          WINAPI libAVFilter_GetSyncSource  (libAVFilter *, IReferenceClock **);
+long          WINAPI libAVFilter_EnumPins       (libAVFilter *, IEnumPins **);
+long          WINAPI libAVFilter_FindPin        (libAVFilter *, const wchar_t *, IPin **);
+long          WINAPI libAVFilter_QueryFilterInfo(libAVFilter *, FILTER_INFO *);
+long          WINAPI libAVFilter_JoinFilterGraph(libAVFilter *, IFilterGraph *, const wchar_t *);
+long          WINAPI libAVFilter_QueryVendorInfo(libAVFilter *, wchar_t **);
 
-void                 ff_dshow_filter_Destroy(DShowFilter *);
-DShowFilter         *ff_dshow_filter_Create (void *, void *, enum dshowDeviceType);
+void                 libAVFilter_Destroy(libAVFilter *);
+libAVFilter         *libAVFilter_Create (void *, void *, enum dshowDeviceType);
 
 /*****************************************************************************
  * dshow_ctx
@@ -314,8 +314,8 @@
 
     IBaseFilter *device_filter[2];
     IPin        *device_pin[2];
-    DShowFilter *capture_filter[2];
-    DShowPin    *capture_pin[2];
+    libAVFilter *capture_filter[2];
+    libAVPin    *capture_pin[2];
 
     HANDLE mutex;
     HANDLE event[2]; /* event[0] is set by DirectShow
@@ -346,9 +346,9 @@
 /*****************************************************************************
  * CrossBar
  ****************************************************************************/
-HRESULT ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2,
+HRESULT dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2,
     IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx);
 
-void ff_dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx);
+void dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx);
 
 #endif /* AVDEVICE_DSHOW_CAPTURE_H */
diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c
index 2438683..95fb466 100644
--- a/libavdevice/dshow_crossbar.c
+++ b/libavdevice/dshow_crossbar.c
@@ -137,7 +137,7 @@
  * Given a fully constructed graph, check if there is a cross bar filter, and configure its pins if so.
  */
 HRESULT
-ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2,
+dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2,
     IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx)
 {
     struct dshow_ctx *ctx = avctx->priv_data;
@@ -163,7 +163,7 @@
         hr = IAMCrossbar_QueryInterface(cross_bar, &IID_IBaseFilter, (void **) &cross_bar_base_filter);
         if (hr != S_OK)
             goto end;
-        ff_dshow_show_filter_properties(cross_bar_base_filter, avctx);
+        dshow_show_filter_properties(cross_bar_base_filter, avctx);
     }
 
     if (devtype == VideoDevice && ctx->show_analog_tv_tuner_dialog) {
@@ -173,7 +173,7 @@
             hr = IAMCrossbar_QueryInterface(tv_tuner_filter, &IID_IBaseFilter, (void **) &tv_tuner_base_filter);
             if (hr != S_OK)
                 goto end;
-            ff_dshow_show_filter_properties(tv_tuner_base_filter, avctx);
+            dshow_show_filter_properties(tv_tuner_base_filter, avctx);
         } else {
             av_log(avctx, AV_LOG_WARNING, "unable to find a tv tuner to display dialog for!");
         }
@@ -185,7 +185,7 @@
             hr = IAMCrossbar_QueryInterface(tv_audio_filter, &IID_IBaseFilter, (void **) &tv_audio_base_filter);
             if (hr != S_OK)
                 goto end;
-            ff_dshow_show_filter_properties(tv_audio_base_filter, avctx);
+            dshow_show_filter_properties(tv_audio_base_filter, avctx);
         } else {
             av_log(avctx, AV_LOG_WARNING, "unable to find a tv audio tuner to display dialog for!");
         }
diff --git a/libavdevice/dshow_enummediatypes.c b/libavdevice/dshow_enummediatypes.c
index 8294450..3a66a4d 100644
--- a/libavdevice/dshow_enummediatypes.c
+++ b/libavdevice/dshow_enummediatypes.c
@@ -21,16 +21,17 @@
 
 #include "dshow_capture.h"
 
-DECLARE_QUERYINTERFACE(enummediatypes, DShowEnumMediaTypes,
+DECLARE_QUERYINTERFACE(libAVEnumMediaTypes,
     { {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
-DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
-DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)
+DECLARE_ADDREF(libAVEnumMediaTypes)
+DECLARE_RELEASE(libAVEnumMediaTypes)
 
-long ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
+long WINAPI
+libAVEnumMediaTypes_Next(libAVEnumMediaTypes *this, unsigned long n,
                          AM_MEDIA_TYPE **types, unsigned long *fetched)
 {
     int count = 0;
-    dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
+    dshowdebug("libAVEnumMediaTypes_Next(%p)\n", this);
     if (!types)
         return E_POINTER;
     if (!this->pos && n == 1) {
@@ -50,26 +51,29 @@
         return S_FALSE;
     return S_OK;
 }
-long ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
+long WINAPI
+libAVEnumMediaTypes_Skip(libAVEnumMediaTypes *this, unsigned long n)
 {
-    dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
+    dshowdebug("libAVEnumMediaTypes_Skip(%p)\n", this);
     if (n) /* Any skip will always fall outside of the only valid type. */
         return S_FALSE;
     return S_OK;
 }
-long ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)
+long WINAPI
+libAVEnumMediaTypes_Reset(libAVEnumMediaTypes *this)
 {
-    dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
+    dshowdebug("libAVEnumMediaTypes_Reset(%p)\n", this);
     this->pos = 0;
     return S_OK;
 }
-long ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
+long WINAPI
+libAVEnumMediaTypes_Clone(libAVEnumMediaTypes *this, libAVEnumMediaTypes **enums)
 {
-    DShowEnumMediaTypes *new;
-    dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
+    libAVEnumMediaTypes *new;
+    dshowdebug("libAVEnumMediaTypes_Clone(%p)\n", this);
     if (!enums)
         return E_POINTER;
-    new = ff_dshow_enummediatypes_Create(&this->type);
+    new = libAVEnumMediaTypes_Create(&this->type);
     if (!new)
         return E_OUTOFMEMORY;
     new->pos = this->pos;
@@ -77,16 +81,17 @@
     return S_OK;
 }
 
-static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
+static int
+libAVEnumMediaTypes_Setup(libAVEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
 {
     IEnumMediaTypesVtbl *vtbl = this->vtbl;
-    SETVTBL(vtbl, enummediatypes, QueryInterface);
-    SETVTBL(vtbl, enummediatypes, AddRef);
-    SETVTBL(vtbl, enummediatypes, Release);
-    SETVTBL(vtbl, enummediatypes, Next);
-    SETVTBL(vtbl, enummediatypes, Skip);
-    SETVTBL(vtbl, enummediatypes, Reset);
-    SETVTBL(vtbl, enummediatypes, Clone);
+    SETVTBL(vtbl, libAVEnumMediaTypes, QueryInterface);
+    SETVTBL(vtbl, libAVEnumMediaTypes, AddRef);
+    SETVTBL(vtbl, libAVEnumMediaTypes, Release);
+    SETVTBL(vtbl, libAVEnumMediaTypes, Next);
+    SETVTBL(vtbl, libAVEnumMediaTypes, Skip);
+    SETVTBL(vtbl, libAVEnumMediaTypes, Reset);
+    SETVTBL(vtbl, libAVEnumMediaTypes, Clone);
 
     if (!type) {
         this->type.majortype = GUID_NULL;
@@ -96,5 +101,5 @@
 
     return 1;
 }
-DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
-DECLARE_DESTROY(enummediatypes, DShowEnumMediaTypes, nothing)
+DECLARE_CREATE(libAVEnumMediaTypes, libAVEnumMediaTypes_Setup(this, type), const AM_MEDIA_TYPE *type)
+DECLARE_DESTROY(libAVEnumMediaTypes, nothing)
diff --git a/libavdevice/dshow_enumpins.c b/libavdevice/dshow_enumpins.c
index 6bf5992..e5c11cb 100644
--- a/libavdevice/dshow_enumpins.c
+++ b/libavdevice/dshow_enumpins.c
@@ -21,20 +21,21 @@
 
 #include "dshow_capture.h"
 
-DECLARE_QUERYINTERFACE(enumpins, DShowEnumPins,
+DECLARE_QUERYINTERFACE(libAVEnumPins,
     { {&IID_IUnknown,0}, {&IID_IEnumPins,0} })
-DECLARE_ADDREF(enumpins, DShowEnumPins)
-DECLARE_RELEASE(enumpins, DShowEnumPins)
+DECLARE_ADDREF(libAVEnumPins)
+DECLARE_RELEASE(libAVEnumPins)
 
-long ff_dshow_enumpins_Next(DShowEnumPins *this, unsigned long n, IPin **pins,
+long WINAPI
+libAVEnumPins_Next(libAVEnumPins *this, unsigned long n, IPin **pins,
                    unsigned long *fetched)
 {
     int count = 0;
-    dshowdebug("ff_dshow_enumpins_Next(%p)\n", this);
+    dshowdebug("libAVEnumPins_Next(%p)\n", this);
     if (!pins)
         return E_POINTER;
     if (!this->pos && n == 1) {
-        ff_dshow_pin_AddRef(this->pin);
+        libAVPin_AddRef(this->pin);
         *pins = (IPin *) this->pin;
         count = 1;
         this->pos = 1;
@@ -45,26 +46,29 @@
         return S_FALSE;
     return S_OK;
 }
-long ff_dshow_enumpins_Skip(DShowEnumPins *this, unsigned long n)
+long WINAPI
+libAVEnumPins_Skip(libAVEnumPins *this, unsigned long n)
 {
-    dshowdebug("ff_dshow_enumpins_Skip(%p)\n", this);
+    dshowdebug("libAVEnumPins_Skip(%p)\n", this);
     if (n) /* Any skip will always fall outside of the only valid pin. */
         return S_FALSE;
     return S_OK;
 }
-long ff_dshow_enumpins_Reset(DShowEnumPins *this)
+long WINAPI
+libAVEnumPins_Reset(libAVEnumPins *this)
 {
-    dshowdebug("ff_dshow_enumpins_Reset(%p)\n", this);
+    dshowdebug("libAVEnumPins_Reset(%p)\n", this);
     this->pos = 0;
     return S_OK;
 }
-long ff_dshow_enumpins_Clone(DShowEnumPins *this, DShowEnumPins **pins)
+long WINAPI
+libAVEnumPins_Clone(libAVEnumPins *this, libAVEnumPins **pins)
 {
-    DShowEnumPins *new;
-    dshowdebug("ff_dshow_enumpins_Clone(%p)\n", this);
+    libAVEnumPins *new;
+    dshowdebug("libAVEnumPins_Clone(%p)\n", this);
     if (!pins)
         return E_POINTER;
-    new = ff_dshow_enumpins_Create(this->pin, this->filter);
+    new = libAVEnumPins_Create(this->pin, this->filter);
     if (!new)
         return E_OUTOFMEMORY;
     new->pos = this->pos;
@@ -72,28 +76,30 @@
     return S_OK;
 }
 
-static int ff_dshow_enumpins_Setup(DShowEnumPins *this, DShowPin *pin, DShowFilter *filter)
+static int
+libAVEnumPins_Setup(libAVEnumPins *this, libAVPin *pin, libAVFilter *filter)
 {
     IEnumPinsVtbl *vtbl = this->vtbl;
-    SETVTBL(vtbl, enumpins, QueryInterface);
-    SETVTBL(vtbl, enumpins, AddRef);
-    SETVTBL(vtbl, enumpins, Release);
-    SETVTBL(vtbl, enumpins, Next);
-    SETVTBL(vtbl, enumpins, Skip);
-    SETVTBL(vtbl, enumpins, Reset);
-    SETVTBL(vtbl, enumpins, Clone);
+    SETVTBL(vtbl, libAVEnumPins, QueryInterface);
+    SETVTBL(vtbl, libAVEnumPins, AddRef);
+    SETVTBL(vtbl, libAVEnumPins, Release);
+    SETVTBL(vtbl, libAVEnumPins, Next);
+    SETVTBL(vtbl, libAVEnumPins, Skip);
+    SETVTBL(vtbl, libAVEnumPins, Reset);
+    SETVTBL(vtbl, libAVEnumPins, Clone);
 
     this->pin = pin;
     this->filter = filter;
-    ff_dshow_filter_AddRef(this->filter);
+    libAVFilter_AddRef(this->filter);
 
     return 1;
 }
-static int ff_dshow_enumpins_Cleanup(DShowEnumPins *this)
+static int
+libAVEnumPins_Cleanup(libAVEnumPins *this)
 {
-    ff_dshow_filter_Release(this->filter);
+    libAVFilter_Release(this->filter);
     return 1;
 }
-DECLARE_CREATE(enumpins, DShowEnumPins, ff_dshow_enumpins_Setup(this, pin, filter),
-               DShowPin *pin, DShowFilter *filter)
-DECLARE_DESTROY(enumpins, DShowEnumPins, ff_dshow_enumpins_Cleanup)
+DECLARE_CREATE(libAVEnumPins, libAVEnumPins_Setup(this, pin, filter),
+               libAVPin *pin, libAVFilter *filter)
+DECLARE_DESTROY(libAVEnumPins, libAVEnumPins_Cleanup)
diff --git a/libavdevice/dshow_filter.c b/libavdevice/dshow_filter.c
index 61e057a..db4bff6 100644
--- a/libavdevice/dshow_filter.c
+++ b/libavdevice/dshow_filter.c
@@ -21,47 +21,53 @@
 
 #include "dshow_capture.h"
 
-DECLARE_QUERYINTERFACE(filter, DShowFilter,
+DECLARE_QUERYINTERFACE(libAVFilter,
     { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
-DECLARE_ADDREF(filter, DShowFilter)
-DECLARE_RELEASE(filter, DShowFilter)
+DECLARE_ADDREF(libAVFilter)
+DECLARE_RELEASE(libAVFilter)
 
-long ff_dshow_filter_GetClassID(DShowFilter *this, CLSID *id)
+long WINAPI
+libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
 {
-    dshowdebug("ff_dshow_filter_GetClassID(%p)\n", this);
+    dshowdebug("libAVFilter_GetClassID(%p)\n", this);
     /* I'm not creating a ClassID just for this. */
     return E_FAIL;
 }
-long ff_dshow_filter_Stop(DShowFilter *this)
+long WINAPI
+libAVFilter_Stop(libAVFilter *this)
 {
-    dshowdebug("ff_dshow_filter_Stop(%p)\n", this);
+    dshowdebug("libAVFilter_Stop(%p)\n", this);
     this->state = State_Stopped;
     return S_OK;
 }
-long ff_dshow_filter_Pause(DShowFilter *this)
+long WINAPI
+libAVFilter_Pause(libAVFilter *this)
 {
-    dshowdebug("ff_dshow_filter_Pause(%p)\n", this);
+    dshowdebug("libAVFilter_Pause(%p)\n", this);
     this->state = State_Paused;
     return S_OK;
 }
-long ff_dshow_filter_Run(DShowFilter *this, REFERENCE_TIME start)
+long WINAPI
+libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
 {
-    dshowdebug("ff_dshow_filter_Run(%p) %"PRId64"\n", this, start);
+    dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start);
     this->state = State_Running;
     this->start_time = start;
     return S_OK;
 }
-long ff_dshow_filter_GetState(DShowFilter *this, DWORD ms, FILTER_STATE *state)
+long WINAPI
+libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
 {
-    dshowdebug("ff_dshow_filter_GetState(%p)\n", this);
+    dshowdebug("libAVFilter_GetState(%p)\n", this);
     if (!state)
         return E_POINTER;
     *state = this->state;
     return S_OK;
 }
-long ff_dshow_filter_SetSyncSource(DShowFilter *this, IReferenceClock *clock)
+long WINAPI
+libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
 {
-    dshowdebug("ff_dshow_filter_SetSyncSource(%p)\n", this);
+    dshowdebug("libAVFilter_SetSyncSource(%p)\n", this);
 
     if (this->clock != clock) {
         if (this->clock)
@@ -73,9 +79,10 @@
 
     return S_OK;
 }
-long ff_dshow_filter_GetSyncSource(DShowFilter *this, IReferenceClock **clock)
+long WINAPI
+libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
 {
-    dshowdebug("ff_dshow_filter_GetSyncSource(%p)\n", this);
+    dshowdebug("libAVFilter_GetSyncSource(%p)\n", this);
 
     if (!clock)
         return E_POINTER;
@@ -85,30 +92,32 @@
 
     return S_OK;
 }
-long ff_dshow_filter_EnumPins(DShowFilter *this, IEnumPins **enumpin)
+long WINAPI
+libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
 {
-    DShowEnumPins *new;
-    dshowdebug("ff_dshow_filter_EnumPins(%p)\n", this);
+    libAVEnumPins *new;
+    dshowdebug("libAVFilter_EnumPins(%p)\n", this);
 
     if (!enumpin)
         return E_POINTER;
-    new = ff_dshow_enumpins_Create(this->pin, this);
+    new = libAVEnumPins_Create(this->pin, this);
     if (!new)
         return E_OUTOFMEMORY;
 
     *enumpin = (IEnumPins *) new;
     return S_OK;
 }
-long ff_dshow_filter_FindPin(DShowFilter *this, const wchar_t *id, IPin **pin)
+long WINAPI
+libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
 {
-    DShowPin *found = NULL;
-    dshowdebug("ff_dshow_filter_FindPin(%p)\n", this);
+    libAVPin *found = NULL;
+    dshowdebug("libAVFilter_FindPin(%p)\n", this);
 
     if (!id || !pin)
         return E_POINTER;
     if (!wcscmp(id, L"In")) {
         found = this->pin;
-        ff_dshow_pin_AddRef(found);
+        libAVPin_AddRef(found);
     }
     *pin = (IPin *) found;
     if (!found)
@@ -116,9 +125,10 @@
 
     return S_OK;
 }
-long ff_dshow_filter_QueryFilterInfo(DShowFilter *this, FILTER_INFO *info)
+long WINAPI
+libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
 {
-    dshowdebug("ff_dshow_filter_QueryFilterInfo(%p)\n", this);
+    dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this);
 
     if (!info)
         return E_POINTER;
@@ -128,10 +138,11 @@
 
     return S_OK;
 }
-long ff_dshow_filter_JoinFilterGraph(DShowFilter *this, IFilterGraph *graph,
+long WINAPI
+libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
                             const wchar_t *name)
 {
-    dshowdebug("ff_dshow_filter_JoinFilterGraph(%p)\n", this);
+    dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
 
     this->info.pGraph = graph;
     if (name)
@@ -139,9 +150,10 @@
 
     return S_OK;
 }
-long ff_dshow_filter_QueryVendorInfo(DShowFilter *this, wchar_t **info)
+long WINAPI
+libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
 {
-    dshowdebug("ff_dshow_filter_QueryVendorInfo(%p)\n", this);
+    dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
 
     if (!info)
         return E_POINTER;
@@ -149,27 +161,27 @@
 }
 
 static int
-ff_dshow_filter_Setup(DShowFilter *this, void *priv_data, void *callback,
+libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
                   enum dshowDeviceType type)
 {
     IBaseFilterVtbl *vtbl = this->vtbl;
-    SETVTBL(vtbl, filter, QueryInterface);
-    SETVTBL(vtbl, filter, AddRef);
-    SETVTBL(vtbl, filter, Release);
-    SETVTBL(vtbl, filter, GetClassID);
-    SETVTBL(vtbl, filter, Stop);
-    SETVTBL(vtbl, filter, Pause);
-    SETVTBL(vtbl, filter, Run);
-    SETVTBL(vtbl, filter, GetState);
-    SETVTBL(vtbl, filter, SetSyncSource);
-    SETVTBL(vtbl, filter, GetSyncSource);
-    SETVTBL(vtbl, filter, EnumPins);
-    SETVTBL(vtbl, filter, FindPin);
-    SETVTBL(vtbl, filter, QueryFilterInfo);
-    SETVTBL(vtbl, filter, JoinFilterGraph);
-    SETVTBL(vtbl, filter, QueryVendorInfo);
+    SETVTBL(vtbl, libAVFilter, QueryInterface);
+    SETVTBL(vtbl, libAVFilter, AddRef);
+    SETVTBL(vtbl, libAVFilter, Release);
+    SETVTBL(vtbl, libAVFilter, GetClassID);
+    SETVTBL(vtbl, libAVFilter, Stop);
+    SETVTBL(vtbl, libAVFilter, Pause);
+    SETVTBL(vtbl, libAVFilter, Run);
+    SETVTBL(vtbl, libAVFilter, GetState);
+    SETVTBL(vtbl, libAVFilter, SetSyncSource);
+    SETVTBL(vtbl, libAVFilter, GetSyncSource);
+    SETVTBL(vtbl, libAVFilter, EnumPins);
+    SETVTBL(vtbl, libAVFilter, FindPin);
+    SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
+    SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
+    SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
 
-    this->pin = ff_dshow_pin_Create(this);
+    this->pin = libAVPin_Create(this);
 
     this->priv_data = priv_data;
     this->callback  = callback;
@@ -177,11 +189,12 @@
 
     return 1;
 }
-static int ff_dshow_filter_Cleanup(DShowFilter *this)
+static int
+libAVFilter_Cleanup(libAVFilter *this)
 {
-    ff_dshow_pin_Release(this->pin);
+    libAVPin_Release(this->pin);
     return 1;
 }
-DECLARE_CREATE(filter, DShowFilter, ff_dshow_filter_Setup(this, priv_data, callback, type),
+DECLARE_CREATE(libAVFilter, libAVFilter_Setup(this, priv_data, callback, type),
                void *priv_data, void *callback, enum dshowDeviceType type)
-DECLARE_DESTROY(filter, DShowFilter, ff_dshow_filter_Cleanup)
+DECLARE_DESTROY(libAVFilter, libAVFilter_Cleanup)
diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c
index 3dae405..53b1c91 100644
--- a/libavdevice/dshow_pin.c
+++ b/libavdevice/dshow_pin.c
@@ -22,24 +22,26 @@
 #include "dshow_capture.h"
 
 #include <stddef.h>
-#define imemoffset offsetof(DShowPin, imemvtbl)
+#define imemoffset offsetof(libAVPin, imemvtbl)
 
-DECLARE_QUERYINTERFACE(pin, DShowPin,
+DECLARE_QUERYINTERFACE(libAVPin,
     { {&IID_IUnknown,0}, {&IID_IPin,0}, {&IID_IMemInputPin,imemoffset} })
-DECLARE_ADDREF(pin, DShowPin)
-DECLARE_RELEASE(pin, DShowPin)
+DECLARE_ADDREF(libAVPin)
+DECLARE_RELEASE(libAVPin)
 
-long ff_dshow_pin_Connect(DShowPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
+long WINAPI
+libAVPin_Connect(libAVPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
 {
-    dshowdebug("ff_dshow_pin_Connect(%p, %p, %p)\n", this, pin, type);
+    dshowdebug("libAVPin_Connect(%p, %p, %p)\n", this, pin, type);
     /* Input pins receive connections. */
     return S_FALSE;
 }
-long ff_dshow_pin_ReceiveConnection(DShowPin *this, IPin *pin,
+long WINAPI
+libAVPin_ReceiveConnection(libAVPin *this, IPin *pin,
                            const AM_MEDIA_TYPE *type)
 {
     enum dshowDeviceType devtype = this->filter->type;
-    dshowdebug("ff_dshow_pin_ReceiveConnection(%p)\n", this);
+    dshowdebug("libAVPin_ReceiveConnection(%p)\n", this);
 
     if (!pin)
         return E_POINTER;
@@ -62,9 +64,10 @@
 
     return S_OK;
 }
-long ff_dshow_pin_Disconnect(DShowPin *this)
+long WINAPI
+libAVPin_Disconnect(libAVPin *this)
 {
-    dshowdebug("ff_dshow_pin_Disconnect(%p)\n", this);
+    dshowdebug("libAVPin_Disconnect(%p)\n", this);
 
     if (this->filter->state != State_Stopped)
         return VFW_E_NOT_STOPPED;
@@ -75,9 +78,10 @@
 
     return S_OK;
 }
-long ff_dshow_pin_ConnectedTo(DShowPin *this, IPin **pin)
+long WINAPI
+libAVPin_ConnectedTo(libAVPin *this, IPin **pin)
 {
-    dshowdebug("ff_dshow_pin_ConnectedTo(%p)\n", this);
+    dshowdebug("libAVPin_ConnectedTo(%p)\n", this);
 
     if (!pin)
         return E_POINTER;
@@ -88,9 +92,10 @@
 
     return S_OK;
 }
-long ff_dshow_pin_ConnectionMediaType(DShowPin *this, AM_MEDIA_TYPE *type)
+long WINAPI
+libAVPin_ConnectionMediaType(libAVPin *this, AM_MEDIA_TYPE *type)
 {
-    dshowdebug("ff_dshow_pin_ConnectionMediaType(%p)\n", this);
+    dshowdebug("libAVPin_ConnectionMediaType(%p)\n", this);
 
     if (!type)
         return E_POINTER;
@@ -99,15 +104,16 @@
 
     return ff_copy_dshow_media_type(type, &this->type);
 }
-long ff_dshow_pin_QueryPinInfo(DShowPin *this, PIN_INFO *info)
+long WINAPI
+libAVPin_QueryPinInfo(libAVPin *this, PIN_INFO *info)
 {
-    dshowdebug("ff_dshow_pin_QueryPinInfo(%p)\n", this);
+    dshowdebug("libAVPin_QueryPinInfo(%p)\n", this);
 
     if (!info)
         return E_POINTER;
 
     if (this->filter)
-        ff_dshow_filter_AddRef(this->filter);
+        libAVFilter_AddRef(this->filter);
 
     info->pFilter = (IBaseFilter *) this->filter;
     info->dir     = PINDIR_INPUT;
@@ -115,17 +121,19 @@
 
     return S_OK;
 }
-long ff_dshow_pin_QueryDirection(DShowPin *this, PIN_DIRECTION *dir)
+long WINAPI
+libAVPin_QueryDirection(libAVPin *this, PIN_DIRECTION *dir)
 {
-    dshowdebug("ff_dshow_pin_QueryDirection(%p)\n", this);
+    dshowdebug("libAVPin_QueryDirection(%p)\n", this);
     if (!dir)
         return E_POINTER;
     *dir = PINDIR_INPUT;
     return S_OK;
 }
-long ff_dshow_pin_QueryId(DShowPin *this, wchar_t **id)
+long WINAPI
+libAVPin_QueryId(libAVPin *this, wchar_t **id)
 {
-    dshowdebug("ff_dshow_pin_QueryId(%p)\n", this);
+    dshowdebug("libAVPin_QueryId(%p)\n", this);
 
     if (!id)
         return E_POINTER;
@@ -134,59 +142,67 @@
 
     return S_OK;
 }
-long ff_dshow_pin_QueryAccept(DShowPin *this, const AM_MEDIA_TYPE *type)
+long WINAPI
+libAVPin_QueryAccept(libAVPin *this, const AM_MEDIA_TYPE *type)
 {
-    dshowdebug("ff_dshow_pin_QueryAccept(%p)\n", this);
+    dshowdebug("libAVPin_QueryAccept(%p)\n", this);
     return S_FALSE;
 }
-long ff_dshow_pin_EnumMediaTypes(DShowPin *this, IEnumMediaTypes **enumtypes)
+long WINAPI
+libAVPin_EnumMediaTypes(libAVPin *this, IEnumMediaTypes **enumtypes)
 {
     const AM_MEDIA_TYPE *type = NULL;
-    DShowEnumMediaTypes *new;
-    dshowdebug("ff_dshow_pin_EnumMediaTypes(%p)\n", this);
+    libAVEnumMediaTypes *new;
+    dshowdebug("libAVPin_EnumMediaTypes(%p)\n", this);
 
     if (!enumtypes)
         return E_POINTER;
-    new = ff_dshow_enummediatypes_Create(type);
+    new = libAVEnumMediaTypes_Create(type);
     if (!new)
         return E_OUTOFMEMORY;
 
     *enumtypes = (IEnumMediaTypes *) new;
     return S_OK;
 }
-long ff_dshow_pin_QueryInternalConnections(DShowPin *this, IPin **pin,
+long WINAPI
+libAVPin_QueryInternalConnections(libAVPin *this, IPin **pin,
                                   unsigned long *npin)
 {
-    dshowdebug("ff_dshow_pin_QueryInternalConnections(%p)\n", this);
+    dshowdebug("libAVPin_QueryInternalConnections(%p)\n", this);
     return E_NOTIMPL;
 }
-long ff_dshow_pin_EndOfStream(DShowPin *this)
+long WINAPI
+libAVPin_EndOfStream(libAVPin *this)
 {
-    dshowdebug("ff_dshow_pin_EndOfStream(%p)\n", this);
+    dshowdebug("libAVPin_EndOfStream(%p)\n", this);
     /* I don't care. */
     return S_OK;
 }
-long ff_dshow_pin_BeginFlush(DShowPin *this)
+long WINAPI
+libAVPin_BeginFlush(libAVPin *this)
 {
-    dshowdebug("ff_dshow_pin_BeginFlush(%p)\n", this);
+    dshowdebug("libAVPin_BeginFlush(%p)\n", this);
     /* I don't care. */
     return S_OK;
 }
-long ff_dshow_pin_EndFlush(DShowPin *this)
+long WINAPI
+libAVPin_EndFlush(libAVPin *this)
 {
-    dshowdebug("ff_dshow_pin_EndFlush(%p)\n", this);
+    dshowdebug("libAVPin_EndFlush(%p)\n", this);
     /* I don't care. */
     return S_OK;
 }
-long ff_dshow_pin_NewSegment(DShowPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
+long WINAPI
+libAVPin_NewSegment(libAVPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
                     double rate)
 {
-    dshowdebug("ff_dshow_pin_NewSegment(%p)\n", this);
+    dshowdebug("libAVPin_NewSegment(%p)\n", this);
     /* I don't care. */
     return S_OK;
 }
 
-static int ff_dshow_pin_Setup(DShowPin *this, DShowFilter *filter)
+static int
+libAVPin_Setup(libAVPin *this, libAVFilter *filter)
 {
     IPinVtbl *vtbl = this->vtbl;
     IMemInputPinVtbl *imemvtbl;
@@ -198,43 +214,44 @@
     if (!imemvtbl)
         return 0;
 
-    SETVTBL(imemvtbl, meminputpin, QueryInterface);
-    SETVTBL(imemvtbl, meminputpin, AddRef);
-    SETVTBL(imemvtbl, meminputpin, Release);
-    SETVTBL(imemvtbl, meminputpin, GetAllocator);
-    SETVTBL(imemvtbl, meminputpin, NotifyAllocator);
-    SETVTBL(imemvtbl, meminputpin, GetAllocatorRequirements);
-    SETVTBL(imemvtbl, meminputpin, Receive);
-    SETVTBL(imemvtbl, meminputpin, ReceiveMultiple);
-    SETVTBL(imemvtbl, meminputpin, ReceiveCanBlock);
+    SETVTBL(imemvtbl, libAVMemInputPin, QueryInterface);
+    SETVTBL(imemvtbl, libAVMemInputPin, AddRef);
+    SETVTBL(imemvtbl, libAVMemInputPin, Release);
+    SETVTBL(imemvtbl, libAVMemInputPin, GetAllocator);
+    SETVTBL(imemvtbl, libAVMemInputPin, NotifyAllocator);
+    SETVTBL(imemvtbl, libAVMemInputPin, GetAllocatorRequirements);
+    SETVTBL(imemvtbl, libAVMemInputPin, Receive);
+    SETVTBL(imemvtbl, libAVMemInputPin, ReceiveMultiple);
+    SETVTBL(imemvtbl, libAVMemInputPin, ReceiveCanBlock);
 
     this->imemvtbl = imemvtbl;
 
-    SETVTBL(vtbl, pin, QueryInterface);
-    SETVTBL(vtbl, pin, AddRef);
-    SETVTBL(vtbl, pin, Release);
-    SETVTBL(vtbl, pin, Connect);
-    SETVTBL(vtbl, pin, ReceiveConnection);
-    SETVTBL(vtbl, pin, Disconnect);
-    SETVTBL(vtbl, pin, ConnectedTo);
-    SETVTBL(vtbl, pin, ConnectionMediaType);
-    SETVTBL(vtbl, pin, QueryPinInfo);
-    SETVTBL(vtbl, pin, QueryDirection);
-    SETVTBL(vtbl, pin, QueryId);
-    SETVTBL(vtbl, pin, QueryAccept);
-    SETVTBL(vtbl, pin, EnumMediaTypes);
-    SETVTBL(vtbl, pin, QueryInternalConnections);
-    SETVTBL(vtbl, pin, EndOfStream);
-    SETVTBL(vtbl, pin, BeginFlush);
-    SETVTBL(vtbl, pin, EndFlush);
-    SETVTBL(vtbl, pin, NewSegment);
+    SETVTBL(vtbl, libAVPin, QueryInterface);
+    SETVTBL(vtbl, libAVPin, AddRef);
+    SETVTBL(vtbl, libAVPin, Release);
+    SETVTBL(vtbl, libAVPin, Connect);
+    SETVTBL(vtbl, libAVPin, ReceiveConnection);
+    SETVTBL(vtbl, libAVPin, Disconnect);
+    SETVTBL(vtbl, libAVPin, ConnectedTo);
+    SETVTBL(vtbl, libAVPin, ConnectionMediaType);
+    SETVTBL(vtbl, libAVPin, QueryPinInfo);
+    SETVTBL(vtbl, libAVPin, QueryDirection);
+    SETVTBL(vtbl, libAVPin, QueryId);
+    SETVTBL(vtbl, libAVPin, QueryAccept);
+    SETVTBL(vtbl, libAVPin, EnumMediaTypes);
+    SETVTBL(vtbl, libAVPin, QueryInternalConnections);
+    SETVTBL(vtbl, libAVPin, EndOfStream);
+    SETVTBL(vtbl, libAVPin, BeginFlush);
+    SETVTBL(vtbl, libAVPin, EndFlush);
+    SETVTBL(vtbl, libAVPin, NewSegment);
 
     this->filter = filter;
 
     return 1;
 }
 
-static void ff_dshow_pin_Free(DShowPin *this)
+static void
+libAVPin_Free(libAVPin *this)
 {
     if (!this)
         return;
@@ -244,51 +261,58 @@
         this->type.pbFormat = NULL;
     }
 }
-DECLARE_CREATE(pin, DShowPin, ff_dshow_pin_Setup(this, filter), DShowFilter *filter)
-DECLARE_DESTROY(pin, DShowPin, ff_dshow_pin_Free)
+DECLARE_CREATE(libAVPin, libAVPin_Setup(this, filter), libAVFilter *filter)
+DECLARE_DESTROY(libAVPin, libAVPin_Free)
 
 /*****************************************************************************
- * DShowMemInputPin
+ * libAVMemInputPin
  ****************************************************************************/
-long ff_dshow_meminputpin_QueryInterface(DShowMemInputPin *this, const GUID *riid,
+long WINAPI
+libAVMemInputPin_QueryInterface(libAVMemInputPin *this, const GUID *riid,
                                 void **ppvObject)
 {
-    DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
-    dshowdebug("ff_dshow_meminputpin_QueryInterface(%p)\n", this);
-    return ff_dshow_pin_QueryInterface(pin, riid, ppvObject);
+    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
+    dshowdebug("libAVMemInputPin_QueryInterface(%p)\n", this);
+    return libAVPin_QueryInterface(pin, riid, ppvObject);
 }
-unsigned long ff_dshow_meminputpin_AddRef(DShowMemInputPin *this)
+unsigned long WINAPI
+libAVMemInputPin_AddRef(libAVMemInputPin *this)
 {
-    DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
-    dshowdebug("ff_dshow_meminputpin_AddRef(%p)\n", this);
-    return ff_dshow_pin_AddRef(pin);
+    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
+    dshowdebug("libAVMemInputPin_AddRef(%p)\n", this);
+    return libAVPin_AddRef(pin);
 }
-unsigned long ff_dshow_meminputpin_Release(DShowMemInputPin *this)
+unsigned long WINAPI
+libAVMemInputPin_Release(libAVMemInputPin *this)
 {
-    DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
-    dshowdebug("ff_dshow_meminputpin_Release(%p)\n", this);
-    return ff_dshow_pin_Release(pin);
+    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
+    dshowdebug("libAVMemInputPin_Release(%p)\n", this);
+    return libAVPin_Release(pin);
 }
-long ff_dshow_meminputpin_GetAllocator(DShowMemInputPin *this, IMemAllocator **alloc)
+long WINAPI
+libAVMemInputPin_GetAllocator(libAVMemInputPin *this, IMemAllocator **alloc)
 {
-    dshowdebug("ff_dshow_meminputpin_GetAllocator(%p)\n", this);
+    dshowdebug("libAVMemInputPin_GetAllocator(%p)\n", this);
     return VFW_E_NO_ALLOCATOR;
 }
-long ff_dshow_meminputpin_NotifyAllocator(DShowMemInputPin *this, IMemAllocator *alloc,
+long WINAPI
+libAVMemInputPin_NotifyAllocator(libAVMemInputPin *this, IMemAllocator *alloc,
                                  BOOL rdwr)
 {
-    dshowdebug("ff_dshow_meminputpin_NotifyAllocator(%p)\n", this);
+    dshowdebug("libAVMemInputPin_NotifyAllocator(%p)\n", this);
     return S_OK;
 }
-long ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *this,
+long WINAPI
+libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *this,
                                           ALLOCATOR_PROPERTIES *props)
 {
-    dshowdebug("ff_dshow_meminputpin_GetAllocatorRequirements(%p)\n", this);
+    dshowdebug("libAVMemInputPin_GetAllocatorRequirements(%p)\n", this);
     return E_NOTIMPL;
 }
-long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
+long WINAPI
+libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)
 {
-    DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
+    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
     enum dshowDeviceType devtype = pin->filter->type;
     void *priv_data;
     AVFormatContext *s;
@@ -304,7 +328,7 @@
     struct dshow_ctx *ctx;
 
 
-    dshowdebug("ff_dshow_meminputpin_Receive(%p)\n", this);
+    dshowdebug("libAVMemInputPin_Receive(%p)\n", this);
 
     if (!sample)
         return E_POINTER;
@@ -342,28 +366,31 @@
 
     return S_OK;
 }
-long ff_dshow_meminputpin_ReceiveMultiple(DShowMemInputPin *this,
+long WINAPI
+libAVMemInputPin_ReceiveMultiple(libAVMemInputPin *this,
                                  IMediaSample **samples, long n, long *nproc)
 {
     int i;
-    dshowdebug("ff_dshow_meminputpin_ReceiveMultiple(%p)\n", this);
+    dshowdebug("libAVMemInputPin_ReceiveMultiple(%p)\n", this);
 
     for (i = 0; i < n; i++)
-        ff_dshow_meminputpin_Receive(this, samples[i]);
+        libAVMemInputPin_Receive(this, samples[i]);
 
     *nproc = n;
     return S_OK;
 }
-long ff_dshow_meminputpin_ReceiveCanBlock(DShowMemInputPin *this)
+long WINAPI
+libAVMemInputPin_ReceiveCanBlock(libAVMemInputPin *this)
 {
-    dshowdebug("ff_dshow_meminputpin_ReceiveCanBlock(%p)\n", this);
+    dshowdebug("libAVMemInputPin_ReceiveCanBlock(%p)\n", this);
     /* I swear I will not block. */
     return S_FALSE;
 }
 
-void ff_dshow_meminputpin_Destroy(DShowMemInputPin *this)
+void
+libAVMemInputPin_Destroy(libAVMemInputPin *this)
 {
-    DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
-    dshowdebug("ff_dshow_meminputpin_Destroy(%p)\n", this);
-    ff_dshow_pin_Destroy(pin);
+    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
+    dshowdebug("libAVMemInputPin_Destroy(%p)\n", this);
+    libAVPin_Destroy(pin);
 }
diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c
index 586caee..6a51816 100644
--- a/libavdevice/fbdev_dec.c
+++ b/libavdevice/fbdev_dec.c
@@ -157,11 +157,11 @@
     uint8_t *pin, *pout;
 
     if (fbdev->time_frame == AV_NOPTS_VALUE)
-        fbdev->time_frame = av_gettime_relative();
+        fbdev->time_frame = av_gettime();
 
     /* wait based on the frame rate */
     while (1) {
-        curtime = av_gettime_relative();
+        curtime = av_gettime();
         delay = fbdev->time_frame - curtime;
         av_log(avctx, AV_LOG_TRACE,
                 "time_frame:%"PRId64" curtime:%"PRId64" delay:%"PRId64"\n",
@@ -186,7 +186,7 @@
                "Error refreshing variable info: %s\n", av_err2str(AVERROR(errno)));
     }
 
-    pkt->pts = av_gettime();
+    pkt->pts = curtime;
 
     /* compute visible data offset */
     pin = fbdev->data + fbdev->bytes_per_pixel * fbdev->varinfo.xoffset +
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index 9b2c55f..f444440 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -394,7 +394,7 @@
     gdigrab->header_size = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) +
                            (bpp <= 8 ? (1 << bpp) : 0) * sizeof(RGBQUAD) /* palette size */;
     gdigrab->time_base   = av_inv_q(gdigrab->framerate);
-    gdigrab->time_frame  = av_gettime_relative() / av_q2d(gdigrab->time_base);
+    gdigrab->time_frame  = av_gettime() / av_q2d(gdigrab->time_base);
 
     gdigrab->hwnd       = hwnd;
     gdigrab->source_hdc = source_hdc;
@@ -551,7 +551,7 @@
 
     /* wait based on the frame rate */
     for (;;) {
-        curtime = av_gettime_relative();
+        curtime = av_gettime();
         delay = time_frame * av_q2d(time_base) - curtime;
         if (delay <= 0) {
             if (delay < INT64_C(-1000000) * av_q2d(time_base)) {
@@ -568,7 +568,7 @@
 
     if (av_new_packet(pkt, file_size) < 0)
         return AVERROR(ENOMEM);
-    pkt->pts = av_gettime();
+    pkt->pts = curtime;
 
     /* Blit screen grab */
     if (!BitBlt(dest_hdc, 0, 0,
diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
index 6cc305b..a0aa9dc 100644
--- a/libavdevice/kmsgrab.c
+++ b/libavdevice/kmsgrab.c
@@ -160,7 +160,6 @@
     KMSGrabContext *ctx = avctx->priv_data;
     drmModeFB2 *fb;
     int err, i, nb_objects;
-    uint64_t modifier = ctx->drm_format_modifier;
 
     fb = drmModeGetFB2(ctx->hwctx->fd, plane->fb_id);
     if (!fb) {
@@ -176,6 +175,13 @@
         err = AVERROR(EIO);
         goto fail;
     }
+    if (fb->modifier != ctx->drm_format_modifier) {
+        av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer "
+               "format modifier changed: now %"PRIx64".\n",
+               ctx->plane_id, fb->modifier);
+        err = AVERROR(EIO);
+        goto fail;
+    }
     if (fb->width != ctx->width || fb->height != ctx->height) {
         av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer "
                "dimensions changed: now %"PRIu32"x%"PRIu32".\n",
@@ -189,9 +195,6 @@
         goto fail;
     }
 
-    if (fb->flags & DRM_MODE_FB_MODIFIERS)
-        modifier = fb->modifier;
-
     *desc = (AVDRMFrameDescriptor) {
         .nb_layers = 1,
         .layers[0] = {
@@ -240,7 +243,7 @@
             desc->objects[obj] = (AVDRMObjectDescriptor) {
                 .fd              = fd,
                 .size            = size,
-                .format_modifier = modifier,
+                .format_modifier = fb->modifier,
             };
             desc->layers[0].planes[i] = (AVDRMPlaneDescriptor) {
                 .object_index = obj,
@@ -268,7 +271,7 @@
     int64_t now;
     int err;
 
-    now = av_gettime_relative();
+    now = av_gettime();
     if (ctx->frame_last) {
         int64_t delay;
         while (1) {
@@ -276,11 +279,10 @@
             if (delay <= 0)
                 break;
             av_usleep(delay);
-            now = av_gettime_relative();
+            now = av_gettime();
         }
     }
     ctx->frame_last = now;
-    now = av_gettime();
 
     plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id);
     if (!plane) {
@@ -555,18 +557,15 @@
             err = AVERROR(EINVAL);
             goto fail;
         }
-
-        if (fb2->flags & DRM_MODE_FB_MODIFIERS) {
-            if (ctx->drm_format_modifier != DRM_FORMAT_MOD_INVALID &&
-                ctx->drm_format_modifier != fb2->modifier) {
-                av_log(avctx, AV_LOG_ERROR, "Framebuffer format modifier "
-                       "%"PRIx64" does not match expected modifier.\n",
-                       fb2->modifier);
-                err = AVERROR(EINVAL);
-                goto fail;
-            } else {
-                ctx->drm_format_modifier = fb2->modifier;
-            }
+        if (ctx->drm_format_modifier != DRM_FORMAT_MOD_INVALID &&
+            ctx->drm_format_modifier != fb2->modifier) {
+            av_log(avctx, AV_LOG_ERROR, "Framebuffer format modifier "
+                   "%"PRIx64" does not match expected modifier.\n",
+                   fb2->modifier);
+            err = AVERROR(EINVAL);
+            goto fail;
+        } else {
+            ctx->drm_format_modifier = fb2->modifier;
         }
         av_log(avctx, AV_LOG_VERBOSE, "Format is %s, from "
                "DRM format %"PRIx32" modifier %"PRIx64".\n",
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 94ad032..ff0be64 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -440,7 +440,7 @@
         size = frame->nb_samples * av_get_bytes_per_sample(frame->format) *
                                    frame->channels;
         if ((ret = av_new_packet(pkt, size)) < 0)
-            goto fail;
+            goto fail;;
         memcpy(pkt->data, frame->data[0], size);
     }
 
@@ -456,7 +456,7 @@
         if ((ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
                                            metadata, size)) < 0) {
             av_freep(&metadata);
-            goto fail;
+            goto fail;;
         }
     }
 
diff --git a/libavdevice/timefilter.h b/libavdevice/timefilter.h
index de70945..cb3d0a7 100644
--- a/libavdevice/timefilter.h
+++ b/libavdevice/timefilter.h
@@ -39,6 +39,16 @@
 /**
  * Create a new Delay Locked Loop time filter
  *
+ * feedback2_factor and feedback3_factor are the factors used for the
+ * multiplications that are respectively performed in the second and third
+ * feedback paths of the loop.
+ *
+ * Unless you know what you are doing, you should set these as follow:
+ *
+ * o = 2 * M_PI * bandwidth * period_in_seconds
+ * feedback2_factor = sqrt(2) * o
+ * feedback3_factor = o * o
+ *
  * Where bandwidth is up to you to choose. Smaller values will filter out more
  * of the jitter, but also take a longer time for the loop to settle. A good
  * starting point is something between 0.3 and 3 Hz.
@@ -49,8 +59,11 @@
  * @param brandwidth  filtering bandwidth, in Hz
  *
  * @return a pointer to a TimeFilter struct, or NULL on error
+ *
+ * For more details about these parameters and background concepts please see:
+ * http://www.kokkinizita.net/papers/usingdll.pdf
  */
-TimeFilter * ff_timefilter_new(double time_base, double period, double bandwidth);
+TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor);
 
 /**
  * Update the filter
diff --git a/libavdevice/version.h b/libavdevice/version.h
index f5aaa16..7022fdb 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -28,8 +28,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVDEVICE_VERSION_MAJOR  58
-#define LIBAVDEVICE_VERSION_MINOR  12
-#define LIBAVDEVICE_VERSION_MICRO 100
+#define LIBAVDEVICE_VERSION_MINOR  11
+#define LIBAVDEVICE_VERSION_MICRO 103
 
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
                                                LIBAVDEVICE_VERSION_MINOR, \
@@ -46,8 +46,5 @@
  * dropped at a future version bump. The defines themselves are not part of
  * the public API and may change, break or disappear at any time.
  */
-#ifndef FF_API_DEVICE_CAPABILITIES
-#define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
-#endif
 
 #endif /* AVDEVICE_VERSION_H */
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index f9ea5a5..95bdc8a 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -206,7 +206,7 @@
     c->time_frame += c->frame_duration;
 
     for (;;) {
-        curtime = av_gettime_relative();
+        curtime = av_gettime();
         delay   = c->time_frame - curtime;
         if (delay <= 0)
             break;
@@ -236,7 +236,7 @@
     shmdt(data);
 }
 
-static AVBufferRef *allocate_shm_buffer(void *opaque, buffer_size_t size)
+static AVBufferRef *allocate_shm_buffer(void *opaque, int size)
 {
     xcb_connection_t *conn = opaque;
     xcb_shm_seg_t segment;
@@ -422,8 +422,7 @@
     int ret = 0;
     int64_t pts;
 
-    wait_frame(s, pkt);
-    pts = av_gettime();
+    pts = wait_frame(s, pkt);
 
     if (c->follow_mouse || c->draw_mouse) {
         pc  = xcb_query_pointer(c->conn, c->screen->root);
@@ -514,26 +513,21 @@
             switch (depth) {
             case 32:
                 if (fmt->bits_per_pixel == 32)
-                    *pix_fmt = setup->image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST ?
-                               AV_PIX_FMT_BGR0 : AV_PIX_FMT_0RGB;
+                    *pix_fmt = AV_PIX_FMT_0RGB;
                 break;
             case 24:
                 if (fmt->bits_per_pixel == 32)
-                    *pix_fmt = setup->image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST ?
-                               AV_PIX_FMT_BGR0 : AV_PIX_FMT_0RGB;
+                    *pix_fmt = AV_PIX_FMT_0RGB32;
                 else if (fmt->bits_per_pixel == 24)
-                    *pix_fmt = setup->image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST ?
-                               AV_PIX_FMT_BGR24 : AV_PIX_FMT_RGB24;
+                    *pix_fmt = AV_PIX_FMT_RGB24;
                 break;
             case 16:
                 if (fmt->bits_per_pixel == 16)
-                    *pix_fmt = setup->image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST ?
-                               AV_PIX_FMT_RGB565LE : AV_PIX_FMT_RGB565BE;
+                    *pix_fmt = AV_PIX_FMT_RGB565;
                 break;
             case 15:
                 if (fmt->bits_per_pixel == 16)
-                    *pix_fmt = setup->image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST ?
-                               AV_PIX_FMT_RGB555LE : AV_PIX_FMT_RGB555BE;
+                    *pix_fmt = AV_PIX_FMT_RGB555;
                 break;
             case 8:
                 if (fmt->bits_per_pixel == 8)
@@ -597,7 +591,7 @@
     c->time_base  = (AVRational){ st->avg_frame_rate.den,
                                   st->avg_frame_rate.num };
     c->frame_duration = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q);
-    c->time_frame = av_gettime_relative();
+    c->time_frame = av_gettime();
 
     ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format, &c->bpp);
     free(geo);
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b2c254e..77b5d3a 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -27,7 +27,6 @@
 # subsystems
 OBJS-$(CONFIG_QSVVPP)                        += qsvvpp.o
 OBJS-$(CONFIG_SCENE_SAD)                     += scene_sad.o
-OBJS-$(CONFIG_DNN)                           += dnn_filter_common.o
 include $(SRC_PATH)/libavfilter/dnn/Makefile
 
 # audio filters
@@ -47,7 +46,6 @@
 OBJS-$(CONFIG_AECHO_FILTER)                  += af_aecho.o
 OBJS-$(CONFIG_AEMPHASIS_FILTER)              += af_aemphasis.o
 OBJS-$(CONFIG_AEVAL_FILTER)                  += aeval.o
-OBJS-$(CONFIG_AEXCITER_FILTER)               += af_aexciter.o
 OBJS-$(CONFIG_AFADE_FILTER)                  += af_afade.o
 OBJS-$(CONFIG_AFFTDN_FILTER)                 += af_afftdn.o
 OBJS-$(CONFIG_AFFTFILT_FILTER)               += af_afftfilt.o
@@ -195,12 +193,9 @@
 OBJS-$(CONFIG_CHROMANR_FILTER)               += vf_chromanr.o
 OBJS-$(CONFIG_CHROMASHIFT_FILTER)            += vf_chromashift.o
 OBJS-$(CONFIG_CIESCOPE_FILTER)               += vf_ciescope.o
-OBJS-$(CONFIG_CODECVIEW_FILTER)              += vf_codecview.o qp_table.o
+OBJS-$(CONFIG_CODECVIEW_FILTER)              += vf_codecview.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)           += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)      += vf_colorchannelmixer.o
-OBJS-$(CONFIG_COLORCONTRAST_FILTER)          += vf_colorcontrast.o
-OBJS-$(CONFIG_COLORCORRECT_FILTER)           += vf_colorcorrect.o
-OBJS-$(CONFIG_COLORIZE_FILTER)               += vf_colorize.o
 OBJS-$(CONFIG_COLORKEY_FILTER)               += vf_colorkey.o
 OBJS-$(CONFIG_COLORKEY_OPENCL_FILTER)        += vf_colorkey_opencl.o opencl.o \
                                                 opencl/colorkey.o
@@ -208,7 +203,6 @@
 OBJS-$(CONFIG_COLORLEVELS_FILTER)            += vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)            += vf_colormatrix.o
 OBJS-$(CONFIG_COLORSPACE_FILTER)             += vf_colorspace.o colorspace.o colorspacedsp.o
-OBJS-$(CONFIG_COLORTEMPERATURE_FILTER)       += vf_colortemperature.o
 OBJS-$(CONFIG_CONVOLUTION_FILTER)            += vf_convolution.o
 OBJS-$(CONFIG_CONVOLUTION_OPENCL_FILTER)     += vf_convolution_opencl.o opencl.o \
                                                 opencl/convolution.o
@@ -254,13 +248,10 @@
 OBJS-$(CONFIG_EDGEDETECT_FILTER)             += vf_edgedetect.o
 OBJS-$(CONFIG_ELBG_FILTER)                   += vf_elbg.o
 OBJS-$(CONFIG_ENTROPY_FILTER)                += vf_entropy.o
-OBJS-$(CONFIG_EPX_FILTER)                    += vf_epx.o
 OBJS-$(CONFIG_EQ_FILTER)                     += vf_eq.o
 OBJS-$(CONFIG_EROSION_FILTER)                += vf_neighbor.o
 OBJS-$(CONFIG_EROSION_OPENCL_FILTER)         += vf_neighbor_opencl.o opencl.o \
                                                 opencl/neighbor.o
-OBJS-$(CONFIG_ESTDIF_FILTER)                 += vf_estdif.o
-OBJS-$(CONFIG_EXPOSURE_FILTER)               += vf_exposure.o
 OBJS-$(CONFIG_EXTRACTPLANES_FILTER)          += vf_extractplanes.o
 OBJS-$(CONFIG_FADE_FILTER)                   += vf_fade.o
 OBJS-$(CONFIG_FFTDNOIZ_FILTER)               += vf_fftdnoiz.o
@@ -280,7 +271,7 @@
 OBJS-$(CONFIG_FREEZEDETECT_FILTER)           += vf_freezedetect.o
 OBJS-$(CONFIG_FREEZEFRAMES_FILTER)           += vf_freezeframes.o
 OBJS-$(CONFIG_FREI0R_FILTER)                 += vf_frei0r.o
-OBJS-$(CONFIG_FSPP_FILTER)                   += vf_fspp.o qp_table.o
+OBJS-$(CONFIG_FSPP_FILTER)                   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)                  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)                    += vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)                += vf_gradfun.o
@@ -299,14 +290,12 @@
 OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER)          += vf_hwupload_cuda.o
 OBJS-$(CONFIG_HWUPLOAD_FILTER)               += vf_hwupload.o
 OBJS-$(CONFIG_HYSTERESIS_FILTER)             += vf_hysteresis.o framesync.o
-OBJS-$(CONFIG_IDENTITY_FILTER)               += vf_identity.o
 OBJS-$(CONFIG_IDET_FILTER)                   += vf_idet.o
 OBJS-$(CONFIG_IL_FILTER)                     += vf_il.o
 OBJS-$(CONFIG_INFLATE_FILTER)                += vf_neighbor.o
 OBJS-$(CONFIG_INTERLACE_FILTER)              += vf_tinterlace.o
 OBJS-$(CONFIG_INTERLEAVE_FILTER)             += f_interleave.o
 OBJS-$(CONFIG_KERNDEINT_FILTER)              += vf_kerndeint.o
-OBJS-$(CONFIG_KIRSCH_FILTER)                 += vf_convolution.o
 OBJS-$(CONFIG_LAGFUN_FILTER)                 += vf_lagfun.o
 OBJS-$(CONFIG_LENSCORRECTION_FILTER)         += vf_lenscorrection.o
 OBJS-$(CONFIG_LENSFUN_FILTER)                += vf_lensfun.o
@@ -334,7 +323,6 @@
 OBJS-$(CONFIG_MIDEQUALIZER_FILTER)           += vf_midequalizer.o framesync.o
 OBJS-$(CONFIG_MINTERPOLATE_FILTER)           += vf_minterpolate.o motion_estimation.o
 OBJS-$(CONFIG_MIX_FILTER)                    += vf_mix.o framesync.o
-OBJS-$(CONFIG_MONOCHROME_FILTER)             += vf_monochrome.o
 OBJS-$(CONFIG_MPDECIMATE_FILTER)             += vf_mpdecimate.o
 OBJS-$(CONFIG_NEGATE_FILTER)                 += vf_lut.o
 OBJS-$(CONFIG_NLMEANS_FILTER)                += vf_nlmeans.o
@@ -364,8 +352,8 @@
 OBJS-$(CONFIG_PHOTOSENSITIVITY_FILTER)       += vf_photosensitivity.o
 OBJS-$(CONFIG_PIXDESCTEST_FILTER)            += vf_pixdesctest.o
 OBJS-$(CONFIG_PIXSCOPE_FILTER)               += vf_datascope.o
-OBJS-$(CONFIG_PP_FILTER)                     += vf_pp.o qp_table.o
-OBJS-$(CONFIG_PP7_FILTER)                    += vf_pp7.o qp_table.o
+OBJS-$(CONFIG_PP_FILTER)                     += vf_pp.o
+OBJS-$(CONFIG_PP7_FILTER)                    += vf_pp7.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)            += vf_premultiply.o framesync.o
 OBJS-$(CONFIG_PREWITT_FILTER)                += vf_convolution.o
 OBJS-$(CONFIG_PREWITT_OPENCL_FILTER)         += vf_convolution_opencl.o opencl.o \
@@ -413,11 +401,9 @@
 OBJS-$(CONFIG_SETSAR_FILTER)                 += vf_aspect.o
 OBJS-$(CONFIG_SETTB_FILTER)                  += settb.o
 OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)        += vf_misc_vaapi.o vaapi_vpp.o
-OBJS-$(CONFIG_SHEAR_FILTER)                  += vf_shear.o
 OBJS-$(CONFIG_SHOWINFO_FILTER)               += vf_showinfo.o
 OBJS-$(CONFIG_SHOWPALETTE_FILTER)            += vf_showpalette.o
 OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)          += vf_shuffleframes.o
-OBJS-$(CONFIG_SHUFFLEPIXELS_FILTER)          += vf_shufflepixels.o
 OBJS-$(CONFIG_SHUFFLEPLANES_FILTER)          += vf_shuffleplanes.o
 OBJS-$(CONFIG_SIDEDATA_FILTER)               += f_sidedata.o
 OBJS-$(CONFIG_SIGNALSTATS_FILTER)            += vf_signalstats.o
@@ -427,7 +413,7 @@
 OBJS-$(CONFIG_SOBEL_OPENCL_FILTER)           += vf_convolution_opencl.o opencl.o \
                                                 opencl/convolution.o
 OBJS-$(CONFIG_SPLIT_FILTER)                  += split.o
-OBJS-$(CONFIG_SPP_FILTER)                    += vf_spp.o qp_table.o
+OBJS-$(CONFIG_SPP_FILTER)                    += vf_spp.o
 OBJS-$(CONFIG_SR_FILTER)                     += vf_sr.o
 OBJS-$(CONFIG_SSIM_FILTER)                   += vf_ssim.o framesync.o
 OBJS-$(CONFIG_STEREO3D_FILTER)               += vf_stereo3d.o
@@ -446,7 +432,6 @@
 OBJS-$(CONFIG_TINTERLACE_FILTER)             += vf_tinterlace.o
 OBJS-$(CONFIG_TLUT2_FILTER)                  += vf_lut2.o framesync.o
 OBJS-$(CONFIG_TMEDIAN_FILTER)                += vf_xmedian.o framesync.o
-OBJS-$(CONFIG_TMIDEQUALIZER_FILTER)          += vf_tmidequalizer.o
 OBJS-$(CONFIG_TMIX_FILTER)                   += vf_mix.o framesync.o
 OBJS-$(CONFIG_TONEMAP_FILTER)                += vf_tonemap.o colorspace.o
 OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER)         += vf_tonemap_opencl.o colorspace.o opencl.o \
@@ -463,7 +448,7 @@
 OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER)         += vf_unsharp_opencl.o opencl.o \
                                                 opencl/unsharp.o
 OBJS-$(CONFIG_UNTILE_FILTER)                 += vf_untile.o
-OBJS-$(CONFIG_USPP_FILTER)                   += vf_uspp.o qp_table.o
+OBJS-$(CONFIG_USPP_FILTER)                   += vf_uspp.o
 OBJS-$(CONFIG_V360_FILTER)                   += vf_v360.o
 OBJS-$(CONFIG_VAGUEDENOISER_FILTER)          += vf_vaguedenoiser.o
 OBJS-$(CONFIG_VECTORSCOPE_FILTER)            += vf_vectorscope.o
@@ -472,7 +457,6 @@
 OBJS-$(CONFIG_VIBRANCE_FILTER)               += vf_vibrance.o
 OBJS-$(CONFIG_VIDSTABDETECT_FILTER)          += vidstabutils.o vf_vidstabdetect.o
 OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)       += vidstabutils.o vf_vidstabtransform.o
-OBJS-$(CONFIG_VIF_FILTER)                    += vf_vif.o framesync.o
 OBJS-$(CONFIG_VIGNETTE_FILTER)               += vf_vignette.o
 OBJS-$(CONFIG_VMAFMOTION_FILTER)             += vf_vmafmotion.o framesync.o
 OBJS-$(CONFIG_VPP_QSV_FILTER)                += vf_vpp_qsv.o
diff --git a/libavfilter/af_acrusher.c b/libavfilter/af_acrusher.c
index d3c31c2..ddce744 100644
--- a/libavfilter/af_acrusher.c
+++ b/libavfilter/af_acrusher.c
@@ -68,7 +68,7 @@
 } ACrusherContext;
 
 #define OFFSET(x) offsetof(ACrusherContext, x)
-#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption acrusher_options[] = {
     { "level_in", "set level in",         OFFSET(level_in),  AV_OPT_TYPE_DOUBLE, {.dbl=1},    0.015625, 64, A },
@@ -325,27 +325,13 @@
     s->lfo.srate = inlink->sample_rate;
     s->lfo.amount = .5;
 
-    if (!s->sr)
-        s->sr = av_calloc(inlink->channels, sizeof(*s->sr));
+    s->sr = av_calloc(inlink->channels, sizeof(*s->sr));
     if (!s->sr)
         return AVERROR(ENOMEM);
 
     return 0;
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    AVFilterLink *inlink = ctx->inputs[0];
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_input(inlink);
-}
-
 static const AVFilterPad avfilter_af_acrusher_inputs[] = {
     {
         .name         = "default",
@@ -373,5 +359,4 @@
     .query_formats = query_formats,
     .inputs        = avfilter_af_acrusher_inputs,
     .outputs       = avfilter_af_acrusher_outputs,
-    .process_command = process_command,
 };
diff --git a/libavfilter/af_adeclick.c b/libavfilter/af_adeclick.c
index c8a41cd..e86a1f7 100644
--- a/libavfilter/af_adeclick.c
+++ b/libavfilter/af_adeclick.c
@@ -92,21 +92,13 @@
 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption adeclick_options[] = {
-    { "window", "set window size",     OFFSET(w),         AV_OPT_TYPE_DOUBLE, {.dbl=55}, 10,  100, AF },
     { "w", "set window size",          OFFSET(w),         AV_OPT_TYPE_DOUBLE, {.dbl=55}, 10,  100, AF },
-    { "overlap", "set window overlap", OFFSET(overlap),   AV_OPT_TYPE_DOUBLE, {.dbl=75}, 50,   95, AF },
     { "o", "set window overlap",       OFFSET(overlap),   AV_OPT_TYPE_DOUBLE, {.dbl=75}, 50,   95, AF },
-    { "arorder", "set autoregression order", OFFSET(ar),  AV_OPT_TYPE_DOUBLE, {.dbl=2},   0,   25, AF },
     { "a", "set autoregression order", OFFSET(ar),        AV_OPT_TYPE_DOUBLE, {.dbl=2},   0,   25, AF },
-    { "threshold", "set threshold",    OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=2},   1,  100, AF },
     { "t", "set threshold",            OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=2},   1,  100, AF },
-    { "burst", "set burst fusion",     OFFSET(burst),     AV_OPT_TYPE_DOUBLE, {.dbl=2},   0,   10, AF },
     { "b", "set burst fusion",         OFFSET(burst),     AV_OPT_TYPE_DOUBLE, {.dbl=2},   0,   10, AF },
-    { "method", "set overlap method",  OFFSET(method),    AV_OPT_TYPE_INT,    {.i64=0},   0,    1, AF, "m" },
     { "m", "set overlap method",       OFFSET(method),    AV_OPT_TYPE_INT,    {.i64=0},   0,    1, AF, "m" },
-    { "add", "overlap-add",            0,                 AV_OPT_TYPE_CONST,  {.i64=0},   0,    0, AF, "m" },
     { "a", "overlap-add",              0,                 AV_OPT_TYPE_CONST,  {.i64=0},   0,    0, AF, "m" },
-    { "save", "overlap-save",          0,                 AV_OPT_TYPE_CONST,  {.i64=1},   0,    0, AF, "m" },
     { "s", "overlap-save",             0,                 AV_OPT_TYPE_CONST,  {.i64=1},   0,    0, AF, "m" },
     { NULL }
 };
@@ -777,22 +769,14 @@
 };
 
 static const AVOption adeclip_options[] = {
-    { "window", "set window size",     OFFSET(w),         AV_OPT_TYPE_DOUBLE, {.dbl=55},     10,  100, AF },
-    { "w", "set window size",          OFFSET(w),         AV_OPT_TYPE_DOUBLE, {.dbl=55},     10,  100, AF },
-    { "overlap", "set window overlap", OFFSET(overlap),   AV_OPT_TYPE_DOUBLE, {.dbl=75},     50,   95, AF },
-    { "o", "set window overlap",       OFFSET(overlap),   AV_OPT_TYPE_DOUBLE, {.dbl=75},     50,   95, AF },
-    { "arorder", "set autoregression order", OFFSET(ar),  AV_OPT_TYPE_DOUBLE, {.dbl=8},       0,   25, AF },
-    { "a", "set autoregression order", OFFSET(ar),        AV_OPT_TYPE_DOUBLE, {.dbl=8},       0,   25, AF },
-    { "threshold", "set threshold",    OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=10},      1,  100, AF },
-    { "t", "set threshold",            OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=10},      1,  100, AF },
-    { "hsize", "set histogram size",   OFFSET(nb_hbins),  AV_OPT_TYPE_INT,    {.i64=1000},  100, 9999, AF },
-    { "n", "set histogram size",       OFFSET(nb_hbins),  AV_OPT_TYPE_INT,    {.i64=1000},  100, 9999, AF },
-    { "method", "set overlap method",  OFFSET(method),    AV_OPT_TYPE_INT,    {.i64=0},       0,    1, AF, "m" },
-    { "m", "set overlap method",       OFFSET(method),    AV_OPT_TYPE_INT,    {.i64=0},       0,    1, AF, "m" },
-    { "add", "overlap-add",            0,                 AV_OPT_TYPE_CONST,  {.i64=0},       0,    0, AF, "m" },
-    { "a", "overlap-add",              0,                 AV_OPT_TYPE_CONST,  {.i64=0},       0,    0, AF, "m" },
-    { "save", "overlap-save",          0,                 AV_OPT_TYPE_CONST,  {.i64=1},       0,    0, AF, "m" },
-    { "s", "overlap-save",             0,                 AV_OPT_TYPE_CONST,  {.i64=1},       0,    0, AF, "m" },
+    { "w", "set window size",          OFFSET(w),              AV_OPT_TYPE_DOUBLE, {.dbl=55},     10,  100, AF },
+    { "o", "set window overlap",       OFFSET(overlap),        AV_OPT_TYPE_DOUBLE, {.dbl=75},     50,   95, AF },
+    { "a", "set autoregression order", OFFSET(ar),             AV_OPT_TYPE_DOUBLE, {.dbl=8},       0,   25, AF },
+    { "t", "set threshold",            OFFSET(threshold),      AV_OPT_TYPE_DOUBLE, {.dbl=10},      1,  100, AF },
+    { "n", "set histogram size",       OFFSET(nb_hbins),       AV_OPT_TYPE_INT,    {.i64=1000},  100, 9999, AF },
+    { "m", "set overlap method",       OFFSET(method),         AV_OPT_TYPE_INT,    {.i64=0},       0,    1, AF, "m" },
+    { "a", "overlap-add",              0,                      AV_OPT_TYPE_CONST,  {.i64=0},       0,    0, AF, "m" },
+    { "s", "overlap-save",             0,                      AV_OPT_TYPE_CONST,  {.i64=1},       0,    0, AF, "m" },
     { NULL }
 };
 
diff --git a/libavfilter/af_aexciter.c b/libavfilter/af_aexciter.c
deleted file mode 100644
index f09c999..0000000
--- a/libavfilter/af_aexciter.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) Markus Schmidt and Christian Holschuh
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/opt.h"
-#include "avfilter.h"
-#include "internal.h"
-#include "audio.h"
-
-typedef struct ChannelParams {
-    double blend_old, drive_old;
-    double rdrive, rbdr, kpa, kpb, kna, knb, ap,
-           an, imr, kc, srct, sq, pwrq;
-    double prev_med, prev_out;
-
-    double hp[5], lp[5];
-    double hw[4][2], lw[2][2];
-} ChannelParams;
-
-typedef struct AExciterContext {
-    const AVClass *class;
-
-    double level_in;
-    double level_out;
-    double amount;
-    double drive;
-    double blend;
-    double freq;
-    double ceil;
-    int listen;
-
-    ChannelParams *cp;
-} AExciterContext;
-
-#define OFFSET(x) offsetof(AExciterContext, x)
-#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption aexciter_options[] = {
-    { "level_in",  "set level in",    OFFSET(level_in),  AV_OPT_TYPE_DOUBLE, {.dbl=1},           0, 64, A },
-    { "level_out", "set level out",   OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1},           0, 64, A },
-    { "amount", "set amount",         OFFSET(amount),    AV_OPT_TYPE_DOUBLE, {.dbl=1},           0, 64, A },
-    { "drive", "set harmonics",       OFFSET(drive),     AV_OPT_TYPE_DOUBLE, {.dbl=8.5},       0.1, 10, A },
-    { "blend", "set blend harmonics", OFFSET(blend),     AV_OPT_TYPE_DOUBLE, {.dbl=0},         -10, 10, A },
-    { "freq", "set scope",            OFFSET(freq),      AV_OPT_TYPE_DOUBLE, {.dbl=7500},  2000, 12000, A },
-    { "ceil", "set ceiling",          OFFSET(ceil),      AV_OPT_TYPE_DOUBLE, {.dbl=9999},  9999, 20000, A },
-    { "listen", "enable listen mode", OFFSET(listen),    AV_OPT_TYPE_BOOL,   {.i64=0},        0,     1, A },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(aexciter);
-
-static inline double M(double x)
-{
-    return (fabs(x) > 0.00000001) ? x : 0.0;
-}
-
-static inline double D(double x)
-{
-    x = fabs(x);
-
-    return (x > 0.00000001) ? sqrt(x) : 0.0;
-}
-
-static void set_params(ChannelParams *p,
-                       double blend, double drive,
-                       double srate, double freq,
-                       double ceil)
-{
-    double a0, a1, a2, b0, b1, b2, w0, alpha;
-
-    p->rdrive = 12.0 / drive;
-    p->rbdr = p->rdrive / (10.5 - blend) * 780.0 / 33.0;
-    p->kpa = D(2.0 * (p->rdrive*p->rdrive) - 1.0) + 1.0;
-    p->kpb = (2.0 - p->kpa) / 2.0;
-    p->ap = ((p->rdrive*p->rdrive) - p->kpa + 1.0) / 2.0;
-    p->kc = p->kpa / D(2.0 * D(2.0 * (p->rdrive*p->rdrive) - 1.0) - 2.0 * p->rdrive*p->rdrive);
-
-    p->srct = (0.1 * srate) / (0.1 * srate + 1.0);
-    p->sq = p->kc*p->kc + 1.0;
-    p->knb = -1.0 * p->rbdr / D(p->sq);
-    p->kna = 2.0 * p->kc * p->rbdr / D(p->sq);
-    p->an = p->rbdr*p->rbdr / p->sq;
-    p->imr = 2.0 * p->knb + D(2.0 * p->kna + 4.0 * p->an - 1.0);
-    p->pwrq = 2.0 / (p->imr + 1.0);
-
-    w0 = 2 * M_PI * freq / srate;
-    alpha = sin(w0) / (2. * 0.707);
-    a0 =   1 + alpha;
-    a1 =  -2 * cos(w0);
-    a2 =   1 - alpha;
-    b0 =  (1 + cos(w0)) / 2;
-    b1 = -(1 + cos(w0));
-    b2 =  (1 + cos(w0)) / 2;
-
-    p->hp[0] =-a1 / a0;
-    p->hp[1] =-a2 / a0;
-    p->hp[2] = b0 / a0;
-    p->hp[3] = b1 / a0;
-    p->hp[4] = b2 / a0;
-
-    w0 = 2 * M_PI * ceil / srate;
-    alpha = sin(w0) / (2. * 0.707);
-    a0 =  1 + alpha;
-    a1 = -2 * cos(w0);
-    a2 =  1 - alpha;
-    b0 = (1 - cos(w0)) / 2;
-    b1 =  1 - cos(w0);
-    b2 = (1 - cos(w0)) / 2;
-
-    p->lp[0] =-a1 / a0;
-    p->lp[1] =-a2 / a0;
-    p->lp[2] = b0 / a0;
-    p->lp[3] = b1 / a0;
-    p->lp[4] = b2 / a0;
-}
-
-static double bprocess(double in, const double *const c,
-                       double *w1, double *w2)
-{
-    double out = c[2] * in + *w1;
-
-    *w1 = c[3] * in + *w2 + c[0] * out;
-    *w2 = c[4] * in + c[1] * out;
-
-    return out;
-}
-
-static double distortion_process(AExciterContext *s, ChannelParams *p, double in)
-{
-    double proc = in, med;
-
-    proc = bprocess(proc, p->hp, &p->hw[0][0], &p->hw[0][1]);
-    proc = bprocess(proc, p->hp, &p->hw[1][0], &p->hw[1][1]);
-
-    if (proc >= 0.0) {
-        med = (D(p->ap + proc * (p->kpa - proc)) + p->kpb) * p->pwrq;
-    } else {
-        med = (D(p->an - proc * (p->kna + proc)) + p->knb) * p->pwrq * -1.0;
-    }
-
-    proc = p->srct * (med - p->prev_med + p->prev_out);
-    p->prev_med = M(med);
-    p->prev_out = M(proc);
-
-    proc = bprocess(proc, p->hp, &p->hw[2][0], &p->hw[2][1]);
-    proc = bprocess(proc, p->hp, &p->hw[3][0], &p->hw[3][1]);
-
-    if (s->ceil >= 10000.) {
-        proc = bprocess(proc, p->lp, &p->lw[0][0], &p->lw[0][1]);
-        proc = bprocess(proc, p->lp, &p->lw[1][0], &p->lw[1][1]);
-    }
-
-    return proc;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-    AVFilterContext *ctx = inlink->dst;
-    AExciterContext *s = ctx->priv;
-    AVFilterLink *outlink = ctx->outputs[0];
-    AVFrame *out;
-    const double *src = (const double *)in->data[0];
-    const double level_in = s->level_in;
-    const double level_out = s->level_out;
-    const double amount = s->amount;
-    const double listen = 1.0 - s->listen;
-    double *dst;
-
-    if (av_frame_is_writable(in)) {
-        out = in;
-    } else {
-        out = ff_get_audio_buffer(inlink, in->nb_samples);
-        if (!out) {
-            av_frame_free(&in);
-            return AVERROR(ENOMEM);
-        }
-        av_frame_copy_props(out, in);
-    }
-
-    dst = (double *)out->data[0];
-    for (int n = 0; n < in->nb_samples; n++) {
-        for (int c = 0; c < inlink->channels; c++) {
-            double sample = src[c] * level_in;
-
-            sample = distortion_process(s, &s->cp[c], sample);
-            sample = sample * amount + listen * src[c];
-
-            sample *= level_out;
-            if (ctx->is_disabled)
-                dst[c] = src[c];
-            else
-                dst[c] = sample;
-        }
-
-        src += inlink->channels;
-        dst += inlink->channels;
-    }
-
-    if (in != out)
-        av_frame_free(&in);
-
-    return ff_filter_frame(outlink, out);
-}
-
-static int query_formats(AVFilterContext *ctx)
-{
-    AVFilterFormats *formats;
-    AVFilterChannelLayouts *layouts;
-    static const enum AVSampleFormat sample_fmts[] = {
-        AV_SAMPLE_FMT_DBL,
-        AV_SAMPLE_FMT_NONE
-    };
-    int ret;
-
-    layouts = ff_all_channel_counts();
-    if (!layouts)
-        return AVERROR(ENOMEM);
-    ret = ff_set_common_channel_layouts(ctx, layouts);
-    if (ret < 0)
-        return ret;
-
-    formats = ff_make_format_list(sample_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-    ret = ff_set_common_formats(ctx, formats);
-    if (ret < 0)
-        return ret;
-
-    formats = ff_all_samplerates();
-    if (!formats)
-        return AVERROR(ENOMEM);
-    return ff_set_common_samplerates(ctx, formats);
-}
-
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    AExciterContext *s = ctx->priv;
-
-    av_freep(&s->cp);
-}
-
-static int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    AExciterContext *s = ctx->priv;
-
-    if (!s->cp)
-        s->cp = av_calloc(inlink->channels, sizeof(*s->cp));
-    if (!s->cp)
-        return AVERROR(ENOMEM);
-
-    for (int i = 0; i < inlink->channels; i++)
-        set_params(&s->cp[i], s->blend, s->drive, inlink->sample_rate,
-                   s->freq, s->ceil);
-
-    return 0;
-}
-
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    AVFilterLink *inlink = ctx->inputs[0];
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_input(inlink);
-}
-
-static const AVFilterPad avfilter_af_aexciter_inputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_AUDIO,
-        .config_props = config_input,
-        .filter_frame = filter_frame,
-    },
-    { NULL }
-};
-
-static const AVFilterPad avfilter_af_aexciter_outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_AUDIO,
-    },
-    { NULL }
-};
-
-AVFilter ff_af_aexciter = {
-    .name          = "aexciter",
-    .description   = NULL_IF_CONFIG_SMALL("Enhance high frequency part of audio."),
-    .priv_size     = sizeof(AExciterContext),
-    .priv_class    = &aexciter_class,
-    .uninit        = uninit,
-    .query_formats = query_formats,
-    .inputs        = avfilter_af_aexciter_inputs,
-    .outputs       = avfilter_af_aexciter_outputs,
-    .process_command = process_command,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-};
diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
index 976b675..16e468b 100644
--- a/libavfilter/af_afade.c
+++ b/libavfilter/af_afade.c
@@ -249,10 +249,10 @@
     { "ss",           "set number of first sample to start fading",  OFFSET(start_sample), AV_OPT_TYPE_INT64,  {.i64 = 0    }, 0, INT64_MAX, TFLAGS },
     { "nb_samples",   "set number of samples for fade duration",     OFFSET(nb_samples),   AV_OPT_TYPE_INT64,  {.i64 = 44100}, 1, INT64_MAX, TFLAGS },
     { "ns",           "set number of samples for fade duration",     OFFSET(nb_samples),   AV_OPT_TYPE_INT64,  {.i64 = 44100}, 1, INT64_MAX, TFLAGS },
-    { "start_time",   "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, INT64_MAX, TFLAGS },
-    { "st",           "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, INT64_MAX, TFLAGS },
-    { "duration",     "set fade duration",                           OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, INT64_MAX, TFLAGS },
-    { "d",            "set fade duration",                           OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, INT64_MAX, TFLAGS },
+    { "start_time",   "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, TFLAGS },
+    { "st",           "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, TFLAGS },
+    { "duration",     "set fade duration",                           OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, TFLAGS },
+    { "d",            "set fade duration",                           OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, TFLAGS },
     { "curve",        "set fade curve type",                         OFFSET(curve),        AV_OPT_TYPE_INT,    {.i64 = TRI  }, NONE, NB_CURVES - 1, TFLAGS, "curve" },
     { "c",            "set fade curve type",                         OFFSET(curve),        AV_OPT_TYPE_INT,    {.i64 = TRI  }, NONE, NB_CURVES - 1, TFLAGS, "curve" },
     { "nofade",       "no fade; keep audio as-is",                   0,                    AV_OPT_TYPE_CONST,  {.i64 = NONE }, 0, 0, TFLAGS, "curve" },
@@ -385,8 +385,8 @@
 static const AVOption acrossfade_options[] = {
     { "nb_samples",   "set number of samples for cross fade duration", OFFSET(nb_samples),   AV_OPT_TYPE_INT,    {.i64 = 44100}, 1, INT32_MAX/10, FLAGS },
     { "ns",           "set number of samples for cross fade duration", OFFSET(nb_samples),   AV_OPT_TYPE_INT,    {.i64 = 44100}, 1, INT32_MAX/10, FLAGS },
-    { "duration",     "set cross fade duration",                       OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, 60000000, FLAGS },
-    { "d",            "set cross fade duration",                       OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, 60000000, FLAGS },
+    { "duration",     "set cross fade duration",                       OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, 60000000, FLAGS },
+    { "d",            "set cross fade duration",                       OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, 60000000, FLAGS },
     { "overlap",      "overlap 1st stream end with 2nd stream start",  OFFSET(overlap),      AV_OPT_TYPE_BOOL,   {.i64 = 1    }, 0,  1, FLAGS },
     { "o",            "overlap 1st stream end with 2nd stream start",  OFFSET(overlap),      AV_OPT_TYPE_BOOL,   {.i64 = 1    }, 0,  1, FLAGS },
     { "curve1",       "set fade curve type for 1st stream",            OFFSET(curve),        AV_OPT_TYPE_INT,    {.i64 = TRI  }, NONE, NB_CURVES - 1, FLAGS, "curve" },
diff --git a/libavfilter/af_afftfilt.c b/libavfilter/af_afftfilt.c
index 9b9001a..a6156bf 100644
--- a/libavfilter/af_afftfilt.c
+++ b/libavfilter/af_afftfilt.c
@@ -118,7 +118,7 @@
 static double imagf(void *priv, double x, double ch) { return getimag(priv, x, ch); }
 
 static const char *const func2_names[]    = { "real", "imag", NULL };
-static double (*const func2[])(void *, double, double) = {  realf,  imagf, NULL };
+double (*func2[])(void *, double, double) = {  realf,  imagf, NULL };
 
 static int config_input(AVFilterLink *inlink)
 {
diff --git a/libavfilter/af_afreqshift.c b/libavfilter/af_afreqshift.c
index 6141730..4cc4e27 100644
--- a/libavfilter/af_afreqshift.c
+++ b/libavfilter/af_afreqshift.c
@@ -34,8 +34,7 @@
     double shift;
     double level;
 
-    double cd[NB_COEFS];
-    float cf[NB_COEFS];
+    double c[NB_COEFS];
 
     int64_t in_samples;
 
@@ -43,8 +42,11 @@
     AVFrame *i2, *o2;
 
     void (*filter_channel)(AVFilterContext *ctx,
-                           int channel,
-                           AVFrame *in, AVFrame *out);
+                           int nb_samples,
+                           int sample_rate,
+                           const double *src, double *dst,
+                           double *i1, double *o1,
+                           double *i2, double *o2);
 } AFreqShift;
 
 static int query_formats(AVFilterContext *ctx)
@@ -52,7 +54,6 @@
     AVFilterFormats *formats = NULL;
     AVFilterChannelLayouts *layouts = NULL;
     static const enum AVSampleFormat sample_fmts[] = {
-        AV_SAMPLE_FMT_FLTP,
         AV_SAMPLE_FMT_DBLP,
         AV_SAMPLE_FMT_NONE
     };
@@ -77,105 +78,89 @@
     return ff_set_common_samplerates(ctx, formats);
 }
 
-#define PFILTER(name, type, sin, cos, cc)                     \
-static void pfilter_channel_## name(AVFilterContext *ctx,     \
-                            int ch,                           \
-                            AVFrame *in, AVFrame *out)        \
-{                                                             \
-    AFreqShift *s = ctx->priv;                                \
-    const int nb_samples = in->nb_samples;                    \
-    const type *src = (const type *)in->extended_data[ch];    \
-    type *dst = (type *)out->extended_data[ch];               \
-    type *i1 = (type *)s->i1->extended_data[ch];              \
-    type *o1 = (type *)s->o1->extended_data[ch];              \
-    type *i2 = (type *)s->i2->extended_data[ch];              \
-    type *o2 = (type *)s->o2->extended_data[ch];              \
-    const type *c = s->cc;                                    \
-    const type level = s->level;                              \
-    type shift = s->shift * M_PI;                             \
-    type cos_theta = cos(shift);                              \
-    type sin_theta = sin(shift);                              \
-                                                              \
-    for (int n = 0; n < nb_samples; n++) {                    \
-        type xn1 = src[n], xn2 = src[n];                      \
-        type I, Q;                                            \
-                                                              \
-        for (int j = 0; j < NB_COEFS / 2; j++) {              \
-            I = c[j] * (xn1 + o2[j]) - i2[j];                 \
-            i2[j] = i1[j];                                    \
-            i1[j] = xn1;                                      \
-            o2[j] = o1[j];                                    \
-            o1[j] = I;                                        \
-            xn1 = I;                                          \
-        }                                                     \
-                                                              \
-        for (int j = NB_COEFS / 2; j < NB_COEFS; j++) {       \
-            Q = c[j] * (xn2 + o2[j]) - i2[j];                 \
-            i2[j] = i1[j];                                    \
-            i1[j] = xn2;                                      \
-            o2[j] = o1[j];                                    \
-            o1[j] = Q;                                        \
-            xn2 = Q;                                          \
-        }                                                     \
-        Q = o2[NB_COEFS - 1];                                 \
-                                                              \
-        dst[n] = (I * cos_theta - Q * sin_theta) * level;     \
-    }                                                         \
+static void pfilter_channel(AVFilterContext *ctx,
+                            int nb_samples,
+                            int sample_rate,
+                            const double *src, double *dst,
+                            double *i1, double *o1,
+                            double *i2, double *o2)
+{
+    AFreqShift *s = ctx->priv;
+    const double *c = s->c;
+    const double level = s->level;
+    double shift = s->shift * M_PI;
+    double cos_theta = cos(shift);
+    double sin_theta = sin(shift);
+
+    for (int n = 0; n < nb_samples; n++) {
+        double xn1 = src[n], xn2 = src[n];
+        double I, Q;
+
+        for (int j = 0; j < NB_COEFS / 2; j++) {
+            I = c[j] * (xn1 + o2[j]) - i2[j];
+            i2[j] = i1[j];
+            i1[j] = xn1;
+            o2[j] = o1[j];
+            o1[j] = I;
+            xn1 = I;
+        }
+
+        for (int j = NB_COEFS / 2; j < NB_COEFS; j++) {
+            Q = c[j] * (xn2 + o2[j]) - i2[j];
+            i2[j] = i1[j];
+            i1[j] = xn2;
+            o2[j] = o1[j];
+            o1[j] = Q;
+            xn2 = Q;
+        }
+        Q = o2[NB_COEFS - 1];
+
+        dst[n] = (I * cos_theta - Q * sin_theta) * level;
+    }
 }
 
-PFILTER(flt, float, sin, cos, cf)
-PFILTER(dbl, double, sin, cos, cd)
+static void ffilter_channel(AVFilterContext *ctx,
+                            int nb_samples,
+                            int sample_rate,
+                            const double *src, double *dst,
+                            double *i1, double *o1,
+                            double *i2, double *o2)
+{
+    AFreqShift *s = ctx->priv;
+    const double *c = s->c;
+    const double level = s->level;
+    double ts = 1. / sample_rate;
+    double shift = s->shift;
+    int64_t N = s->in_samples;
 
-#define FFILTER(name, type, sin, cos, fmod, cc)               \
-static void ffilter_channel_## name(AVFilterContext *ctx,     \
-                            int ch,                           \
-                            AVFrame *in, AVFrame *out)        \
-{                                                             \
-    AFreqShift *s = ctx->priv;                                \
-    const int nb_samples = in->nb_samples;                    \
-    const type *src = (const type *)in->extended_data[ch];    \
-    type *dst = (type *)out->extended_data[ch];               \
-    type *i1 = (type *)s->i1->extended_data[ch];              \
-    type *o1 = (type *)s->o1->extended_data[ch];              \
-    type *i2 = (type *)s->i2->extended_data[ch];              \
-    type *o2 = (type *)s->o2->extended_data[ch];              \
-    const type *c = s->cc;                                    \
-    const type level = s->level;                              \
-    type ts = 1. / in->sample_rate;                           \
-    type shift = s->shift;                                    \
-    int64_t N = s->in_samples;                                \
-                                                              \
-    for (int n = 0; n < nb_samples; n++) {                    \
-        type xn1 = src[n], xn2 = src[n];                      \
-        type I, Q, theta;                                     \
-                                                              \
-        for (int j = 0; j < NB_COEFS / 2; j++) {              \
-            I = c[j] * (xn1 + o2[j]) - i2[j];                 \
-            i2[j] = i1[j];                                    \
-            i1[j] = xn1;                                      \
-            o2[j] = o1[j];                                    \
-            o1[j] = I;                                        \
-            xn1 = I;                                          \
-        }                                                     \
-                                                              \
-        for (int j = NB_COEFS / 2; j < NB_COEFS; j++) {       \
-            Q = c[j] * (xn2 + o2[j]) - i2[j];                 \
-            i2[j] = i1[j];                                    \
-            i1[j] = xn2;                                      \
-            o2[j] = o1[j];                                    \
-            o1[j] = Q;                                        \
-            xn2 = Q;                                          \
-        }                                                     \
-        Q = o2[NB_COEFS - 1];                                 \
-                                                              \
-        theta = 2. * M_PI * fmod(shift * (N + n) * ts, 1.);   \
-        dst[n] = (I * cos(theta) - Q * sin(theta)) * level;   \
-    }                                                         \
+    for (int n = 0; n < nb_samples; n++) {
+        double xn1 = src[n], xn2 = src[n];
+        double I, Q, theta;
+
+        for (int j = 0; j < NB_COEFS / 2; j++) {
+            I = c[j] * (xn1 + o2[j]) - i2[j];
+            i2[j] = i1[j];
+            i1[j] = xn1;
+            o2[j] = o1[j];
+            o1[j] = I;
+            xn1 = I;
+        }
+
+        for (int j = NB_COEFS / 2; j < NB_COEFS; j++) {
+            Q = c[j] * (xn2 + o2[j]) - i2[j];
+            i2[j] = i1[j];
+            i1[j] = xn2;
+            o2[j] = o1[j];
+            o1[j] = Q;
+            xn2 = Q;
+        }
+        Q = o2[NB_COEFS - 1];
+
+        theta = 2. * M_PI * fmod(shift * (N + n) * ts, 1.);
+        dst[n] = (I * cos(theta) - Q * sin(theta)) * level;
+    }
 }
 
-FFILTER(flt, float, sinf, cosf, fmodf, cf)
-FFILTER(dbl, double, sin, cos, fmod, cd)
-
 static void compute_transition_param(double *K, double *Q, double transition)
 {
     double kksqrt, e, e2, e4, k, q;
@@ -258,19 +243,15 @@
     return coef;
 }
 
-static void compute_coefs(double *coef_arrd, float *coef_arrf, int nbr_coefs, double transition)
+static void compute_coefs(double *coef_arr, int nbr_coefs, double transition)
 {
     const int order = nbr_coefs * 2 + 1;
     double k, q;
 
     compute_transition_param(&k, &q, transition);
 
-    for (int n = 0; n < nbr_coefs; n++) {
-        const int idx = (n / 2) + (n & 1) * nbr_coefs / 2;
-
-        coef_arrd[idx] = compute_coef(n, k, q, order);
-        coef_arrf[idx] = coef_arrd[idx];
-    }
+    for (int n = 0; n < nbr_coefs; n++)
+        coef_arr[(n / 2) + (n & 1) * nbr_coefs / 2] = compute_coef(n, k, q, order);
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -278,7 +259,7 @@
     AVFilterContext *ctx = inlink->dst;
     AFreqShift *s = ctx->priv;
 
-    compute_coefs(s->cd, s->cf, NB_COEFS, 2. * 20. / inlink->sample_rate);
+    compute_coefs(s->c, NB_COEFS, 2. * 20. / inlink->sample_rate);
 
     s->i1 = ff_get_audio_buffer(inlink, NB_COEFS);
     s->o1 = ff_get_audio_buffer(inlink, NB_COEFS);
@@ -287,17 +268,10 @@
     if (!s->i1 || !s->o1 || !s->i2 || !s->o2)
         return AVERROR(ENOMEM);
 
-    if (inlink->format == AV_SAMPLE_FMT_DBLP) {
-        if (!strcmp(ctx->filter->name, "afreqshift"))
-            s->filter_channel = ffilter_channel_dbl;
-        else
-            s->filter_channel = pfilter_channel_dbl;
-    } else {
-        if (!strcmp(ctx->filter->name, "afreqshift"))
-            s->filter_channel = ffilter_channel_flt;
-        else
-            s->filter_channel = pfilter_channel_flt;
-    }
+    if (!strcmp(ctx->filter->name, "afreqshift"))
+        s->filter_channel = ffilter_channel;
+    else
+        s->filter_channel = pfilter_channel;
 
     return 0;
 }
@@ -315,8 +289,16 @@
     const int start = (in->channels * jobnr) / nb_jobs;
     const int end = (in->channels * (jobnr+1)) / nb_jobs;
 
-    for (int ch = start; ch < end; ch++)
-        s->filter_channel(ctx, ch, in, out);
+    for (int ch = start; ch < end; ch++) {
+        s->filter_channel(ctx, in->nb_samples,
+                          in->sample_rate,
+                          (const double *)in->extended_data[ch],
+                          (double *)out->extended_data[ch],
+                          (double *)s->i1->extended_data[ch],
+                          (double *)s->o1->extended_data[ch],
+                          (double *)s->i2->extended_data[ch],
+                          (double *)s->o2->extended_data[ch]);
+    }
 
     return 0;
 }
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 0f4129c..59d2232 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -453,7 +453,7 @@
     return 0;
 }
 
-static const char *const format[] = { "%lf", "%lf %lfi", "%lf %lfr", "%lf %lfd", "%lf %lfi" };
+static const char *format[] = { "%lf", "%lf %lfi", "%lf %lfr", "%lf %lfd", "%lf %lfi" };
 
 static int read_channels(AVFilterContext *ctx, int channels, uint8_t *item_str, int ab)
 {
@@ -966,7 +966,7 @@
         for (int k = FFMAX(n - N + i, 0); k <= FFMIN(i, n); k++) {
             acc += ((fact(i) * fact(N - i)) /
                     (fact(k) * fact(i - k) * fact(n - k) * fact(N - i - n + k))) *
-                   ((k & 1) ? -1. : 1.);
+                   ((k & 1) ? -1. : 1.);;
         }
 
         z += a[i] * pow(2., i) * acc;
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 45a5dad..c4d8916 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -164,7 +164,6 @@
     int duration_mode;          /**< mode for determining duration */
     float dropout_transition;   /**< transition time when an input drops out */
     char *weights_str;          /**< string for custom weights for every input */
-    int normalize;              /**< if inputs are scaled */
 
     int nb_channels;            /**< number of channels */
     int sample_rate;            /**< sample rate */
@@ -196,8 +195,6 @@
             OFFSET(dropout_transition), AV_OPT_TYPE_FLOAT, { .dbl = 2.0 }, 0, INT_MAX, A|F },
     { "weights", "Set weight for each input.",
             OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, A|F|T },
-    { "normalize", "Scale inputs",
-            OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, A|F|T },
     { NULL }
 };
 
@@ -230,14 +227,10 @@
     }
 
     for (i = 0; i < s->nb_inputs; i++) {
-        if (s->input_state[i] & INPUT_ON) {
-            if (!s->normalize)
-                s->input_scale[i] = FFABS(s->weights[i]);
-            else
-                s->input_scale[i] = 1.0f / s->scale_norm[i] * FFSIGN(s->weights[i]);
-        } else {
+        if (s->input_state[i] & INPUT_ON)
+            s->input_scale[i] = 1.0f / s->scale_norm[i] * FFSIGN(s->weights[i]);
+        else
             s->input_scale[i] = 0.0f;
-        }
     }
 }
 
diff --git a/libavfilter/af_arnndn.c b/libavfilter/af_arnndn.c
index 049865b..4551ce2 100644
--- a/libavfilter/af_arnndn.c
+++ b/libavfilter/af_arnndn.c
@@ -36,7 +36,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/tx.h"
 #include "avfilter.h"
@@ -129,7 +128,7 @@
     float mem_hp_x[2];
     float lastg[NB_BANDS];
     float history[FRAME_SIZE];
-    RNNState rnn[2];
+    RNNState rnn;
     AVTXContext *tx, *txi;
     av_tx_fn tx_fn, txi_fn;
 } DenoiseState;
@@ -146,7 +145,7 @@
     DECLARE_ALIGNED(32, float, window)[WINDOW_SIZE];
     DECLARE_ALIGNED(32, float, dct_table)[FFALIGN(NB_BANDS, 4)][FFALIGN(NB_BANDS, 4)];
 
-    RNNModel *model[2];
+    RNNModel *model;
 
     AVFloatDSPContext *fdsp;
 } AudioRNNContext;
@@ -185,9 +184,9 @@
     av_free(model);
 }
 
-static int rnnoise_model_from_file(FILE *f, RNNModel **rnn)
+static RNNModel *rnnoise_model_from_file(FILE *f)
 {
-    RNNModel *ret = NULL;
+    RNNModel *ret;
     DenseLayer *input_dense;
     GRULayer *vad_gru;
     GRULayer *noise_gru;
@@ -197,17 +196,17 @@
     int in;
 
     if (fscanf(f, "rnnoise-nu model file version %d\n", &in) != 1 || in != 1)
-        return AVERROR_INVALIDDATA;
+        return NULL;
 
     ret = av_calloc(1, sizeof(RNNModel));
     if (!ret)
-        return AVERROR(ENOMEM);
+        return NULL;
 
 #define ALLOC_LAYER(type, name) \
     name = av_calloc(1, sizeof(type)); \
     if (!name) { \
         rnnoise_model_free(ret); \
-        return AVERROR(ENOMEM); \
+        return NULL; \
     } \
     ret->name = name
 
@@ -221,7 +220,7 @@
 #define INPUT_VAL(name) do { \
     if (fscanf(f, "%d", &in) != 1 || in < 0 || in > 128) { \
         rnnoise_model_free(ret); \
-        return AVERROR(EINVAL); \
+        return NULL; \
     } \
     name = in; \
     } while (0)
@@ -245,13 +244,13 @@
     float *values = av_calloc((len), sizeof(float)); \
     if (!values) { \
         rnnoise_model_free(ret); \
-        return AVERROR(ENOMEM); \
+        return NULL; \
     } \
     name = values; \
     for (int i = 0; i < (len); i++) { \
         if (fscanf(f, "%d", &in) != 1) { \
             rnnoise_model_free(ret); \
-            return AVERROR(EINVAL); \
+            return NULL; \
         } \
         values[i] = in; \
     } \
@@ -261,7 +260,7 @@
     float *values = av_calloc(FFALIGN((len0), 4) * FFALIGN((len1), 4) * (len2), sizeof(float)); \
     if (!values) { \
         rnnoise_model_free(ret); \
-        return AVERROR(ENOMEM); \
+        return NULL; \
     } \
     name = values; \
     for (int k = 0; k < (len0); k++) { \
@@ -269,7 +268,7 @@
             for (int j = 0; j < (len1); j++) { \
                 if (fscanf(f, "%d", &in) != 1) { \
                     rnnoise_model_free(ret); \
-                    return AVERROR(EINVAL); \
+                    return NULL; \
                 } \
                 values[j * (len2) * FFALIGN((len0), 4) + i * FFALIGN((len0), 4) + k] = in; \
             } \
@@ -277,24 +276,13 @@
     } \
     } while (0)
 
-#define NEW_LINE() do { \
-    int c; \
-    while ((c = fgetc(f)) != EOF) { \
-        if (c == '\n') \
-        break; \
-    } \
-    } while (0)
-
 #define INPUT_DENSE(name) do { \
     INPUT_VAL(name->nb_inputs); \
     INPUT_VAL(name->nb_neurons); \
     ret->name ## _size = name->nb_neurons; \
     INPUT_ACTIVATION(name->activation); \
-    NEW_LINE(); \
     INPUT_ARRAY(name->input_weights, name->nb_inputs * name->nb_neurons); \
-    NEW_LINE(); \
     INPUT_ARRAY(name->bias, name->nb_neurons); \
-    NEW_LINE(); \
     } while (0)
 
 #define INPUT_GRU(name) do { \
@@ -302,13 +290,9 @@
     INPUT_VAL(name->nb_neurons); \
     ret->name ## _size = name->nb_neurons; \
     INPUT_ACTIVATION(name->activation); \
-    NEW_LINE(); \
     INPUT_ARRAY3(name->input_weights, name->nb_inputs, name->nb_neurons, 3); \
-    NEW_LINE(); \
     INPUT_ARRAY3(name->recurrent_weights, name->nb_neurons, name->nb_neurons, 3); \
-    NEW_LINE(); \
     INPUT_ARRAY(name->bias, name->nb_neurons * 3); \
-    NEW_LINE(); \
     } while (0)
 
     INPUT_DENSE(input_dense);
@@ -320,12 +304,10 @@
 
     if (vad_output->nb_neurons != 1) {
         rnnoise_model_free(ret);
-        return AVERROR(EINVAL);
+        return NULL;
     }
 
-    *rnn = ret;
-
-    return 0;
+    return ret;
 }
 
 static int query_formats(AVFilterContext *ctx)
@@ -367,34 +349,27 @@
 
     s->channels = inlink->channels;
 
-    if (!s->st)
-        s->st = av_calloc(s->channels, sizeof(DenoiseState));
+    s->st = av_calloc(s->channels, sizeof(DenoiseState));
     if (!s->st)
         return AVERROR(ENOMEM);
 
     for (int i = 0; i < s->channels; i++) {
         DenoiseState *st = &s->st[i];
 
-        st->rnn[0].model = s->model[0];
-        st->rnn[0].vad_gru_state = av_calloc(sizeof(float), FFALIGN(s->model[0]->vad_gru_size, 16));
-        st->rnn[0].noise_gru_state = av_calloc(sizeof(float), FFALIGN(s->model[0]->noise_gru_size, 16));
-        st->rnn[0].denoise_gru_state = av_calloc(sizeof(float), FFALIGN(s->model[0]->denoise_gru_size, 16));
-        if (!st->rnn[0].vad_gru_state ||
-            !st->rnn[0].noise_gru_state ||
-            !st->rnn[0].denoise_gru_state)
+        st->rnn.model = s->model;
+        st->rnn.vad_gru_state = av_calloc(sizeof(float), FFALIGN(s->model->vad_gru_size, 16));
+        st->rnn.noise_gru_state = av_calloc(sizeof(float), FFALIGN(s->model->noise_gru_size, 16));
+        st->rnn.denoise_gru_state = av_calloc(sizeof(float), FFALIGN(s->model->denoise_gru_size, 16));
+        if (!st->rnn.vad_gru_state ||
+            !st->rnn.noise_gru_state ||
+            !st->rnn.denoise_gru_state)
             return AVERROR(ENOMEM);
-    }
 
-    for (int i = 0; i < s->channels; i++) {
-        DenoiseState *st = &s->st[i];
-
-        if (!st->tx)
-            ret = av_tx_init(&st->tx, &st->tx_fn, AV_TX_FLOAT_FFT, 0, WINDOW_SIZE, NULL, 0);
+        ret = av_tx_init(&st->tx, &st->tx_fn, AV_TX_FLOAT_FFT, 0, WINDOW_SIZE, NULL, 0);
         if (ret < 0)
             return ret;
 
-        if (!st->txi)
-            ret = av_tx_init(&st->txi, &st->txi_fn, AV_TX_FLOAT_FFT, 1, WINDOW_SIZE, NULL, 0);
+        ret = av_tx_init(&st->txi, &st->txi_fn, AV_TX_FLOAT_FFT, 1, WINDOW_SIZE, NULL, 0);
         if (ret < 0)
             return ret;
     }
@@ -1392,7 +1367,7 @@
     silence = compute_frame_features(s, st, X, P, Ex, Ep, Exp, features, x);
 
     if (!silence && !disabled) {
-        compute_rnn(s, &st->rnn[0], g, &vad_prob, features);
+        compute_rnn(s, &st->rnn, g, &vad_prob, features);
         pitch_filter(X, P, Ex, Ep, Exp, g);
         for (int i = 0; i < NB_BANDS; i++) {
             float alpha = .6f;
@@ -1482,40 +1457,25 @@
     return FFERROR_NOT_READY;
 }
 
-static int open_model(AVFilterContext *ctx, RNNModel **model)
-{
-    AudioRNNContext *s = ctx->priv;
-    int ret;
-    FILE *f;
-
-    if (!s->model_name)
-        return AVERROR(EINVAL);
-    f = av_fopen_utf8(s->model_name, "r");
-    if (!f) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to open model file: %s\n", s->model_name);
-        return AVERROR(EINVAL);
-    }
-
-    ret = rnnoise_model_from_file(f, model);
-    fclose(f);
-    if (!*model || ret < 0)
-        return ret;
-
-    return 0;
-}
-
 static av_cold int init(AVFilterContext *ctx)
 {
     AudioRNNContext *s = ctx->priv;
-    int ret;
+    FILE *f;
 
     s->fdsp = avpriv_float_dsp_alloc(0);
     if (!s->fdsp)
         return AVERROR(ENOMEM);
 
-    ret = open_model(ctx, &s->model[0]);
-    if (ret < 0)
-        return ret;
+    if (!s->model_name)
+        return AVERROR(EINVAL);
+    f = av_fopen_utf8(s->model_name, "r");
+    if (!f)
+        return AVERROR(EINVAL);
+
+    s->model = rnnoise_model_from_file(f);
+    fclose(f);
+    if (!s->model)
+        return AVERROR(EINVAL);
 
     for (int i = 0; i < FRAME_SIZE; i++) {
         s->window[i] = sin(.5*M_PI*sin(.5*M_PI*(i+.5)/FRAME_SIZE) * sin(.5*M_PI*(i+.5)/FRAME_SIZE));
@@ -1533,59 +1493,22 @@
     return 0;
 }
 
-static void free_model(AVFilterContext *ctx, int n)
-{
-    AudioRNNContext *s = ctx->priv;
-
-    rnnoise_model_free(s->model[n]);
-    s->model[n] = NULL;
-
-    for (int ch = 0; ch < s->channels && s->st; ch++) {
-        av_freep(&s->st[ch].rnn[n].vad_gru_state);
-        av_freep(&s->st[ch].rnn[n].noise_gru_state);
-        av_freep(&s->st[ch].rnn[n].denoise_gru_state);
-    }
-}
-
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    AudioRNNContext *s = ctx->priv;
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    ret = open_model(ctx, &s->model[1]);
-    if (ret < 0)
-        return ret;
-
-    FFSWAP(RNNModel *, s->model[0], s->model[1]);
-    for (int ch = 0; ch < s->channels; ch++)
-        FFSWAP(RNNState, s->st[ch].rnn[0], s->st[ch].rnn[1]);
-
-    ret = config_input(ctx->inputs[0]);
-    if (ret < 0) {
-        for (int ch = 0; ch < s->channels; ch++)
-            FFSWAP(RNNState, s->st[ch].rnn[0], s->st[ch].rnn[1]);
-        FFSWAP(RNNModel *, s->model[0], s->model[1]);
-        return ret;
-    }
-
-    free_model(ctx, 1);
-    return 0;
-}
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
     AudioRNNContext *s = ctx->priv;
 
     av_freep(&s->fdsp);
-    free_model(ctx, 0);
-    for (int ch = 0; ch < s->channels && s->st; ch++) {
-        av_tx_uninit(&s->st[ch].tx);
-        av_tx_uninit(&s->st[ch].txi);
+    rnnoise_model_free(s->model);
+    s->model = NULL;
+
+    if (s->st) {
+        for (int ch = 0; ch < s->channels; ch++) {
+            av_freep(&s->st[ch].rnn.vad_gru_state);
+            av_freep(&s->st[ch].rnn.noise_gru_state);
+            av_freep(&s->st[ch].rnn.denoise_gru_state);
+            av_tx_uninit(&s->st[ch].tx);
+            av_tx_uninit(&s->st[ch].txi);
+        }
     }
     av_freep(&s->st);
 }
@@ -1608,7 +1531,7 @@
 };
 
 #define OFFSET(x) offsetof(AudioRNNContext, x)
-#define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption arnndn_options[] = {
     { "model", "set model name", OFFSET(model_name), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, AF },
@@ -1632,5 +1555,4 @@
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
                      AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c
index 4900cb6..aaae3c6 100644
--- a/libavfilter/af_asoftclip.c
+++ b/libavfilter/af_asoftclip.c
@@ -45,8 +45,6 @@
     int type;
     int oversample;
     int64_t delay;
-    double threshold;
-    double output;
     double param;
 
     SwrContext *up_ctx;
@@ -73,8 +71,6 @@
     { "quintic",             NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_QUINTIC},0,          0, A, "types" },
     { "sin",                 NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_SIN},    0,          0, A, "types" },
     { "erf",                 NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_ERF},    0,          0, A, "types" },
-    { "threshold", "set softclip threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 1, A },
-    { "output", "set softclip output gain", OFFSET(output), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 16, A },
     { "param", "set softclip parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01,        3, A },
     { "oversample", "set oversample factor", OFFSET(oversample), AV_OPT_TYPE_INT, {.i64=1}, 1, 32, F },
     { NULL }
@@ -112,14 +108,13 @@
     return ff_set_common_samplerates(ctx, formats);
 }
 
+#define SQR(x) ((x) * (x))
+
 static void filter_flt(ASoftClipContext *s,
                        void **dptr, const void **sptr,
                        int nb_samples, int channels,
                        int start, int end)
 {
-    float threshold = s->threshold;
-    float gain = s->output * threshold;
-    float factor = 1.f / threshold;
     float param = s->param;
 
     for (int c = start; c < end; c++) {
@@ -129,73 +124,53 @@
         switch (s->type) {
         case ASC_HARD:
             for (int n = 0; n < nb_samples; n++) {
-                dst[n] = av_clipf(src[n] * factor, -1.f, 1.f);
-                dst[n] *= gain;
+                dst[n] = av_clipf(src[n], -1.f, 1.f);
             }
             break;
         case ASC_TANH:
             for (int n = 0; n < nb_samples; n++) {
-                dst[n] = tanhf(src[n] * factor * param);
-                dst[n] *= gain;
+                dst[n] = tanhf(src[n] * param);
             }
             break;
         case ASC_ATAN:
-            for (int n = 0; n < nb_samples; n++) {
-                dst[n] = 2.f / M_PI * atanf(src[n] * factor * param);
-                dst[n] *= gain;
-            }
+            for (int n = 0; n < nb_samples; n++)
+                dst[n] = 2.f / M_PI * atanf(src[n] * param);
             break;
         case ASC_CUBIC:
             for (int n = 0; n < nb_samples; n++) {
-                float sample = src[n] * factor;
-
-                if (FFABS(sample) >= 1.5f)
-                    dst[n] = FFSIGN(sample);
+                if (FFABS(src[n]) >= 1.5f)
+                    dst[n] = FFSIGN(src[n]);
                 else
-                    dst[n] = sample - 0.1481f * powf(sample, 3.f);
-                dst[n] *= gain;
+                    dst[n] = src[n] - 0.1481f * powf(src[n], 3.f);
             }
             break;
         case ASC_EXP:
-            for (int n = 0; n < nb_samples; n++) {
-                dst[n] = 2.f / (1.f + expf(-2.f * src[n] * factor)) - 1.;
-                dst[n] *= gain;
-            }
+            for (int n = 0; n < nb_samples; n++)
+                dst[n] = 2.f / (1.f + expf(-2.f * src[n])) - 1.;
             break;
         case ASC_ALG:
-            for (int n = 0; n < nb_samples; n++) {
-                float sample = src[n] * factor;
-
-                dst[n] = sample / (sqrtf(param + sample * sample));
-                dst[n] *= gain;
-            }
+            for (int n = 0; n < nb_samples; n++)
+                dst[n] = src[n] / (sqrtf(param + src[n] * src[n]));
             break;
         case ASC_QUINTIC:
             for (int n = 0; n < nb_samples; n++) {
-                float sample = src[n] * factor;
-
-                if (FFABS(sample) >= 1.25)
-                    dst[n] = FFSIGN(sample);
+                if (FFABS(src[n]) >= 1.25)
+                    dst[n] = FFSIGN(src[n]);
                 else
-                    dst[n] = sample - 0.08192f * powf(sample, 5.f);
-                dst[n] *= gain;
+                    dst[n] = src[n] - 0.08192f * powf(src[n], 5.f);
             }
             break;
         case ASC_SIN:
             for (int n = 0; n < nb_samples; n++) {
-                float sample = src[n] * factor;
-
-                if (FFABS(sample) >= M_PI_2)
-                    dst[n] = FFSIGN(sample);
+                if (FFABS(src[n]) >= M_PI_2)
+                    dst[n] = FFSIGN(src[n]);
                 else
-                    dst[n] = sinf(sample);
-                dst[n] *= gain;
+                    dst[n] = sinf(src[n]);
             }
             break;
         case ASC_ERF:
             for (int n = 0; n < nb_samples; n++) {
-                dst[n] = erff(src[n] * factor);
-                dst[n] *= gain;
+                dst[n] = erff(src[n]);
             }
             break;
         default:
@@ -209,9 +184,6 @@
                        int nb_samples, int channels,
                        int start, int end)
 {
-    double threshold = s->threshold;
-    double gain = s->output * threshold;
-    double factor = 1. / threshold;
     double param = s->param;
 
     for (int c = start; c < end; c++) {
@@ -221,73 +193,53 @@
         switch (s->type) {
         case ASC_HARD:
             for (int n = 0; n < nb_samples; n++) {
-                dst[n] = av_clipd(src[n] * factor, -1., 1.);
-                dst[n] *= gain;
+                dst[n] = av_clipd(src[n], -1., 1.);
             }
             break;
         case ASC_TANH:
             for (int n = 0; n < nb_samples; n++) {
-                dst[n] = tanh(src[n] * factor * param);
-                dst[n] *= gain;
+                dst[n] = tanh(src[n] * param);
             }
             break;
         case ASC_ATAN:
-            for (int n = 0; n < nb_samples; n++) {
-                dst[n] = 2. / M_PI * atan(src[n] * factor * param);
-                dst[n] *= gain;
-            }
+            for (int n = 0; n < nb_samples; n++)
+                dst[n] = 2. / M_PI * atan(src[n] * param);
             break;
         case ASC_CUBIC:
             for (int n = 0; n < nb_samples; n++) {
-                double sample = src[n] * factor;
-
-                if (FFABS(sample) >= 1.5)
-                    dst[n] = FFSIGN(sample);
+                if (FFABS(src[n]) >= 1.5)
+                    dst[n] = FFSIGN(src[n]);
                 else
-                    dst[n] = sample - 0.1481 * pow(sample, 3.);
-                dst[n] *= gain;
+                    dst[n] = src[n] - 0.1481 * pow(src[n], 3.);
             }
             break;
         case ASC_EXP:
-            for (int n = 0; n < nb_samples; n++) {
-                dst[n] = 2. / (1. + exp(-2. * src[n] * factor)) - 1.;
-                dst[n] *= gain;
-            }
+            for (int n = 0; n < nb_samples; n++)
+                dst[n] = 2. / (1. + exp(-2. * src[n])) - 1.;
             break;
         case ASC_ALG:
-            for (int n = 0; n < nb_samples; n++) {
-                double sample = src[n] * factor;
-
-                dst[n] = sample / (sqrt(param + sample * sample));
-                dst[n] *= gain;
-            }
+            for (int n = 0; n < nb_samples; n++)
+                dst[n] = src[n] / (sqrt(param + src[n] * src[n]));
             break;
         case ASC_QUINTIC:
             for (int n = 0; n < nb_samples; n++) {
-                double sample = src[n] * factor;
-
-                if (FFABS(sample) >= 1.25)
-                    dst[n] = FFSIGN(sample);
+                if (FFABS(src[n]) >= 1.25)
+                    dst[n] = FFSIGN(src[n]);
                 else
-                    dst[n] = sample - 0.08192 * pow(sample, 5.);
-                dst[n] *= gain;
+                    dst[n] = src[n] - 0.08192 * pow(src[n], 5.);
             }
             break;
         case ASC_SIN:
             for (int n = 0; n < nb_samples; n++) {
-                double sample = src[n] * factor;
-
-                if (FFABS(sample) >= M_PI_2)
-                    dst[n] = FFSIGN(sample);
+                if (FFABS(src[n]) >= M_PI_2)
+                    dst[n] = FFSIGN(src[n]);
                 else
-                    dst[n] = sin(sample);
-                dst[n] *= gain;
+                    dst[n] = sin(src[n]);
             }
             break;
         case ASC_ERF:
             for (int n = 0; n < nb_samples; n++) {
-                dst[n] = erf(src[n] * factor);
-                dst[n] *= gain;
+                dst[n] = erf(src[n]);
             }
             break;
         default:
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index f50cbe1..2703638 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -329,11 +329,11 @@
 
     drop = p->win_samples[p->win_pos];
     p->win_samples[p->win_pos] = nd;
-    index = av_clip(lrint(av_clipd(FFABS(nd), 0.0, 1.0) * HISTOGRAM_MAX), 0, HISTOGRAM_MAX);
+    index = av_clip(FFABS(nd) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX);
     p->max_index = FFMAX(p->max_index, index);
     p->histogram[index]++;
     if (!isnan(p->noise_floor))
-        p->histogram[av_clip(lrint(av_clipd(FFABS(drop), 0.0, 1.0) * HISTOGRAM_MAX), 0, HISTOGRAM_MAX)]--;
+        p->histogram[av_clip(FFABS(drop) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX)]--;
     p->win_pos++;
 
     while (p->histogram[p->max_index] == 0)
diff --git a/libavfilter/af_asupercut.c b/libavfilter/af_asupercut.c
index d5c9a75..89f4cf0 100644
--- a/libavfilter/af_asupercut.c
+++ b/libavfilter/af_asupercut.c
@@ -405,7 +405,7 @@
                        AVFILTER_FLAG_SLICE_THREADS,
 };
 
-static const AVOption asuperpass_asuperstop_options[] = {
+static const AVOption asuperpass_options[] = {
     { "centerf","set center frequency", OFFSET(cutoff), AV_OPT_TYPE_DOUBLE, {.dbl=1000}, 2, 999999, FLAGS },
     { "order",  "set filter order",     OFFSET(order),  AV_OPT_TYPE_INT,    {.i64=4},    4,     20, FLAGS },
     { "qfactor","set Q-factor",         OFFSET(qfactor),AV_OPT_TYPE_DOUBLE, {.dbl=1.},0.01,   100., FLAGS },
@@ -413,7 +413,6 @@
     { NULL }
 };
 
-#define asuperpass_options asuperpass_asuperstop_options
 AVFILTER_DEFINE_CLASS(asuperpass);
 
 AVFilter ff_af_asuperpass = {
@@ -430,7 +429,14 @@
                        AVFILTER_FLAG_SLICE_THREADS,
 };
 
-#define asuperstop_options asuperpass_asuperstop_options
+static const AVOption asuperstop_options[] = {
+    { "centerf","set center frequency", OFFSET(cutoff), AV_OPT_TYPE_DOUBLE, {.dbl=1000}, 2, 999999, FLAGS },
+    { "order",  "set filter order",     OFFSET(order),  AV_OPT_TYPE_INT,    {.i64=4},    4,     20, FLAGS },
+    { "qfactor","set Q-factor",         OFFSET(qfactor),AV_OPT_TYPE_DOUBLE, {.dbl=1.},0.01,   100., FLAGS },
+    { "level",  "set input level",      OFFSET(level),  AV_OPT_TYPE_DOUBLE, {.dbl=1.},   0.,    2., FLAGS },
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(asuperstop);
 
 AVFilter ff_af_asuperstop = {
diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index 4a09f82..edefe15 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -514,54 +514,22 @@
     case bass:
         beta = sqrt((A * A + 1) - (A - 1) * (A - 1));
     case lowshelf:
-        if (s->poles == 1) {
-            double A = ff_exp10(s->gain / 20);
-            double ro = -sin(w0 / 2. - M_PI_4) / sin(w0 / 2. + M_PI_4);
-            double n = (A + 1) / (A - 1);
-            double alpha1 = A == 1. ? 0. : n - FFSIGN(n) * sqrt(n * n - 1);
-            double beta0 = ((1 + A) + (1 - A) * alpha1) * 0.5;
-            double beta1 = ((1 - A) + (1 + A) * alpha1) * 0.5;
-
-            s->a0 = 1 + ro * alpha1;
-            s->a1 = -ro - alpha1;
-            s->a2 = 0;
-            s->b0 = beta0 + ro * beta1;
-            s->b1 = -beta1 - ro * beta0;
-            s->b2 = 0;
-        } else {
-            s->a0 =          (A + 1) + (A - 1) * cos(w0) + beta * alpha;
-            s->a1 =    -2 * ((A - 1) + (A + 1) * cos(w0));
-            s->a2 =          (A + 1) + (A - 1) * cos(w0) - beta * alpha;
-            s->b0 =     A * ((A + 1) - (A - 1) * cos(w0) + beta * alpha);
-            s->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
-            s->b2 =     A * ((A + 1) - (A - 1) * cos(w0) - beta * alpha);
-        }
+        s->a0 =          (A + 1) + (A - 1) * cos(w0) + beta * alpha;
+        s->a1 =    -2 * ((A - 1) + (A + 1) * cos(w0));
+        s->a2 =          (A + 1) + (A - 1) * cos(w0) - beta * alpha;
+        s->b0 =     A * ((A + 1) - (A - 1) * cos(w0) + beta * alpha);
+        s->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
+        s->b2 =     A * ((A + 1) - (A - 1) * cos(w0) - beta * alpha);
         break;
     case treble:
         beta = sqrt((A * A + 1) - (A - 1) * (A - 1));
     case highshelf:
-        if (s->poles == 1) {
-            double A = ff_exp10(s->gain / 20);
-            double ro = sin(w0 / 2. - M_PI_4) / sin(w0 / 2. + M_PI_4);
-            double n = (A + 1) / (A - 1);
-            double alpha1 = A == 1. ? 0. : n - FFSIGN(n) * sqrt(n * n - 1);
-            double beta0 = ((1 + A) + (1 - A) * alpha1) * 0.5;
-            double beta1 = ((1 - A) + (1 + A) * alpha1) * 0.5;
-
-            s->a0 = 1 + ro * alpha1;
-            s->a1 = ro + alpha1;
-            s->a2 = 0;
-            s->b0 = beta0 + ro * beta1;
-            s->b1 = beta1 + ro * beta0;
-            s->b2 = 0;
-        } else {
-            s->a0 =          (A + 1) - (A - 1) * cos(w0) + beta * alpha;
-            s->a1 =     2 * ((A - 1) - (A + 1) * cos(w0));
-            s->a2 =          (A + 1) - (A - 1) * cos(w0) - beta * alpha;
-            s->b0 =     A * ((A + 1) + (A - 1) * cos(w0) + beta * alpha);
-            s->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
-            s->b2 =     A * ((A + 1) + (A - 1) * cos(w0) - beta * alpha);
-        }
+        s->a0 =          (A + 1) - (A - 1) * cos(w0) + beta * alpha;
+        s->a1 =     2 * ((A - 1) - (A + 1) * cos(w0));
+        s->a2 =          (A + 1) - (A - 1) * cos(w0) - beta * alpha;
+        s->b0 =     A * ((A + 1) + (A - 1) * cos(w0) + beta * alpha);
+        s->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
+        s->b2 =     A * ((A + 1) + (A - 1) * cos(w0) - beta * alpha);
         break;
     case bandpass:
         if (s->csg) {
@@ -873,6 +841,7 @@
 static av_cold int name_##_init(AVFilterContext *ctx)                   \
 {                                                                       \
     BiquadsContext *s = ctx->priv;                                      \
+    s->class = &name_##_class;                                          \
     s->filter_type = name_;                                             \
     return 0;                                                           \
 }                                                                       \
@@ -930,8 +899,8 @@
 
 DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter.");
 #endif  /* CONFIG_EQUALIZER_FILTER */
-#if CONFIG_BASS_FILTER || CONFIG_LOWSHELF_FILTER
-static const AVOption bass_lowshelf_options[] = {
+#if CONFIG_BASS_FILTER
+static const AVOption bass_options[] = {
     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
@@ -945,8 +914,6 @@
     {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
-    {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
-    {"p",     "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
@@ -969,18 +936,10 @@
     {NULL}
 };
 
-#if CONFIG_BASS_FILTER
-#define bass_options bass_lowshelf_options
 DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies.");
 #endif  /* CONFIG_BASS_FILTER */
-
-#if CONFIG_LOWSHELF_FILTER
-#define lowshelf_options bass_lowshelf_options
-DEFINE_BIQUAD_FILTER(lowshelf, "Apply a low shelf filter.");
-#endif  /* CONFIG_LOWSHELF_FILTER */
-#endif  /* CONFIG_BASS_FILTER || CONFIG LOWSHELF_FILTER */
-#if CONFIG_TREBLE_FILTER || CONFIG_HIGHSHELF_FILTER
-static const AVOption treble_highshelf_options[] = {
+#if CONFIG_TREBLE_FILTER
+static const AVOption treble_options[] = {
     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
@@ -994,8 +953,6 @@
     {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
-    {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
-    {"p",     "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
@@ -1018,16 +975,8 @@
     {NULL}
 };
 
-#if CONFIG_TREBLE_FILTER
-#define treble_options treble_highshelf_options
 DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies.");
 #endif  /* CONFIG_TREBLE_FILTER */
-
-#if CONFIG_HIGHSHELF_FILTER
-#define highshelf_options treble_highshelf_options
-DEFINE_BIQUAD_FILTER(highshelf, "Apply a high shelf filter.");
-#endif  /* CONFIG_HIGHSHELF_FILTER */
-#endif  /* CONFIG_TREBLE_FILTER || CONFIG_HIGHSHELF_FILTER */
 #if CONFIG_BANDPASS_FILTER
 static const AVOption bandpass_options[] = {
     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
@@ -1220,6 +1169,84 @@
 
 DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter.");
 #endif  /* CONFIG_ALLPASS_FILTER */
+#if CONFIG_LOWSHELF_FILTER
+static const AVOption lowshelf_options[] = {
+    {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
+    {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
+    {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
+    {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
+    {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
+    {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
+    {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
+    {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
+    {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
+    {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
+    {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
+    {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
+    {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
+    {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
+    {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
+    {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
+    {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
+    {"normalize", "normalize coefficients", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
+    {"n",         "normalize coefficients", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
+    {"transform", "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_TTYPE-1, AF, "transform_type"},
+    {"a",         "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_TTYPE-1, AF, "transform_type"},
+    {"di",   "direct form I",  0, AV_OPT_TYPE_CONST, {.i64=DI}, 0, 0, AF, "transform_type"},
+    {"dii",  "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
+    {"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
+    {"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+    {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+    {"r",         "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+    {"auto", "automatic",            0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+    {"s16", "signed 16-bit",         0, AV_OPT_TYPE_CONST, {.i64=0},  0, 0, AF, "precision"},
+    {"s32", "signed 32-bit",         0, AV_OPT_TYPE_CONST, {.i64=1},  0, 0, AF, "precision"},
+    {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2},  0, 0, AF, "precision"},
+    {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3},  0, 0, AF, "precision"},
+    {NULL}
+};
+
+DEFINE_BIQUAD_FILTER(lowshelf, "Apply a low shelf filter.");
+#endif  /* CONFIG_LOWSHELF_FILTER */
+#if CONFIG_HIGHSHELF_FILTER
+static const AVOption highshelf_options[] = {
+    {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
+    {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
+    {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
+    {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
+    {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
+    {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
+    {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
+    {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
+    {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
+    {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
+    {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
+    {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
+    {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
+    {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
+    {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
+    {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
+    {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
+    {"normalize", "normalize coefficients", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
+    {"n",         "normalize coefficients", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
+    {"transform", "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_TTYPE-1, AF, "transform_type"},
+    {"a",         "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_TTYPE-1, AF, "transform_type"},
+    {"di",   "direct form I",  0, AV_OPT_TYPE_CONST, {.i64=DI}, 0, 0, AF, "transform_type"},
+    {"dii",  "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
+    {"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
+    {"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+    {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+    {"r",         "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+    {"auto", "automatic",            0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+    {"s16", "signed 16-bit",         0, AV_OPT_TYPE_CONST, {.i64=0},  0, 0, AF, "precision"},
+    {"s32", "signed 32-bit",         0, AV_OPT_TYPE_CONST, {.i64=1},  0, 0, AF, "precision"},
+    {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2},  0, 0, AF, "precision"},
+    {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3},  0, 0, AF, "precision"},
+    {NULL}
+};
+
+DEFINE_BIQUAD_FILTER(highshelf, "Apply a high shelf filter.");
+#endif  /* CONFIG_HIGHSHELF_FILTER */
 #if CONFIG_BIQUAD_FILTER
 static const AVOption biquad_options[] = {
     {"a0", NULL, OFFSET(oa0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT32_MIN, INT32_MAX, FLAGS},
diff --git a/libavfilter/af_crystalizer.c b/libavfilter/af_crystalizer.c
index d1f4498..f3d8ae6 100644
--- a/libavfilter/af_crystalizer.c
+++ b/libavfilter/af_crystalizer.c
@@ -36,7 +36,7 @@
 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption crystalizer_options[] = {
-    { "i", "set intensity",    OFFSET(mult), AV_OPT_TYPE_FLOAT, {.dbl=2.0},-10, 10, A },
+    { "i", "set intensity",    OFFSET(mult), AV_OPT_TYPE_FLOAT, {.dbl=2.0}, 0, 10, A },
     { "c", "enable clipping",  OFFSET(clip), AV_OPT_TYPE_BOOL,  {.i64=1},   0,  1, A },
     { NULL }
 };
@@ -91,7 +91,7 @@
     const void **s = td->s;
     const int nb_samples = td->nb_samples;
     const int channels = td->channels;
-    const float mult = td->mult;
+    float mult = td->mult;
     const int clip = td->clip;
     const int start = (channels * jobnr) / nb_jobs;
     const int end = (channels * (jobnr+1)) / nb_jobs;
@@ -126,7 +126,7 @@
     const void **s = td->s;
     const int nb_samples = td->nb_samples;
     const int channels = td->channels;
-    double mult = td->mult;
+    float mult = td->mult;
     const int clip = td->clip;
     const int start = (channels * jobnr) / nb_jobs;
     const int end = (channels * (jobnr+1)) / nb_jobs;
@@ -195,7 +195,7 @@
     const void **s = td->s;
     const int nb_samples = td->nb_samples;
     const int channels = td->channels;
-    const double mult = td->mult;
+    float mult = td->mult;
     const int clip = td->clip;
     const int start = (channels * jobnr) / nb_jobs;
     const int end = (channels * (jobnr+1)) / nb_jobs;
@@ -220,157 +220,16 @@
     return 0;
 }
 
-static int ifilter_flt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    void **d = td->d;
-    void **p = td->p;
-    const void **s = td->s;
-    const int nb_samples = td->nb_samples;
-    const int channels = td->channels;
-    const float mult = -td->mult;
-    const float div = -td->mult + 1.f;
-    const int clip = td->clip;
-    const int start = (channels * jobnr) / nb_jobs;
-    const int end = (channels * (jobnr+1)) / nb_jobs;
-    float *prv = p[0];
-    int n, c;
-
-    for (c = start; c < end; c++) {
-        const float *src = s[0];
-        float *dst = d[0];
-
-        for (n = 0; n < nb_samples; n++) {
-            float current = src[c];
-            dst[c] = (current + prv[c] * mult) / div;
-            prv[c] = dst[c];
-            if (clip) {
-                dst[c] = av_clipf(dst[c], -1, 1);
-            }
-
-            dst += channels;
-            src += channels;
-        }
-    }
-
-    return 0;
-}
-
-static int ifilter_dbl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    void **d = td->d;
-    void **p = td->p;
-    const void **s = td->s;
-    const int nb_samples = td->nb_samples;
-    const int channels = td->channels;
-    const double mult = -td->mult;
-    const double div = -td->mult + 1.f;
-    const int clip = td->clip;
-    const int start = (channels * jobnr) / nb_jobs;
-    const int end = (channels * (jobnr+1)) / nb_jobs;
-    double *prv = p[0];
-    int n, c;
-
-    for (c = start; c < end; c++) {
-        const double *src = s[0];
-        double *dst = d[0];
-
-        for (n = 0; n < nb_samples; n++) {
-            double current = src[c];
-
-            dst[c] = (current + prv[c] * mult) / div;
-            prv[c] = dst[c];
-            if (clip) {
-                dst[c] = av_clipd(dst[c], -1, 1);
-            }
-
-            dst += channels;
-            src += channels;
-        }
-    }
-
-    return 0;
-}
-
-static int ifilter_fltp(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    void **d = td->d;
-    void **p = td->p;
-    const void **s = td->s;
-    const int nb_samples = td->nb_samples;
-    const int channels = td->channels;
-    const float mult = -td->mult;
-    const float div = -td->mult + 1.f;
-    const int clip = td->clip;
-    const int start = (channels * jobnr) / nb_jobs;
-    const int end = (channels * (jobnr+1)) / nb_jobs;
-    int n, c;
-
-    for (c = start; c < end; c++) {
-        const float *src = s[c];
-        float *dst = d[c];
-        float *prv = p[c];
-
-        for (n = 0; n < nb_samples; n++) {
-            float current = src[n];
-
-            dst[n] = (current + prv[0] * mult) / div;
-            prv[0] = dst[n];
-            if (clip) {
-                dst[n] = av_clipf(dst[n], -1, 1);
-            }
-        }
-    }
-
-    return 0;
-}
-
-static int ifilter_dblp(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    void **d = td->d;
-    void **p = td->p;
-    const void **s = td->s;
-    const int nb_samples = td->nb_samples;
-    const int channels = td->channels;
-    const double mult = -td->mult;
-    const double div = -td->mult + 1.f;
-    const int clip = td->clip;
-    const int start = (channels * jobnr) / nb_jobs;
-    const int end = (channels * (jobnr+1)) / nb_jobs;
-    int n, c;
-
-    for (c = start; c < end; c++) {
-        const double *src = s[c];
-        double *dst = d[c];
-        double *prv = p[c];
-
-        for (n = 0; n < nb_samples; n++) {
-            double current = src[n];
-
-            dst[n] = (current + prv[0] * mult) / div;
-            prv[0] = dst[n];
-            if (clip) {
-                dst[n] = av_clipd(dst[n], -1, 1);
-            }
-        }
-    }
-
-    return 0;
-}
-
 static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
     CrystalizerContext *s = ctx->priv;
 
     switch (inlink->format) {
-    case AV_SAMPLE_FMT_FLT:  s->filter = s->mult >= 0.f ? filter_flt  : ifilter_flt;  break;
-    case AV_SAMPLE_FMT_DBL:  s->filter = s->mult >= 0.f ? filter_dbl  : ifilter_dbl;  break;
-    case AV_SAMPLE_FMT_FLTP: s->filter = s->mult >= 0.f ? filter_fltp : ifilter_fltp; break;
-    case AV_SAMPLE_FMT_DBLP: s->filter = s->mult >= 0.f ? filter_dblp : ifilter_dblp; break;
+    case AV_SAMPLE_FMT_FLT:  s->filter = filter_flt;  break;
+    case AV_SAMPLE_FMT_DBL:  s->filter = filter_dbl;  break;
+    case AV_SAMPLE_FMT_FLTP: s->filter = filter_fltp; break;
+    case AV_SAMPLE_FMT_DBLP: s->filter = filter_dblp; break;
     }
 
     return 0;
@@ -426,18 +285,6 @@
     av_frame_free(&s->prev);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_input(ctx->inputs[0]);
-}
-
 static const AVFilterPad inputs[] = {
     {
         .name         = "default",
@@ -458,14 +305,14 @@
 
 AVFilter ff_af_crystalizer = {
     .name           = "crystalizer",
-    .description    = NULL_IF_CONFIG_SMALL("Simple audio noise sharpening filter."),
+    .description    = NULL_IF_CONFIG_SMALL("Simple expand audio dynamic range filter."),
     .query_formats  = query_formats,
     .priv_size      = sizeof(CrystalizerContext),
     .priv_class     = &crystalizer_class,
     .uninit         = uninit,
     .inputs         = inputs,
     .outputs        = outputs,
-    .process_command = process_command,
+    .process_command = ff_filter_process_command,
     .flags          = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
                       AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 81fa62b..365453d 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -719,7 +719,6 @@
         cqueue_dequeue(s->is_enabled, &is_enabled);
 
         amplify_frame(s, out, is_enabled > 0.);
-        s->pts = out->pts + out->nb_samples;
         ret = ff_filter_frame(outlink, out);
     }
 
@@ -770,7 +769,7 @@
     } else if (s->queue.available) {
         AVFrame *out = ff_bufqueue_get(&s->queue);
 
-        s->pts = out->pts + out->nb_samples;
+        s->pts = out->pts;
         ret = ff_filter_frame(outlink, out);
     }
 
@@ -798,7 +797,7 @@
                 return ret;
         }
 
-        if (ff_inlink_check_available_samples(inlink, s->frame_len) > 0) {
+        if (ff_inlink_queued_samples(inlink) >= s->frame_len) {
             ff_filter_set_ready(ctx, 10);
             return 0;
         }
diff --git a/libavfilter/af_tremolo.c b/libavfilter/af_tremolo.c
index 6baeb7f..f55e8e2 100644
--- a/libavfilter/af_tremolo.c
+++ b/libavfilter/af_tremolo.c
@@ -126,7 +126,7 @@
     const double offset = 1. - s->depth / 2.;
     int i;
 
-    s->table_size = lrint(inlink->sample_rate / s->freq + 0.5);
+    s->table_size = inlink->sample_rate / s->freq;
     s->table = av_malloc_array(s->table_size, sizeof(*s->table));
     if (!s->table)
         return AVERROR(ENOMEM);
diff --git a/libavfilter/af_vibrato.c b/libavfilter/af_vibrato.c
index 5db1f0f..22bbab6 100644
--- a/libavfilter/af_vibrato.c
+++ b/libavfilter/af_vibrato.c
@@ -162,7 +162,7 @@
     s->buf = av_calloc(inlink->channels, sizeof(*s->buf));
     if (!s->buf)
         return AVERROR(ENOMEM);
-    s->buf_size = lrint(inlink->sample_rate * 0.005 + 0.5);
+    s->buf_size = inlink->sample_rate * 0.005;
     for (c = 0; c < s->channels; c++) {
         s->buf[c] = av_malloc_array(s->buf_size, sizeof(*s->buf[c]));
         if (!s->buf[c])
@@ -170,7 +170,7 @@
     }
     s->buf_index = 0;
 
-    s->wave_table_size = lrint(inlink->sample_rate / s->freq + 0.5);
+    s->wave_table_size = inlink->sample_rate / s->freq;
     s->wave_table = av_malloc_array(s->wave_table_size, sizeof(*s->wave_table));
     if (!s->wave_table)
         return AVERROR(ENOMEM);
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 0872c6e..a145d0a 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -39,7 +39,6 @@
 extern AVFilter ff_af_aecho;
 extern AVFilter ff_af_aemphasis;
 extern AVFilter ff_af_aeval;
-extern AVFilter ff_af_aexciter;
 extern AVFilter ff_af_afade;
 extern AVFilter ff_af_afftdn;
 extern AVFilter ff_af_afftfilt;
@@ -187,16 +186,12 @@
 extern AVFilter ff_vf_codecview;
 extern AVFilter ff_vf_colorbalance;
 extern AVFilter ff_vf_colorchannelmixer;
-extern AVFilter ff_vf_colorcontrast;
-extern AVFilter ff_vf_colorcorrect;
-extern AVFilter ff_vf_colorize;
 extern AVFilter ff_vf_colorkey;
 extern AVFilter ff_vf_colorkey_opencl;
 extern AVFilter ff_vf_colorhold;
 extern AVFilter ff_vf_colorlevels;
 extern AVFilter ff_vf_colormatrix;
 extern AVFilter ff_vf_colorspace;
-extern AVFilter ff_vf_colortemperature;
 extern AVFilter ff_vf_convolution;
 extern AVFilter ff_vf_convolution_opencl;
 extern AVFilter ff_vf_convolve;
@@ -239,12 +234,9 @@
 extern AVFilter ff_vf_edgedetect;
 extern AVFilter ff_vf_elbg;
 extern AVFilter ff_vf_entropy;
-extern AVFilter ff_vf_epx;
 extern AVFilter ff_vf_eq;
 extern AVFilter ff_vf_erosion;
 extern AVFilter ff_vf_erosion_opencl;
-extern AVFilter ff_vf_estdif;
-extern AVFilter ff_vf_exposure;
 extern AVFilter ff_vf_extractplanes;
 extern AVFilter ff_vf_fade;
 extern AVFilter ff_vf_fftdnoiz;
@@ -283,14 +275,12 @@
 extern AVFilter ff_vf_hwupload;
 extern AVFilter ff_vf_hwupload_cuda;
 extern AVFilter ff_vf_hysteresis;
-extern AVFilter ff_vf_identity;
 extern AVFilter ff_vf_idet;
 extern AVFilter ff_vf_il;
 extern AVFilter ff_vf_inflate;
 extern AVFilter ff_vf_interlace;
 extern AVFilter ff_vf_interleave;
 extern AVFilter ff_vf_kerndeint;
-extern AVFilter ff_vf_kirsch;
 extern AVFilter ff_vf_lagfun;
 extern AVFilter ff_vf_lenscorrection;
 extern AVFilter ff_vf_lensfun;
@@ -318,9 +308,7 @@
 extern AVFilter ff_vf_midequalizer;
 extern AVFilter ff_vf_minterpolate;
 extern AVFilter ff_vf_mix;
-extern AVFilter ff_vf_monochrome;
 extern AVFilter ff_vf_mpdecimate;
-extern AVFilter ff_vf_msad;
 extern AVFilter ff_vf_negate;
 extern AVFilter ff_vf_nlmeans;
 extern AVFilter ff_vf_nlmeans_opencl;
@@ -394,11 +382,9 @@
 extern AVFilter ff_vf_setsar;
 extern AVFilter ff_vf_settb;
 extern AVFilter ff_vf_sharpness_vaapi;
-extern AVFilter ff_vf_shear;
 extern AVFilter ff_vf_showinfo;
 extern AVFilter ff_vf_showpalette;
 extern AVFilter ff_vf_shuffleframes;
-extern AVFilter ff_vf_shufflepixels;
 extern AVFilter ff_vf_shuffleplanes;
 extern AVFilter ff_vf_sidedata;
 extern AVFilter ff_vf_signalstats;
@@ -426,7 +412,6 @@
 extern AVFilter ff_vf_tinterlace;
 extern AVFilter ff_vf_tlut2;
 extern AVFilter ff_vf_tmedian;
-extern AVFilter ff_vf_tmidequalizer;
 extern AVFilter ff_vf_tmix;
 extern AVFilter ff_vf_tonemap;
 extern AVFilter ff_vf_tonemap_opencl;
@@ -450,7 +435,6 @@
 extern AVFilter ff_vf_vibrance;
 extern AVFilter ff_vf_vidstabdetect;
 extern AVFilter ff_vf_vidstabtransform;
-extern AVFilter ff_vf_vif;
 extern AVFilter ff_vf_vignette;
 extern AVFilter ff_vf_vmafmotion;
 extern AVFilter ff_vf_vpp_qsv;
diff --git a/libavfilter/atadenoise.h b/libavfilter/atadenoise.h
index 7d92ece..26cb20b 100644
--- a/libavfilter/atadenoise.h
+++ b/libavfilter/atadenoise.h
@@ -31,12 +31,12 @@
 };
 
 typedef struct ATADenoiseDSPContext {
-    void (*filter_row[4])(const uint8_t *src, uint8_t *dst,
-                          const uint8_t **srcf,
-                          int w, int mid, int size,
-                          int thra, int thrb, const float *weight);
+    void (*filter_row)(const uint8_t *src, uint8_t *dst,
+                       const uint8_t **srcf,
+                       int w, int mid, int size,
+                       int thra, int thrb);
 } ATADenoiseDSPContext;
 
-void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm, const float *sigma);
+void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm);
 
 #endif /* AVFILTER_ATADENOISE_H */
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index dba1f08..115174a 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -1133,11 +1133,11 @@
     int64_t last_time, cur_time;
 
 #define UPDATE_TIME(t) \
-    cur_time = av_gettime_relative(); \
+    cur_time = av_gettime(); \
     t += cur_time - last_time; \
     last_time = cur_time
 
-    last_time = av_gettime_relative();
+    last_time = av_gettime();
 
     memcpy(s->fft_result, s->fft_data, s->fft_len * sizeof(*s->fft_data));
     if (s->attack_data) {
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 22ecad5..8ff22c7 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -232,12 +232,11 @@
     ff_filter_set_ready(link->src, 200);
 }
 
-#if FF_API_FILTER_LINK_SET_CLOSED
 void avfilter_link_set_closed(AVFilterLink *link, int closed)
 {
     ff_avfilter_link_set_out_status(link, closed ? AVERROR_EOF : 0, AV_NOPTS_VALUE);
 }
-#endif
+
 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
                            unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
 {
@@ -621,12 +620,11 @@
 
 #define OFFSET(x) offsetof(AVFilterContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM
-#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 static const AVOption avfilter_options[] = {
     { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
         { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" },
         { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .flags = FLAGS, .unit = "thread_type" },
-    { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = TFLAGS },
+    { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
     { "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
         { .i64 = 0 }, 0, INT_MAX, FLAGS },
     { "extra_hw_frames", "Number of extra hardware frames to allocate for the user",
@@ -876,6 +874,11 @@
         count++;
     }
 
+    if (ctx->enable_str) {
+        ret = set_enable_expr(ctx, ctx->enable_str);
+        if (ret < 0)
+            return ret;
+    }
     return count;
 }
 
@@ -926,12 +929,6 @@
     else if (ctx->filter->init_dict)
         ret = ctx->filter->init_dict(ctx, options);
 
-    if (ctx->enable_str) {
-        ret = set_enable_expr(ctx, ctx->enable_str);
-        if (ret < 0)
-            return ret;
-    }
-
     return ret;
 }
 
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index be12424..100183f 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -588,6 +588,11 @@
     int channels;
 
     /**
+     * Link processing flags.
+     */
+    unsigned flags;
+
+    /**
      * Number of past frames sent through the link.
      */
     int64_t frame_count_in, frame_count_out;
@@ -681,7 +686,7 @@
 attribute_deprecated
 int avfilter_link_get_channels(AVFilterLink *link);
 #endif
-#if FF_API_FILTER_LINK_SET_CLOSED
+
 /**
  * Set the closed field of a link.
  * @deprecated applications are not supposed to mess with links, they should
@@ -689,7 +694,7 @@
  */
 attribute_deprecated
 void avfilter_link_set_closed(AVFilterLink *link, int closed);
-#endif
+
 /**
  * Negotiate the media format, dimensions, etc of all inputs to a filter.
  *
diff --git a/libavfilter/bbox.c b/libavfilter/bbox.c
index 3ed9045..be9b2e6 100644
--- a/libavfilter/bbox.c
+++ b/libavfilter/bbox.c
@@ -20,71 +20,56 @@
 
 #include "bbox.h"
 
-#define BBOX(type, name)                                             \
-static int bbox_##name(FFBoundingBox *bbox,                          \
-                       const type *data, int linesize, int w, int h, \
-                       int min_val)                                  \
-{                                                                    \
-    int x, y;                                                        \
-    int start_x;                                                     \
-    int start_y;                                                     \
-    int end_x;                                                       \
-    int end_y;                                                       \
-    const type *line;                                                \
-                                                                     \
-    /* left bound */                                                 \
-    for (start_x = 0; start_x < w; start_x++)                        \
-        for (y = 0; y < h; y++)                                      \
-            if ((data[y * linesize + start_x] > min_val))            \
-                goto outl;                                           \
-outl:                                                                \
-    if (start_x == w) /* no points found */                          \
-        return 0;                                                    \
-                                                                     \
-    /* right bound */                                                \
-    for (end_x = w - 1; end_x >= start_x; end_x--)                   \
-        for (y = 0; y < h; y++)                                      \
-            if ((data[y * linesize + end_x] > min_val))              \
-                goto outr;                                           \
-outr:                                                                \
-                                                                     \
-    /* top bound */                                                  \
-    line = data;                                                     \
-    for (start_y = 0; start_y < h; start_y++) {                      \
-        for (x = 0; x < w; x++)                                      \
-            if (line[x] > min_val)                                   \
-                goto outt;                                           \
-        line += linesize;                                            \
-    }                                                                \
-outt:                                                                \
-                                                                     \
-    /* bottom bound */                                               \
-    line = data + (h-1)*linesize;                                    \
-    for (end_y = h - 1; end_y >= start_y; end_y--) {                 \
-        for (x = 0; x < w; x++)                                      \
-            if (line[x] > min_val)                                   \
-                goto outb;                                           \
-        line -= linesize;                                            \
-    }                                                                \
-outb:                                                                \
-                                                                     \
-    bbox->x1 = start_x;                                              \
-    bbox->y1 = start_y;                                              \
-    bbox->x2 = end_x;                                                \
-    bbox->y2 = end_y;                                                \
-    return 1;                                                        \
-}
-
-BBOX(uint8_t, 8)
-BBOX(uint16_t, 16)
-
 int ff_calculate_bounding_box(FFBoundingBox *bbox,
-                              const uint8_t *data, int linesize,
-                              int w, int h,
-                              int min_val, int depth)
+                              const uint8_t *data, int linesize, int w, int h,
+                              int min_val)
 {
-    if (depth <= 8)
-        return bbox_8(bbox, data, linesize, w, h, min_val);
-    else
-        return bbox_16(bbox, (const uint16_t *)data, linesize / 2, w, h, min_val);
+    int x, y;
+    int start_x;
+    int start_y;
+    int end_x;
+    int end_y;
+    const uint8_t *line;
+
+    /* left bound */
+    for (start_x = 0; start_x < w; start_x++)
+        for (y = 0; y < h; y++)
+            if ((data[y * linesize + start_x] > min_val))
+                goto outl;
+outl:
+    if (start_x == w) /* no points found */
+        return 0;
+
+    /* right bound */
+    for (end_x = w - 1; end_x >= start_x; end_x--)
+        for (y = 0; y < h; y++)
+            if ((data[y * linesize + end_x] > min_val))
+                goto outr;
+outr:
+
+    /* top bound */
+    line = data;
+    for (start_y = 0; start_y < h; start_y++) {
+        for (x = 0; x < w; x++)
+            if (line[x] > min_val)
+                goto outt;
+        line += linesize;
+    }
+outt:
+
+    /* bottom bound */
+    line = data + (h-1)*linesize;
+    for (end_y = h - 1; end_y >= start_y; end_y--) {
+        for (x = 0; x < w; x++)
+            if (line[x] > min_val)
+                goto outb;
+        line -= linesize;
+    }
+outb:
+
+    bbox->x1 = start_x;
+    bbox->y1 = start_y;
+    bbox->x2 = end_x;
+    bbox->y2 = end_y;
+    return 1;
 }
diff --git a/libavfilter/bbox.h b/libavfilter/bbox.h
index 116158d..cf026b8 100644
--- a/libavfilter/bbox.h
+++ b/libavfilter/bbox.h
@@ -39,6 +39,6 @@
  */
 int ff_calculate_bounding_box(FFBoundingBox *bbox,
                               const uint8_t *data, int linesize,
-                              int w, int h, int min_val, int depth);
+                              int w, int h, int min_val);
 
 #endif /* AVFILTER_BBOX_H */
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 15d897c..5884894 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -148,7 +148,7 @@
     return get_frame_internal(ctx, frame, 0, nb_samples);
 }
 
-#if FF_API_BUFFERSINK_ALLOC
+#if FF_API_NEXT
 AVBufferSinkParams *av_buffersink_params_alloc(void)
 {
     static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 69ed0f2..65d0cca 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -95,7 +95,7 @@
  */
 #define AV_BUFFERSINK_FLAG_NO_REQUEST 2
 
-#if FF_API_BUFFERSINK_ALLOC
+#if FF_API_NEXT
 /**
  * Deprecated and unused struct to use for initializing a buffersink context.
  */
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index da1cf99..bf30f54 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -149,6 +149,33 @@
     return av_buffersrc_add_frame_flags(ctx, frame, 0);
 }
 
+static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
+                                           AVFrame *frame, int flags);
+
+int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
+{
+    AVFrame *copy = NULL;
+    int ret = 0;
+
+    if (frame && frame->channel_layout &&
+        av_get_channel_layout_nb_channels(frame->channel_layout) != frame->channels) {
+        av_log(ctx, AV_LOG_ERROR, "Layout indicates a different number of channels than actually present\n");
+        return AVERROR(EINVAL);
+    }
+
+    if (!(flags & AV_BUFFERSRC_FLAG_KEEP_REF) || !frame)
+        return av_buffersrc_add_frame_internal(ctx, frame, flags);
+
+    if (!(copy = av_frame_alloc()))
+        return AVERROR(ENOMEM);
+    ret = av_frame_ref(copy, frame);
+    if (ret >= 0)
+        ret = av_buffersrc_add_frame_internal(ctx, copy, flags);
+
+    av_frame_free(&copy);
+    return ret;
+}
+
 static int push_frame(AVFilterGraph *graph)
 {
     int ret;
@@ -163,18 +190,13 @@
     return 0;
 }
 
-int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
+static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
+                                           AVFrame *frame, int flags)
 {
     BufferSourceContext *s = ctx->priv;
     AVFrame *copy;
     int refcounted, ret;
 
-    if (frame && frame->channel_layout &&
-        av_get_channel_layout_nb_channels(frame->channel_layout) != frame->channels) {
-        av_log(ctx, AV_LOG_ERROR, "Layout indicates a different number of channels than actually present\n");
-        return AVERROR(EINVAL);
-    }
-
     s->nb_failed_requests = 0;
 
     if (!frame)
@@ -207,7 +229,7 @@
     if (!(copy = av_frame_alloc()))
         return AVERROR(ENOMEM);
 
-    if (refcounted && !(flags & AV_BUFFERSRC_FLAG_KEEP_REF)) {
+    if (refcounted) {
         av_frame_move_ref(copy, frame);
     } else {
         ret = av_frame_ref(copy, frame);
diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h
index 88aabe9..fc6aad5 100644
--- a/libavfilter/convolution.h
+++ b/libavfilter/convolution.h
@@ -57,7 +57,7 @@
     void (*filter[4])(uint8_t *dst, int width,
                       float rdiv, float bias, const int *const matrix,
                       const uint8_t *c[], int peak, int radius,
-                      int dstride, int stride, int size);
+                      int dstride, int stride);
 } ConvolutionContext;
 
 void ff_convolution_init_x86(ConvolutionContext *s);
diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index d6d58f4..b0b7630 100644
--- a/libavfilter/dnn/Makefile
+++ b/libavfilter/dnn/Makefile
@@ -1,7 +1,5 @@
 OBJS-$(CONFIG_DNN)                           += dnn/dnn_interface.o
 OBJS-$(CONFIG_DNN)                           += dnn/dnn_io_proc.o
-OBJS-$(CONFIG_DNN)                           += dnn/queue.o
-OBJS-$(CONFIG_DNN)                           += dnn/safe_queue.o
 OBJS-$(CONFIG_DNN)                           += dnn/dnn_backend_native.o
 OBJS-$(CONFIG_DNN)                           += dnn/dnn_backend_native_layers.o
 OBJS-$(CONFIG_DNN)                           += dnn/dnn_backend_native_layer_avgpool.o
diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c
index 3bc253c..4fc3ba2 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -36,7 +36,7 @@
     { NULL },
 };
 
-static const AVClass dnn_native_class = {
+const AVClass dnn_native_class = {
     .class_name = "dnn_native",
     .item_name  = av_default_item_name,
     .option     = dnn_native_options,
@@ -50,7 +50,7 @@
 
 static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
 {
-    NativeModel *native_model = model;
+    NativeModel *native_model = (NativeModel *)model;
     NativeContext *ctx = &native_model->ctx;
 
     for (int i = 0; i < native_model->operands_num; ++i) {
@@ -78,7 +78,7 @@
                                        const char *output_name, int *output_width, int *output_height)
 {
     DNNReturnType ret;
-    NativeModel *native_model = model;
+    NativeModel *native_model = (NativeModel *)model;
     NativeContext *ctx = &native_model->ctx;
     AVFrame *in_frame = av_frame_alloc();
     AVFrame *out_frame = NULL;
@@ -112,7 +112,7 @@
 // layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...
 // For CONV layer: activation_function, input_num, output_num, kernel_size, kernel, biases
 // For DEPTH_TO_SPACE layer: block_size
-DNNModel *ff_dnn_load_model_native(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx)
+DNNModel *ff_dnn_load_model_native(const char *model_filename, const char *options, void *userdata)
 {
     DNNModel *model = NULL;
     char header_expected[] = "FFMPEGDNNNATIVE";
@@ -208,7 +208,7 @@
         }
 
         native_model->layers[layer].type = layer_type;
-        parsed_size = ff_layer_funcs[layer_type].pf_load(&native_model->layers[layer], model_file_context, file_size, native_model->operands_num);
+        parsed_size = layer_funcs[layer_type].pf_load(&native_model->layers[layer], model_file_context, file_size, native_model->operands_num);
         if (!parsed_size) {
             goto fail;
         }
@@ -255,8 +255,7 @@
 
     model->get_input = &get_input_native;
     model->get_output = &get_output_native;
-    model->filter_ctx = filter_ctx;
-    model->func_type = func_type;
+    model->userdata = userdata;
 
     return model;
 
@@ -270,7 +269,7 @@
                                           const char **output_names, uint32_t nb_output, AVFrame *out_frame,
                                           int do_ioproc)
 {
-    NativeModel *native_model = model->model;
+    NativeModel *native_model = (NativeModel *)model->model;
     NativeContext *ctx = &native_model->ctx;
     int32_t layer;
     DNNData input, output;
@@ -301,7 +300,7 @@
     oprd->dims[2] = in_frame->width;
 
     av_freep(&oprd->data);
-    oprd->length = ff_calculate_operand_data_length(oprd);
+    oprd->length = calculate_operand_data_length(oprd);
     if (oprd->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n");
         return DNN_ERROR;
@@ -319,22 +318,22 @@
     input.dt = oprd->data_type;
     if (do_ioproc) {
         if (native_model->model->pre_proc != NULL) {
-            native_model->model->pre_proc(in_frame, &input, native_model->model->filter_ctx);
+            native_model->model->pre_proc(in_frame, &input, native_model->model->userdata);
         } else {
-            ff_proc_from_frame_to_dnn(in_frame, &input, native_model->model->func_type, ctx);
+            proc_from_frame_to_dnn(in_frame, &input, ctx);
         }
     }
 
     if (nb_output != 1) {
         // currently, the filter does not need multiple outputs,
         // so we just pending the support until we really need it.
-        avpriv_report_missing_feature(ctx, "multiple outputs");
+        av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
         return DNN_ERROR;
     }
 
     for (layer = 0; layer < native_model->layers_num; ++layer){
         DNNLayerType layer_type = native_model->layers[layer].type;
-        if (ff_layer_funcs[layer_type].pf_exec(native_model->operands,
+        if (layer_funcs[layer_type].pf_exec(native_model->operands,
                                             native_model->layers[layer].input_operand_indexes,
                                             native_model->layers[layer].output_operand_index,
                                             native_model->layers[layer].params,
@@ -367,9 +366,9 @@
 
         if (do_ioproc) {
             if (native_model->model->post_proc != NULL) {
-                native_model->model->post_proc(out_frame, &output, native_model->model->filter_ctx);
+                native_model->model->post_proc(out_frame, &output, native_model->model->userdata);
             } else {
-                ff_proc_from_dnn_to_frame(out_frame, &output, ctx);
+                proc_from_dnn_to_frame(out_frame, &output, ctx);
             }
         } else {
             out_frame->width = output.width;
@@ -383,7 +382,7 @@
 DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                           const char **output_names, uint32_t nb_output, AVFrame *out_frame)
 {
-    NativeModel *native_model = model->model;
+    NativeModel *native_model = (NativeModel *)model->model;
     NativeContext *ctx = &native_model->ctx;
 
     if (!in_frame) {
@@ -399,7 +398,7 @@
     return execute_model_native(model, input_name, in_frame, output_names, nb_output, out_frame, 1);
 }
 
-int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd)
+int32_t calculate_operand_dims_count(const DnnOperand *oprd)
 {
     int32_t result = 1;
     for (int i = 0; i < 4; ++i)
@@ -408,7 +407,7 @@
     return result;
 }
 
-int32_t ff_calculate_operand_data_length(const DnnOperand* oprd)
+int32_t calculate_operand_data_length(const DnnOperand* oprd)
 {
     // currently, we just support DNN_FLOAT
     uint64_t len = sizeof(float);
@@ -429,7 +428,7 @@
     if (*model)
     {
         if ((*model)->model) {
-            native_model = (*model)->model;
+            native_model = (NativeModel *)(*model)->model;
             if (native_model->layers) {
                 for (layer = 0; layer < native_model->layers_num; ++layer){
                     if (native_model->layers[layer].type == DLT_CONV2D){
diff --git a/libavfilter/dnn/dnn_backend_native.h b/libavfilter/dnn/dnn_backend_native.h
index d313c48..2d02c06 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -128,7 +128,7 @@
     int32_t operands_num;
 } NativeModel;
 
-DNNModel *ff_dnn_load_model_native(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx);
+DNNModel *ff_dnn_load_model_native(const char *model_filename, const char *options, void *userdata);
 
 DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                           const char **output_names, uint32_t nb_output, AVFrame *out_frame);
@@ -137,6 +137,6 @@
 
 // NOTE: User must check for error (return value <= 0) to handle
 // case like integer overflow.
-int32_t ff_calculate_operand_data_length(const DnnOperand *oprd);
-int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd);
+int32_t calculate_operand_data_length(const DnnOperand *oprd);
+int32_t calculate_operand_dims_count(const DnnOperand *oprd);
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
index dcfb8c8..989006d 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
@@ -26,7 +26,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_avgpool.h"
 
-int ff_dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     AvgPoolParams *avgpool_params;
     int dnn_size = 0;
@@ -55,8 +55,8 @@
     return dnn_size;
 }
 
-int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                  int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes,
+                             int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     float *output;
     int height_end, width_end, height_radius, width_radius, output_height, output_width, kernel_area;
@@ -66,7 +66,7 @@
     int width = operands[input_operand_index].dims[2];
     int channel = operands[input_operand_index].dims[3];
     const float *input = operands[input_operand_index].data;
-    const AvgPoolParams *avgpool_params = parameters;
+    const AvgPoolParams *avgpool_params = (const AvgPoolParams *)parameters;
 
     int kernel_strides = avgpool_params->strides;
     int src_linesize = width * channel;
@@ -106,7 +106,7 @@
     // not support pooling in channel dimension now
     output_operand->dims[3] = channel;
     output_operand->data_type = operands[input_operand_index].data_type;
-    output_operand->length = ff_calculate_operand_data_length(output_operand);
+    output_operand->length = calculate_operand_data_length(output_operand);
     if (output_operand->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h
index 75d9eb1..543370f 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h
@@ -33,8 +33,8 @@
     DNNPaddingParam padding_method;
 } AvgPoolParams;
 
-int ff_dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                  int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes,
+                             int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index b5c2c39..0fb968a 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -26,21 +26,21 @@
 #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
 
 //struct to pass parameters
-typedef struct ThreadCommonParam{
+typedef struct thread_common_param{
     DnnOperand *operands;
     const int32_t *input_operand_indexes;
     int32_t output_operand_index;
     const void *parameters;
     NativeContext *ctx;
     float *output_data;
-} ThreadCommonParam;
+} thread_common_param;
 
-typedef struct ThreadParam{
-    ThreadCommonParam *thread_common_param;
+typedef struct thread_param{
+    thread_common_param *thread_common_param;
     int thread_start, thread_end;
-} ThreadParam;
+} thread_param;
 
-int ff_dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     ConvolutionalParams *conv_params;
     int kernel_size;
@@ -70,7 +70,7 @@
         return 0;
     }
 
-    conv_params->kernel = av_malloc_array(kernel_size, sizeof(*conv_params->kernel));
+    conv_params->kernel = av_malloc(kernel_size * sizeof(float));
     if (!conv_params->kernel) {
         av_freep(&conv_params);
         return 0;
@@ -81,7 +81,7 @@
 
     conv_params->biases = NULL;
     if (conv_params->has_bias) {
-        conv_params->biases = av_malloc_array(conv_params->output_num, sizeof(*conv_params->biases));
+        conv_params->biases = av_malloc(conv_params->output_num * sizeof(float));
         if (!conv_params->biases){
             av_freep(&conv_params->kernel);
             av_freep(&conv_params);
@@ -108,15 +108,15 @@
 static void * dnn_execute_layer_conv2d_thread(void *threadarg)
 {
     //pass parameters
-    ThreadParam *thread_param = threadarg;
-    ThreadCommonParam *thread_common_param = thread_param->thread_common_param;
+    thread_param *thread_param = (struct thread_param *)threadarg;
+    thread_common_param *thread_common_param = thread_param->thread_common_param;
     DnnOperand *operands = thread_common_param->operands;
     int32_t input_operand_index = thread_common_param->input_operand_indexes[0];
     int height = operands[input_operand_index].dims[1];
     int width = operands[input_operand_index].dims[2];
     int channel = operands[input_operand_index].dims[3];
     const float *input = operands[input_operand_index].data;
-    const ConvolutionalParams *conv_params = thread_common_param->parameters;
+    const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(thread_common_param->parameters);
 
     int radius = conv_params->kernel_size >> 1;
     int src_linesize = width * conv_params->input_num;
@@ -181,18 +181,18 @@
 }
 
 
-int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes,
+                             int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count())
         ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);
 #if HAVE_PTHREAD_CANCEL
-    pthread_t *thread_id = av_malloc_array(thread_num, sizeof(*thread_id));
+    pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t));
     int thread_stride;
 #endif
-    ThreadParam **thread_param = av_malloc_array(thread_num, sizeof(*thread_param));
-    ThreadCommonParam thread_common_param;
-    const ConvolutionalParams *conv_params = parameters;
+    thread_param **thread_param = av_malloc(thread_num * sizeof(*thread_param));
+    thread_common_param thread_common_param;
+    const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(parameters);
     int height = operands[input_operand_indexes[0]].dims[1];
     int width = operands[input_operand_indexes[0]].dims[2];
     int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
@@ -203,7 +203,7 @@
     output_operand->dims[2] = width - pad_size * 2;
     output_operand->dims[3] = conv_params->output_num;
     output_operand->data_type = operands[input_operand_indexes[0]].data_type;
-    output_operand->length = ff_calculate_operand_data_length(output_operand);
+    output_operand->length = calculate_operand_data_length(output_operand);
     if (output_operand->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
@@ -224,7 +224,7 @@
     thread_stride = (height - pad_size * 2) / thread_num;
     //create threads
     for (int i = 0; i < thread_num; i++){
-        thread_param[i] = av_malloc(sizeof(*thread_param[0]));
+        thread_param[i] = av_malloc(sizeof(**thread_param));
         thread_param[i]->thread_common_param = &thread_common_param;
         thread_param[i]->thread_start = thread_stride * i + pad_size;
         thread_param[i]->thread_end = (i == thread_num - 1) ? (height - pad_size) : (thread_param[i]->thread_start + thread_stride);
@@ -237,20 +237,20 @@
     }
 
     //release memory
-    av_freep(&thread_id);
+    av_free(thread_id);
 
     for (int i = 0; i < thread_num; i++){
-        av_freep(&thread_param[i]);
+        av_free(thread_param[i]);
     }
 #else
-    thread_param[0] = av_malloc(sizeof(*thread_param[0]));
+    thread_param[0] = av_malloc(sizeof(**thread_param));
     thread_param[0]->thread_common_param = &thread_common_param;
     thread_param[0]->thread_start = pad_size;
     thread_param[0]->thread_end = height - pad_size;
     dnn_execute_layer_conv2d_thread((void *)thread_param[0]);
-    av_freep(&thread_param[0]);
+    av_free(thread_param[0]);
 #endif
 
-    av_freep(&thread_param);
+    av_free(thread_param);
     return DNN_SUCCESS;
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
index 03ca795..1295028 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
@@ -34,7 +34,7 @@
     float *biases;
 } ConvolutionalParams;
 
-int ff_dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes,
+                             int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.c b/libavfilter/dnn/dnn_backend_native_layer_dense.c
index 117590d..1029137 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_dense.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_dense.c
@@ -21,7 +21,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_dense.h"
 
-int ff_dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     DenseParams *dense_params;
     int kernel_size;
@@ -82,8 +82,8 @@
     return dnn_size;
 }
 
-int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes,
-                               int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes,
+                             int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     float *output;
     int32_t input_operand_index = input_operand_indexes[0];
@@ -92,7 +92,7 @@
     int width = operands[input_operand_index].dims[2];
     int channel = operands[input_operand_index].dims[3];
     const float *input = operands[input_operand_index].data;
-    const DenseParams *dense_params = parameters;
+    const DenseParams *dense_params = (const DenseParams *)parameters;
 
     int src_linesize = width * channel;
     DnnOperand *output_operand = &operands[output_operand_index];
@@ -101,7 +101,7 @@
     output_operand->dims[2] = width;
     output_operand->dims[3] = dense_params->output_num;
     output_operand->data_type = operands[input_operand_index].data_type;
-    output_operand->length = ff_calculate_operand_data_length(output_operand);
+    output_operand->length = calculate_operand_data_length(output_operand);
     if (output_operand->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.h b/libavfilter/dnn/dnn_backend_native_layer_dense.h
index 8624885..f98284b 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_dense.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_dense.h
@@ -31,7 +31,7 @@
     float *biases;
 } DenseParams;
 
-int ff_dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes,
-                               int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes,
+                             int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
index 2fde6d1..4107ee6 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
@@ -27,7 +27,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_depth2space.h"
 
-int ff_dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     DepthToSpaceParams *params;
     int dnn_size = 0;
@@ -49,11 +49,11 @@
     return dnn_size;
 }
 
-int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                     int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes,
+                                  int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     float *output;
-    const DepthToSpaceParams *params = parameters;
+    const DepthToSpaceParams *params = (const DepthToSpaceParams *)parameters;
     int block_size = params->block_size;
     int32_t input_operand_index = input_operand_indexes[0];
     int number = operands[input_operand_index].dims[0];
@@ -74,7 +74,7 @@
     output_operand->dims[2] = width * block_size;
     output_operand->dims[3] = new_channels;
     output_operand->data_type = operands[input_operand_index].data_type;
-    output_operand->length = ff_calculate_operand_data_length(output_operand);
+    output_operand->length = calculate_operand_data_length(output_operand);
     if (output_operand->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.h b/libavfilter/dnn/dnn_backend_native_layer_depth2space.h
index ef59394..648a927 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.h
@@ -34,8 +34,8 @@
     int block_size;
 } DepthToSpaceParams;
 
-int ff_dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                     int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes,
+                                  int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
index c116188..998a752 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
@@ -28,6 +28,7 @@
 #include "dnn_backend_native_layer_mathbinary.h"
 
 typedef float (*FunType)(float src0, float src1);
+FunType pfun;
 
 static float sub(float src0, float src1)
 {
@@ -59,7 +60,7 @@
     int dims_count;
     const float *src;
     float *dst;
-    dims_count = ff_calculate_operand_dims_count(output);
+    dims_count = calculate_operand_dims_count(output);
     src = input->data;
     dst = output->data;
     if (params->input0_broadcast || params->input1_broadcast) {
@@ -79,7 +80,7 @@
     int dims_count;
     const float *src;
     float *dst;
-    dims_count = ff_calculate_operand_dims_count(output);
+    dims_count = calculate_operand_dims_count(output);
     src = input->data;
     dst = output->data;
     if (params->input0_broadcast) {
@@ -98,7 +99,7 @@
         }
     }
 }
-int ff_dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     DnnLayerMathBinaryParams *params;
     int dnn_size = 0;
@@ -147,18 +148,18 @@
     return dnn_size;
 }
 
-int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                     int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes,
+                                 int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     const DnnOperand *input = &operands[input_operand_indexes[0]];
     DnnOperand *output = &operands[output_operand_index];
-    const DnnLayerMathBinaryParams *params = parameters;
+    const DnnLayerMathBinaryParams *params = (const DnnLayerMathBinaryParams *)parameters;
 
     for (int i = 0; i < 4; ++i)
         output->dims[i] = input->dims[i];
 
     output->data_type = input->data_type;
-    output->length = ff_calculate_operand_data_length(output);
+    output->length = calculate_operand_data_length(output);
     if (output->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
index eee294b..bb97ba2 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
@@ -47,8 +47,8 @@
     float v;
 } DnnLayerMathBinaryParams;
 
-int ff_dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                     int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes,
+                                 int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c
index 1bb05d0..ae5d4da 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c
@@ -29,7 +29,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_mathunary.h"
 
-int ff_dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     DnnLayerMathUnaryParams *params;
     int dnn_size = 0;
@@ -52,12 +52,12 @@
 
 }
 
-int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                    int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes,
+                                int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     const DnnOperand *input = &operands[input_operand_indexes[0]];
     DnnOperand *output = &operands[output_operand_index];
-    const DnnLayerMathUnaryParams *params = parameters;
+    const DnnLayerMathUnaryParams *params = (const DnnLayerMathUnaryParams *)parameters;
     int dims_count;
     const float *src;
     float *dst;
@@ -66,7 +66,7 @@
         output->dims[i] = input->dims[i];
 
     output->data_type = input->data_type;
-    output->length = ff_calculate_operand_data_length(output);
+    output->length = calculate_operand_data_length(output);
     if (output->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
@@ -77,7 +77,7 @@
         return DNN_ERROR;
     }
 
-    dims_count = ff_calculate_operand_dims_count(output);
+    dims_count = calculate_operand_dims_count(output);
     src = input->data;
     dst = output->data;
 
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h
index 2199931..301d02e 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h
@@ -53,8 +53,8 @@
     DNNMathUnaryOperation un_op;
 } DnnLayerMathUnaryParams;
 
-int ff_dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                    int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes,
+                                int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_maximum.c b/libavfilter/dnn/dnn_backend_native_layer_maximum.c
index 65af553..7ad5a22 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_maximum.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_maximum.c
@@ -27,7 +27,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_maximum.h"
 
-int ff_dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     DnnLayerMaximumParams *params;
     int dnn_size = 0;
@@ -49,12 +49,12 @@
     return dnn_size;
 }
 
-int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                 int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes,
+                              int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     const DnnOperand *input = &operands[input_operand_indexes[0]];
     DnnOperand *output = &operands[output_operand_index];
-    const DnnLayerMaximumParams *params = parameters;
+    const DnnLayerMaximumParams *params = (const DnnLayerMaximumParams *)parameters;
     int dims_count;
     const float *src;
     float *dst;
@@ -63,7 +63,7 @@
         output->dims[i] = input->dims[i];
 
     output->data_type = input->data_type;
-    output->length = ff_calculate_operand_data_length(output);
+    output->length = calculate_operand_data_length(output);
     if (output->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
@@ -74,7 +74,7 @@
         return DNN_ERROR;
     }
 
-    dims_count = ff_calculate_operand_dims_count(output);
+    dims_count = calculate_operand_dims_count(output);
     src = input->data;
     dst = output->data;
     for (int i = 0; i < dims_count; ++i)
diff --git a/libavfilter/dnn/dnn_backend_native_layer_maximum.h b/libavfilter/dnn/dnn_backend_native_layer_maximum.h
index 523acbe..be63a3a 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_maximum.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_maximum.h
@@ -37,8 +37,8 @@
     }val;
 } DnnLayerMaximumParams;
 
-int ff_dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                 int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes,
+                              int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.c b/libavfilter/dnn/dnn_backend_native_layer_pad.c
index a60451a..05892d4 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_pad.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_pad.c
@@ -22,7 +22,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_pad.h"
 
-int ff_dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
+int dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num)
 {
     LayerPadParams *params;
     int dnn_size = 0;
@@ -75,13 +75,13 @@
     }
 }
 
-int ff_dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes,
-                             int32_t output_operand_index, const void *parameters, NativeContext *ctx)
+int dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes,
+                          int32_t output_operand_index, const void *parameters, NativeContext *ctx)
 {
     int32_t before_paddings;
     int32_t after_paddings;
     float* output;
-    const LayerPadParams *params = parameters;
+    const LayerPadParams *params = (const LayerPadParams *)parameters;
 
     // suppose format is <N, H, W, C>
     int32_t input_operand_index = input_operand_indexes[0];
@@ -110,7 +110,7 @@
     output_operand->dims[2] = new_width;
     output_operand->dims[3] = new_channel;
     output_operand->data_type = operands[input_operand_index].data_type;
-    output_operand->length = ff_calculate_operand_data_length(output_operand);
+    output_operand->length = calculate_operand_data_length(output_operand);
     if (output_operand->length <= 0) {
         av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
         return DNN_ERROR;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.h b/libavfilter/dnn/dnn_backend_native_layer_pad.h
index 4f76c67..6c69211 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_pad.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_pad.h
@@ -36,8 +36,8 @@
     float constant_values;
 } LayerPadParams;
 
-int ff_dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes,
-                             int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+int dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
+int dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes,
+                          int32_t output_operand_index, const void *parameters, NativeContext *ctx);
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layers.c b/libavfilter/dnn/dnn_backend_native_layers.c
index 492939f..638a94e 100644
--- a/libavfilter/dnn/dnn_backend_native_layers.c
+++ b/libavfilter/dnn/dnn_backend_native_layers.c
@@ -29,14 +29,14 @@
 #include "dnn_backend_native_layer_avgpool.h"
 #include "dnn_backend_native_layer_dense.h"
 
-const LayerFunc ff_layer_funcs[DLT_COUNT] = {
+LayerFunc layer_funcs[DLT_COUNT] = {
     {NULL, NULL},
-    {ff_dnn_execute_layer_conv2d,      ff_dnn_load_layer_conv2d},
-    {ff_dnn_execute_layer_depth2space, ff_dnn_load_layer_depth2space},
-    {ff_dnn_execute_layer_pad,         ff_dnn_load_layer_pad},
-    {ff_dnn_execute_layer_maximum,     ff_dnn_load_layer_maximum},
-    {ff_dnn_execute_layer_math_binary, ff_dnn_load_layer_math_binary},
-    {ff_dnn_execute_layer_math_unary,  ff_dnn_load_layer_math_unary},
-    {ff_dnn_execute_layer_avg_pool,    ff_dnn_load_layer_avg_pool},
-    {ff_dnn_execute_layer_dense,       ff_dnn_load_layer_dense},
+    {dnn_execute_layer_conv2d,      dnn_load_layer_conv2d},
+    {dnn_execute_layer_depth2space, dnn_load_layer_depth2space},
+    {dnn_execute_layer_pad,         dnn_load_layer_pad},
+    {dnn_execute_layer_maximum,     dnn_load_layer_maximum},
+    {dnn_execute_layer_math_binary, dnn_load_layer_math_binary},
+    {dnn_execute_layer_math_unary,  dnn_load_layer_math_unary},
+    {dnn_execute_layer_avg_pool,  dnn_load_layer_avg_pool},
+    {dnn_execute_layer_dense,  dnn_load_layer_dense},
 };
diff --git a/libavfilter/dnn/dnn_backend_native_layers.h b/libavfilter/dnn/dnn_backend_native_layers.h
index bbd0292..dc76ace 100644
--- a/libavfilter/dnn/dnn_backend_native_layers.h
+++ b/libavfilter/dnn/dnn_backend_native_layers.h
@@ -33,6 +33,6 @@
     LAYER_LOAD_FUNC pf_load;
 }LayerFunc;
 
-extern const LayerFunc ff_layer_funcs[DLT_COUNT];
+extern LayerFunc layer_funcs[DLT_COUNT];
 
 #endif
diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 5be053b..d510e16 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -30,15 +30,10 @@
 #include "libavutil/opt.h"
 #include "libavutil/avstring.h"
 #include "../internal.h"
-#include "queue.h"
-#include "safe_queue.h"
 #include <c_api/ie_c_api.h>
 
 typedef struct OVOptions{
     char *device_type;
-    int nireq;
-    int batch_size;
-    int input_resizable;
 } OVOptions;
 
 typedef struct OVContext {
@@ -53,30 +48,8 @@
     ie_network_t *network;
     ie_executable_network_t *exe_network;
     ie_infer_request_t *infer_request;
-
-    /* for async execution */
-    SafeQueue *request_queue;   // holds RequestItem
-    Queue *task_queue;          // holds TaskItem
 } OVModel;
 
-typedef struct TaskItem {
-    OVModel *ov_model;
-    const char *input_name;
-    AVFrame *in_frame;
-    const char *output_name;
-    AVFrame *out_frame;
-    int do_ioproc;
-    int async;
-    int done;
-} TaskItem;
-
-typedef struct RequestItem {
-    ie_infer_request_t *infer_request;
-    TaskItem **tasks;
-    int task_count;
-    ie_complete_call_back_t callback;
-} RequestItem;
-
 #define APPEND_STRING(generated_string, iterate_string)                                            \
     generated_string = generated_string ? av_asprintf("%s %s", generated_string, iterate_string) : \
                                           av_asprintf("%s", iterate_string);
@@ -85,351 +58,30 @@
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption dnn_openvino_options[] = {
     { "device", "device to run model", OFFSET(options.device_type), AV_OPT_TYPE_STRING, { .str = "CPU" }, 0, 0, FLAGS },
-    { "nireq",  "number of request",   OFFSET(options.nireq),       AV_OPT_TYPE_INT,    { .i64 = 0 },     0, INT_MAX, FLAGS },
-    { "batch_size",  "batch size per request", OFFSET(options.batch_size),  AV_OPT_TYPE_INT,    { .i64 = 1 },     1, 1000, FLAGS},
-    { "input_resizable", "can input be resizable or not", OFFSET(options.input_resizable), AV_OPT_TYPE_BOOL,   { .i64 = 0 },     0, 1, FLAGS },
     { NULL }
 };
 
 AVFILTER_DEFINE_CLASS(dnn_openvino);
 
+static DNNReturnType execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
+                                      const char **output_names, uint32_t nb_output, AVFrame *out_frame,
+                                      int do_ioproc);
+
 static DNNDataType precision_to_datatype(precision_e precision)
 {
     switch (precision)
     {
     case FP32:
         return DNN_FLOAT;
-    case U8:
-        return DNN_UINT8;
     default:
         av_assert0(!"not supported yet.");
         return DNN_FLOAT;
     }
 }
 
-static int get_datatype_size(DNNDataType dt)
-{
-    switch (dt)
-    {
-    case DNN_FLOAT:
-        return sizeof(float);
-    case DNN_UINT8:
-        return sizeof(uint8_t);
-    default:
-        av_assert0(!"not supported yet.");
-        return 1;
-    }
-}
-
-static DNNReturnType fill_model_input_ov(OVModel *ov_model, RequestItem *request)
-{
-    dimensions_t dims;
-    precision_e precision;
-    ie_blob_buffer_t blob_buffer;
-    OVContext *ctx = &ov_model->ctx;
-    IEStatusCode status;
-    DNNData input;
-    ie_blob_t *input_blob = NULL;
-    TaskItem *task = request->tasks[0];
-
-    status = ie_infer_request_get_blob(request->infer_request, task->input_name, &input_blob);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to get input blob with name %s\n", task->input_name);
-        return DNN_ERROR;
-    }
-
-    status |= ie_blob_get_dims(input_blob, &dims);
-    status |= ie_blob_get_precision(input_blob, &precision);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to get input blob dims/precision\n");
-        return DNN_ERROR;
-    }
-
-    status = ie_blob_get_buffer(input_blob, &blob_buffer);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to get input blob buffer\n");
-        return DNN_ERROR;
-    }
-
-    input.height = dims.dims[2];
-    input.width = dims.dims[3];
-    input.channels = dims.dims[1];
-    input.data = blob_buffer.buffer;
-    input.dt = precision_to_datatype(precision);
-    // all models in openvino open model zoo use BGR as input,
-    // change to be an option when necessary.
-    input.order = DCO_BGR;
-
-    av_assert0(request->task_count <= dims.dims[0]);
-    for (int i = 0; i < request->task_count; ++i) {
-        task = request->tasks[i];
-        if (task->do_ioproc) {
-            if (ov_model->model->pre_proc != NULL) {
-                ov_model->model->pre_proc(task->in_frame, &input, ov_model->model->filter_ctx);
-            } else {
-                ff_proc_from_frame_to_dnn(task->in_frame, &input, ov_model->model->func_type, ctx);
-            }
-        }
-        input.data = (uint8_t *)input.data
-                     + input.width * input.height * input.channels * get_datatype_size(input.dt);
-    }
-    ie_blob_free(&input_blob);
-
-    return DNN_SUCCESS;
-}
-
-static void infer_completion_callback(void *args)
-{
-    dimensions_t dims;
-    precision_e precision;
-    IEStatusCode status;
-    RequestItem *request = args;
-    TaskItem *task = request->tasks[0];
-    SafeQueue *requestq = task->ov_model->request_queue;
-    ie_blob_t *output_blob = NULL;
-    ie_blob_buffer_t blob_buffer;
-    DNNData output;
-    OVContext *ctx = &task->ov_model->ctx;
-
-    status = ie_infer_request_get_blob(request->infer_request, task->output_name, &output_blob);
-    if (status != OK) {
-        //incorrect output name
-        char *model_output_name = NULL;
-        char *all_output_names = NULL;
-        size_t model_output_count = 0;
-        av_log(ctx, AV_LOG_ERROR, "Failed to get model output data\n");
-        status = ie_network_get_outputs_number(task->ov_model->network, &model_output_count);
-        for (size_t i = 0; i < model_output_count; i++) {
-            status = ie_network_get_output_name(task->ov_model->network, i, &model_output_name);
-            APPEND_STRING(all_output_names, model_output_name)
-        }
-        av_log(ctx, AV_LOG_ERROR,
-               "output \"%s\" may not correct, all output(s) are: \"%s\"\n",
-               task->output_name, all_output_names);
-        return;
-    }
-
-    status = ie_blob_get_buffer(output_blob, &blob_buffer);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to access output memory\n");
-        return;
-    }
-
-    status |= ie_blob_get_dims(output_blob, &dims);
-    status |= ie_blob_get_precision(output_blob, &precision);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to get dims or precision of output\n");
-        return;
-    }
-
-    output.channels = dims.dims[1];
-    output.height   = dims.dims[2];
-    output.width    = dims.dims[3];
-    output.dt       = precision_to_datatype(precision);
-    output.data     = blob_buffer.buffer;
-
-    av_assert0(request->task_count <= dims.dims[0]);
-    av_assert0(request->task_count >= 1);
-    for (int i = 0; i < request->task_count; ++i) {
-        task = request->tasks[i];
-        if (task->do_ioproc) {
-            if (task->ov_model->model->post_proc != NULL) {
-                task->ov_model->model->post_proc(task->out_frame, &output, task->ov_model->model->filter_ctx);
-            } else {
-                ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx);
-            }
-        } else {
-            task->out_frame->width = output.width;
-            task->out_frame->height = output.height;
-        }
-        task->done = 1;
-        output.data = (uint8_t *)output.data
-                      + output.width * output.height * output.channels * get_datatype_size(output.dt);
-    }
-    ie_blob_free(&output_blob);
-
-    request->task_count = 0;
-
-    if (task->async) {
-        if (ff_safe_queue_push_back(requestq, request) < 0) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n");
-            return;
-        }
-    }
-}
-
-static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, const char *output_name)
-{
-    OVContext *ctx = &ov_model->ctx;
-    IEStatusCode status;
-    ie_available_devices_t a_dev;
-    ie_config_t config = {NULL, NULL, NULL};
-    char *all_dev_names = NULL;
-
-    // batch size
-    if (ctx->options.batch_size <= 0) {
-        ctx->options.batch_size = 1;
-    }
-
-    if (ctx->options.batch_size > 1) {
-        input_shapes_t input_shapes;
-        status = ie_network_get_input_shapes(ov_model->network, &input_shapes);
-        if (status != OK)
-            goto err;
-        for (int i = 0; i < input_shapes.shape_num; i++)
-            input_shapes.shapes[i].shape.dims[0] = ctx->options.batch_size;
-        status = ie_network_reshape(ov_model->network, input_shapes);
-        ie_network_input_shapes_free(&input_shapes);
-        if (status != OK)
-            goto err;
-    }
-
-    // The order of dims in the openvino is fixed and it is always NCHW for 4-D data.
-    // while we pass NHWC data from FFmpeg to openvino
-    status = ie_network_set_input_layout(ov_model->network, input_name, NHWC);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for input %s\n", input_name);
-        goto err;
-    }
-    status = ie_network_set_output_layout(ov_model->network, output_name, NHWC);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for output %s\n", output_name);
-        goto err;
-    }
-
-    // all models in openvino open model zoo use BGR with range [0.0f, 255.0f] as input,
-    // we don't have a AVPixelFormat to descibe it, so we'll use AV_PIX_FMT_BGR24 and
-    // ask openvino to do the conversion internally.
-    // the current supported SR model (frame processing) is generated from tensorflow model,
-    // and its input is Y channel as float with range [0.0f, 1.0f], so do not set for this case.
-    // TODO: we need to get a final clear&general solution with all backends/formats considered.
-    if (ov_model->model->func_type != DFT_PROCESS_FRAME) {
-        status = ie_network_set_input_precision(ov_model->network, input_name, U8);
-        if (status != OK) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to set input precision as U8 for %s\n", input_name);
-            return DNN_ERROR;
-        }
-    }
-
-    status = ie_core_load_network(ov_model->core, ov_model->network, ctx->options.device_type, &config, &ov_model->exe_network);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to load OpenVINO model network\n");
-        status = ie_core_get_available_devices(ov_model->core, &a_dev);
-        if (status != OK) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to get available devices\n");
-            goto err;
-        }
-        for (int i = 0; i < a_dev.num_devices; i++) {
-            APPEND_STRING(all_dev_names, a_dev.devices[i])
-        }
-        av_log(ctx, AV_LOG_ERROR,"device %s may not be supported, all available devices are: \"%s\"\n",
-               ctx->options.device_type, all_dev_names);
-        goto err;
-    }
-
-    // create infer_request for sync execution
-    status = ie_exec_network_create_infer_request(ov_model->exe_network, &ov_model->infer_request);
-    if (status != OK)
-        goto err;
-
-    // create infer_requests for async execution
-    if (ctx->options.nireq <= 0) {
-        // the default value is a rough estimation
-        ctx->options.nireq = av_cpu_count() / 2 + 1;
-    }
-
-    ov_model->request_queue = ff_safe_queue_create();
-    if (!ov_model->request_queue) {
-        goto err;
-    }
-
-    for (int i = 0; i < ctx->options.nireq; i++) {
-        RequestItem *item = av_mallocz(sizeof(*item));
-        if (!item) {
-            goto err;
-        }
-
-        status = ie_exec_network_create_infer_request(ov_model->exe_network, &item->infer_request);
-        if (status != OK) {
-            av_freep(&item);
-            goto err;
-        }
-
-        item->tasks = av_malloc_array(ctx->options.batch_size, sizeof(*item->tasks));
-        if (!item->tasks) {
-            av_freep(&item);
-            goto err;
-        }
-        item->task_count = 0;
-
-        item->callback.completeCallBackFunc = infer_completion_callback;
-        item->callback.args = item;
-        if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
-            av_freep(&item);
-            goto err;
-        }
-    }
-
-    ov_model->task_queue = ff_queue_create();
-    if (!ov_model->task_queue) {
-        goto err;
-    }
-
-    return DNN_SUCCESS;
-
-err:
-    ff_dnn_free_model_ov(&ov_model->model);
-    return DNN_ERROR;
-}
-
-static DNNReturnType execute_model_ov(RequestItem *request)
-{
-    IEStatusCode status;
-    DNNReturnType ret;
-    TaskItem *task = request->tasks[0];
-    OVContext *ctx = &task->ov_model->ctx;
-
-    if (task->async) {
-        if (request->task_count < ctx->options.batch_size) {
-            if (ff_safe_queue_push_front(task->ov_model->request_queue, request) < 0) {
-                av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n");
-                return DNN_ERROR;
-            }
-            return DNN_SUCCESS;
-        }
-        ret = fill_model_input_ov(task->ov_model, request);
-        if (ret != DNN_SUCCESS) {
-            return ret;
-        }
-        status = ie_infer_set_completion_callback(request->infer_request, &request->callback);
-        if (status != OK) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to set completion callback for inference\n");
-            return DNN_ERROR;
-        }
-        status = ie_infer_request_infer_async(request->infer_request);
-        if (status != OK) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to start async inference\n");
-            return DNN_ERROR;
-        }
-        return DNN_SUCCESS;
-    } else {
-        ret = fill_model_input_ov(task->ov_model, request);
-        if (ret != DNN_SUCCESS) {
-            return ret;
-        }
-        status = ie_infer_request_infer(request->infer_request);
-        if (status != OK) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to start synchronous model inference\n");
-            return DNN_ERROR;
-        }
-        infer_completion_callback(request);
-        return task->done ? DNN_SUCCESS : DNN_ERROR;
-    }
-}
-
 static DNNReturnType get_input_ov(void *model, DNNData *input, const char *input_name)
 {
-    OVModel *ov_model = model;
+    OVModel *ov_model = (OVModel *)model;
     OVContext *ctx = &ov_model->ctx;
     char *model_input_name = NULL;
     char *all_input_names = NULL;
@@ -437,7 +89,6 @@
     size_t model_input_count = 0;
     dimensions_t dims;
     precision_e precision;
-    int input_resizable = ctx->options.input_resizable;
 
     status = ie_network_get_inputs_number(ov_model->network, &model_input_count);
     if (status != OK) {
@@ -460,9 +111,17 @@
                 return DNN_ERROR;
             }
 
+            // The order of dims in the openvino is fixed and it is always NCHW for 4-D data.
+            // while we pass NHWC data from FFmpeg to openvino
+            status = ie_network_set_input_layout(ov_model->network, input_name, NHWC);
+            if (status != OK) {
+                av_log(ctx, AV_LOG_ERROR, "Input \"%s\" does not match layout NHWC\n", input_name);
+                return DNN_ERROR;
+            }
+
             input->channels = dims.dims[1];
-            input->height   = input_resizable ? -1 : dims.dims[2];
-            input->width    = input_resizable ? -1 : dims.dims[3];
+            input->height   = dims.dims[2];
+            input->width    = dims.dims[3];
             input->dt       = precision_to_datatype(precision);
             return DNN_SUCCESS;
         } else {
@@ -481,15 +140,10 @@
                                    const char *output_name, int *output_width, int *output_height)
 {
     DNNReturnType ret;
-    OVModel *ov_model = model;
+    OVModel *ov_model = (OVModel *)model;
     OVContext *ctx = &ov_model->ctx;
-    TaskItem task;
-    RequestItem request;
     AVFrame *in_frame = av_frame_alloc();
     AVFrame *out_frame = NULL;
-    TaskItem *ptask = &task;
-    IEStatusCode status;
-    input_shapes_t input_shapes;
 
     if (!in_frame) {
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input frame\n");
@@ -504,39 +158,7 @@
     in_frame->width = input_width;
     in_frame->height = input_height;
 
-    if (ctx->options.input_resizable) {
-        status = ie_network_get_input_shapes(ov_model->network, &input_shapes);
-        input_shapes.shapes->shape.dims[2] = input_height;
-        input_shapes.shapes->shape.dims[3] = input_width;
-        status |= ie_network_reshape(ov_model->network, input_shapes);
-        ie_network_input_shapes_free(&input_shapes);
-        if (status != OK) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to reshape input size for %s\n", input_name);
-            return DNN_ERROR;
-        }
-    }
-
-    if (!ov_model->exe_network) {
-        if (init_model_ov(ov_model, input_name, output_name) != DNN_SUCCESS) {
-            av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
-            return DNN_ERROR;
-        }
-    }
-
-    task.done = 0;
-    task.do_ioproc = 0;
-    task.async = 0;
-    task.input_name = input_name;
-    task.in_frame = in_frame;
-    task.output_name = output_name;
-    task.out_frame = out_frame;
-    task.ov_model = ov_model;
-
-    request.infer_request = ov_model->infer_request;
-    request.task_count = 1;
-    request.tasks = &ptask;
-
-    ret = execute_model_ov(&request);
+    ret = execute_model_ov(ov_model->model, input_name, in_frame, &output_name, 1, out_frame, 0);
     *output_width = out_frame->width;
     *output_height = out_frame->height;
 
@@ -545,12 +167,15 @@
     return ret;
 }
 
-DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx)
+DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, void *userdata)
 {
+    char *all_dev_names = NULL;
     DNNModel *model = NULL;
     OVModel *ov_model = NULL;
     OVContext *ctx = NULL;
     IEStatusCode status;
+    ie_config_t config = {NULL, NULL, NULL};
+    ie_available_devices_t a_dev;
 
     model = av_mallocz(sizeof(DNNModel));
     if (!model){
@@ -558,11 +183,8 @@
     }
 
     ov_model = av_mallocz(sizeof(OVModel));
-    if (!ov_model) {
-        av_freep(&model);
-        return NULL;
-    }
-    model->model = ov_model;
+    if (!ov_model)
+        goto err;
     ov_model->model = model;
     ov_model->ctx.class = &dnn_openvino_class;
     ctx = &ov_model->ctx;
@@ -579,223 +201,191 @@
         goto err;
 
     status = ie_core_read_network(ov_model->core, model_filename, NULL, &ov_model->network);
+    if (status != OK)
+        goto err;
+
+    status = ie_core_load_network(ov_model->core, ov_model->network, ctx->options.device_type, &config, &ov_model->exe_network);
     if (status != OK) {
-        ie_version_t ver;
-        ver = ie_c_api_version();
-        av_log(ctx, AV_LOG_ERROR, "Failed to read the network from model file %s,\n"
-                                  "Please check if the model version matches the runtime OpenVINO %s\n",
-                                   model_filename, ver.api_version);
-        ie_version_free(&ver);
+        av_log(ctx, AV_LOG_ERROR, "Failed to init OpenVINO model\n");
+        status = ie_core_get_available_devices(ov_model->core, &a_dev);
+        if (status != OK) {
+            av_log(ctx, AV_LOG_ERROR, "Failed to get available devices\n");
+            goto err;
+        }
+        for (int i = 0; i < a_dev.num_devices; i++) {
+            APPEND_STRING(all_dev_names, a_dev.devices[i])
+        }
+        av_log(ctx, AV_LOG_ERROR,"device %s may not be supported, all available devices are: \"%s\"\n",
+               ctx->options.device_type, all_dev_names);
         goto err;
     }
 
+    status = ie_exec_network_create_infer_request(ov_model->exe_network, &ov_model->infer_request);
+    if (status != OK)
+        goto err;
+
+    model->model = (void *)ov_model;
     model->get_input = &get_input_ov;
     model->get_output = &get_output_ov;
     model->options = options;
-    model->filter_ctx = filter_ctx;
-    model->func_type = func_type;
+    model->userdata = userdata;
 
     return model;
 
 err:
-    ff_dnn_free_model_ov(&model);
+    if (model)
+        av_freep(&model);
+    if (ov_model) {
+        if (ov_model->infer_request)
+            ie_infer_request_free(&ov_model->infer_request);
+        if (ov_model->exe_network)
+            ie_exec_network_free(&ov_model->exe_network);
+        if (ov_model->network)
+            ie_network_free(&ov_model->network);
+        if (ov_model->core)
+            ie_core_free(&ov_model->core);
+        av_freep(&ov_model);
+    }
     return NULL;
 }
 
+static DNNReturnType execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
+                                      const char **output_names, uint32_t nb_output, AVFrame *out_frame,
+                                      int do_ioproc)
+{
+    char *model_output_name = NULL;
+    char *all_output_names = NULL;
+    dimensions_t dims;
+    precision_e precision;
+    ie_blob_buffer_t blob_buffer;
+    OVModel *ov_model = (OVModel *)model->model;
+    OVContext *ctx = &ov_model->ctx;
+    IEStatusCode status;
+    size_t model_output_count = 0;
+    DNNData input, output;
+    ie_blob_t *input_blob = NULL;
+
+    status = ie_infer_request_get_blob(ov_model->infer_request, input_name, &input_blob);
+    if (status != OK) {
+        av_log(ctx, AV_LOG_ERROR, "Failed to get input blob\n");
+        return DNN_ERROR;
+    }
+
+    status |= ie_blob_get_dims(input_blob, &dims);
+    status |= ie_blob_get_precision(input_blob, &precision);
+    if (status != OK) {
+        av_log(ctx, AV_LOG_ERROR, "Failed to get input blob dims/precision\n");
+        return DNN_ERROR;
+    }
+
+    status = ie_blob_get_buffer(input_blob, &blob_buffer);
+    if (status != OK) {
+        av_log(ctx, AV_LOG_ERROR, "Failed to get input blob buffer\n");
+        return DNN_ERROR;
+    }
+
+    input.height = dims.dims[2];
+    input.width = dims.dims[3];
+    input.channels = dims.dims[1];
+    input.data = blob_buffer.buffer;
+    input.dt = precision_to_datatype(precision);
+    if (do_ioproc) {
+        if (ov_model->model->pre_proc != NULL) {
+            ov_model->model->pre_proc(in_frame, &input, ov_model->model->userdata);
+        } else {
+            proc_from_frame_to_dnn(in_frame, &input, ctx);
+        }
+    }
+    ie_blob_free(&input_blob);
+
+    if (nb_output != 1) {
+        // currently, the filter does not need multiple outputs,
+        // so we just pending the support until we really need it.
+        av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
+        return DNN_ERROR;
+    }
+
+    status = ie_infer_request_infer(ov_model->infer_request);
+    if (status != OK) {
+        av_log(ctx, AV_LOG_ERROR, "Failed to start synchronous model inference\n");
+        return DNN_ERROR;
+    }
+
+    for (uint32_t i = 0; i < nb_output; ++i) {
+        const char *output_name = output_names[i];
+        ie_blob_t *output_blob = NULL;
+        status = ie_infer_request_get_blob(ov_model->infer_request, output_name, &output_blob);
+        if (status != OK) {
+            //incorrect output name
+            av_log(ctx, AV_LOG_ERROR, "Failed to get model output data\n");
+            status = ie_network_get_outputs_number(ov_model->network, &model_output_count);
+            for (size_t i = 0; i < model_output_count; i++) {
+                status = ie_network_get_output_name(ov_model->network, i, &model_output_name);
+                APPEND_STRING(all_output_names, model_output_name)
+            }
+            av_log(ctx, AV_LOG_ERROR,
+                   "output \"%s\" may not correct, all output(s) are: \"%s\"\n",
+                   output_name, all_output_names);
+            return DNN_ERROR;
+        }
+
+        status = ie_blob_get_buffer(output_blob, &blob_buffer);
+        if (status != OK) {
+            av_log(ctx, AV_LOG_ERROR, "Failed to access output memory\n");
+            return DNN_ERROR;
+        }
+
+        status |= ie_blob_get_dims(output_blob, &dims);
+        status |= ie_blob_get_precision(output_blob, &precision);
+        if (status != OK) {
+            av_log(ctx, AV_LOG_ERROR, "Failed to get dims or precision of output\n");
+            return DNN_ERROR;
+        }
+
+        output.channels = dims.dims[1];
+        output.height   = dims.dims[2];
+        output.width    = dims.dims[3];
+        output.dt       = precision_to_datatype(precision);
+        output.data     = blob_buffer.buffer;
+        if (do_ioproc) {
+            if (ov_model->model->post_proc != NULL) {
+                ov_model->model->post_proc(out_frame, &output, ov_model->model->userdata);
+            } else {
+                proc_from_dnn_to_frame(out_frame, &output, ctx);
+            }
+        } else {
+            out_frame->width = output.width;
+            out_frame->height = output.height;
+        }
+        ie_blob_free(&output_blob);
+    }
+
+    return DNN_SUCCESS;
+}
+
 DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                       const char **output_names, uint32_t nb_output, AVFrame *out_frame)
 {
-    OVModel *ov_model = model->model;
+    OVModel *ov_model = (OVModel *)model->model;
     OVContext *ctx = &ov_model->ctx;
-    TaskItem task;
-    RequestItem request;
-    TaskItem *ptask = &task;
 
     if (!in_frame) {
         av_log(ctx, AV_LOG_ERROR, "in frame is NULL when execute model.\n");
         return DNN_ERROR;
     }
 
-    if (!out_frame && model->func_type == DFT_PROCESS_FRAME) {
+    if (!out_frame) {
         av_log(ctx, AV_LOG_ERROR, "out frame is NULL when execute model.\n");
         return DNN_ERROR;
     }
 
-    if (nb_output != 1) {
-        // currently, the filter does not need multiple outputs,
-        // so we just pending the support until we really need it.
-        avpriv_report_missing_feature(ctx, "multiple outputs");
-        return DNN_ERROR;
-    }
-
-    if (ctx->options.batch_size > 1) {
-        avpriv_report_missing_feature(ctx, "batch mode for sync execution");
-        return DNN_ERROR;
-    }
-
-    if (!ov_model->exe_network) {
-        if (init_model_ov(ov_model, input_name, output_names[0]) != DNN_SUCCESS) {
-            av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
-            return DNN_ERROR;
-        }
-    }
-
-    task.done = 0;
-    task.do_ioproc = 1;
-    task.async = 0;
-    task.input_name = input_name;
-    task.in_frame = in_frame;
-    task.output_name = output_names[0];
-    task.out_frame = out_frame;
-    task.ov_model = ov_model;
-
-    request.infer_request = ov_model->infer_request;
-    request.task_count = 1;
-    request.tasks = &ptask;
-
-    return execute_model_ov(&request);
-}
-
-DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
-                                            const char **output_names, uint32_t nb_output, AVFrame *out_frame)
-{
-    OVModel *ov_model = model->model;
-    OVContext *ctx = &ov_model->ctx;
-    RequestItem *request;
-    TaskItem *task;
-
-    if (!in_frame) {
-        av_log(ctx, AV_LOG_ERROR, "in frame is NULL when async execute model.\n");
-        return DNN_ERROR;
-    }
-
-    if (!out_frame && model->func_type == DFT_PROCESS_FRAME) {
-        av_log(ctx, AV_LOG_ERROR, "out frame is NULL when async execute model.\n");
-        return DNN_ERROR;
-    }
-
-    task = av_malloc(sizeof(*task));
-    if (!task) {
-        av_log(ctx, AV_LOG_ERROR, "unable to alloc memory for task item.\n");
-        return DNN_ERROR;
-    }
-
-    if (!ov_model->exe_network) {
-        if (init_model_ov(ov_model, input_name, output_names[0]) != DNN_SUCCESS) {
-            av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
-            return DNN_ERROR;
-        }
-    }
-
-    task->done = 0;
-    task->do_ioproc = 1;
-    task->async = 1;
-    task->input_name = input_name;
-    task->in_frame = in_frame;
-    task->output_name = output_names[0];
-    task->out_frame = out_frame;
-    task->ov_model = ov_model;
-    if (ff_queue_push_back(ov_model->task_queue, task) < 0) {
-        av_freep(&task);
-        av_log(ctx, AV_LOG_ERROR, "unable to push back task_queue.\n");
-        return DNN_ERROR;
-    }
-
-    request = ff_safe_queue_pop_front(ov_model->request_queue);
-    if (!request) {
-        av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");
-        return DNN_ERROR;
-    }
-
-    request->tasks[request->task_count++] = task;
-    return execute_model_ov(request);
-}
-
-DNNAsyncStatusType ff_dnn_get_async_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out)
-{
-    OVModel *ov_model = model->model;
-    TaskItem *task = ff_queue_peek_front(ov_model->task_queue);
-
-    if (!task) {
-        return DAST_EMPTY_QUEUE;
-    }
-
-    if (!task->done) {
-        return DAST_NOT_READY;
-    }
-
-    *in = task->in_frame;
-    *out = task->out_frame;
-    ff_queue_pop_front(ov_model->task_queue);
-    av_freep(&task);
-
-    return DAST_SUCCESS;
-}
-
-DNNReturnType ff_dnn_flush_ov(const DNNModel *model)
-{
-    OVModel *ov_model = model->model;
-    OVContext *ctx = &ov_model->ctx;
-    RequestItem *request;
-    IEStatusCode status;
-    DNNReturnType ret;
-
-    request = ff_safe_queue_pop_front(ov_model->request_queue);
-    if (!request) {
-        av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");
-        return DNN_ERROR;
-    }
-
-    if (request->task_count == 0) {
-        // no pending task need to flush
-        if (ff_safe_queue_push_back(ov_model->request_queue, request) < 0) {
-            av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n");
-            return DNN_ERROR;
-        }
-        return DNN_SUCCESS;
-    }
-
-    ret = fill_model_input_ov(ov_model, request);
-    if (ret != DNN_SUCCESS) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to fill model input.\n");
-        return ret;
-    }
-    status = ie_infer_set_completion_callback(request->infer_request, &request->callback);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to set completion callback for inference\n");
-        return DNN_ERROR;
-    }
-    status = ie_infer_request_infer_async(request->infer_request);
-    if (status != OK) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to start async inference\n");
-        return DNN_ERROR;
-    }
-
-    return DNN_SUCCESS;
+    return execute_model_ov(model, input_name, in_frame, output_names, nb_output, out_frame, 1);
 }
 
 void ff_dnn_free_model_ov(DNNModel **model)
 {
     if (*model){
-        OVModel *ov_model = (*model)->model;
-        while (ff_safe_queue_size(ov_model->request_queue) != 0) {
-            RequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue);
-            if (item && item->infer_request) {
-                ie_infer_request_free(&item->infer_request);
-            }
-            av_freep(&item->tasks);
-            av_freep(&item);
-        }
-        ff_safe_queue_destroy(ov_model->request_queue);
-
-        while (ff_queue_size(ov_model->task_queue) != 0) {
-            TaskItem *item = ff_queue_pop_front(ov_model->task_queue);
-            av_frame_free(&item->in_frame);
-            av_frame_free(&item->out_frame);
-            av_freep(&item);
-        }
-        ff_queue_destroy(ov_model->task_queue);
-
+        OVModel *ov_model = (OVModel *)(*model)->model;
         if (ov_model->infer_request)
             ie_infer_request_free(&ov_model->infer_request);
         if (ov_model->exe_network)
diff --git a/libavfilter/dnn/dnn_backend_openvino.h b/libavfilter/dnn/dnn_backend_openvino.h
index a484a7b..3f8f01d 100644
--- a/libavfilter/dnn/dnn_backend_openvino.h
+++ b/libavfilter/dnn/dnn_backend_openvino.h
@@ -29,14 +29,10 @@
 
 #include "../dnn_interface.h"
 
-DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx);
+DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, void *userdata);
 
 DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                       const char **output_names, uint32_t nb_output, AVFrame *out_frame);
-DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
-                                            const char **output_names, uint32_t nb_output, AVFrame *out_frame);
-DNNAsyncStatusType ff_dnn_get_async_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out);
-DNNReturnType ff_dnn_flush_ov(const DNNModel *model);
 
 void ff_dnn_free_model_ov(DNNModel **model);
 
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index 750a476..76cc037 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -97,7 +97,7 @@
     }
 
     graph_buf = TF_NewBuffer();
-    graph_buf->data = graph_data;
+    graph_buf->data = (void *)graph_data;
     graph_buf->length = size;
     graph_buf->data_deallocator = free_buffer;
 
@@ -128,7 +128,7 @@
 
 static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input_name)
 {
-    TFModel *tf_model = model;
+    TFModel *tf_model = (TFModel *)model;
     TFContext *ctx = &tf_model->ctx;
     TF_Status *status;
     int64_t dims[4];
@@ -165,7 +165,7 @@
                                    const char *output_name, int *output_width, int *output_height)
 {
     DNNReturnType ret;
-    TFModel *tf_model = model;
+    TFModel *tf_model = (TFModel *)model;
     TFContext *ctx = &tf_model->ctx;
     AVFrame *in_frame = av_frame_alloc();
     AVFrame *out_frame = NULL;
@@ -424,7 +424,7 @@
         op_desc = TF_NewOperation(tf_model->graph, "Sigmoid", name_buffer);
         break;
     default:
-        avpriv_report_missing_feature(ctx, "convolutional activation function %d", params->activation);
+        av_log(ctx, AV_LOG_ERROR, "Unsupported convolutional activation function\n");
         return DNN_ERROR;
     }
     input.oper = *cur_op;
@@ -580,13 +580,13 @@
     DNNModel *model = NULL;
     NativeModel *native_model;
 
-    model = ff_dnn_load_model_native(model_filename, DFT_PROCESS_FRAME, NULL, NULL);
+    model = ff_dnn_load_model_native(model_filename, NULL, NULL);
     if (!model){
         av_log(ctx, AV_LOG_ERROR, "Failed to load native model\n");
         return DNN_ERROR;
     }
 
-    native_model = model->model;
+    native_model = (NativeModel *)model->model;
     tf_model->graph = TF_NewGraph();
     tf_model->status = TF_NewStatus();
 
@@ -664,7 +664,7 @@
     return DNN_SUCCESS;
 }
 
-DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx)
+DNNModel *ff_dnn_load_model_tf(const char *model_filename, const char *options, void *userdata)
 {
     DNNModel *model = NULL;
     TFModel *tf_model = NULL;
@@ -700,12 +700,11 @@
         }
     }
 
-    model->model = tf_model;
+    model->model = (void *)tf_model;
     model->get_input = &get_input_tf;
     model->get_output = &get_output_tf;
     model->options = options;
-    model->filter_ctx = filter_ctx;
-    model->func_type = func_type;
+    model->userdata = userdata;
 
     return model;
 }
@@ -715,7 +714,7 @@
                                       int do_ioproc)
 {
     TF_Output *tf_outputs;
-    TFModel *tf_model = model->model;
+    TFModel *tf_model = (TFModel *)model->model;
     TFContext *ctx = &tf_model->ctx;
     DNNData input, output;
     TF_Tensor **output_tensors;
@@ -742,16 +741,16 @@
 
     if (do_ioproc) {
         if (tf_model->model->pre_proc != NULL) {
-            tf_model->model->pre_proc(in_frame, &input, tf_model->model->filter_ctx);
+            tf_model->model->pre_proc(in_frame, &input, tf_model->model->userdata);
         } else {
-            ff_proc_from_frame_to_dnn(in_frame, &input, tf_model->model->func_type, ctx);
+            proc_from_frame_to_dnn(in_frame, &input, ctx);
         }
     }
 
     if (nb_output != 1) {
         // currently, the filter does not need multiple outputs,
         // so we just pending the support until we really need it.
-        avpriv_report_missing_feature(ctx, "multiple outputs");
+        av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
         return DNN_ERROR;
     }
 
@@ -799,9 +798,9 @@
 
         if (do_ioproc) {
             if (tf_model->model->post_proc != NULL) {
-                tf_model->model->post_proc(out_frame, &output, tf_model->model->filter_ctx);
+                tf_model->model->post_proc(out_frame, &output, tf_model->model->userdata);
             } else {
-                ff_proc_from_dnn_to_frame(out_frame, &output, ctx);
+                proc_from_dnn_to_frame(out_frame, &output, ctx);
             }
         } else {
             out_frame->width = output.width;
@@ -823,7 +822,7 @@
 DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                       const char **output_names, uint32_t nb_output, AVFrame *out_frame)
 {
-    TFModel *tf_model = model->model;
+    TFModel *tf_model = (TFModel *)model->model;
     TFContext *ctx = &tf_model->ctx;
 
     if (!in_frame) {
@@ -844,7 +843,7 @@
     TFModel *tf_model;
 
     if (*model){
-        tf_model = (*model)->model;
+        tf_model = (TFModel *)(*model)->model;
         if (tf_model->graph){
             TF_DeleteGraph(tf_model->graph);
         }
diff --git a/libavfilter/dnn/dnn_backend_tf.h b/libavfilter/dnn/dnn_backend_tf.h
index 8cec047..1e00669 100644
--- a/libavfilter/dnn/dnn_backend_tf.h
+++ b/libavfilter/dnn/dnn_backend_tf.h
@@ -29,7 +29,7 @@
 
 #include "../dnn_interface.h"
 
-DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx);
+DNNModel *ff_dnn_load_model_tf(const char *model_filename, const char *options, void *userdata);
 
 DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                       const char **output_names, uint32_t nb_output, AVFrame *out_frame);
diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c
index 02e532f..7973d3e 100644
--- a/libavfilter/dnn/dnn_interface.c
+++ b/libavfilter/dnn/dnn_interface.c
@@ -33,7 +33,7 @@
 {
     DNNModule *dnn_module;
 
-    dnn_module = av_mallocz(sizeof(DNNModule));
+    dnn_module = av_malloc(sizeof(DNNModule));
     if(!dnn_module){
         return NULL;
     }
@@ -58,9 +58,6 @@
     #if (CONFIG_LIBOPENVINO == 1)
         dnn_module->load_model = &ff_dnn_load_model_ov;
         dnn_module->execute_model = &ff_dnn_execute_model_ov;
-        dnn_module->execute_model_async = &ff_dnn_execute_model_async_ov;
-        dnn_module->get_async_result = &ff_dnn_get_async_result_ov;
-        dnn_module->flush = &ff_dnn_flush_ov;
         dnn_module->free_model = &ff_dnn_free_model_ov;
     #else
         av_freep(&dnn_module);
diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index e104cc5..8ce1959 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -21,14 +21,13 @@
 #include "dnn_io_proc.h"
 #include "libavutil/imgutils.h"
 #include "libswscale/swscale.h"
-#include "libavutil/avassert.h"
 
-DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
+DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
 {
     struct SwsContext *sws_ctx;
     int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
     if (output->dt != DNN_FLOAT) {
-        avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT");
+        av_log(log_ctx, AV_LOG_ERROR, "do not support data type rather than DNN_FLOAT\n");
         return DNN_ERROR;
     }
 
@@ -42,13 +41,6 @@
                                  frame->height,
                                  AV_PIX_FMT_GRAY8,
                                  0, NULL, NULL, NULL);
-        if (!sws_ctx) {
-            av_log(log_ctx, AV_LOG_ERROR, "Impossible to create scale context for the conversion "
-                "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32), frame->width * 3, frame->height,
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAY8),   frame->width * 3, frame->height);
-            return DNN_ERROR;
-        }
         sws_scale(sws_ctx, (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0},
                            (const int[4]){frame->width * 3 * sizeof(float), 0, 0, 0}, 0, frame->height,
                            (uint8_t * const*)frame->data, frame->linesize);
@@ -65,7 +57,6 @@
     case AV_PIX_FMT_YUV410P:
     case AV_PIX_FMT_YUV411P:
     case AV_PIX_FMT_GRAY8:
-    case AV_PIX_FMT_NV12:
         sws_ctx = sws_getContext(frame->width,
                                  frame->height,
                                  AV_PIX_FMT_GRAYF32,
@@ -73,32 +64,25 @@
                                  frame->height,
                                  AV_PIX_FMT_GRAY8,
                                  0, NULL, NULL, NULL);
-        if (!sws_ctx) {
-            av_log(log_ctx, AV_LOG_ERROR, "Impossible to create scale context for the conversion "
-                "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32), frame->width, frame->height,
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAY8),   frame->width, frame->height);
-            return DNN_ERROR;
-        }
         sws_scale(sws_ctx, (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0},
                            (const int[4]){frame->width * sizeof(float), 0, 0, 0}, 0, frame->height,
                            (uint8_t * const*)frame->data, frame->linesize);
         sws_freeContext(sws_ctx);
         return DNN_SUCCESS;
     default:
-        avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format));
+        av_log(log_ctx, AV_LOG_ERROR, "do not support frame format %d\n", frame->format);
         return DNN_ERROR;
     }
 
     return DNN_SUCCESS;
 }
 
-static DNNReturnType proc_from_frame_to_dnn_frameprocessing(AVFrame *frame, DNNData *input, void *log_ctx)
+DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
 {
     struct SwsContext *sws_ctx;
     int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
     if (input->dt != DNN_FLOAT) {
-        avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT");
+        av_log(log_ctx, AV_LOG_ERROR, "do not support data type rather than DNN_FLOAT\n");
         return DNN_ERROR;
     }
 
@@ -112,13 +96,6 @@
                                  frame->height,
                                  AV_PIX_FMT_GRAYF32,
                                  0, NULL, NULL, NULL);
-        if (!sws_ctx) {
-            av_log(log_ctx, AV_LOG_ERROR, "Impossible to create scale context for the conversion "
-                "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAY8),  frame->width * 3, frame->height,
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32),frame->width * 3, frame->height);
-            return DNN_ERROR;
-        }
         sws_scale(sws_ctx, (const uint8_t **)frame->data,
                            frame->linesize, 0, frame->height,
                            (uint8_t * const*)(&input->data),
@@ -136,7 +113,6 @@
     case AV_PIX_FMT_YUV410P:
     case AV_PIX_FMT_YUV411P:
     case AV_PIX_FMT_GRAY8:
-    case AV_PIX_FMT_NV12:
         sws_ctx = sws_getContext(frame->width,
                                  frame->height,
                                  AV_PIX_FMT_GRAY8,
@@ -144,13 +120,6 @@
                                  frame->height,
                                  AV_PIX_FMT_GRAYF32,
                                  0, NULL, NULL, NULL);
-        if (!sws_ctx) {
-            av_log(log_ctx, AV_LOG_ERROR, "Impossible to create scale context for the conversion "
-                "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAY8),  frame->width, frame->height,
-                av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32),frame->width, frame->height);
-            return DNN_ERROR;
-        }
         sws_scale(sws_ctx, (const uint8_t **)frame->data,
                            frame->linesize, 0, frame->height,
                            (uint8_t * const*)(&input->data),
@@ -158,62 +127,9 @@
         sws_freeContext(sws_ctx);
         break;
     default:
-        avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format));
+        av_log(log_ctx, AV_LOG_ERROR, "do not support frame format %d\n", frame->format);
         return DNN_ERROR;
     }
 
     return DNN_SUCCESS;
 }
-
-static enum AVPixelFormat get_pixel_format(DNNData *data)
-{
-    if (data->dt == DNN_UINT8 && data->order == DCO_BGR) {
-        return AV_PIX_FMT_BGR24;
-    }
-
-    av_assert0(!"not supported yet.\n");
-    return AV_PIX_FMT_BGR24;
-}
-
-static DNNReturnType proc_from_frame_to_dnn_analytics(AVFrame *frame, DNNData *input, void *log_ctx)
-{
-    struct SwsContext *sws_ctx;
-    int linesizes[4];
-    enum AVPixelFormat fmt = get_pixel_format(input);
-    sws_ctx = sws_getContext(frame->width, frame->height, frame->format,
-                             input->width, input->height, fmt,
-                             SWS_FAST_BILINEAR, NULL, NULL, NULL);
-    if (!sws_ctx) {
-        av_log(log_ctx, AV_LOG_ERROR, "Impossible to create scale context for the conversion "
-            "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
-            av_get_pix_fmt_name(frame->format), frame->width, frame->height,
-            av_get_pix_fmt_name(fmt), input->width, input->height);
-        return DNN_ERROR;
-    }
-
-    if (av_image_fill_linesizes(linesizes, fmt, input->width) < 0) {
-        av_log(log_ctx, AV_LOG_ERROR, "unable to get linesizes with av_image_fill_linesizes");
-        sws_freeContext(sws_ctx);
-        return DNN_ERROR;
-    }
-
-    sws_scale(sws_ctx, (const uint8_t *const *)frame->data, frame->linesize, 0, frame->height,
-                       (uint8_t *const *)(&input->data), linesizes);
-
-    sws_freeContext(sws_ctx);
-    return DNN_SUCCESS;
-}
-
-DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, DNNFunctionType func_type, void *log_ctx)
-{
-    switch (func_type)
-    {
-    case DFT_PROCESS_FRAME:
-        return proc_from_frame_to_dnn_frameprocessing(frame, input, log_ctx);
-    case DFT_ANALYTICS_DETECT:
-        return proc_from_frame_to_dnn_analytics(frame, input, log_ctx);
-    default:
-        avpriv_report_missing_feature(log_ctx, "model function type %d", func_type);
-        return DNN_ERROR;
-    }
-}
diff --git a/libavfilter/dnn/dnn_io_proc.h b/libavfilter/dnn/dnn_io_proc.h
index 91ad3cb..4c7dc7c 100644
--- a/libavfilter/dnn/dnn_io_proc.h
+++ b/libavfilter/dnn/dnn_io_proc.h
@@ -30,7 +30,7 @@
 #include "../dnn_interface.h"
 #include "libavutil/frame.h"
 
-DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, DNNFunctionType func_type, void *log_ctx);
-DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx);
+DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx);
+DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx);
 
 #endif
diff --git a/libavfilter/dnn/queue.c b/libavfilter/dnn/queue.c
deleted file mode 100644
index 954437a..0000000
--- a/libavfilter/dnn/queue.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2020
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include "queue.h"
-#include "libavutil/mem.h"
-#include "libavutil/avassert.h"
-
-typedef struct QueueEntry QueueEntry;
-
-struct QueueEntry {
-    void *value;
-    QueueEntry *prev;
-    QueueEntry *next;
-};
-
-struct Queue {
-    QueueEntry *head;
-    QueueEntry *tail;
-    size_t length;
-};
-
-static inline QueueEntry *create_entry(void *val)
-{
-    QueueEntry *entry = av_malloc(sizeof(*entry));
-    if (entry)
-        entry->value = val;
-    return entry;
-}
-
-Queue* ff_queue_create(void)
-{
-    Queue *q = av_malloc(sizeof(*q));
-    if (!q)
-        return NULL;
-
-    q->head = create_entry(q);
-    q->tail = create_entry(q);
-
-    if (!q->head || !q->tail) {
-        av_freep(&q->head);
-        av_freep(&q->tail);
-        av_freep(&q);
-        return NULL;
-    }
-
-    q->head->next = q->tail;
-    q->tail->prev = q->head;
-    q->head->prev = NULL;
-    q->tail->next = NULL;
-    q->length = 0;
-
-    return q;
-}
-
-void ff_queue_destroy(Queue *q)
-{
-    QueueEntry *entry;
-    if (!q)
-        return;
-
-    entry = q->head;
-    while (entry != NULL) {
-        QueueEntry *temp = entry;
-        entry = entry->next;
-        av_freep(&temp);
-    }
-
-    av_freep(&q);
-}
-
-size_t ff_queue_size(Queue *q)
-{
-     return q ? q->length : 0;
-}
-
-void *ff_queue_peek_front(Queue *q)
-{
-    if (!q || q->length == 0)
-        return NULL;
-
-    return q->head->next->value;
-}
-
-void *ff_queue_peek_back(Queue *q)
-{
-    if (!q || q->length == 0)
-        return NULL;
-
-    return q->tail->prev->value;
-}
-
-int ff_queue_push_front(Queue *q, void *v)
-{
-    QueueEntry *new_entry;
-    QueueEntry *original_next;
-    if (!q)
-        return 0;
-
-    new_entry = create_entry(v);
-    if (!new_entry)
-        return -1;
-    original_next = q->head->next;
-
-    q->head->next = new_entry;
-    original_next->prev = new_entry;
-    new_entry->prev = q->head;
-    new_entry->next = original_next;
-    q->length++;
-
-    return q->length;
-}
-
-int ff_queue_push_back(Queue *q, void *v)
-{
-    QueueEntry *new_entry;
-    QueueEntry *original_prev;
-    if (!q)
-        return 0;
-
-    new_entry = create_entry(v);
-    if (!new_entry)
-        return -1;
-    original_prev = q->tail->prev;
-
-    q->tail->prev = new_entry;
-    original_prev->next = new_entry;
-    new_entry->next = q->tail;
-    new_entry->prev = original_prev;
-    q->length++;
-
-    return q->length;
-}
-
-void *ff_queue_pop_front(Queue *q)
-{
-    QueueEntry *front;
-    QueueEntry *new_head_next;
-    void *ret;
-
-    if (!q || q->length == 0)
-        return NULL;
-
-    front = q->head->next;
-    new_head_next = front->next;
-    ret = front->value;
-
-    q->head->next = new_head_next;
-    new_head_next->prev = q->head;
-
-    av_freep(&front);
-    q->length--;
-    return ret;
-}
-
-void *ff_queue_pop_back(Queue *q)
-{
-    QueueEntry *back;
-    QueueEntry *new_tail_prev;
-    void *ret;
-
-    if (!q || q->length == 0)
-        return NULL;
-
-    back = q->tail->prev;
-    new_tail_prev = back->prev;
-    ret = back->value;
-
-    q->tail->prev = new_tail_prev;
-    new_tail_prev->next = q->tail;
-
-    av_freep(&back);
-    q->length--;
-    return ret;
-}
diff --git a/libavfilter/dnn/queue.h b/libavfilter/dnn/queue.h
deleted file mode 100644
index 4d71213..0000000
--- a/libavfilter/dnn/queue.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2020
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef AVFILTER_DNN_QUEUE_H
-#define AVFILTER_DNN_QUEUE_H
-
-typedef struct Queue Queue;
-
-Queue *ff_queue_create(void);
-void ff_queue_destroy(Queue *q);
-
-size_t ff_queue_size(Queue *q);
-
-void *ff_queue_peek_front(Queue *q);
-void *ff_queue_peek_back(Queue *q);
-
-int ff_queue_push_front(Queue *q, void *v);
-int ff_queue_push_back(Queue *q, void *v);
-
-void *ff_queue_pop_front(Queue *q);
-void *ff_queue_pop_back(Queue *q);
-
-#endif
diff --git a/libavfilter/dnn/safe_queue.c b/libavfilter/dnn/safe_queue.c
deleted file mode 100644
index e962d4c..0000000
--- a/libavfilter/dnn/safe_queue.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2020
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include "queue.h"
-#include "safe_queue.h"
-#include "libavutil/mem.h"
-#include "libavutil/avassert.h"
-#include "libavutil/thread.h"
-
-#if HAVE_PTHREAD_CANCEL
-#define DNNCond pthread_cond_t
-#define dnn_cond_init pthread_cond_init
-#define dnn_cond_destroy pthread_cond_destroy
-#define dnn_cond_signal pthread_cond_signal
-#define dnn_cond_wait pthread_cond_wait
-#else
-#define DNNCond char
-static inline int dnn_cond_init(DNNCond *cond, const void *attr) { return 0; }
-static inline int dnn_cond_destroy(DNNCond *cond) { return 0; }
-static inline int dnn_cond_signal(DNNCond *cond) { return 0; }
-static inline int dnn_cond_wait(DNNCond *cond, AVMutex *mutex)
-{
-    av_assert0(!"should not reach here");
-    return 0;
-}
-#endif
-
-struct SafeQueue {
-    Queue *q;
-    AVMutex mutex;
-    DNNCond cond;
-};
-
-SafeQueue *ff_safe_queue_create(void)
-{
-    SafeQueue *sq = av_malloc(sizeof(*sq));
-    if (!sq)
-        return NULL;
-
-    sq->q = ff_queue_create();
-    if (!sq->q) {
-        av_freep(&sq);
-        return NULL;
-    }
-
-    ff_mutex_init(&sq->mutex, NULL);
-    dnn_cond_init(&sq->cond, NULL);
-    return sq;
-}
-
-void ff_safe_queue_destroy(SafeQueue *sq)
-{
-    if (!sq)
-        return;
-
-    ff_queue_destroy(sq->q);
-    ff_mutex_destroy(&sq->mutex);
-    dnn_cond_destroy(&sq->cond);
-    av_freep(&sq);
-}
-
-size_t ff_safe_queue_size(SafeQueue *sq)
-{
-    return sq ? ff_queue_size(sq->q) : 0;
-}
-
-int ff_safe_queue_push_front(SafeQueue *sq, void *v)
-{
-    int ret;
-    ff_mutex_lock(&sq->mutex);
-    ret = ff_queue_push_front(sq->q, v);
-    dnn_cond_signal(&sq->cond);
-    ff_mutex_unlock(&sq->mutex);
-    return ret;
-}
-
-int ff_safe_queue_push_back(SafeQueue *sq, void *v)
-{
-    int ret;
-    ff_mutex_lock(&sq->mutex);
-    ret = ff_queue_push_back(sq->q, v);
-    dnn_cond_signal(&sq->cond);
-    ff_mutex_unlock(&sq->mutex);
-    return ret;
-}
-
-void *ff_safe_queue_pop_front(SafeQueue *sq)
-{
-    void *value;
-    ff_mutex_lock(&sq->mutex);
-    while (ff_queue_size(sq->q) == 0) {
-        dnn_cond_wait(&sq->cond, &sq->mutex);
-    }
-    value = ff_queue_pop_front(sq->q);
-    dnn_cond_signal(&sq->cond);
-    ff_mutex_unlock(&sq->mutex);
-    return value;
-}
diff --git a/libavfilter/dnn/safe_queue.h b/libavfilter/dnn/safe_queue.h
deleted file mode 100644
index 36d6daa..0000000
--- a/libavfilter/dnn/safe_queue.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2020
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVFILTER_DNN_SAFE_QUEUE_H
-#define AVFILTER_DNN_SAFE_QUEUE_H
-
-typedef struct SafeQueue SafeQueue;
-
-SafeQueue *ff_safe_queue_create(void);
-void ff_safe_queue_destroy(SafeQueue *sq);
-
-size_t ff_safe_queue_size(SafeQueue *sq);
-
-int ff_safe_queue_push_front(SafeQueue *sq, void *v);
-int ff_safe_queue_push_back(SafeQueue *sq, void *v);
-
-void *ff_safe_queue_pop_front(SafeQueue *sq);
-
-#endif
diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c
deleted file mode 100644
index 413adba..0000000
--- a/libavfilter/dnn_filter_common.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "dnn_filter_common.h"
-
-int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx)
-{
-    if (!ctx->model_filename) {
-        av_log(filter_ctx, AV_LOG_ERROR, "model file for network is not specified\n");
-        return AVERROR(EINVAL);
-    }
-    if (!ctx->model_inputname) {
-        av_log(filter_ctx, AV_LOG_ERROR, "input name of the model network is not specified\n");
-        return AVERROR(EINVAL);
-    }
-    if (!ctx->model_outputname) {
-        av_log(filter_ctx, AV_LOG_ERROR, "output name of the model network is not specified\n");
-        return AVERROR(EINVAL);
-    }
-
-    ctx->dnn_module = ff_get_dnn_module(ctx->backend_type);
-    if (!ctx->dnn_module) {
-        av_log(filter_ctx, AV_LOG_ERROR, "could not create DNN module for requested backend\n");
-        return AVERROR(ENOMEM);
-    }
-    if (!ctx->dnn_module->load_model) {
-        av_log(filter_ctx, AV_LOG_ERROR, "load_model for network is not specified\n");
-        return AVERROR(EINVAL);
-    }
-
-    ctx->model = (ctx->dnn_module->load_model)(ctx->model_filename, func_type, ctx->backend_options, filter_ctx);
-    if (!ctx->model) {
-        av_log(filter_ctx, AV_LOG_ERROR, "could not load DNN model\n");
-        return AVERROR(EINVAL);
-    }
-
-    if (!ctx->dnn_module->execute_model_async && ctx->async) {
-        ctx->async = 0;
-        av_log(filter_ctx, AV_LOG_WARNING, "this backend does not support async execution, roll back to sync.\n");
-    }
-
-#if !HAVE_PTHREAD_CANCEL
-    if (ctx->async) {
-        ctx->async = 0;
-        av_log(filter_ctx, AV_LOG_WARNING, "pthread is not supported, roll back to sync.\n");
-    }
-#endif
-
-    return 0;
-}
-
-DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input)
-{
-    return ctx->model->get_input(ctx->model->model, input, ctx->model_inputname);
-}
-
-DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height)
-{
-    return ctx->model->get_output(ctx->model->model, ctx->model_inputname, input_width, input_height,
-                                    ctx->model_outputname, output_width, output_height);
-}
-
-DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame)
-{
-    return (ctx->dnn_module->execute_model)(ctx->model, ctx->model_inputname, in_frame,
-                                            (const char **)&ctx->model_outputname, 1, out_frame);
-}
-
-DNNReturnType ff_dnn_execute_model_async(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame)
-{
-    return (ctx->dnn_module->execute_model_async)(ctx->model, ctx->model_inputname, in_frame,
-                                                  (const char **)&ctx->model_outputname, 1, out_frame);
-}
-
-DNNAsyncStatusType ff_dnn_get_async_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame)
-{
-    return (ctx->dnn_module->get_async_result)(ctx->model, in_frame, out_frame);
-}
-
-DNNReturnType ff_dnn_flush(DnnContext *ctx)
-{
-    return (ctx->dnn_module->flush)(ctx->model);
-}
-
-void ff_dnn_uninit(DnnContext *ctx)
-{
-    if (ctx->dnn_module) {
-        (ctx->dnn_module->free_model)(&ctx->model);
-        av_freep(&ctx->dnn_module);
-    }
-}
diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h
deleted file mode 100644
index 79c4d3e..0000000
--- a/libavfilter/dnn_filter_common.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * common functions for the dnn based filters
- */
-
-#ifndef AVFILTER_DNN_FILTER_COMMON_H
-#define AVFILTER_DNN_FILTER_COMMON_H
-
-#include "dnn_interface.h"
-
-typedef struct DnnContext {
-    char *model_filename;
-    DNNBackendType backend_type;
-    char *model_inputname;
-    char *model_outputname;
-    char *backend_options;
-    int async;
-
-    DNNModule *dnn_module;
-    DNNModel *model;
-} DnnContext;
-
-#define DNN_COMMON_OPTIONS \
-    { "model",              "path to model file",         OFFSET(model_filename),   AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },\
-    { "input",              "input name of the model",    OFFSET(model_inputname),  AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },\
-    { "output",             "output name of the model",   OFFSET(model_outputname), AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },\
-    { "backend_configs",    "backend configs",            OFFSET(backend_options),  AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },\
-    { "options",            "backend configs",            OFFSET(backend_options),  AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },\
-    { "async",              "use DNN async inference",    OFFSET(async),            AV_OPT_TYPE_BOOL,      { .i64 = 1},     0, 1, FLAGS},
-
-
-int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx);
-DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input);
-DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height);
-DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame);
-DNNReturnType ff_dnn_execute_model_async(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame);
-DNNAsyncStatusType ff_dnn_get_async_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame);
-DNNReturnType ff_dnn_flush(DnnContext *ctx);
-void ff_dnn_uninit(DnnContext *ctx);
-
-#endif
diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h
index d3a0c58..2f129d5 100644
--- a/libavfilter/dnn_interface.h
+++ b/libavfilter/dnn_interface.h
@@ -28,7 +28,6 @@
 
 #include <stdint.h>
 #include "libavutil/frame.h"
-#include "avfilter.h"
 
 typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType;
 
@@ -36,31 +35,10 @@
 
 typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;
 
-typedef enum {
-    DCO_NONE,
-    DCO_BGR,
-} DNNColorOrder;
-
-typedef enum {
-    DAST_FAIL,              // something wrong
-    DAST_EMPTY_QUEUE,       // no more inference result to get
-    DAST_NOT_READY,         // all queued inferences are not finished
-    DAST_SUCCESS            // got a result frame successfully
-} DNNAsyncStatusType;
-
-typedef enum {
-    DFT_NONE,
-    DFT_PROCESS_FRAME,      // process the whole frame
-    DFT_ANALYTICS_DETECT,   // detect from the whole frame
-    // we can add more such as detect_from_crop, classify_from_bbox, etc.
-}DNNFunctionType;
-
 typedef struct DNNData{
     void *data;
-    int width, height, channels;
-    // dt and order together decide the color format
     DNNDataType dt;
-    DNNColorOrder order;
+    int width, height, channels;
 } DNNData;
 
 typedef struct DNNModel{
@@ -68,10 +46,8 @@
     void *model;
     // Stores options when the model is executed by the backend
     const char *options;
-    // Stores FilterContext used for the interaction between AVFrame and DNNData
-    AVFilterContext *filter_ctx;
-    // Stores function type of the model
-    DNNFunctionType func_type;
+    // Stores userdata used for the interaction between AVFrame and DNNData
+    void *userdata;
     // Gets model input information
     // Just reuse struct DNNData here, actually the DNNData.data field is not needed.
     DNNReturnType (*get_input)(void *model, DNNData *input, const char *input_name);
@@ -80,26 +56,19 @@
                                 const char *output_name, int *output_width, int *output_height);
     // set the pre process to transfer data from AVFrame to DNNData
     // the default implementation within DNN is used if it is not provided by the filter
-    int (*pre_proc)(AVFrame *frame_in, DNNData *model_input, AVFilterContext *filter_ctx);
+    int (*pre_proc)(AVFrame *frame_in, DNNData *model_input, void *user_data);
     // set the post process to transfer data from DNNData to AVFrame
     // the default implementation within DNN is used if it is not provided by the filter
-    int (*post_proc)(AVFrame *frame_out, DNNData *model_output, AVFilterContext *filter_ctx);
+    int (*post_proc)(AVFrame *frame_out, DNNData *model_output, void *user_data);
 } DNNModel;
 
 // Stores pointers to functions for loading, executing, freeing DNN models for one of the backends.
 typedef struct DNNModule{
     // Loads model and parameters from given file. Returns NULL if it is not possible.
-    DNNModel *(*load_model)(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx);
+    DNNModel *(*load_model)(const char *model_filename, const char *options, void *userdata);
     // Executes model with specified input and output. Returns DNN_ERROR otherwise.
     DNNReturnType (*execute_model)(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                    const char **output_names, uint32_t nb_output, AVFrame *out_frame);
-    // Executes model with specified input and output asynchronously. Returns DNN_ERROR otherwise.
-    DNNReturnType (*execute_model_async)(const DNNModel *model, const char *input_name, AVFrame *in_frame,
-                                         const char **output_names, uint32_t nb_output, AVFrame *out_frame);
-    // Retrieve inference result.
-    DNNAsyncStatusType (*get_async_result)(const DNNModel *model, AVFrame **in, AVFrame **out);
-    // Flush all the pending tasks.
-    DNNReturnType (*flush)(const DNNModel *model);
     // Frees memory allocated for model.
     void (*free_model)(DNNModel **model);
 } DNNModule;
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
index 0a59ff9..5f4cb54 100644
--- a/libavfilter/drawutils.c
+++ b/libavfilter/drawutils.c
@@ -70,10 +70,6 @@
     case AV_PIX_FMT_GBRAP12BE:
     case AV_PIX_FMT_GBRAP16LE:
     case AV_PIX_FMT_GBRAP16BE:
-    case AV_PIX_FMT_GBRPF32LE:
-    case AV_PIX_FMT_GBRPF32BE:
-    case AV_PIX_FMT_GBRAPF32LE:
-    case AV_PIX_FMT_GBRAPF32BE:
     case AV_PIX_FMT_GBRP:  rgba_map[GREEN] = 0; rgba_map[BLUE ] = 1; rgba_map[RED  ] = 2; rgba_map[ALPHA] = 3; break;
     default:                    /* unsupported */
         return AVERROR(EINVAL);
@@ -81,6 +77,104 @@
     return 0;
 }
 
+int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4],
+                            enum AVPixelFormat pix_fmt, uint8_t rgba_color[4],
+                            int *is_packed_rgba, uint8_t rgba_map_ptr[4])
+{
+    uint8_t rgba_map[4] = {0};
+    int i;
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
+    int hsub;
+
+    av_assert0(pix_desc);
+
+    hsub = pix_desc->log2_chroma_w;
+
+    *is_packed_rgba = ff_fill_rgba_map(rgba_map, pix_fmt) >= 0;
+
+    if (*is_packed_rgba) {
+        pixel_step[0] = (av_get_bits_per_pixel(pix_desc))>>3;
+        for (i = 0; i < 4; i++)
+            dst_color[rgba_map[i]] = rgba_color[i];
+
+        line[0] = av_malloc_array(w, pixel_step[0]);
+        if (!line[0])
+            return AVERROR(ENOMEM);
+        for (i = 0; i < w; i++)
+            memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
+        if (rgba_map_ptr)
+            memcpy(rgba_map_ptr, rgba_map, sizeof(rgba_map[0]) * 4);
+    } else {
+        int plane;
+
+        dst_color[0] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
+        dst_color[1] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
+        dst_color[2] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
+        dst_color[3] = rgba_color[3];
+
+        for (plane = 0; plane < 4; plane++) {
+            int line_size;
+            int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
+
+            pixel_step[plane] = 1;
+            line_size = AV_CEIL_RSHIFT(w, hsub1) * pixel_step[plane];
+            line[plane] = av_malloc(line_size);
+            if (!line[plane]) {
+                while(plane && line[plane-1])
+                    av_freep(&line[--plane]);
+                return AVERROR(ENOMEM);
+            }
+            memset(line[plane], dst_color[plane], line_size);
+        }
+    }
+
+    return 0;
+}
+
+void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4],
+                       uint8_t *src[4], int pixelstep[4],
+                       int hsub, int vsub, int x, int y, int w, int h)
+{
+    int i, plane;
+    uint8_t *p;
+
+    for (plane = 0; plane < 4 && dst[plane]; plane++) {
+        int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
+        int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
+        int width  = AV_CEIL_RSHIFT(w, hsub1);
+        int height = AV_CEIL_RSHIFT(h, vsub1);
+
+        p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
+        for (i = 0; i < height; i++) {
+            memcpy(p + (x >> hsub1) * pixelstep[plane],
+                   src[plane], width * pixelstep[plane]);
+            p += dst_linesize[plane];
+        }
+    }
+}
+
+void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4],
+                       uint8_t *src[4], int src_linesize[4], int pixelstep[4],
+                       int hsub, int vsub, int x, int y, int y2, int w, int h)
+{
+    int i, plane;
+    uint8_t *p;
+
+    for (plane = 0; plane < 4 && dst[plane]; plane++) {
+        int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
+        int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
+        int width  = AV_CEIL_RSHIFT(w, hsub1);
+        int height = AV_CEIL_RSHIFT(h, vsub1);
+
+        p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
+        for (i = 0; i < height; i++) {
+            memcpy(p + (x >> hsub1) * pixelstep[plane],
+                   src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), width * pixelstep[plane]);
+            p += dst_linesize[plane];
+        }
+    }
+}
+
 int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
diff --git a/libavfilter/drawutils.h b/libavfilter/drawutils.h
index 2ca2475..b999d70 100644
--- a/libavfilter/drawutils.h
+++ b/libavfilter/drawutils.h
@@ -30,6 +30,19 @@
 
 int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt);
 
+int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w,
+                            uint8_t dst_color[4],
+                            enum AVPixelFormat pix_fmt, uint8_t rgba_color[4],
+                            int *is_packed_rgba, uint8_t rgba_map[4]);
+
+void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4],
+                       uint8_t *src[4], int pixelstep[4],
+                       int hsub, int vsub, int x, int y, int w, int h);
+
+void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4],
+                       uint8_t *src[4], int src_linesize[4], int pixelstep[4],
+                       int hsub, int vsub, int x, int y, int y2, int w, int h);
+
 #define MAX_PLANES 4
 
 typedef struct FFDrawContext {
diff --git a/libavfilter/ebur128.c b/libavfilter/ebur128.c
index d93500e..ca2fca0 100644
--- a/libavfilter/ebur128.c
+++ b/libavfilter/ebur128.c
@@ -49,7 +49,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #define CHECK_ERROR(condition, errorcode, goto_point)                          \
@@ -362,6 +361,9 @@
         st->d->v[ci][1] = fabs(st->d->v[ci][1]) < DBL_MIN ? 0.0 : st->d->v[ci][1]; \
     }                                                                              \
 }
+EBUR128_FILTER(short, -((double)SHRT_MIN))
+EBUR128_FILTER(int, -((double)INT_MIN))
+EBUR128_FILTER(float,  1.0)
 EBUR128_FILTER(double, 1.0)
 
 static double ebur128_energy_to_loudness(double energy)
@@ -456,8 +458,8 @@
 }
 
 static int ebur128_energy_shortterm(FFEBUR128State * st, double *out);
-#define EBUR128_ADD_FRAMES_PLANAR(type)                                                \
-static void ebur128_add_frames_planar_##type(FFEBUR128State* st, const type** srcs,    \
+#define FF_EBUR128_ADD_FRAMES_PLANAR(type)                                             \
+void ff_ebur128_add_frames_planar_##type(FFEBUR128State* st, const type** srcs,        \
                                  size_t frames, int stride) {                          \
     size_t src_index = 0;                                                              \
     while (frames > 0) {                                                               \
@@ -499,7 +501,10 @@
         }                                                                              \
     }                                                                                  \
 }
-EBUR128_ADD_FRAMES_PLANAR(double)
+FF_EBUR128_ADD_FRAMES_PLANAR(short)
+FF_EBUR128_ADD_FRAMES_PLANAR(int)
+FF_EBUR128_ADD_FRAMES_PLANAR(float)
+FF_EBUR128_ADD_FRAMES_PLANAR(double)
 #define FF_EBUR128_ADD_FRAMES(type)                                            \
 void ff_ebur128_add_frames_##type(FFEBUR128State* st, const type* src,         \
                                     size_t frames) {                           \
@@ -507,8 +512,11 @@
   const type **buf = (const type**)st->d->data_ptrs;                           \
   for (i = 0; i < st->channels; i++)                                           \
     buf[i] = src + i;                                                          \
-  ebur128_add_frames_planar_##type(st, buf, frames, st->channels);             \
+  ff_ebur128_add_frames_planar_##type(st, buf, frames, st->channels);          \
 }
+FF_EBUR128_ADD_FRAMES(short)
+FF_EBUR128_ADD_FRAMES(int)
+FF_EBUR128_ADD_FRAMES(float)
 FF_EBUR128_ADD_FRAMES(double)
 
 static int ebur128_calc_relative_threshold(FFEBUR128State **sts, size_t size,
@@ -597,6 +605,12 @@
     return ebur128_gated_loudness(&st, 1, out);
 }
 
+int ff_ebur128_loudness_global_multiple(FFEBUR128State ** sts, size_t size,
+                                        double *out)
+{
+    return ebur128_gated_loudness(sts, size, out);
+}
+
 static int ebur128_energy_in_interval(FFEBUR128State * st,
                                       size_t interval_frames, double *out)
 {
@@ -613,6 +627,21 @@
                                       out);
 }
 
+int ff_ebur128_loudness_momentary(FFEBUR128State * st, double *out)
+{
+    double energy;
+    int error = ebur128_energy_in_interval(st, st->d->samples_in_100ms * 4,
+                                           &energy);
+    if (error) {
+        return error;
+    } else if (energy <= 0.0) {
+        *out = -HUGE_VAL;
+        return 0;
+    }
+    *out = ebur128_energy_to_loudness(energy);
+    return 0;
+}
+
 int ff_ebur128_loudness_shortterm(FFEBUR128State * st, double *out)
 {
     double energy;
@@ -627,6 +656,22 @@
     return 0;
 }
 
+int ff_ebur128_loudness_window(FFEBUR128State * st,
+                               unsigned long window, double *out)
+{
+    double energy;
+    size_t interval_frames = st->samplerate * window / 1000;
+    int error = ebur128_energy_in_interval(st, interval_frames, &energy);
+    if (error) {
+        return error;
+    } else if (energy <= 0.0) {
+        *out = -HUGE_VAL;
+        return 0;
+    }
+    *out = ebur128_energy_to_loudness(energy);
+    return 0;
+}
+
 /* EBU - TECH 3342 */
 int ff_ebur128_loudness_range_multiple(FFEBUR128State ** sts, size_t size,
                                        double *out)
diff --git a/libavfilter/ebur128.h b/libavfilter/ebur128.h
index 8e7385e..7436754 100644
--- a/libavfilter/ebur128.h
+++ b/libavfilter/ebur128.h
@@ -81,7 +81,7 @@
  *  modes that suit your needs, as performance will be better.
  */
 enum mode {
-  /** can resurrrect and call ff_ebur128_loudness_momentary */
+  /** can call ff_ebur128_loudness_momentary */
     FF_EBUR128_MODE_M = (1 << 0),
   /** can call ff_ebur128_loudness_shortterm */
     FF_EBUR128_MODE_S = (1 << 1) | FF_EBUR128_MODE_M,
@@ -151,9 +151,41 @@
  *  @param src array of source frames. Channels must be interleaved.
  *  @param frames number of frames. Not number of samples!
  */
+void ff_ebur128_add_frames_short(FFEBUR128State * st,
+                                 const short *src, size_t frames);
+/** \brief See \ref ebur128_add_frames_short */
+void ff_ebur128_add_frames_int(FFEBUR128State * st,
+                               const int *src, size_t frames);
+/** \brief See \ref ebur128_add_frames_short */
+void ff_ebur128_add_frames_float(FFEBUR128State * st,
+                                 const float *src, size_t frames);
+/** \brief See \ref ebur128_add_frames_short */
 void ff_ebur128_add_frames_double(FFEBUR128State * st,
                                   const double *src, size_t frames);
 
+/** \brief Add frames to be processed.
+ *
+ *  @param st library state.
+ *  @param srcs array of source frame channel data pointers
+ *  @param frames number of frames. Not number of samples!
+ *  @param stride number of samples to skip to for the next sample of the same channel
+ */
+void ff_ebur128_add_frames_planar_short(FFEBUR128State * st,
+                                        const short **srcs,
+                                        size_t frames, int stride);
+/** \brief See \ref ebur128_add_frames_planar_short */
+void ff_ebur128_add_frames_planar_int(FFEBUR128State * st,
+                                      const int **srcs,
+                                      size_t frames, int stride);
+/** \brief See \ref ebur128_add_frames_planar_short */
+void ff_ebur128_add_frames_planar_float(FFEBUR128State * st,
+                                        const float **srcs,
+                                        size_t frames, int stride);
+/** \brief See \ref ebur128_add_frames_planar_short */
+void ff_ebur128_add_frames_planar_double(FFEBUR128State * st,
+                                         const double **srcs,
+                                         size_t frames, int stride);
+
 /** \brief Get global integrated loudness in LUFS.
  *
  *  @param st library state.
@@ -164,7 +196,28 @@
  *    - AVERROR(EINVAL) if mode "FF_EBUR128_MODE_I" has not been set.
  */
 int ff_ebur128_loudness_global(FFEBUR128State * st, double *out);
+/** \brief Get global integrated loudness in LUFS across multiple instances.
+ *
+ *  @param sts array of library states.
+ *  @param size length of sts
+ *  @param out integrated loudness in LUFS. -HUGE_VAL if result is negative
+ *             infinity.
+ *  @return
+ *    - 0 on success.
+ *    - AVERROR(EINVAL) if mode "FF_EBUR128_MODE_I" has not been set.
+ */
+int ff_ebur128_loudness_global_multiple(FFEBUR128State ** sts,
+                                        size_t size, double *out);
 
+/** \brief Get momentary loudness (last 400ms) in LUFS.
+ *
+ *  @param st library state.
+ *  @param out momentary loudness in LUFS. -HUGE_VAL if result is negative
+ *             infinity.
+ *  @return
+ *    - 0 on success.
+ */
+int ff_ebur128_loudness_momentary(FFEBUR128State * st, double *out);
 /** \brief Get short-term loudness (last 3s) in LUFS.
  *
  *  @param st library state.
@@ -176,6 +229,20 @@
  */
 int ff_ebur128_loudness_shortterm(FFEBUR128State * st, double *out);
 
+/** \brief Get loudness of the specified window in LUFS.
+ *
+ *  window must not be larger than the current window set in st.
+ *
+ *  @param st library state.
+ *  @param window window in ms to calculate loudness.
+ *  @param out loudness in LUFS. -HUGE_VAL if result is negative infinity.
+ *  @return
+ *    - 0 on success.
+ *    - AVERROR(EINVAL) if window larger than current window in st.
+ */
+int ff_ebur128_loudness_window(FFEBUR128State * st,
+                               unsigned long window, double *out);
+
 /** \brief Get loudness range (LRA) of programme in LU.
  *
  *  Calculates loudness range according to EBU 3342.
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index dab8891..3b178ce 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -48,7 +48,7 @@
 
 };
 
-FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(buffer_size_t size),
+FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(int size),
                                       int width,
                                       int height,
                                       enum AVPixelFormat format,
@@ -116,7 +116,7 @@
     return NULL;
 }
 
-FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(buffer_size_t size),
+FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(int size),
                                       int channels,
                                       int nb_samples,
                                       enum AVSampleFormat format,
diff --git a/libavfilter/framepool.h b/libavfilter/framepool.h
index 28857a4..e5560e4 100644
--- a/libavfilter/framepool.h
+++ b/libavfilter/framepool.h
@@ -23,7 +23,6 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/frame.h"
-#include "libavutil/internal.h"
 
 /**
  * Frame pool. This structure is opaque and not meant to be accessed
@@ -44,7 +43,7 @@
  * @param align buffers alignement of each frame in this pool
  * @return newly created video frame pool on success, NULL on error.
  */
-FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(buffer_size_t size),
+FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(int size),
                                       int width,
                                       int height,
                                       enum AVPixelFormat format,
@@ -62,7 +61,7 @@
  * @param align buffers alignement of each frame in this pool
  * @return newly created audio frame pool on success, NULL on error.
  */
-FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(buffer_size_t size),
+FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(int size),
                                       int channels,
                                       int samples,
                                       enum AVSampleFormat format,
diff --git a/libavfilter/gblur.h b/libavfilter/gblur.h
index dce5067..8712980 100644
--- a/libavfilter/gblur.h
+++ b/libavfilter/gblur.h
@@ -37,7 +37,6 @@
     int steps;
     int planes;
 
-    int flt;
     int depth;
     int planewidth[4];
     int planeheight[4];
@@ -50,9 +49,7 @@
     float nuV;
     int nb_planes;
     void (*horiz_slice)(float *buffer, int width, int height, int steps, float nu, float bscale);
-    void (*postscale_slice)(float *buffer, int length, float postscale, float min, float max);
 } GBlurContext;
-
 void ff_gblur_init(GBlurContext *s);
 void ff_gblur_init_x86(GBlurContext *s);
 #endif
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index f3b434d..183215d 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -368,8 +368,6 @@
 /**
  * Generic processing of user supplied commands that are set
  * in the same way as the filter options.
- * NOTE: 'enable' option is handled separately, and not by
- * this function.
  */
 int ff_filter_process_command(AVFilterContext *ctx, const char *cmd,
                               const char *arg, char *res, int res_len, int flags);
diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c
index 34051ee..f8f8415 100644
--- a/libavfilter/lavfutils.c
+++ b/libavfilter/lavfutils.c
@@ -19,7 +19,6 @@
  */
 
 #include "libavutil/imgutils.h"
-#include "libavformat/avformat.h"
 #include "lavfutils.h"
 
 int ff_load_image(uint8_t *data[4], int linesize[4],
diff --git a/libavfilter/lavfutils.h b/libavfilter/lavfutils.h
index 96738ce..2d5308f 100644
--- a/libavfilter/lavfutils.h
+++ b/libavfilter/lavfutils.h
@@ -24,8 +24,7 @@
 #ifndef AVFILTER_LAVFUTILS_H
 #define AVFILTER_LAVFUTILS_H
 
-#include <stdint.h>
-#include "libavutil/pixfmt.h"
+#include "libavformat/avformat.h"
 
 /**
  * Load image from filename and put the resulting image in data.
diff --git a/libavfilter/qp_table.c b/libavfilter/qp_table.c
deleted file mode 100644
index 33812b7..0000000
--- a/libavfilter/qp_table.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdint.h>
-
-// for FF_QSCALE_TYPE_*
-#include "libavcodec/internal.h"
-
-#include "libavutil/frame.h"
-#include "libavutil/mem.h"
-#include "libavutil/video_enc_params.h"
-
-#include "qp_table.h"
-
-int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h,
-                        int *qscale_type)
-{
-    AVFrameSideData *sd;
-    AVVideoEncParams *par;
-    unsigned int mb_h = (frame->height + 15) / 16;
-    unsigned int mb_w = (frame->width + 15) / 16;
-    unsigned int nb_mb = mb_h * mb_w;
-    unsigned int block_idx;
-
-    *table = NULL;
-
-    sd = av_frame_get_side_data(frame, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
-    if (!sd)
-        return 0;
-    par = (AVVideoEncParams*)sd->data;
-    if (par->type != AV_VIDEO_ENC_PARAMS_MPEG2 ||
-        (par->nb_blocks != 0 && par->nb_blocks != nb_mb))
-        return AVERROR(ENOSYS);
-
-    *table = av_malloc(nb_mb);
-    if (!*table)
-        return AVERROR(ENOMEM);
-    if (table_w)
-        *table_w = mb_w;
-    if (table_h)
-        *table_h = mb_h;
-    if (qscale_type)
-        *qscale_type = FF_QSCALE_TYPE_MPEG2;
-
-    if (par->nb_blocks == 0) {
-        memset(*table, par->qp, nb_mb);
-        return 0;
-    }
-
-    for (block_idx = 0; block_idx < nb_mb; block_idx++) {
-        AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx);
-        (*table)[block_idx] = par->qp + b->delta_qp;
-    }
-
-    return 0;
-}
-
diff --git a/libavfilter/qp_table.h b/libavfilter/qp_table.h
deleted file mode 100644
index a552fe2..0000000
--- a/libavfilter/qp_table.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef AVFILTER_QP_TABLE_H
-#define AVFILTER_QP_TABLE_H
-
-#include <stdint.h>
-
-#include "libavutil/frame.h"
-
-/**
- * Extract a libpostproc-compatible QP table - an 8-bit QP value per 16x16
- * macroblock, stored in raster order - from AVVideoEncParams side data.
- */
-int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h,
-                        int *qscale_type);
-
-#endif // AVFILTER_QP_TABLE_H
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index f216b3f..8d5ff2e 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -76,110 +76,6 @@
 
 static const AVRational default_tb = { 1, 90000 };
 
-static const struct {
-    int mfx_iopattern;
-    const char *desc;
-} qsv_iopatterns[] = {
-    {MFX_IOPATTERN_IN_VIDEO_MEMORY,     "input is video memory surface"         },
-    {MFX_IOPATTERN_IN_SYSTEM_MEMORY,    "input is system memory surface"        },
-    {MFX_IOPATTERN_IN_OPAQUE_MEMORY,    "input is opaque memory surface"        },
-    {MFX_IOPATTERN_OUT_VIDEO_MEMORY,    "output is video memory surface"        },
-    {MFX_IOPATTERN_OUT_SYSTEM_MEMORY,   "output is system memory surface"       },
-    {MFX_IOPATTERN_OUT_OPAQUE_MEMORY,   "output is opaque memory surface"       },
-};
-
-int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
-                              const char *extra_string)
-{
-    const char *desc = NULL;
-
-    for (int i = 0; i < FF_ARRAY_ELEMS(qsv_iopatterns); i++) {
-        if (qsv_iopatterns[i].mfx_iopattern == mfx_iopattern) {
-            desc = qsv_iopatterns[i].desc;
-        }
-    }
-    if (!desc)
-        desc = "unknown iopattern";
-
-    av_log(log_ctx, AV_LOG_VERBOSE, "%s: %s\n", extra_string, desc);
-    return 0;
-}
-
-static const struct {
-    mfxStatus   mfxerr;
-    int         averr;
-    const char *desc;
-} qsv_errors[] = {
-    { MFX_ERR_NONE,                     0,               "success"                              },
-    { MFX_ERR_UNKNOWN,                  AVERROR_UNKNOWN, "unknown error"                        },
-    { MFX_ERR_NULL_PTR,                 AVERROR(EINVAL), "NULL pointer"                         },
-    { MFX_ERR_UNSUPPORTED,              AVERROR(ENOSYS), "unsupported"                          },
-    { MFX_ERR_MEMORY_ALLOC,             AVERROR(ENOMEM), "failed to allocate memory"            },
-    { MFX_ERR_NOT_ENOUGH_BUFFER,        AVERROR(ENOMEM), "insufficient input/output buffer"     },
-    { MFX_ERR_INVALID_HANDLE,           AVERROR(EINVAL), "invalid handle"                       },
-    { MFX_ERR_LOCK_MEMORY,              AVERROR(EIO),    "failed to lock the memory block"      },
-    { MFX_ERR_NOT_INITIALIZED,          AVERROR_BUG,     "not initialized"                      },
-    { MFX_ERR_NOT_FOUND,                AVERROR(ENOSYS), "specified object was not found"       },
-    /* the following 3 errors should always be handled explicitly, so those "mappings"
-     * are for completeness only */
-    { MFX_ERR_MORE_DATA,                AVERROR_UNKNOWN, "expect more data at input"            },
-    { MFX_ERR_MORE_SURFACE,             AVERROR_UNKNOWN, "expect more surface at output"        },
-    { MFX_ERR_MORE_BITSTREAM,           AVERROR_UNKNOWN, "expect more bitstream at output"      },
-    { MFX_ERR_ABORTED,                  AVERROR_UNKNOWN, "operation aborted"                    },
-    { MFX_ERR_DEVICE_LOST,              AVERROR(EIO),    "device lost"                          },
-    { MFX_ERR_INCOMPATIBLE_VIDEO_PARAM, AVERROR(EINVAL), "incompatible video parameters"        },
-    { MFX_ERR_INVALID_VIDEO_PARAM,      AVERROR(EINVAL), "invalid video parameters"             },
-    { MFX_ERR_UNDEFINED_BEHAVIOR,       AVERROR_BUG,     "undefined behavior"                   },
-    { MFX_ERR_DEVICE_FAILED,            AVERROR(EIO),    "device failed"                        },
-    { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio parameters"        },
-    { MFX_ERR_INVALID_AUDIO_PARAM,      AVERROR(EINVAL), "invalid audio parameters"             },
-
-    { MFX_WRN_IN_EXECUTION,             0,               "operation in execution"               },
-    { MFX_WRN_DEVICE_BUSY,              0,               "device busy"                          },
-    { MFX_WRN_VIDEO_PARAM_CHANGED,      0,               "video parameters changed"             },
-    { MFX_WRN_PARTIAL_ACCELERATION,     0,               "partial acceleration"                 },
-    { MFX_WRN_INCOMPATIBLE_VIDEO_PARAM, 0,               "incompatible video parameters"        },
-    { MFX_WRN_VALUE_NOT_CHANGED,        0,               "value is saturated"                   },
-    { MFX_WRN_OUT_OF_RANGE,             0,               "value out of range"                   },
-    { MFX_WRN_FILTER_SKIPPED,           0,               "filter skipped"                       },
-    { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0,               "incompatible audio parameters"        },
-};
-
-static int qsv_map_error(mfxStatus mfx_err, const char **desc)
-{
-    int i;
-    for (i = 0; i < FF_ARRAY_ELEMS(qsv_errors); i++) {
-        if (qsv_errors[i].mfxerr == mfx_err) {
-            if (desc)
-                *desc = qsv_errors[i].desc;
-            return qsv_errors[i].averr;
-        }
-    }
-    if (desc)
-        *desc = "unknown error";
-    return AVERROR_UNKNOWN;
-}
-
-int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
-                          const char *error_string)
-{
-    const char *desc;
-    int ret;
-    ret = qsv_map_error(err, &desc);
-    av_log(log_ctx, AV_LOG_ERROR, "%s: %s (%d)\n", error_string, desc, err);
-    return ret;
-}
-
-int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
-                            const char *warning_string)
-{
-    const char *desc;
-    int ret;
-    ret = qsv_map_error(err, &desc);
-    av_log(log_ctx, AV_LOG_WARNING, "%s: %s (%d)\n", warning_string, desc, err);
-    return ret;
-}
-
 /* functions for frameAlloc */
 static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
                              mfxFrameAllocResponse *resp)
@@ -609,19 +505,15 @@
         }
     }
 
-    if (ret < 0)
-        return ff_qsvvpp_print_error(avctx, ret, "Error getting the session handle");
-    else if (ret > 0) {
-        ff_qsvvpp_print_warning(avctx, ret, "Warning in getting the session handle");
+    if (ret != MFX_ERR_NONE) {
+        av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n");
         return AVERROR_UNKNOWN;
     }
 
     /* create a "slave" session with those same properties, to be used for vpp */
     ret = MFXInit(impl, &ver, &s->session);
-    if (ret < 0)
-        return ff_qsvvpp_print_error(avctx, ret, "Error initializing a session");
-    else if (ret > 0) {
-        ff_qsvvpp_print_warning(avctx, ret, "Warning in session initialization");
+    if (ret != MFX_ERR_NONE) {
+        av_log(avctx, AV_LOG_ERROR, "Error initializing a session for scaling\n");
         return AVERROR_UNKNOWN;
     }
 
@@ -754,16 +646,11 @@
     else if (IS_OPAQUE_MEMORY(s->out_mem_mode))
         s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
 
-    /* Print input memory mode */
-    ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0x0F, "VPP");
-    /* Print output memory mode */
-    ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP");
     ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
     if (ret < 0) {
-        ret = ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
+        av_log(avctx, AV_LOG_ERROR, "Failed to create a qsvvpp, ret = %d.\n", ret);
         goto failed;
-    } else if (ret > 0)
-        ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
+    }
 
     *vpp = s;
     return 0;
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index b4baeed..c2bcce7 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -71,13 +71,4 @@
 /* vpp filter frame and call the cb if needed */
 int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame);
 
-int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
-                              const char *extra_string);
-
-int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
-                          const char *error_string);
-
-int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
-                            const char *warning_string);
-
 #endif /* AVFILTER_QSVVPP_H */
diff --git a/libavfilter/version.h b/libavfilter/version.h
index e28a656..5d7cf25 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR 109
+#define LIBAVFILTER_VERSION_MINOR  93
 #define LIBAVFILTER_VERSION_MICRO 100
 
 
@@ -65,11 +65,5 @@
 #ifndef FF_API_NEXT
 #define FF_API_NEXT                         (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
-#ifndef FF_API_FILTER_LINK_SET_CLOSED
-#define FF_API_FILTER_LINK_SET_CLOSED       (LIBAVFILTER_VERSION_MAJOR < 8)
-#endif
-#ifndef FF_API_BUFFERSINK_ALLOC
-#define FF_API_BUFFERSINK_ALLOC             (LIBAVFILTER_VERSION_MAJOR < 9)
-#endif
 
 #endif /* AVFILTER_VERSION_H */
diff --git a/libavfilter/vf_addroi.c b/libavfilter/vf_addroi.c
index d6b83ee..489998c 100644
--- a/libavfilter/vf_addroi.c
+++ b/libavfilter/vf_addroi.c
@@ -26,8 +26,8 @@
     X, Y, W, H,
     NB_PARAMS,
 };
-static const char addroi_param_names[] = {
-    'x', 'y', 'w', 'h',
+static const char *addroi_param_names[] = {
+    "x", "y", "w", "h",
 };
 
 enum {
@@ -74,12 +74,12 @@
 
         val = av_expr_eval(ctx->region_expr[i], vars, NULL);
         if (val < 0.0) {
-            av_log(avctx, AV_LOG_WARNING, "Calculated value %g for %c is "
+            av_log(avctx, AV_LOG_WARNING, "Calculated value %g for %s is "
                    "less than zero - using zero instead.\n", val,
                    addroi_param_names[i]);
             val = 0.0;
         } else if (val > max_value) {
-            av_log(avctx, AV_LOG_WARNING, "Calculated value %g for %c is "
+            av_log(avctx, AV_LOG_WARNING, "Calculated value %g for %s is "
                    "greater than maximum allowed value %d - "
                    "using %d instead.\n", val, addroi_param_names[i],
                    max_value, max_value);
@@ -194,7 +194,7 @@
                             0, avctx);
         if (err < 0) {
             av_log(ctx, AV_LOG_ERROR,
-                   "Error parsing %c expression '%s'.\n",
+                   "Error parsing %s expression '%s'.\n",
                    addroi_param_names[i], ctx->region_str[i]);
             return err;
         }
diff --git a/libavfilter/vf_atadenoise.c b/libavfilter/vf_atadenoise.c
index ccbda72..e1a8220 100644
--- a/libavfilter/vf_atadenoise.c
+++ b/libavfilter/vf_atadenoise.c
@@ -44,7 +44,6 @@
     const AVClass *class;
 
     float fthra[4], fthrb[4];
-    float sigma[4];
     int thra[4], thrb[4];
     int algorithm;
 
@@ -56,8 +55,7 @@
     struct FFBufQueue q;
     void *data[4][SIZE];
     int linesize[4][SIZE];
-    float weights[4][SIZE];
-    int size, mid, radius;
+    int size, mid;
     int available;
 
     int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
@@ -81,9 +79,6 @@
     { "a",  "set variant of algorithm",      OFFSET(algorithm),AV_OPT_TYPE_INT,   {.i64=PARALLEL},  0, NB_ATAA-1, FLAGS, "a" },
     { "p",  "parallel",                      0,                AV_OPT_TYPE_CONST, {.i64=PARALLEL},  0, 0,         FLAGS, "a" },
     { "s",  "serial",                        0,                AV_OPT_TYPE_CONST, {.i64=SERIAL},    0, 0,         FLAGS, "a" },
-    { "0s", "set sigma for 1st plane",       OFFSET(sigma[0]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
-    { "1s", "set sigma for 2nd plane",       OFFSET(sigma[1]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
-    { "2s", "set sigma for 3rd plane",       OFFSET(sigma[2]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
     { NULL }
 };
 
@@ -134,8 +129,7 @@
         av_log(ctx, AV_LOG_WARNING, "size %d is invalid. Must be an odd value, setting it to %d.\n", s->size, s->size|1);
         s->size |= 1;
     }
-    s->radius = s->size / 2;
-    s->mid = s->radius;
+    s->mid = s->size / 2 + 1;
 
     return 0;
 }
@@ -144,114 +138,11 @@
     AVFrame *in, *out;
 } ThreadData;
 
-#define WFILTER_ROW(type, name)                                             \
-static void fweight_row##name(const uint8_t *ssrc, uint8_t *ddst,           \
-                              const uint8_t *ssrcf[SIZE],                   \
-                              int w, int mid, int size,                     \
-                              int thra, int thrb, const float *weights)     \
-{                                                                           \
-    const type *src = (const type *)ssrc;                                   \
-    const type **srcf = (const type **)ssrcf;                               \
-    type *dst = (type *)ddst;                                               \
-                                                                            \
-    for (int x = 0; x < w; x++) {                                           \
-       const int srcx = src[x];                                             \
-       unsigned lsumdiff = 0, rsumdiff = 0;                                 \
-       unsigned ldiff, rdiff;                                               \
-       float sum = srcx;                                                    \
-       float wsum = 1.f;                                                    \
-       int l = 0, r = 0;                                                    \
-       int srcjx, srcix;                                                    \
-                                                                            \
-       for (int j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) {   \
-           srcjx = srcf[j][x];                                              \
-                                                                            \
-           ldiff = FFABS(srcx - srcjx);                                     \
-           lsumdiff += ldiff;                                               \
-           if (ldiff > thra ||                                              \
-               lsumdiff > thrb)                                             \
-               break;                                                       \
-           l++;                                                             \
-           sum += srcjx * weights[j];                                       \
-           wsum += weights[j];                                              \
-                                                                            \
-           srcix = srcf[i][x];                                              \
-                                                                            \
-           rdiff = FFABS(srcx - srcix);                                     \
-           rsumdiff += rdiff;                                               \
-           if (rdiff > thra ||                                              \
-               rsumdiff > thrb)                                             \
-               break;                                                       \
-           r++;                                                             \
-           sum += srcix * weights[i];                                       \
-           wsum += weights[i];                                              \
-       }                                                                    \
-                                                                            \
-       dst[x] = lrintf(sum / wsum);                                         \
-   }                                                                        \
-}
-
-WFILTER_ROW(uint8_t, 8)
-WFILTER_ROW(uint16_t, 16)
-
-#define WFILTER_ROW_SERIAL(type, name)                                      \
-static void fweight_row##name##_serial(const uint8_t *ssrc, uint8_t *ddst,  \
-                                       const uint8_t *ssrcf[SIZE],          \
-                                       int w, int mid, int size,            \
-                                       int thra, int thrb,                  \
-                                       const float *weights)                \
-{                                                                           \
-    const type *src = (const type *)ssrc;                                   \
-    const type **srcf = (const type **)ssrcf;                               \
-    type *dst = (type *)ddst;                                               \
-                                                                            \
-    for (int x = 0; x < w; x++) {                                           \
-       const int srcx = src[x];                                             \
-       unsigned lsumdiff = 0, rsumdiff = 0;                                 \
-       unsigned ldiff, rdiff;                                               \
-       float sum = srcx;                                                    \
-       float wsum = 1.f;                                                    \
-       int l = 0, r = 0;                                                    \
-       int srcjx, srcix;                                                    \
-                                                                            \
-       for (int j = mid - 1; j >= 0; j--) {                                 \
-           srcjx = srcf[j][x];                                              \
-                                                                            \
-           ldiff = FFABS(srcx - srcjx);                                     \
-           lsumdiff += ldiff;                                               \
-           if (ldiff > thra ||                                              \
-               lsumdiff > thrb)                                             \
-               break;                                                       \
-           l++;                                                             \
-           sum += srcjx * weights[j];                                       \
-           wsum += weights[j];                                              \
-       }                                                                    \
-                                                                            \
-       for (int i = mid + 1; i < size; i++) {                               \
-           srcix = srcf[i][x];                                              \
-                                                                            \
-           rdiff = FFABS(srcx - srcix);                                     \
-           rsumdiff += rdiff;                                               \
-           if (rdiff > thra ||                                              \
-               rsumdiff > thrb)                                             \
-               break;                                                       \
-           r++;                                                             \
-           sum += srcix * weights[i];                                       \
-           wsum += weights[i];                                              \
-       }                                                                    \
-                                                                            \
-       dst[x] = lrintf(sum / wsum);                                         \
-   }                                                                        \
-}
-
-WFILTER_ROW_SERIAL(uint8_t, 8)
-WFILTER_ROW_SERIAL(uint16_t, 16)
-
 #define FILTER_ROW(type, name)                                              \
 static void filter_row##name(const uint8_t *ssrc, uint8_t *ddst,            \
                              const uint8_t *ssrcf[SIZE],                    \
                              int w, int mid, int size,                      \
-                             int thra, int thrb, const float *weights)      \
+                             int thra, int thrb)                            \
 {                                                                           \
     const type *src = (const type *)ssrc;                                   \
     const type **srcf = (const type **)ssrcf;                               \
@@ -298,8 +189,7 @@
 static void filter_row##name##_serial(const uint8_t *ssrc, uint8_t *ddst,   \
                                       const uint8_t *ssrcf[SIZE],           \
                                       int w, int mid, int size,             \
-                                      int thra, int thrb,                   \
-                                      const float *weights)                 \
+                                      int thra, int thrb)                   \
 {                                                                           \
     const type *src = (const type *)ssrc;                                   \
     const type **srcf = (const type **)ssrcf;                               \
@@ -355,7 +245,6 @@
     int p, y, i;
 
     for (p = 0; p < s->nb_planes; p++) {
-        const float *weights = s->weights[p];
         const int h = s->planeheight[p];
         const int w = s->planewidth[p];
         const int slice_start = (h * jobnr) / nb_jobs;
@@ -378,7 +267,7 @@
             srcf[i] = data[i] + slice_start * linesize[i];
 
         for (y = slice_start; y < slice_end; y++) {
-            s->dsp.filter_row[p](src, dst, srcf, w, mid, size, thra, thrb, weights);
+            s->dsp.filter_row(src, dst, srcf, w, mid, size, thra, thrb);
 
             dst += out->linesize[p];
             src += in->linesize[p];
@@ -407,17 +296,10 @@
 
     depth = desc->comp[0].depth;
     s->filter_slice = filter_slice;
-
-    for (int p = 0; p < s->nb_planes; p++) {
-        if (depth == 8 && s->sigma[p] == INT16_MAX)
-            s->dsp.filter_row[p] = s->algorithm == PARALLEL ? filter_row8 : filter_row8_serial;
-        else if (s->sigma[p] == INT16_MAX)
-            s->dsp.filter_row[p] = s->algorithm == PARALLEL ? filter_row16 : filter_row16_serial;
-        else if (depth == 8 && s->sigma[p] < INT16_MAX)
-            s->dsp.filter_row[p] = s->algorithm == PARALLEL ? fweight_row8 : fweight_row8_serial;
-        else if (s->sigma[p] < INT16_MAX)
-            s->dsp.filter_row[p] = s->algorithm == PARALLEL ? fweight_row16 : fweight_row16_serial;
-    }
+    if (depth == 8)
+        s->dsp.filter_row = s->algorithm == PARALLEL ? filter_row8 : filter_row8_serial;
+    else
+        s->dsp.filter_row = s->algorithm == PARALLEL ? filter_row16 : filter_row16_serial;
 
     s->thra[0] = s->fthra[0] * (1 << depth) - 1;
     s->thra[1] = s->fthra[1] * (1 << depth) - 1;
@@ -426,18 +308,8 @@
     s->thrb[1] = s->fthrb[1] * (1 << depth) - 1;
     s->thrb[2] = s->fthrb[2] * (1 << depth) - 1;
 
-    for (int p = 0; p < s->nb_planes; p++) {
-        float sigma = s->radius * s->sigma[p];
-
-        s->weights[p][s->radius] = 1.f;
-        for (int n = 1; n <= s->radius; n++) {
-            s->weights[p][s->radius + n] =
-            s->weights[p][s->radius - n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
-        }
-    }
-
     if (ARCH_X86)
-        ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma);
+        ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm);
 
     return 0;
 }
diff --git a/libavfilter/vf_bbox.c b/libavfilter/vf_bbox.c
index acbb4ea..4ac2980 100644
--- a/libavfilter/vf_bbox.c
+++ b/libavfilter/vf_bbox.c
@@ -33,14 +33,13 @@
 typedef struct BBoxContext {
     const AVClass *class;
     int min_val;
-    int depth;
 } BBoxContext;
 
 #define OFFSET(x) offsetof(BBoxContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption bbox_options[] = {
-    { "min_val", "set minimum luminance value for bounding box", OFFSET(min_val), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, UINT16_MAX, FLAGS },
+    { "min_val", "set minimum luminance value for bounding box", OFFSET(min_val), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 254, FLAGS },
     { NULL }
 };
 
@@ -49,26 +48,11 @@
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
-        AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
+        AV_PIX_FMT_YUV420P,
+        AV_PIX_FMT_YUV444P,
+        AV_PIX_FMT_YUV440P,
+        AV_PIX_FMT_YUV422P,
+        AV_PIX_FMT_YUV411P,
         AV_PIX_FMT_NONE,
     };
 
@@ -91,7 +75,7 @@
     has_bbox =
         ff_calculate_bounding_box(&box,
                                   frame->data[0], frame->linesize[0],
-                                  inlink->w, inlink->h, bbox->min_val, bbox->depth);
+                                  inlink->w, inlink->h, bbox->min_val);
     w = box.x2 - box.x1 + 1;
     h = box.y2 - box.y1 + 1;
 
@@ -121,20 +105,6 @@
     return ff_filter_frame(inlink->dst->outputs[0], frame);
 }
 
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    BBoxContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc;
-
-    desc = av_pix_fmt_desc_get(outlink->format);
-    if (!desc)
-        return AVERROR_BUG;
-    s->depth = desc->comp[0].depth;
-
-    return 0;
-}
-
 static const AVFilterPad bbox_inputs[] = {
     {
         .name         = "default",
@@ -148,7 +118,6 @@
     {
         .name = "default",
         .type = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_output,
     },
     { NULL }
 };
@@ -162,5 +131,4 @@
     .inputs        = bbox_inputs,
     .outputs       = bbox_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c
index 3eaf8dd..59e008c 100644
--- a/libavfilter/vf_bilateral.c
+++ b/libavfilter/vf_bilateral.c
@@ -55,7 +55,7 @@
 } BilateralContext;
 
 #define OFFSET(x) offsetof(BilateralContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption bilateral_options[] = {
     { "sigmaS", "set spatial sigma",    OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 512, FLAGS },
@@ -92,11 +92,13 @@
     return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
 }
 
-static int config_params(AVFilterContext *ctx)
+static int config_input(AVFilterLink *inlink)
 {
-    BilateralContext *s = ctx->priv;
+    BilateralContext *s = inlink->dst->priv;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     float inv_sigma_range;
 
+    s->depth = desc->comp[0].depth;
     inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1));
     s->alpha = expf(-sqrtf(2.f) / s->sigmaS);
 
@@ -104,19 +106,6 @@
     for (int i = 0; i < (1 << s->depth); i++)
         s->range_table[i] = s->alpha * expf(-i * inv_sigma_range);
 
-    return 0;
-}
-
-static int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    BilateralContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-
-    s->depth = desc->comp[0].depth;
-
-    config_params(ctx);
-
     s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
     s->planewidth[0] = s->planewidth[3] = inlink->w;
     s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
@@ -346,21 +335,6 @@
     av_freep(&s->line_factor_b);
 }
 
-static int process_command(AVFilterContext *ctx,
-                           const char *cmd,
-                           const char *arg,
-                           char *res,
-                           int res_len,
-                           int flags)
-{
-    int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
-
-    if (ret < 0)
-        return ret;
-
-    return config_params(ctx);
-}
-
 static const AVFilterPad bilateral_inputs[] = {
     {
         .name         = "default",
@@ -389,5 +363,4 @@
     .inputs        = bilateral_inputs,
     .outputs       = bilateral_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
-    .process_command = process_command,
 };
diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c
index 565a754..4b5d8ff 100644
--- a/libavfilter/vf_blackdetect.c
+++ b/libavfilter/vf_blackdetect.c
@@ -26,7 +26,6 @@
 
 #include <float.h>
 #include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/timestamp.h"
 #include "avfilter.h"
 #include "internal.h"
@@ -45,10 +44,6 @@
     unsigned int pixel_black_th_i;
 
     unsigned int nb_black_pixels;   ///< number of black pixels counted so far
-    AVRational   time_base;
-    int          depth;
-    int          nb_threads;
-    unsigned int *counter;
 } BlackDetectContext;
 
 #define OFFSET(x) offsetof(BlackDetectContext, x)
@@ -82,19 +77,6 @@
         AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
         AV_PIX_FMT_NV12, AV_PIX_FMT_NV21,
         YUVJ_FORMATS,
-        AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
         AV_PIX_FMT_NONE
     };
 
@@ -107,139 +89,97 @@
 static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
-    BlackDetectContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    const int depth = desc->comp[0].depth;
-    const int max = (1 << depth) - 1;
-    const int factor = (1 << (depth - 8));
+    BlackDetectContext *blackdetect = ctx->priv;
 
-    s->depth = depth;
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
-    s->time_base = inlink->time_base;
-    s->black_min_duration = s->black_min_duration_time / av_q2d(s->time_base);
-    s->counter = av_calloc(s->nb_threads, sizeof(*s->counter));
-    if (!s->counter)
-        return AVERROR(ENOMEM);
+    blackdetect->black_min_duration =
+        blackdetect->black_min_duration_time / av_q2d(inlink->time_base);
 
-    s->pixel_black_th_i = ff_fmt_is_in(inlink->format, yuvj_formats) ?
+    blackdetect->pixel_black_th_i = ff_fmt_is_in(inlink->format, yuvj_formats) ?
         // luminance_minimum_value + pixel_black_th * luminance_range_size
-             s->pixel_black_th *  max :
-        16 * factor + s->pixel_black_th * (235 - 16) * factor;
+             blackdetect->pixel_black_th *  255 :
+        16 + blackdetect->pixel_black_th * (235 - 16);
 
-    av_log(s, AV_LOG_VERBOSE,
+    av_log(blackdetect, AV_LOG_VERBOSE,
            "black_min_duration:%s pixel_black_th:%f pixel_black_th_i:%d picture_black_ratio_th:%f\n",
-           av_ts2timestr(s->black_min_duration, &s->time_base),
-           s->pixel_black_th, s->pixel_black_th_i,
-           s->picture_black_ratio_th);
+           av_ts2timestr(blackdetect->black_min_duration, &inlink->time_base),
+           blackdetect->pixel_black_th, blackdetect->pixel_black_th_i,
+           blackdetect->picture_black_ratio_th);
     return 0;
 }
 
 static void check_black_end(AVFilterContext *ctx)
 {
-    BlackDetectContext *s = ctx->priv;
+    BlackDetectContext *blackdetect = ctx->priv;
+    AVFilterLink *inlink = ctx->inputs[0];
 
-    if ((s->black_end - s->black_start) >= s->black_min_duration) {
-        av_log(s, AV_LOG_INFO,
+    if ((blackdetect->black_end - blackdetect->black_start) >= blackdetect->black_min_duration) {
+        av_log(blackdetect, AV_LOG_INFO,
                "black_start:%s black_end:%s black_duration:%s\n",
-               av_ts2timestr(s->black_start, &s->time_base),
-               av_ts2timestr(s->black_end,   &s->time_base),
-               av_ts2timestr(s->black_end - s->black_start, &s->time_base));
+               av_ts2timestr(blackdetect->black_start, &inlink->time_base),
+               av_ts2timestr(blackdetect->black_end,   &inlink->time_base),
+               av_ts2timestr(blackdetect->black_end - blackdetect->black_start, &inlink->time_base));
     }
 }
 
-static int black_counter(AVFilterContext *ctx, void *arg,
-                         int jobnr, int nb_jobs)
+static int request_frame(AVFilterLink *outlink)
 {
-    BlackDetectContext *s = ctx->priv;
-    const unsigned int threshold = s->pixel_black_th_i;
-    unsigned int *counterp = &s->counter[jobnr];
-    AVFrame *in = arg;
-    const int linesize = in->linesize[0];
-    const int w = in->width;
-    const int h = in->height;
-    const int start = (h * jobnr) / nb_jobs;
-    const int end = (h * (jobnr+1)) / nb_jobs;
-    const int size = end - start;
-    unsigned int counter = 0;
+    AVFilterContext *ctx = outlink->src;
+    BlackDetectContext *blackdetect = ctx->priv;
+    AVFilterLink *inlink = ctx->inputs[0];
+    int ret = ff_request_frame(inlink);
 
-    if (s->depth == 8) {
-        const uint8_t *p = in->data[0] + start * linesize;
-
-        for (int i = 0; i < size; i++) {
-            for (int x = 0; x < w; x++)
-                counter += p[x] <= threshold;
-            p += linesize;
-        }
-    } else {
-        const uint16_t *p = (const uint16_t *)(in->data[0] + start * linesize);
-
-        for (int i = 0; i < size; i++) {
-            for (int x = 0; x < w; x++)
-                counter += p[x] <= threshold;
-            p += linesize / 2;
-        }
+    if (ret == AVERROR_EOF && blackdetect->black_started) {
+        // FIXME: black_end should be set to last_picref_pts + last_picref_duration
+        blackdetect->black_end = blackdetect->last_picref_pts;
+        check_black_end(ctx);
     }
-
-    *counterp = counter;
-
-    return 0;
+    return ret;
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
 {
     AVFilterContext *ctx = inlink->dst;
-    BlackDetectContext *s = ctx->priv;
+    BlackDetectContext *blackdetect = ctx->priv;
     double picture_black_ratio = 0;
+    const uint8_t *p = picref->data[0];
+    int x, i;
 
-    ctx->internal->execute(ctx, black_counter, picref, NULL,
-                           FFMIN(inlink->h, s->nb_threads));
+    for (i = 0; i < inlink->h; i++) {
+        for (x = 0; x < inlink->w; x++)
+            blackdetect->nb_black_pixels += p[x] <= blackdetect->pixel_black_th_i;
+        p += picref->linesize[0];
+    }
 
-    for (int i = 0; i < s->nb_threads; i++)
-        s->nb_black_pixels += s->counter[i];
-
-    picture_black_ratio = (double)s->nb_black_pixels / (inlink->w * inlink->h);
+    picture_black_ratio = (double)blackdetect->nb_black_pixels / (inlink->w * inlink->h);
 
     av_log(ctx, AV_LOG_DEBUG,
            "frame:%"PRId64" picture_black_ratio:%f pts:%s t:%s type:%c\n",
            inlink->frame_count_out, picture_black_ratio,
-           av_ts2str(picref->pts), av_ts2timestr(picref->pts, &s->time_base),
+           av_ts2str(picref->pts), av_ts2timestr(picref->pts, &inlink->time_base),
            av_get_picture_type_char(picref->pict_type));
 
-    if (picture_black_ratio >= s->picture_black_ratio_th) {
-        if (!s->black_started) {
+    if (picture_black_ratio >= blackdetect->picture_black_ratio_th) {
+        if (!blackdetect->black_started) {
             /* black starts here */
-            s->black_started = 1;
-            s->black_start = picref->pts;
+            blackdetect->black_started = 1;
+            blackdetect->black_start = picref->pts;
             av_dict_set(&picref->metadata, "lavfi.black_start",
-                av_ts2timestr(s->black_start, &s->time_base), 0);
+                av_ts2timestr(blackdetect->black_start, &inlink->time_base), 0);
         }
-    } else if (s->black_started) {
+    } else if (blackdetect->black_started) {
         /* black ends here */
-        s->black_started = 0;
-        s->black_end = picref->pts;
+        blackdetect->black_started = 0;
+        blackdetect->black_end = picref->pts;
         check_black_end(ctx);
         av_dict_set(&picref->metadata, "lavfi.black_end",
-            av_ts2timestr(s->black_end, &s->time_base), 0);
+            av_ts2timestr(blackdetect->black_end, &inlink->time_base), 0);
     }
 
-    s->last_picref_pts = picref->pts;
-    s->nb_black_pixels = 0;
+    blackdetect->last_picref_pts = picref->pts;
+    blackdetect->nb_black_pixels = 0;
     return ff_filter_frame(inlink->dst->outputs[0], picref);
 }
 
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    BlackDetectContext *s = ctx->priv;
-
-    av_freep(&s->counter);
-
-    if (s->black_started) {
-        // FIXME: black_end should be set to last_picref_pts + last_picref_duration
-        s->black_end = s->last_picref_pts;
-        check_black_end(ctx);
-    }
-}
-
 static const AVFilterPad blackdetect_inputs[] = {
     {
         .name          = "default",
@@ -254,6 +194,7 @@
     {
         .name          = "default",
         .type          = AVMEDIA_TYPE_VIDEO,
+        .request_frame = request_frame,
     },
     { NULL }
 };
@@ -265,7 +206,5 @@
     .query_formats = query_formats,
     .inputs        = blackdetect_inputs,
     .outputs       = blackdetect_outputs,
-    .uninit        = uninit,
     .priv_class    = &blackdetect_class,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index d12bfff..d59bed8 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -60,60 +60,63 @@
     FilterParams *param;
 } ThreadData;
 
+#define COMMON_OPTIONS \
+    { "c0_mode", "set component #0 blend mode", OFFSET(params[0].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode"},\
+    { "c1_mode", "set component #1 blend mode", OFFSET(params[1].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode"},\
+    { "c2_mode", "set component #2 blend mode", OFFSET(params[2].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode"},\
+    { "c3_mode", "set component #3 blend mode", OFFSET(params[3].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode"},\
+    { "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, {.i64=-1},-1, BLEND_NB-1, FLAGS, "mode"},\
+    { "addition",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_ADDITION},   0, 0, FLAGS, "mode" },\
+    { "addition128","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINMERGE}, 0, 0, FLAGS, "mode" },\
+    { "grainmerge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINMERGE}, 0, 0, FLAGS, "mode" },\
+    { "and",        "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_AND},        0, 0, FLAGS, "mode" },\
+    { "average",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_AVERAGE},    0, 0, FLAGS, "mode" },\
+    { "burn",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_BURN},       0, 0, FLAGS, "mode" },\
+    { "darken",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DARKEN},     0, 0, FLAGS, "mode" },\
+    { "difference", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE}, 0, 0, FLAGS, "mode" },\
+    { "difference128", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINEXTRACT}, 0, 0, FLAGS, "mode" },\
+    { "grainextract", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINEXTRACT}, 0, 0, FLAGS, "mode" },\
+    { "divide",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE},     0, 0, FLAGS, "mode" },\
+    { "dodge",      "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE},      0, 0, FLAGS, "mode" },\
+    { "exclusion",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION},  0, 0, FLAGS, "mode" },\
+    { "extremity",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXTREMITY},  0, 0, FLAGS, "mode" },\
+    { "freeze",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_FREEZE},     0, 0, FLAGS, "mode" },\
+    { "glow",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GLOW},       0, 0, FLAGS, "mode" },\
+    { "hardlight",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT},  0, 0, FLAGS, "mode" },\
+    { "hardmix",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDMIX},    0, 0, FLAGS, "mode" },\
+    { "heat",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HEAT},       0, 0, FLAGS, "mode" },\
+    { "lighten",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN},    0, 0, FLAGS, "mode" },\
+    { "linearlight","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LINEARLIGHT},0, 0, FLAGS, "mode" },\
+    { "multiply",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY},   0, 0, FLAGS, "mode" },\
+    { "multiply128","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY128},0, 0, FLAGS, "mode" },\
+    { "negation",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION},   0, 0, FLAGS, "mode" },\
+    { "normal",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NORMAL},     0, 0, FLAGS, "mode" },\
+    { "or",         "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_OR},         0, 0, FLAGS, "mode" },\
+    { "overlay",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_OVERLAY},    0, 0, FLAGS, "mode" },\
+    { "phoenix",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_PHOENIX},    0, 0, FLAGS, "mode" },\
+    { "pinlight",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_PINLIGHT},   0, 0, FLAGS, "mode" },\
+    { "reflect",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_REFLECT},    0, 0, FLAGS, "mode" },\
+    { "screen",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SCREEN},     0, 0, FLAGS, "mode" },\
+    { "softlight",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTLIGHT},  0, 0, FLAGS, "mode" },\
+    { "subtract",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SUBTRACT},   0, 0, FLAGS, "mode" },\
+    { "vividlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_VIVIDLIGHT}, 0, 0, FLAGS, "mode" },\
+    { "xor",        "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_XOR},        0, 0, FLAGS, "mode" },\
+    { "c0_expr",  "set color component #0 expression", OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },\
+    { "c1_expr",  "set color component #1 expression", OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },\
+    { "c2_expr",  "set color component #2 expression", OFFSET(params[2].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },\
+    { "c3_expr",  "set color component #3 expression", OFFSET(params[3].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },\
+    { "all_expr", "set expression for all color components", OFFSET(all_expr), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },\
+    { "c0_opacity",  "set color component #0 opacity", OFFSET(params[0].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },\
+    { "c1_opacity",  "set color component #1 opacity", OFFSET(params[1].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },\
+    { "c2_opacity",  "set color component #2 opacity", OFFSET(params[2].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },\
+    { "c3_opacity",  "set color component #3 opacity", OFFSET(params[3].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },\
+    { "all_opacity", "set opacity for all color components", OFFSET(all_opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS}
+
 #define OFFSET(x) offsetof(BlendContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption blend_options[] = {
-    { "c0_mode", "set component #0 blend mode", OFFSET(params[0].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode" },
-    { "c1_mode", "set component #1 blend mode", OFFSET(params[1].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode" },
-    { "c2_mode", "set component #2 blend mode", OFFSET(params[2].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode" },
-    { "c3_mode", "set component #3 blend mode", OFFSET(params[3].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode" },
-    { "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, {.i64=-1},-1, BLEND_NB-1, FLAGS, "mode" },
-    { "addition",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_ADDITION},   0, 0, FLAGS, "mode" },
-    { "addition128","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINMERGE}, 0, 0, FLAGS, "mode" },
-    { "grainmerge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINMERGE}, 0, 0, FLAGS, "mode" },
-    { "and",        "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_AND},        0, 0, FLAGS, "mode" },
-    { "average",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_AVERAGE},    0, 0, FLAGS, "mode" },
-    { "burn",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_BURN},       0, 0, FLAGS, "mode" },
-    { "darken",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DARKEN},     0, 0, FLAGS, "mode" },
-    { "difference", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE}, 0, 0, FLAGS, "mode" },
-    { "difference128", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINEXTRACT}, 0, 0, FLAGS, "mode" },
-    { "grainextract", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINEXTRACT}, 0, 0, FLAGS, "mode" },
-    { "divide",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE},     0, 0, FLAGS, "mode" },
-    { "dodge",      "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE},      0, 0, FLAGS, "mode" },
-    { "exclusion",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION},  0, 0, FLAGS, "mode" },
-    { "extremity",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXTREMITY},  0, 0, FLAGS, "mode" },
-    { "freeze",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_FREEZE},     0, 0, FLAGS, "mode" },
-    { "glow",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GLOW},       0, 0, FLAGS, "mode" },
-    { "hardlight",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT},  0, 0, FLAGS, "mode" },
-    { "hardmix",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDMIX},    0, 0, FLAGS, "mode" },
-    { "heat",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HEAT},       0, 0, FLAGS, "mode" },
-    { "lighten",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN},    0, 0, FLAGS, "mode" },
-    { "linearlight","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LINEARLIGHT},0, 0, FLAGS, "mode" },
-    { "multiply",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY},   0, 0, FLAGS, "mode" },
-    { "multiply128","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY128},0, 0, FLAGS, "mode" },
-    { "negation",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION},   0, 0, FLAGS, "mode" },
-    { "normal",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NORMAL},     0, 0, FLAGS, "mode" },
-    { "or",         "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_OR},         0, 0, FLAGS, "mode" },
-    { "overlay",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_OVERLAY},    0, 0, FLAGS, "mode" },
-    { "phoenix",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_PHOENIX},    0, 0, FLAGS, "mode" },
-    { "pinlight",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_PINLIGHT},   0, 0, FLAGS, "mode" },
-    { "reflect",    "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_REFLECT},    0, 0, FLAGS, "mode" },
-    { "screen",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SCREEN},     0, 0, FLAGS, "mode" },
-    { "softlight",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTLIGHT},  0, 0, FLAGS, "mode" },
-    { "subtract",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SUBTRACT},   0, 0, FLAGS, "mode" },
-    { "vividlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_VIVIDLIGHT}, 0, 0, FLAGS, "mode" },
-    { "xor",        "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_XOR},        0, 0, FLAGS, "mode" },
-    { "c0_expr",  "set color component #0 expression", OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "c1_expr",  "set color component #1 expression", OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "c2_expr",  "set color component #2 expression", OFFSET(params[2].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "c3_expr",  "set color component #3 expression", OFFSET(params[3].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "all_expr", "set expression for all color components", OFFSET(all_expr), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "c0_opacity",  "set color component #0 opacity", OFFSET(params[0].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
-    { "c1_opacity",  "set color component #1 opacity", OFFSET(params[1].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
-    { "c2_opacity",  "set color component #2 opacity", OFFSET(params[2].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
-    { "c3_opacity",  "set color component #3 opacity", OFFSET(params[3].opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
-    { "all_opacity", "set opacity for all color components", OFFSET(all_opacity), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
+    COMMON_OPTIONS,
     { NULL }
 };
 
@@ -780,45 +783,13 @@
         ff_blend_init_x86(param, depth);
 }
 
-static int config_params(AVFilterContext *ctx)
-{
-    BlendContext *s = ctx->priv;
-    int ret;
-
-    for (int plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) {
-        FilterParams *param = &s->params[plane];
-
-        if (s->all_mode >= 0)
-            param->mode = s->all_mode;
-        if (s->all_opacity < 1)
-            param->opacity = s->all_opacity;
-
-        ff_blend_init(param, s->depth);
-
-        if (s->all_expr && !param->expr_str) {
-            param->expr_str = av_strdup(s->all_expr);
-            if (!param->expr_str)
-                return AVERROR(ENOMEM);
-        }
-        if (param->expr_str) {
-            ret = av_expr_parse(&param->e, param->expr_str, var_names,
-                                NULL, NULL, NULL, NULL, 0, ctx);
-            if (ret < 0)
-                return ret;
-            param->blend = s->depth > 8 ? s->depth > 16 ? blend_expr_32bit : blend_expr_16bit : blend_expr_8bit;
-        }
-    }
-
-    return 0;
-}
-
 static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     AVFilterLink *toplink = ctx->inputs[TOP];
     BlendContext *s = ctx->priv;
     const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(toplink->format);
-    int ret;
+    int ret, plane;
 
     if (!s->tblend) {
         AVFilterLink *bottomlink = ctx->inputs[BOTTOM];
@@ -853,9 +824,29 @@
         if ((ret = ff_framesync_init_dualinput(&s->fs, ctx)) < 0)
             return ret;
 
-    ret = config_params(ctx);
-    if (ret < 0)
-        return ret;
+    for (plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) {
+        FilterParams *param = &s->params[plane];
+
+        if (s->all_mode >= 0)
+            param->mode = s->all_mode;
+        if (s->all_opacity < 1)
+            param->opacity = s->all_opacity;
+
+        ff_blend_init(param, s->depth);
+
+        if (s->all_expr && !param->expr_str) {
+            param->expr_str = av_strdup(s->all_expr);
+            if (!param->expr_str)
+                return AVERROR(ENOMEM);
+        }
+        if (param->expr_str) {
+            ret = av_expr_parse(&param->e, param->expr_str, var_names,
+                                NULL, NULL, NULL, NULL, 0, ctx);
+            if (ret < 0)
+                return ret;
+            param->blend = s->depth > 8 ? s->depth > 16 ? blend_expr_32bit : blend_expr_16bit : blend_expr_8bit;
+        }
+    }
 
     if (s->tblend)
         return 0;
@@ -866,18 +857,6 @@
     return ret;
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_params(ctx);
-}
-
 #if CONFIG_BLEND_FILTER
 
 static int activate(AVFilterContext *ctx)
@@ -919,7 +898,6 @@
     .outputs       = blend_outputs,
     .priv_class    = &blend_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 #endif
@@ -947,7 +925,11 @@
     return 0;
 }
 
-#define tblend_options blend_options
+static const AVOption tblend_options[] = {
+    COMMON_OPTIONS,
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(tblend);
 
 static const AVFilterPad tblend_inputs[] = {
@@ -979,7 +961,6 @@
     .inputs        = tblend_inputs,
     .outputs       = tblend_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 #endif
diff --git a/libavfilter/vf_chromanr.c b/libavfilter/vf_chromanr.c
index 0632530..3c027b8 100644
--- a/libavfilter/vf_chromanr.c
+++ b/libavfilter/vf_chromanr.c
@@ -58,11 +58,11 @@
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV444P,
+        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
         AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
         AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P,
         AV_PIX_FMT_YUV420P9,   AV_PIX_FMT_YUV422P9,   AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10,  AV_PIX_FMT_YUV422P10,  AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV444P10,
+        AV_PIX_FMT_YUV420P10,  AV_PIX_FMT_YUV422P10,  AV_PIX_FMT_YUV444P10,
         AV_PIX_FMT_YUV444P12,  AV_PIX_FMT_YUV422P12,  AV_PIX_FMT_YUV440P12, AV_PIX_FMT_YUV420P12,
         AV_PIX_FMT_YUV444P14,  AV_PIX_FMT_YUV422P14,  AV_PIX_FMT_YUV420P14,
         AV_PIX_FMT_YUV420P16,  AV_PIX_FMT_YUV422P16,  AV_PIX_FMT_YUV444P16,
diff --git a/libavfilter/vf_codecview.c b/libavfilter/vf_codecview.c
index 197dc96..331bfba 100644
--- a/libavfilter/vf_codecview.c
+++ b/libavfilter/vf_codecview.c
@@ -33,7 +33,6 @@
 #include "libavutil/motion_vector.h"
 #include "libavutil/opt.h"
 #include "avfilter.h"
-#include "qp_table.h"
 #include "internal.h"
 
 #define MV_P_FOR  (1<<0)
@@ -220,14 +219,8 @@
     AVFilterLink *outlink = ctx->outputs[0];
 
     if (s->qp) {
-        int qstride, qp_type, ret;
-        int8_t *qp_table;
-
-        ret = ff_qp_table_extract(frame, &qp_table, &qstride, NULL, &qp_type);
-        if (ret < 0) {
-            av_frame_free(&frame);
-            return ret;
-        }
+        int qstride, qp_type;
+        int8_t *qp_table = av_frame_get_qp_table(frame, &qstride, &qp_type);
 
         if (qp_table) {
             int x, y;
@@ -247,7 +240,6 @@
                 pv += lzv;
             }
         }
-        av_freep(&qp_table);
     }
 
     if (s->mv || s->mv_type) {
diff --git a/libavfilter/vf_colorchannelmixer.c b/libavfilter/vf_colorchannelmixer.c
index 9857a66..3bbe44d 100644
--- a/libavfilter/vf_colorchannelmixer.c
+++ b/libavfilter/vf_colorchannelmixer.c
@@ -18,8 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <float.h>
-
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
@@ -43,8 +41,6 @@
     double gr, gg, gb, ga;
     double br, bg, bb, ba;
     double ar, ag, ab, aa;
-    double sr, sg, sb;
-    double preserve_lightness;
 
     int *lut[4][4];
 
@@ -52,7 +48,7 @@
 
     uint8_t rgba_map[4];
 
-    int (*filter_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
+    int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
 } ColorChannelMixerContext;
 
 #define OFFSET(x) offsetof(ColorChannelMixerContext, x)
@@ -75,7 +71,6 @@
     { "ag", "set the green gain for the alpha channel", OFFSET(ag), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
     { "ab", "set the blue gain for the alpha channel",  OFFSET(ab), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
     { "aa", "set the alpha gain for the alpha channel", OFFSET(aa), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS },
-    { "pl", "preserve lightness",       OFFSET(preserve_lightness), AV_OPT_TYPE_DOUBLE, {.dbl=0},  0, 1, FLAGS },
     { NULL }
 };
 
@@ -106,29 +101,13 @@
     return ff_set_common_formats(ctx, fmts_list);
 }
 
-static float lerpf(float v0, float v1, float f)
-{
-    return v0 + (v1 - v0) * f;
-}
-
-static void preservel(float *r, float *g, float *b, float lin, float lout)
-{
-    *r *= lout / lin;
-    *g *= lout / lin;
-    *b *= lout / lin;
-}
-
 static av_always_inline int filter_slice_rgba_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs,
-                                                     int have_alpha, int pl)
+                                                     int have_alpha)
 {
     ColorChannelMixerContext *s = ctx->priv;
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const float l = s->preserve_lightness;
-    const float sr = s->sr;
-    const float sg = s->sg;
-    const float sb = s->sb;
     const int slice_start = (out->height * jobnr) / nb_jobs;
     const int slice_end = (out->height * (jobnr+1)) / nb_jobs;
     const uint8_t *srcg = in->data[0] + slice_start * in->linesize[0];
@@ -147,42 +126,19 @@
             const uint8_t gin = srcg[j];
             const uint8_t bin = srcb[j];
             const uint8_t ain = have_alpha ? srca[j] : 0;
-            int rout, gout, bout;
-            float lin;
 
-            if (pl)
-                lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
-
-            rout = s->lut[R][R][rin] +
-                   s->lut[R][G][gin] +
-                   s->lut[R][B][bin] +
-                   (have_alpha == 1 ? s->lut[R][A][ain] : 0);
-            gout = s->lut[G][R][rin] +
-                   s->lut[G][G][gin] +
-                   s->lut[G][B][bin] +
-                   (have_alpha == 1 ? s->lut[G][A][ain] : 0);
-            bout = s->lut[B][R][rin] +
-                   s->lut[B][G][gin] +
-                   s->lut[B][B][bin] +
-                   (have_alpha == 1 ? s->lut[B][A][ain] : 0);
-
-            if (pl) {
-                float frout = rout / sr;
-                float fgout = gout / sg;
-                float fbout = bout / sb;
-                float lout = FFMAX3(frout, fgout, fbout) + FFMIN3(frout, fgout, fbout);
-
-                preservel(&frout, &fgout, &fbout, lin, lout);
-
-                rout = lrintf(lerpf(rout, frout, l));
-                gout = lrintf(lerpf(gout, fgout, l));
-                bout = lrintf(lerpf(bout, fbout, l));
-            }
-
-            dstr[j] = av_clip_uint8(rout);
-            dstg[j] = av_clip_uint8(gout);
-            dstb[j] = av_clip_uint8(bout);
-
+            dstr[j] = av_clip_uint8(s->lut[R][R][rin] +
+                                    s->lut[R][G][gin] +
+                                    s->lut[R][B][bin] +
+                                    (have_alpha == 1 ? s->lut[R][A][ain] : 0));
+            dstg[j] = av_clip_uint8(s->lut[G][R][rin] +
+                                    s->lut[G][G][gin] +
+                                    s->lut[G][B][bin] +
+                                    (have_alpha == 1 ? s->lut[G][A][ain] : 0));
+            dstb[j] = av_clip_uint8(s->lut[B][R][rin] +
+                                    s->lut[B][G][gin] +
+                                    s->lut[B][B][bin] +
+                                    (have_alpha == 1 ? s->lut[B][A][ain] : 0));
             if (have_alpha == 1) {
                 dsta[j] = av_clip_uint8(s->lut[A][R][rin] +
                                         s->lut[A][G][gin] +
@@ -205,16 +161,12 @@
 }
 
 static av_always_inline int filter_slice_rgba16_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs,
-                                                       int have_alpha, int depth, int pl)
+                                                       int have_alpha, int depth)
 {
     ColorChannelMixerContext *s = ctx->priv;
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const float l = s->preserve_lightness;
-    const float sr = s->sr;
-    const float sg = s->sg;
-    const float sb = s->sb;
     const int slice_start = (out->height * jobnr) / nb_jobs;
     const int slice_end = (out->height * (jobnr+1)) / nb_jobs;
     const uint16_t *srcg = (const uint16_t *)(in->data[0] + slice_start * in->linesize[0]);
@@ -233,42 +185,19 @@
             const uint16_t gin = srcg[j];
             const uint16_t bin = srcb[j];
             const uint16_t ain = have_alpha ? srca[j] : 0;
-            int rout, gout, bout;
-            float lin;
 
-            if (pl)
-                lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
-
-            rout = s->lut[R][R][rin] +
-                   s->lut[R][G][gin] +
-                   s->lut[R][B][bin] +
-                   (have_alpha == 1 ? s->lut[R][A][ain] : 0);
-            gout = s->lut[G][R][rin] +
-                   s->lut[G][G][gin] +
-                   s->lut[G][B][bin] +
-                   (have_alpha == 1 ? s->lut[G][A][ain] : 0);
-            bout = s->lut[B][R][rin] +
-                   s->lut[B][G][gin] +
-                   s->lut[B][B][bin] +
-                   (have_alpha == 1 ? s->lut[B][A][ain] : 0);
-
-            if (pl) {
-                float frout = rout / sr;
-                float fgout = gout / sg;
-                float fbout = bout / sb;
-                float lout = FFMAX3(frout, fgout, fbout) + FFMIN3(frout, fgout, fbout);
-
-                preservel(&frout, &fgout, &fbout, lin, lout);
-
-                rout = lrintf(lerpf(rout, frout, l));
-                gout = lrintf(lerpf(gout, fgout, l));
-                bout = lrintf(lerpf(bout, fbout, l));
-            }
-
-            dstr[j] = av_clip_uintp2(rout, depth);
-            dstg[j] = av_clip_uintp2(gout, depth);
-            dstb[j] = av_clip_uintp2(bout, depth);
-
+            dstr[j] = av_clip_uintp2(s->lut[R][R][rin] +
+                                     s->lut[R][G][gin] +
+                                     s->lut[R][B][bin] +
+                                     (have_alpha == 1 ? s->lut[R][A][ain] : 0), depth);
+            dstg[j] = av_clip_uintp2(s->lut[G][R][rin] +
+                                     s->lut[G][G][gin] +
+                                     s->lut[G][B][bin] +
+                                     (have_alpha == 1 ? s->lut[G][A][ain] : 0), depth);
+            dstb[j] = av_clip_uintp2(s->lut[B][R][rin] +
+                                     s->lut[B][G][gin] +
+                                     s->lut[B][B][bin] +
+                                     (have_alpha == 1 ? s->lut[B][A][ain] : 0), depth);
             if (have_alpha == 1) {
                 dsta[j] = av_clip_uintp2(s->lut[A][R][rin] +
                                          s->lut[A][G][gin] +
@@ -292,115 +221,61 @@
 
 static int filter_slice_gbrp(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba_planar(ctx, arg, jobnr, nb_jobs, 0, 0);
+    return filter_slice_rgba_planar(ctx, arg, jobnr, nb_jobs, 0);
 }
 
 static int filter_slice_gbrap(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba_planar(ctx, arg, jobnr, nb_jobs, 1, 0);
-}
-
-static int filter_slice_gbrp_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba_planar(ctx, arg, jobnr, nb_jobs, 0, 1);
-}
-
-static int filter_slice_gbrap_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba_planar(ctx, arg, jobnr, nb_jobs, 1, 1);
+    return filter_slice_rgba_planar(ctx, arg, jobnr, nb_jobs, 1);
 }
 
 static int filter_slice_gbrp9(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 9, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 9);
 }
 
 static int filter_slice_gbrp10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 10, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 10);
 }
 
 static int filter_slice_gbrap10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 10, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 10);
 }
 
 static int filter_slice_gbrp12(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 12, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 12);
 }
 
 static int filter_slice_gbrap12(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 12, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 12);
 }
 
 static int filter_slice_gbrp14(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 14, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 14);
 }
 
 static int filter_slice_gbrp16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 16, 0);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 16);
 }
 
 static int filter_slice_gbrap16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 16, 0);
-}
-
-static int filter_slice_gbrp9_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 9, 1);
-}
-
-static int filter_slice_gbrp10_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 10, 1);
-}
-
-static int filter_slice_gbrap10_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 10, 1);
-}
-
-static int filter_slice_gbrp12_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 12, 1);
-}
-
-static int filter_slice_gbrap12_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 12, 1);
-}
-
-static int filter_slice_gbrp14_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 14, 1);
-}
-
-static int filter_slice_gbrp16_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 0, 16, 1);
-}
-
-static int filter_slice_gbrap16_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 16, 1);
+    return filter_slice_rgba16_planar(ctx, arg, jobnr, nb_jobs, 1, 16);
 }
 
 static av_always_inline int filter_slice_rgba_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs,
-                                                     int have_alpha, int step, int pl)
+                                                     int have_alpha, int step)
 {
     ColorChannelMixerContext *s = ctx->priv;
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const float l = s->preserve_lightness;
-    const float sr = s->sr;
-    const float sg = s->sg;
-    const float sb = s->sb;
     const int slice_start = (out->height * jobnr) / nb_jobs;
     const int slice_end = (out->height * (jobnr+1)) / nb_jobs;
     const uint8_t roffset = s->rgba_map[R];
@@ -420,42 +295,19 @@
             const uint8_t gin = src[j + goffset];
             const uint8_t bin = src[j + boffset];
             const uint8_t ain = src[j + aoffset];
-            int rout, gout, bout;
-            float lin;
 
-            if (pl)
-                lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
-
-            rout = s->lut[R][R][rin] +
-                   s->lut[R][G][gin] +
-                   s->lut[R][B][bin] +
-                   (have_alpha == 1 ? s->lut[R][A][ain] : 0);
-            gout = s->lut[G][R][rin] +
-                   s->lut[G][G][gin] +
-                   s->lut[G][B][bin] +
-                   (have_alpha == 1 ? s->lut[G][A][ain] : 0);
-            bout = s->lut[B][R][rin] +
-                   s->lut[B][G][gin] +
-                   s->lut[B][B][bin] +
-                   (have_alpha == 1 ? s->lut[B][A][ain] : 0);
-
-            if (pl) {
-                float frout = rout / sr;
-                float fgout = gout / sg;
-                float fbout = bout / sb;
-                float lout = FFMAX3(frout, fgout, fbout) + FFMIN3(frout, fgout, fbout);
-
-                preservel(&frout, &fgout, &fbout, lin, lout);
-
-                rout = lrintf(lerpf(rout, frout, l));
-                gout = lrintf(lerpf(gout, fgout, l));
-                bout = lrintf(lerpf(bout, fbout, l));
-            }
-
-            dst[j + roffset] = av_clip_uint8(rout);
-            dst[j + goffset] = av_clip_uint8(gout);
-            dst[j + boffset] = av_clip_uint8(bout);
-
+            dst[j + roffset] = av_clip_uint8(s->lut[R][R][rin] +
+                                             s->lut[R][G][gin] +
+                                             s->lut[R][B][bin] +
+                                             (have_alpha == 1 ? s->lut[R][A][ain] : 0));
+            dst[j + goffset] = av_clip_uint8(s->lut[G][R][rin] +
+                                             s->lut[G][G][gin] +
+                                             s->lut[G][B][bin] +
+                                             (have_alpha == 1 ? s->lut[G][A][ain] : 0));
+            dst[j + boffset] = av_clip_uint8(s->lut[B][R][rin] +
+                                             s->lut[B][G][gin] +
+                                             s->lut[B][B][bin] +
+                                             (have_alpha == 1 ? s->lut[B][A][ain] : 0));
             if (have_alpha == 1) {
                 dst[j + aoffset] = av_clip_uint8(s->lut[A][R][rin] +
                                                  s->lut[A][G][gin] +
@@ -473,16 +325,12 @@
 }
 
 static av_always_inline int filter_slice_rgba16_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs,
-                                                       int have_alpha, int step, int pl)
+                                                       int have_alpha, int step)
 {
     ColorChannelMixerContext *s = ctx->priv;
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const float l = s->preserve_lightness;
-    const float sr = s->sr;
-    const float sg = s->sg;
-    const float sb = s->sb;
     const int slice_start = (out->height * jobnr) / nb_jobs;
     const int slice_end = (out->height * (jobnr+1)) / nb_jobs;
     const uint8_t roffset = s->rgba_map[R];
@@ -502,42 +350,19 @@
             const uint16_t gin = src[j + goffset];
             const uint16_t bin = src[j + boffset];
             const uint16_t ain = src[j + aoffset];
-            int rout, gout, bout;
-            float lin;
 
-            if (pl)
-                lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
-
-            rout = s->lut[R][R][rin] +
-                   s->lut[R][G][gin] +
-                   s->lut[R][B][bin] +
-                   (have_alpha == 1 ? s->lut[R][A][ain] : 0);
-            gout = s->lut[G][R][rin] +
-                   s->lut[G][G][gin] +
-                   s->lut[G][B][bin] +
-                   (have_alpha == 1 ? s->lut[G][A][ain] : 0);
-            bout = s->lut[B][R][rin] +
-                   s->lut[B][G][gin] +
-                   s->lut[B][B][bin] +
-                   (have_alpha == 1 ? s->lut[B][A][ain] : 0);
-
-            if (pl) {
-                float frout = rout / sr;
-                float fgout = gout / sg;
-                float fbout = bout / sb;
-                float lout = FFMAX3(frout, fgout, fbout) + FFMIN3(frout, fgout, fbout);
-
-                preservel(&frout, &fgout, &fbout, lin, lout);
-
-                rout = lrintf(lerpf(rout, frout, l));
-                gout = lrintf(lerpf(gout, fgout, l));
-                bout = lrintf(lerpf(bout, fbout, l));
-            }
-
-            dst[j + roffset] = av_clip_uint16(rout);
-            dst[j + goffset] = av_clip_uint16(gout);
-            dst[j + boffset] = av_clip_uint16(bout);
-
+            dst[j + roffset] = av_clip_uint16(s->lut[R][R][rin] +
+                                              s->lut[R][G][gin] +
+                                              s->lut[R][B][bin] +
+                                              (have_alpha == 1 ? s->lut[R][A][ain] : 0));
+            dst[j + goffset] = av_clip_uint16(s->lut[G][R][rin] +
+                                              s->lut[G][G][gin] +
+                                              s->lut[G][B][bin] +
+                                              (have_alpha == 1 ? s->lut[G][A][ain] : 0));
+            dst[j + boffset] = av_clip_uint16(s->lut[B][R][rin] +
+                                              s->lut[B][G][gin] +
+                                              s->lut[B][B][bin] +
+                                              (have_alpha == 1 ? s->lut[B][A][ain] : 0));
             if (have_alpha == 1) {
                 dst[j + aoffset] = av_clip_uint16(s->lut[A][R][rin] +
                                                   s->lut[A][G][gin] +
@@ -555,52 +380,27 @@
 
 static int filter_slice_rgba64(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_packed(ctx, arg, jobnr, nb_jobs, 1, 4, 0);
+    return filter_slice_rgba16_packed(ctx, arg, jobnr, nb_jobs, 1, 4);
 }
 
 static int filter_slice_rgb48(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba16_packed(ctx, arg, jobnr, nb_jobs, 0, 3, 0);
-}
-
-static int filter_slice_rgba64_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_packed(ctx, arg, jobnr, nb_jobs, 1, 4, 1);
-}
-
-static int filter_slice_rgb48_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba16_packed(ctx, arg, jobnr, nb_jobs, 0, 3, 1);
+    return filter_slice_rgba16_packed(ctx, arg, jobnr, nb_jobs, 0, 3);
 }
 
 static int filter_slice_rgba(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, 1, 4, 0);
+    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, 1, 4);
 }
 
 static int filter_slice_rgb24(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, 0, 3, 0);
+    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, 0, 3);
 }
 
 static int filter_slice_rgb0(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
-    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, -1, 4, 0);
-}
-
-static int filter_slice_rgba_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, 1, 4, 1);
-}
-
-static int filter_slice_rgb24_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, 0, 3, 1);
-}
-
-static int filter_slice_rgb0_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, -1, 4, 1);
+    return filter_slice_rgba_packed(ctx, arg, jobnr, nb_jobs, -1, 4);
 }
 
 static int config_output(AVFilterLink *outlink)
@@ -624,19 +424,6 @@
                 s->lut[i][j] = buffer;
     }
 
-    s->sr = s->rr + s->rg + s->rb + s->ra;
-    s->sg = s->gr + s->gg + s->gb + s->ga;
-    s->sb = s->br + s->bg + s->bb + s->ba;
-
-    if (fabs(s->sr) <= DBL_EPSILON)
-        s->sr = 1.;
-
-    if (fabs(s->sg) <= DBL_EPSILON)
-        s->sg = 1.;
-
-    if (fabs(s->sb) <= DBL_EPSILON)
-        s->sb = 1.;
-
     for (i = 0; i < size; i++) {
         s->lut[R][R][i] = lrint(i * s->rr);
         s->lut[R][G][i] = lrint(i * s->rg);
@@ -662,72 +449,57 @@
     switch (outlink->format) {
     case AV_PIX_FMT_BGR24:
     case AV_PIX_FMT_RGB24:
-        s->filter_slice[0] = filter_slice_rgb24;
-        s->filter_slice[1] = filter_slice_rgb24_pl;
+        s->filter_slice = filter_slice_rgb24;
         break;
     case AV_PIX_FMT_0BGR:
     case AV_PIX_FMT_0RGB:
     case AV_PIX_FMT_BGR0:
     case AV_PIX_FMT_RGB0:
-        s->filter_slice[0] = filter_slice_rgb0;
-        s->filter_slice[1] = filter_slice_rgb0_pl;
+        s->filter_slice = filter_slice_rgb0;
         break;
     case AV_PIX_FMT_ABGR:
     case AV_PIX_FMT_ARGB:
     case AV_PIX_FMT_BGRA:
     case AV_PIX_FMT_RGBA:
-        s->filter_slice[0] = filter_slice_rgba;
-        s->filter_slice[1] = filter_slice_rgba_pl;
+        s->filter_slice = filter_slice_rgba;
         break;
     case AV_PIX_FMT_BGR48:
     case AV_PIX_FMT_RGB48:
-        s->filter_slice[0] = filter_slice_rgb48;
-        s->filter_slice[1] = filter_slice_rgb48_pl;
+        s->filter_slice = filter_slice_rgb48;
         break;
     case AV_PIX_FMT_BGRA64:
     case AV_PIX_FMT_RGBA64:
-        s->filter_slice[0] = filter_slice_rgba64;
-        s->filter_slice[1] = filter_slice_rgba64_pl;
+        s->filter_slice = filter_slice_rgba64;
         break;
     case AV_PIX_FMT_GBRP:
-        s->filter_slice[0] = filter_slice_gbrp;
-        s->filter_slice[1] = filter_slice_gbrp_pl;
+        s->filter_slice = filter_slice_gbrp;
         break;
     case AV_PIX_FMT_GBRAP:
-        s->filter_slice[0] = filter_slice_gbrap;
-        s->filter_slice[1] = filter_slice_gbrap_pl;
+        s->filter_slice = filter_slice_gbrap;
         break;
     case AV_PIX_FMT_GBRP9:
-        s->filter_slice[0] = filter_slice_gbrp9;
-        s->filter_slice[1] = filter_slice_gbrp9_pl;
+        s->filter_slice = filter_slice_gbrp9;
         break;
     case AV_PIX_FMT_GBRP10:
-        s->filter_slice[0] = filter_slice_gbrp10;
-        s->filter_slice[1] = filter_slice_gbrp10_pl;
+        s->filter_slice = filter_slice_gbrp10;
         break;
     case AV_PIX_FMT_GBRAP10:
-        s->filter_slice[0] = filter_slice_gbrap10;
-        s->filter_slice[1] = filter_slice_gbrap10_pl;
+        s->filter_slice = filter_slice_gbrap10;
         break;
     case AV_PIX_FMT_GBRP12:
-        s->filter_slice[0] = filter_slice_gbrp12;
-        s->filter_slice[1] = filter_slice_gbrp12_pl;
+        s->filter_slice = filter_slice_gbrp12;
         break;
     case AV_PIX_FMT_GBRAP12:
-        s->filter_slice[0] = filter_slice_gbrap12;
-        s->filter_slice[1] = filter_slice_gbrap12_pl;
+        s->filter_slice = filter_slice_gbrap12;
         break;
     case AV_PIX_FMT_GBRP14:
-        s->filter_slice[0] = filter_slice_gbrp14;
-        s->filter_slice[1] = filter_slice_gbrp14_pl;
+        s->filter_slice = filter_slice_gbrp14;
         break;
     case AV_PIX_FMT_GBRP16:
-        s->filter_slice[0] = filter_slice_gbrp16;
-        s->filter_slice[1] = filter_slice_gbrp16_pl;
+        s->filter_slice = filter_slice_gbrp16;
         break;
     case AV_PIX_FMT_GBRAP16:
-        s->filter_slice[0] = filter_slice_gbrap16;
-        s->filter_slice[1] = filter_slice_gbrap16_pl;
+        s->filter_slice = filter_slice_gbrap16;
         break;
     }
 
@@ -739,7 +511,6 @@
     AVFilterContext *ctx = inlink->dst;
     ColorChannelMixerContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    const int pl = s->preserve_lightness > 0.;
     ThreadData td;
     AVFrame *out;
 
@@ -756,7 +527,7 @@
 
     td.in = in;
     td.out = out;
-    ctx->internal->execute(ctx, s->filter_slice[pl], &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+    ctx->internal->execute(ctx, s->filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (in != out)
         av_frame_free(&in);
diff --git a/libavfilter/vf_colorcontrast.c b/libavfilter/vf_colorcontrast.c
deleted file mode 100644
index 7206c95..0000000
--- a/libavfilter/vf_colorcontrast.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <float.h>
-
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
-#include "avfilter.h"
-#include "drawutils.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-#define R 0
-#define G 1
-#define B 2
-
-typedef struct ColorContrastContext {
-    const AVClass *class;
-
-    float rc, gm, by;
-    float rcw, gmw, byw;
-    float preserve;
-
-    int step;
-    int depth;
-    uint8_t rgba_map[4];
-
-    int (*do_slice)(AVFilterContext *s, void *arg,
-                    int jobnr, int nb_jobs);
-} ColorContrastContext;
-
-static inline float lerpf(float v0, float v1, float f)
-{
-    return v0 + (v1 - v0) * f;
-}
-
-#define PROCESS(max)                                                    \
-    br = (b + r) * 0.5f;                                                \
-    gb = (g + b) * 0.5f;                                                \
-    rg = (r + g) * 0.5f;                                                \
-                                                                        \
-    gd = g - br;                                                        \
-    bd = b - rg;                                                        \
-    rd = r - gb;                                                        \
-                                                                        \
-    g0 = g + gd * gm;                                                   \
-    b0 = b - gd * gm;                                                   \
-    r0 = r - gd * gm;                                                   \
-                                                                        \
-    g1 = g - bd * by;                                                   \
-    b1 = b + bd * by;                                                   \
-    r1 = r - bd * by;                                                   \
-                                                                        \
-    g2 = g - rd * rc;                                                   \
-    b2 = b - rd * rc;                                                   \
-    r2 = r + rd * rc;                                                   \
-                                                                        \
-    ng = av_clipf((g0 * gmw + g1 * byw + g2 * rcw) * scale, 0.f, max);  \
-    nb = av_clipf((b0 * gmw + b1 * byw + b2 * rcw) * scale, 0.f, max);  \
-    nr = av_clipf((r0 * gmw + r1 * byw + r2 * rcw) * scale, 0.f, max);  \
-                                                                        \
-    li = FFMAX3(r, g, b) + FFMIN3(r, g, b);                             \
-    lo = FFMAX3(nr, ng, nb) + FFMIN3(nr, ng, nb) + FLT_EPSILON;         \
-    lf = li / lo;                                                       \
-                                                                        \
-    r = nr * lf;                                                        \
-    g = ng * lf;                                                        \
-    b = nb * lf;                                                        \
-                                                                        \
-    nr = lerpf(nr, r, preserve);                                        \
-    ng = lerpf(ng, g, preserve);                                        \
-    nb = lerpf(nb, b, preserve);
-
-static int colorcontrast_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorContrastContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int glinesize = frame->linesize[0];
-    const int blinesize = frame->linesize[1];
-    const int rlinesize = frame->linesize[2];
-    uint8_t *gptr = frame->data[0] + slice_start * glinesize;
-    uint8_t *bptr = frame->data[1] + slice_start * blinesize;
-    uint8_t *rptr = frame->data[2] + slice_start * rlinesize;
-    const float preserve = s->preserve;
-    const float gm = s->gm * 0.5f;
-    const float by = s->by * 0.5f;
-    const float rc = s->rc * 0.5f;
-    const float gmw = s->gmw;
-    const float byw = s->byw;
-    const float rcw = s->rcw;
-    const float sum = gmw + byw + rcw;
-    const float scale = 1.f / sum;
-
-    for (int y = slice_start; y < slice_end && sum > FLT_EPSILON; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = gptr[x];
-            float b = bptr[x];
-            float r = rptr[x];
-            float g0, g1, g2;
-            float b0, b1, b2;
-            float r0, r1, r2;
-            float gd, bd, rd;
-            float gb, br, rg;
-            float nr, ng, nb;
-            float li, lo, lf;
-
-            PROCESS(255.f);
-
-            gptr[x] = av_clip_uint8(ng);
-            bptr[x] = av_clip_uint8(nb);
-            rptr[x] = av_clip_uint8(nr);
-        }
-
-        gptr += glinesize;
-        bptr += blinesize;
-        rptr += rlinesize;
-    }
-
-    return 0;
-}
-
-static int colorcontrast_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorContrastContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const float max = (1 << depth) - 1;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int glinesize = frame->linesize[0] / 2;
-    const int blinesize = frame->linesize[1] / 2;
-    const int rlinesize = frame->linesize[2] / 2;
-    uint16_t *gptr = (uint16_t *)frame->data[0] + slice_start * glinesize;
-    uint16_t *bptr = (uint16_t *)frame->data[1] + slice_start * blinesize;
-    uint16_t *rptr = (uint16_t *)frame->data[2] + slice_start * rlinesize;
-    const float preserve = s->preserve;
-    const float gm = s->gm * 0.5f;
-    const float by = s->by * 0.5f;
-    const float rc = s->rc * 0.5f;
-    const float gmw = s->gmw;
-    const float byw = s->byw;
-    const float rcw = s->rcw;
-    const float sum = gmw + byw + rcw;
-    const float scale = 1.f / sum;
-
-    for (int y = slice_start; y < slice_end && sum > FLT_EPSILON; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = gptr[x];
-            float b = bptr[x];
-            float r = rptr[x];
-            float g0, g1, g2;
-            float b0, b1, b2;
-            float r0, r1, r2;
-            float gd, bd, rd;
-            float gb, br, rg;
-            float nr, ng, nb;
-            float li, lo, lf;
-
-            PROCESS(max);
-
-            gptr[x] = av_clip_uintp2_c(ng, depth);
-            bptr[x] = av_clip_uintp2_c(nb, depth);
-            rptr[x] = av_clip_uintp2_c(nr, depth);
-        }
-
-        gptr += glinesize;
-        bptr += blinesize;
-        rptr += rlinesize;
-    }
-
-    return 0;
-}
-
-static int colorcontrast_slice8p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorContrastContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int step = s->step;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int linesize = frame->linesize[0];
-    const uint8_t roffset = s->rgba_map[R];
-    const uint8_t goffset = s->rgba_map[G];
-    const uint8_t boffset = s->rgba_map[B];
-    uint8_t *ptr = frame->data[0] + slice_start * linesize;
-    const float preserve = s->preserve;
-    const float gm = s->gm * 0.5f;
-    const float by = s->by * 0.5f;
-    const float rc = s->rc * 0.5f;
-    const float gmw = s->gmw;
-    const float byw = s->byw;
-    const float rcw = s->rcw;
-    const float sum = gmw + byw + rcw;
-    const float scale = 1.f / sum;
-
-    for (int y = slice_start; y < slice_end && sum > FLT_EPSILON; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = ptr[x * step + goffset];
-            float b = ptr[x * step + boffset];
-            float r = ptr[x * step + roffset];
-            float g0, g1, g2;
-            float b0, b1, b2;
-            float r0, r1, r2;
-            float gd, bd, rd;
-            float gb, br, rg;
-            float nr, ng, nb;
-            float li, lo, lf;
-
-            PROCESS(255.f);
-
-            ptr[x * step + goffset] = av_clip_uint8(ng);
-            ptr[x * step + boffset] = av_clip_uint8(nb);
-            ptr[x * step + roffset] = av_clip_uint8(nr);
-        }
-
-        ptr += linesize;
-    }
-
-    return 0;
-}
-
-static int colorcontrast_slice16p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorContrastContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int step = s->step;
-    const int depth = s->depth;
-    const float max = (1 << depth) - 1;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int linesize = frame->linesize[0] / 2;
-    const uint8_t roffset = s->rgba_map[R];
-    const uint8_t goffset = s->rgba_map[G];
-    const uint8_t boffset = s->rgba_map[B];
-    uint16_t *ptr = (uint16_t *)frame->data[0] + slice_start * linesize;
-    const float preserve = s->preserve;
-    const float gm = s->gm * 0.5f;
-    const float by = s->by * 0.5f;
-    const float rc = s->rc * 0.5f;
-    const float gmw = s->gmw;
-    const float byw = s->byw;
-    const float rcw = s->rcw;
-    const float sum = gmw + byw + rcw;
-    const float scale = 1.f / sum;
-
-    for (int y = slice_start; y < slice_end && sum > FLT_EPSILON; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = ptr[x * step + goffset];
-            float b = ptr[x * step + boffset];
-            float r = ptr[x * step + roffset];
-            float g0, g1, g2;
-            float b0, b1, b2;
-            float r0, r1, r2;
-            float gd, bd, rd;
-            float gb, br, rg;
-            float nr, ng, nb;
-            float li, lo, lf;
-
-            PROCESS(max);
-
-            ptr[x * step + goffset] = av_clip_uintp2_c(ng, depth);
-            ptr[x * step + boffset] = av_clip_uintp2_c(nb, depth);
-            ptr[x * step + roffset] = av_clip_uintp2_c(nr, depth);
-        }
-
-        ptr += linesize;
-    }
-
-    return 0;
-}
-
-static int filter_frame(AVFilterLink *link, AVFrame *frame)
-{
-    AVFilterContext *ctx = link->dst;
-    ColorContrastContext *s = ctx->priv;
-    int res;
-
-    if (res = ctx->internal->execute(ctx, s->do_slice, frame, NULL,
-                                       FFMIN(frame->height, ff_filter_get_nb_threads(ctx))))
-        return res;
-
-    return ff_filter_frame(ctx->outputs[0], frame);
-}
-
-static av_cold int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
-        AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,
-        AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR,
-        AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR,
-        AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
-        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12,
-        AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_RGB48,  AV_PIX_FMT_BGR48,
-        AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *formats = NULL;
-
-    formats = ff_make_format_list(pixel_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-
-    return ff_set_common_formats(ctx, formats);
-}
-
-static av_cold int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorContrastContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
-
-    s->step = desc->nb_components;
-    if (inlink->format == AV_PIX_FMT_RGB0 ||
-        inlink->format == AV_PIX_FMT_0RGB ||
-        inlink->format == AV_PIX_FMT_BGR0 ||
-        inlink->format == AV_PIX_FMT_0BGR)
-        s->step = 4;
-
-    s->depth = desc->comp[0].depth;
-    s->do_slice = s->depth <= 8 ? colorcontrast_slice8 : colorcontrast_slice16;
-    if (!planar)
-        s->do_slice = s->depth <= 8 ? colorcontrast_slice8p : colorcontrast_slice16p;
-
-    ff_fill_rgba_map(s->rgba_map, inlink->format);
-
-    return 0;
-}
-
-static const AVFilterPad colorcontrast_inputs[] = {
-    {
-        .name           = "default",
-        .type           = AVMEDIA_TYPE_VIDEO,
-        .needs_writable = 1,
-        .filter_frame   = filter_frame,
-        .config_props   = config_input,
-    },
-    { NULL }
-};
-
-static const AVFilterPad colorcontrast_outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_VIDEO,
-    },
-    { NULL }
-};
-
-#define OFFSET(x) offsetof(ColorContrastContext, x)
-#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption colorcontrast_options[] = {
-    { "rc",  "set the red-cyan contrast",      OFFSET(rc),  AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "gm",  "set the green-magenta contrast", OFFSET(gm),  AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "by",  "set the blue-yellow contrast",   OFFSET(by),  AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "rcw", "set the red-cyan weight",        OFFSET(rcw), AV_OPT_TYPE_FLOAT, {.dbl=0},  0, 1, VF },
-    { "gmw", "set the green-magenta weight",   OFFSET(gmw), AV_OPT_TYPE_FLOAT, {.dbl=0},  0, 1, VF },
-    { "byw", "set the blue-yellow weight",     OFFSET(byw), AV_OPT_TYPE_FLOAT, {.dbl=0},  0, 1, VF },
-    { "pl",  "set the amount of preserving lightness", OFFSET(preserve), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 1, VF },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(colorcontrast);
-
-AVFilter ff_vf_colorcontrast = {
-    .name          = "colorcontrast",
-    .description   = NULL_IF_CONFIG_SMALL("Adjust color contrast between RGB components."),
-    .priv_size     = sizeof(ColorContrastContext),
-    .priv_class    = &colorcontrast_class,
-    .query_formats = query_formats,
-    .inputs        = colorcontrast_inputs,
-    .outputs       = colorcontrast_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_colorcorrect.c b/libavfilter/vf_colorcorrect.c
deleted file mode 100644
index f998f02..0000000
--- a/libavfilter/vf_colorcorrect.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <float.h>
-
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct ColorCorrectContext {
-    const AVClass *class;
-
-    float rl, bl;
-    float rh, bh;
-    float saturation;
-
-    int depth;
-
-    int (*do_slice)(AVFilterContext *s, void *arg,
-                    int jobnr, int nb_jobs);
-} ColorCorrectContext;
-
-#define PROCESS()                            \
-    float y = yptr[x] * imax;                \
-    float u = uptr[x] * imax - .5f;          \
-    float v = vptr[x] * imax - .5f;          \
-    float ny, nu, nv;                        \
-                                             \
-    ny = y;                                  \
-    nu = saturation * (u + y * bd + bl);     \
-    nv = saturation * (v + y * rd + rl);
-
-static int colorcorrect_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorCorrectContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const float max = (1 << depth) - 1;
-    const float imax = 1.f / max;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ylinesize = frame->linesize[0];
-    const int ulinesize = frame->linesize[1];
-    const int vlinesize = frame->linesize[2];
-    uint8_t *yptr = frame->data[0] + slice_start * ylinesize;
-    uint8_t *uptr = frame->data[1] + slice_start * ulinesize;
-    uint8_t *vptr = frame->data[2] + slice_start * vlinesize;
-    const float saturation = s->saturation;
-    const float bl = s->bl;
-    const float rl = s->rl;
-    const float bd = s->bh - bl;
-    const float rd = s->rh - rl;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            PROCESS()
-
-            yptr[x] = av_clip_uint8( ny         * max);
-            uptr[x] = av_clip_uint8((nu + 0.5f) * max);
-            vptr[x] = av_clip_uint8((nv + 0.5f) * max);
-        }
-
-        yptr += ylinesize;
-        uptr += ulinesize;
-        vptr += vlinesize;
-    }
-
-    return 0;
-}
-
-static int colorcorrect_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorCorrectContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const float max = (1 << depth) - 1;
-    const float imax = 1.f / max;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ylinesize = frame->linesize[0] / 2;
-    const int ulinesize = frame->linesize[1] / 2;
-    const int vlinesize = frame->linesize[2] / 2;
-    uint16_t *yptr = (uint16_t *)frame->data[0] + slice_start * ylinesize;
-    uint16_t *uptr = (uint16_t *)frame->data[1] + slice_start * ulinesize;
-    uint16_t *vptr = (uint16_t *)frame->data[2] + slice_start * vlinesize;
-    const float saturation = s->saturation;
-    const float bl = s->bl;
-    const float rl = s->rl;
-    const float bd = s->bh - bl;
-    const float rd = s->rh - rl;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            PROCESS()
-
-            yptr[x] = av_clip_uintp2_c( ny         * max, depth);
-            uptr[x] = av_clip_uintp2_c((nu + 0.5f) * max, depth);
-            vptr[x] = av_clip_uintp2_c((nv + 0.5f) * max, depth);
-        }
-
-        yptr += ylinesize;
-        uptr += ulinesize;
-        vptr += vlinesize;
-    }
-
-    return 0;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorCorrectContext *s = ctx->priv;
-
-    ctx->internal->execute(ctx, s->do_slice, frame, NULL,
-                           FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
-
-    return ff_filter_frame(ctx->outputs[0], frame);
-}
-
-static av_cold int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *formats = NULL;
-
-    formats = ff_make_format_list(pixel_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-
-    return ff_set_common_formats(ctx, formats);
-}
-
-static av_cold int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorCorrectContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-
-    s->depth = desc->comp[0].depth;
-    s->do_slice = s->depth <= 8 ? colorcorrect_slice8 : colorcorrect_slice16;
-
-    return 0;
-}
-
-static const AVFilterPad colorcorrect_inputs[] = {
-    {
-        .name           = "default",
-        .type           = AVMEDIA_TYPE_VIDEO,
-        .needs_writable = 1,
-        .filter_frame   = filter_frame,
-        .config_props   = config_input,
-    },
-    { NULL }
-};
-
-static const AVFilterPad colorcorrect_outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_VIDEO,
-    },
-    { NULL }
-};
-
-#define OFFSET(x) offsetof(ColorCorrectContext, x)
-#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption colorcorrect_options[] = {
-    { "rl", "set the red shadow spot",              OFFSET(rl), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "bl", "set the blue shadow spot",             OFFSET(bl), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "rh", "set the red highlight spot",           OFFSET(rh), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "bh", "set the blue highlight spot",          OFFSET(bh), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { "saturation", "set the amount of saturation", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl=1}, -3, 3, VF },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(colorcorrect);
-
-AVFilter ff_vf_colorcorrect = {
-    .name          = "colorcorrect",
-    .description   = NULL_IF_CONFIG_SMALL("Adjust color white balance selectively for blacks and whites."),
-    .priv_size     = sizeof(ColorCorrectContext),
-    .priv_class    = &colorcorrect_class,
-    .query_formats = query_formats,
-    .inputs        = colorcorrect_inputs,
-    .outputs       = colorcorrect_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_colorize.c b/libavfilter/vf_colorize.c
deleted file mode 100644
index e9d3482..0000000
--- a/libavfilter/vf_colorize.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct ColorizeContext {
-    const AVClass *class;
-
-    float hue;
-    float saturation;
-    float lightness;
-    float mix;
-
-    int depth;
-    int c[3];
-    int planewidth[4];
-    int planeheight[4];
-
-    int (*do_plane_slice[2])(AVFilterContext *s, void *arg,
-                             int jobnr, int nb_jobs);
-} ColorizeContext;
-
-static inline float lerpf(float v0, float v1, float f)
-{
-    return v0 + (v1 - v0) * f;
-}
-
-static int colorizey_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorizeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = s->planewidth[0];
-    const int height = s->planeheight[0];
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ylinesize = frame->linesize[0];
-    uint8_t *yptr = frame->data[0] + slice_start * ylinesize;
-    const int yv = s->c[0];
-    const float mix = s->mix;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++)
-            yptr[x] = lerpf(yv, yptr[x], mix);
-
-        yptr += ylinesize;
-    }
-
-    return 0;
-}
-
-static int colorizey_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorizeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = s->planewidth[0];
-    const int height = s->planeheight[0];
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ylinesize = frame->linesize[0] / 2;
-    uint16_t *yptr = (uint16_t *)frame->data[0] + slice_start * ylinesize;
-    const int yv = s->c[0];
-    const float mix = s->mix;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++)
-            yptr[x] = lerpf(yv, yptr[x], mix);
-
-        yptr += ylinesize;
-    }
-
-    return 0;
-}
-
-static int colorize_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorizeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = s->planewidth[1];
-    const int height = s->planeheight[1];
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ulinesize = frame->linesize[1];
-    const int vlinesize = frame->linesize[2];
-    uint8_t *uptr = frame->data[1] + slice_start * ulinesize;
-    uint8_t *vptr = frame->data[2] + slice_start * vlinesize;
-    const int u = s->c[1];
-    const int v = s->c[2];
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            uptr[x] = u;
-            vptr[x] = v;
-        }
-
-        uptr += ulinesize;
-        vptr += vlinesize;
-    }
-
-    return 0;
-}
-
-static int colorize_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorizeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = s->planewidth[1];
-    const int height = s->planeheight[1];
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ulinesize = frame->linesize[1] / 2;
-    const int vlinesize = frame->linesize[2] / 2;
-    uint16_t *uptr = (uint16_t *)frame->data[1] + slice_start * ulinesize;
-    uint16_t *vptr = (uint16_t *)frame->data[2] + slice_start * vlinesize;
-    const int u = s->c[1];
-    const int v = s->c[2];
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            uptr[x] = u;
-            vptr[x] = v;
-        }
-
-        uptr += ulinesize;
-        vptr += vlinesize;
-    }
-
-    return 0;
-}
-
-static int do_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorizeContext *s = ctx->priv;
-
-    s->do_plane_slice[0](ctx, arg, jobnr, nb_jobs);
-    s->do_plane_slice[1](ctx, arg, jobnr, nb_jobs);
-
-    return 0;
-}
-
-static float hue2rgb(float p, float q, float t)
-{
-    if (t < 0.f) t += 1.f;
-    if (t > 1.f) t -= 1.f;
-    if (t < 1.f/6.f) return p + (q - p) * 6.f * t;
-    if (t < 1.f/2.f) return q;
-    if (t < 2.f/3.f) return p + (q - p) * (2.f/3.f - t) * 6.f;
-
-    return p;
-}
-
-static void hsl2rgb(float h, float s, float l, float *r, float *g, float *b)
-{
-    h /= 360.f;
-
-    if (s == 0.f) {
-        *r = *g = *b = l;
-    } else {
-        const float q = l < 0.5f ? l * (1.f + s) : l + s - l * s;
-        const float p = 2.f * l - q;
-
-        *r = hue2rgb(p, q, h + 1.f / 3.f);
-        *g = hue2rgb(p, q, h);
-        *b = hue2rgb(p, q, h - 1.f / 3.f);
-    }
-}
-
-static void rgb2yuv(float r, float g, float b, int *y, int *u, int *v, int depth)
-{
-    *y = ((0.21260*219.0/255.0) * r + (0.71520*219.0/255.0) * g +
-         (0.07220*219.0/255.0) * b) * ((1 << depth) - 1);
-    *u = (-(0.11457*224.0/255.0) * r - (0.38543*224.0/255.0) * g +
-         (0.50000*224.0/255.0) * b + 0.5) * ((1 << depth) - 1);
-    *v = ((0.50000*224.0/255.0) * r - (0.45415*224.0/255.0) * g -
-         (0.04585*224.0/255.0) * b + 0.5) * ((1 << depth) - 1);
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorizeContext *s = ctx->priv;
-    float c[3];
-
-    hsl2rgb(s->hue, s->saturation, s->lightness, &c[0], &c[1], &c[2]);
-    rgb2yuv(c[0], c[1], c[2], &s->c[0], &s->c[1], &s->c[2], s->depth);
-
-    ctx->internal->execute(ctx, do_slice, frame, NULL,
-                           FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
-
-    return ff_filter_frame(ctx->outputs[0], frame);
-}
-
-static av_cold int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *formats = NULL;
-
-    formats = ff_make_format_list(pixel_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-
-    return ff_set_common_formats(ctx, formats);
-}
-
-static av_cold int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorizeContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int depth;
-
-    s->depth = depth = desc->comp[0].depth;
-
-    s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0] = s->planewidth[3] = inlink->w;
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-
-    s->do_plane_slice[0] = depth <= 8 ? colorizey_slice8 : colorizey_slice16;
-    s->do_plane_slice[1] = depth <= 8 ? colorize_slice8 : colorize_slice16;
-
-    return 0;
-}
-
-static const AVFilterPad colorize_inputs[] = {
-    {
-        .name           = "default",
-        .type           = AVMEDIA_TYPE_VIDEO,
-        .needs_writable = 1,
-        .filter_frame   = filter_frame,
-        .config_props   = config_input,
-    },
-    { NULL }
-};
-
-static const AVFilterPad colorize_outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_VIDEO,
-    },
-    { NULL }
-};
-
-#define OFFSET(x) offsetof(ColorizeContext, x)
-#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption colorize_options[] = {
-    { "hue",        "set the hue",                     OFFSET(hue),        AV_OPT_TYPE_FLOAT, {.dbl=0},  0, 360, VF },
-    { "saturation", "set the saturation",              OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl=0.5},0,   1, VF },
-    { "lightness",  "set the lightness",               OFFSET(lightness),  AV_OPT_TYPE_FLOAT, {.dbl=0.5},0,   1, VF },
-    { "mix",        "set the mix of source lightness", OFFSET(mix),        AV_OPT_TYPE_FLOAT, {.dbl=1},  0,   1, VF },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(colorize);
-
-AVFilter ff_vf_colorize = {
-    .name          = "colorize",
-    .description   = NULL_IF_CONFIG_SMALL("Overlay a solid color on the video stream."),
-    .priv_size     = sizeof(ColorizeContext),
-    .priv_class    = &colorize_class,
-    .query_formats = query_formats,
-    .inputs        = colorize_inputs,
-    .outputs       = colorize_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c
index 9085e40..c03e288 100644
--- a/libavfilter/vf_colorlevels.c
+++ b/libavfilter/vf_colorlevels.c
@@ -40,14 +40,11 @@
 typedef struct ColorLevelsContext {
     const AVClass *class;
     Range range[4];
-
     int nb_comp;
     int bpp;
     int step;
     uint8_t rgba_map[4];
     int linesize;
-
-    int (*colorlevels_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
 } ColorLevelsContext;
 
 #define OFFSET(x) offsetof(ColorLevelsContext, x)
@@ -93,74 +90,6 @@
     return ff_set_common_formats(ctx, fmts_list);
 }
 
-typedef struct ThreadData {
-    const uint8_t *srcrow;
-    uint8_t *dstrow;
-    int dst_linesize;
-    int src_linesize;
-
-    float coeff[4];
-
-    int h;
-
-    int imin[4];
-    int omin[4];
-} ThreadData;
-
-#define LOAD_COMMON                                             \
-    ColorLevelsContext *s = ctx->priv;                          \
-    const ThreadData *td = arg;                                 \
-    const int process_h = td->h;                                \
-    const int slice_start = (process_h *  jobnr   ) / nb_jobs;  \
-    const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;  \
-    const uint8_t *srcrow = td->srcrow;                         \
-    uint8_t *dstrow = td->dstrow;                               \
-    const int step = s->step;
-
-static int colorlevels_slice_8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    LOAD_COMMON
-
-    for (int comp = 0; comp < s->nb_comp; comp++) {
-        const uint8_t offset = s->rgba_map[comp];
-        const int imin = td->imin[comp];
-        const int omin = td->omin[comp];
-        const float coeff = td->coeff[comp];
-
-        for (int y = slice_start; y < slice_end; y++) {
-            const uint8_t *src = srcrow + y * td->src_linesize;
-            uint8_t *dst = dstrow + y * td->dst_linesize;
-
-            for (int x = 0; x < s->linesize; x += step)
-                dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff + omin);
-        }
-    }
-
-    return 0;
-}
-
-static int colorlevels_slice_16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    LOAD_COMMON
-
-    for (int comp = 0; comp < s->nb_comp; comp++) {
-        const uint8_t offset = s->rgba_map[comp];
-        const int imin = td->imin[comp];
-        const int omin = td->omin[comp];
-        const float coeff = td->coeff[comp];
-
-        for (int y = slice_start; y < slice_end; y++) {
-            const uint16_t *src = (const uint16_t *)(srcrow + y * td->src_linesize);
-            uint16_t *dst = (uint16_t *)(dstrow + y * td->dst_linesize);
-
-            for (int x = 0; x < s->linesize; x += step)
-                dst[x + offset] = av_clip_uint16((src[x + offset] - imin) * coeff + omin);
-        }
-    }
-
-    return 0;
-}
-
 static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
@@ -169,13 +98,71 @@
 
     s->nb_comp = desc->nb_components;
     s->bpp = desc->comp[0].depth >> 3;
-    s->step = av_get_padded_bits_per_pixel(desc) >> (3 + (s->bpp == 2));
+    s->step = (av_get_padded_bits_per_pixel(desc) >> 3) / s->bpp;
     s->linesize = inlink->w * s->step;
     ff_fill_rgba_map(s->rgba_map, inlink->format);
 
-    s->colorlevels_slice = colorlevels_slice_8;
-    if (s->bpp == 2)
-        s->colorlevels_slice = colorlevels_slice_16;
+    return 0;
+}
+
+struct thread_data {
+    const uint8_t *srcrow;
+    uint8_t *dstrow;
+    int dst_linesize;
+    int src_linesize;
+
+    double coeff;
+    uint8_t offset;
+
+    int h;
+
+    int imin;
+    int omin;
+};
+
+#define LOAD_COMMON\
+    ColorLevelsContext *s = ctx->priv;\
+    const struct thread_data *td = arg;\
+\
+    int process_h = td->h;\
+    const int slice_start = (process_h *  jobnr   ) / nb_jobs;\
+    const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;\
+    int x, y;\
+    const uint8_t *srcrow = td->srcrow;\
+    uint8_t *dstrow = td->dstrow;\
+    const int step = s->step;\
+    const uint8_t offset = td->offset;\
+\
+    int imin = td->imin;\
+    int omin = td->omin;\
+    double coeff = td->coeff;\
+
+static int colorlevel_slice_8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+    LOAD_COMMON
+
+    for (y = slice_start; y < slice_end; y++) {
+        const uint8_t *src = srcrow + y * td->src_linesize;
+        uint8_t *dst = dstrow + y * td->dst_linesize;
+
+        for (x = 0; x < s->linesize; x += step)
+            dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff + omin);
+    }
+
+    return 0;
+}
+
+static int colorlevel_slice_16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+    LOAD_COMMON
+
+    for (y = slice_start; y < slice_end; y++) {
+        const uint16_t *src = (const uint16_t *)(srcrow + y * td->src_linesize);
+        uint16_t *dst = (uint16_t *)(dstrow + y * td->dst_linesize);
+
+        for (x = 0; x < s->linesize; x += step)
+            dst[x + offset] = av_clip_uint16((src[x + offset] - imin) * coeff + omin);
+    }
 
     return 0;
 }
@@ -186,8 +173,8 @@
     ColorLevelsContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
     const int step = s->step;
-    ThreadData td;
     AVFrame *out;
+    int x, y, i;
 
     if (av_frame_is_writable(in)) {
         out = in;
@@ -200,30 +187,26 @@
         av_frame_copy_props(out, in);
     }
 
-    td.h             = inlink->h;
-    td.dst_linesize  = out->linesize[0];
-    td.src_linesize  = in->linesize[0];
-    td.srcrow        = in->data[0];
-    td.dstrow        = out->data[0];
-
     switch (s->bpp) {
     case 1:
-        for (int i = 0; i < s->nb_comp; i++) {
+        for (i = 0; i < s->nb_comp; i++) {
             Range *r = &s->range[i];
             const uint8_t offset = s->rgba_map[i];
             const uint8_t *srcrow = in->data[0];
+            uint8_t *dstrow = out->data[0];
             int imin = lrint(r->in_min  * UINT8_MAX);
             int imax = lrint(r->in_max  * UINT8_MAX);
             int omin = lrint(r->out_min * UINT8_MAX);
             int omax = lrint(r->out_max * UINT8_MAX);
-            float coeff;
+            double coeff;
+            struct thread_data td;
 
             if (imin < 0) {
                 imin = UINT8_MAX;
-                for (int y = 0; y < inlink->h; y++) {
+                for (y = 0; y < inlink->h; y++) {
                     const uint8_t *src = srcrow;
 
-                    for (int x = 0; x < s->linesize; x += step)
+                    for (x = 0; x < s->linesize; x += step)
                         imin = FFMIN(imin, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
@@ -231,39 +214,51 @@
             if (imax < 0) {
                 srcrow = in->data[0];
                 imax = 0;
-                for (int y = 0; y < inlink->h; y++) {
+                for (y = 0; y < inlink->h; y++) {
                     const uint8_t *src = srcrow;
 
-                    for (int x = 0; x < s->linesize; x += step)
+                    for (x = 0; x < s->linesize; x += step)
                         imax = FFMAX(imax, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
             }
 
+            srcrow = in->data[0];
             coeff = (omax - omin) / (double)(imax - imin);
 
-            td.coeff[i] = coeff;
-            td.imin[i]  = imin;
-            td.omin[i]  = omin;
+            td.srcrow        = srcrow;
+            td.dstrow        = dstrow;
+            td.dst_linesize  = out->linesize[0];
+            td.src_linesize  = in->linesize[0];
+            td.coeff         = coeff;
+            td.offset        = offset;
+            td.h             = inlink->h;
+            td.imin          = imin;
+            td.omin          = omin;
+
+            ctx->internal->execute(ctx, colorlevel_slice_8, &td, NULL,
+                                   FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
         }
         break;
     case 2:
-        for (int i = 0; i < s->nb_comp; i++) {
+        for (i = 0; i < s->nb_comp; i++) {
             Range *r = &s->range[i];
             const uint8_t offset = s->rgba_map[i];
             const uint8_t *srcrow = in->data[0];
+            uint8_t *dstrow = out->data[0];
             int imin = lrint(r->in_min  * UINT16_MAX);
             int imax = lrint(r->in_max  * UINT16_MAX);
             int omin = lrint(r->out_min * UINT16_MAX);
             int omax = lrint(r->out_max * UINT16_MAX);
-            float coeff;
+            double coeff;
+            struct thread_data td;
 
             if (imin < 0) {
                 imin = UINT16_MAX;
-                for (int y = 0; y < inlink->h; y++) {
+                for (y = 0; y < inlink->h; y++) {
                     const uint16_t *src = (const uint16_t *)srcrow;
 
-                    for (int x = 0; x < s->linesize; x += step)
+                    for (x = 0; x < s->linesize; x += step)
                         imin = FFMIN(imin, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
@@ -271,26 +266,32 @@
             if (imax < 0) {
                 srcrow = in->data[0];
                 imax = 0;
-                for (int y = 0; y < inlink->h; y++) {
+                for (y = 0; y < inlink->h; y++) {
                     const uint16_t *src = (const uint16_t *)srcrow;
 
-                    for (int x = 0; x < s->linesize; x += step)
+                    for (x = 0; x < s->linesize; x += step)
                         imax = FFMAX(imax, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
             }
 
+            srcrow = in->data[0];
             coeff = (omax - omin) / (double)(imax - imin);
 
-            td.coeff[i] = coeff;
-            td.imin[i]  = imin;
-            td.omin[i]  = omin;
-        }
-        break;
-    }
+            td.srcrow        = srcrow;
+            td.dstrow        = dstrow;
+            td.dst_linesize  = out->linesize[0];
+            td.src_linesize  = in->linesize[0];
+            td.coeff         = coeff;
+            td.offset        = offset;
+            td.h             = inlink->h;
+            td.imin          = imin;
+            td.omin          = omin;
 
-    ctx->internal->execute(ctx, s->colorlevels_slice, &td, NULL,
-                           FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
+            ctx->internal->execute(ctx, colorlevel_slice_16, &td, NULL,
+                                   FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
+        }
+    }
 
     if (in != out)
         av_frame_free(&in);
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 4716695..39af74c 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -24,7 +24,6 @@
  */
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
diff --git a/libavfilter/vf_colortemperature.c b/libavfilter/vf_colortemperature.c
deleted file mode 100644
index 7be5e79..0000000
--- a/libavfilter/vf_colortemperature.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <float.h>
-
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
-#include "avfilter.h"
-#include "drawutils.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-#define R 0
-#define G 1
-#define B 2
-
-typedef struct ColorTemperatureContext {
-    const AVClass *class;
-
-    float temperature;
-    float mix;
-    float preserve;
-
-    float color[3];
-
-    int step;
-    int depth;
-    uint8_t rgba_map[4];
-
-    int (*do_slice)(AVFilterContext *s, void *arg,
-                    int jobnr, int nb_jobs);
-} ColorTemperatureContext;
-
-static float saturate(float input)
-{
-    return av_clipf(input, 0.f, 1.f);
-}
-
-static void kelvin2rgb(float k, float *rgb)
-{
-    float kelvin = k / 100.0f;
-
-    if (kelvin <= 66.0f) {
-        rgb[0] = 1.0f;
-        rgb[1] = saturate(0.39008157876901960784f * logf(kelvin) - 0.63184144378862745098f);
-    } else {
-        const float t = fmaxf(kelvin - 60.0f, 0.0f);
-        rgb[0] = saturate(1.29293618606274509804f * powf(t, -0.1332047592f));
-        rgb[1] = saturate(1.12989086089529411765f * powf(t, -0.0755148492f));
-    }
-
-    if (kelvin >= 66.0f)
-        rgb[2] = 1.0f;
-    else if (kelvin <= 19.0f)
-        rgb[2] = 0.0f;
-    else
-        rgb[2] = saturate(0.54320678911019607843f * logf(kelvin - 10.0f) - 1.19625408914f);
-}
-
-static float lerpf(float v0, float v1, float f)
-{
-    return v0 + (v1 - v0) * f;
-}
-
-#define PROCESS()                                                   \
-    nr = r * color[0];                                              \
-    ng = g * color[1];                                              \
-    nb = b * color[2];                                              \
-                                                                    \
-    nr = lerpf(r, nr, mix);                                         \
-    ng = lerpf(g, ng, mix);                                         \
-    nb = lerpf(b, nb, mix);                                         \
-                                                                    \
-    l0 = (FFMAX3(r, g, b) + FFMIN3(r, g, b)) + FLT_EPSILON;         \
-    l1 = (FFMAX3(nr, ng, nb) + FFMIN3(nr, ng, nb)) + FLT_EPSILON;   \
-    l = l0 / l1;                                                    \
-                                                                    \
-    r = nr * l;                                                     \
-    g = ng * l;                                                     \
-    b = nb * l;                                                     \
-                                                                    \
-    nr = lerpf(nr, r, preserve);                                    \
-    ng = lerpf(ng, g, preserve);                                    \
-    nb = lerpf(nb, b, preserve);
-
-static int temperature_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorTemperatureContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = frame->width;
-    const int height = frame->height;
-    const float mix = s->mix;
-    const float preserve = s->preserve;
-    const float *color = s->color;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int glinesize = frame->linesize[0];
-    const int blinesize = frame->linesize[1];
-    const int rlinesize = frame->linesize[2];
-    uint8_t *gptr = frame->data[0] + slice_start * glinesize;
-    uint8_t *bptr = frame->data[1] + slice_start * blinesize;
-    uint8_t *rptr = frame->data[2] + slice_start * rlinesize;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = gptr[x];
-            float b = bptr[x];
-            float r = rptr[x];
-            float nr, ng, nb;
-            float l0, l1, l;
-
-            PROCESS()
-
-            gptr[x] = av_clip_uint8(ng);
-            bptr[x] = av_clip_uint8(nb);
-            rptr[x] = av_clip_uint8(nr);
-        }
-
-        gptr += glinesize;
-        bptr += blinesize;
-        rptr += rlinesize;
-    }
-
-    return 0;
-}
-
-static int temperature_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorTemperatureContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const int width = frame->width;
-    const int height = frame->height;
-    const float preserve = s->preserve;
-    const float mix = s->mix;
-    const float *color = s->color;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int glinesize = frame->linesize[0] / sizeof(uint16_t);
-    const int blinesize = frame->linesize[1] / sizeof(uint16_t);
-    const int rlinesize = frame->linesize[2] / sizeof(uint16_t);
-    uint16_t *gptr = (uint16_t *)frame->data[0] + slice_start * glinesize;
-    uint16_t *bptr = (uint16_t *)frame->data[1] + slice_start * blinesize;
-    uint16_t *rptr = (uint16_t *)frame->data[2] + slice_start * rlinesize;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = gptr[x];
-            float b = bptr[x];
-            float r = rptr[x];
-            float nr, ng, nb;
-            float l0, l1, l;
-
-            PROCESS()
-
-            gptr[x] = av_clip_uintp2_c(ng, depth);
-            bptr[x] = av_clip_uintp2_c(nb, depth);
-            rptr[x] = av_clip_uintp2_c(nr, depth);
-        }
-
-        gptr += glinesize;
-        bptr += blinesize;
-        rptr += rlinesize;
-    }
-
-    return 0;
-}
-
-static int temperature_slice8p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorTemperatureContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int step = s->step;
-    const int width = frame->width;
-    const int height = frame->height;
-    const float mix = s->mix;
-    const float preserve = s->preserve;
-    const float *color = s->color;
-    const uint8_t roffset = s->rgba_map[R];
-    const uint8_t goffset = s->rgba_map[G];
-    const uint8_t boffset = s->rgba_map[B];
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int linesize = frame->linesize[0];
-    uint8_t *ptr = frame->data[0] + slice_start * linesize;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = ptr[x * step + goffset];
-            float b = ptr[x * step + boffset];
-            float r = ptr[x * step + roffset];
-            float nr, ng, nb;
-            float l0, l1, l;
-
-            PROCESS()
-
-            ptr[x * step + goffset] = av_clip_uint8(ng);
-            ptr[x * step + boffset] = av_clip_uint8(nb);
-            ptr[x * step + roffset] = av_clip_uint8(nr);
-        }
-
-        ptr += linesize;
-    }
-
-    return 0;
-}
-
-static int temperature_slice16p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ColorTemperatureContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int step = s->step;
-    const int depth = s->depth;
-    const int width = frame->width;
-    const int height = frame->height;
-    const float preserve = s->preserve;
-    const float mix = s->mix;
-    const float *color = s->color;
-    const uint8_t roffset = s->rgba_map[R];
-    const uint8_t goffset = s->rgba_map[G];
-    const uint8_t boffset = s->rgba_map[B];
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int linesize = frame->linesize[0] / sizeof(uint16_t);
-    uint16_t *ptr = (uint16_t *)frame->data[0] + slice_start * linesize;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = ptr[x * step + goffset];
-            float b = ptr[x * step + boffset];
-            float r = ptr[x * step + roffset];
-            float nr, ng, nb;
-            float l0, l1, l;
-
-            PROCESS()
-
-            ptr[x * step + goffset] = av_clip_uintp2_c(ng, depth);
-            ptr[x * step + boffset] = av_clip_uintp2_c(nb, depth);
-            ptr[x * step + roffset] = av_clip_uintp2_c(nr, depth);
-        }
-
-        ptr += linesize;
-    }
-
-    return 0;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorTemperatureContext *s = ctx->priv;
-
-    kelvin2rgb(s->temperature, s->color);
-
-    ctx->internal->execute(ctx, s->do_slice, frame, NULL,
-                           FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
-
-    return ff_filter_frame(ctx->outputs[0], frame);
-}
-
-static av_cold int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
-        AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,
-        AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR,
-        AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR,
-        AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
-        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12,
-        AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_RGB48,  AV_PIX_FMT_BGR48,
-        AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *formats = NULL;
-
-    formats = ff_make_format_list(pixel_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-
-    return ff_set_common_formats(ctx, formats);
-}
-
-static av_cold int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ColorTemperatureContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
-
-    s->step = desc->nb_components;
-    if (inlink->format == AV_PIX_FMT_RGB0 ||
-        inlink->format == AV_PIX_FMT_0RGB ||
-        inlink->format == AV_PIX_FMT_BGR0 ||
-        inlink->format == AV_PIX_FMT_0BGR)
-        s->step = 4;
-
-    s->depth = desc->comp[0].depth;
-    s->do_slice = s->depth <= 8 ? temperature_slice8 : temperature_slice16;
-    if (!planar)
-        s->do_slice = s->depth <= 8 ? temperature_slice8p : temperature_slice16p;
-
-    ff_fill_rgba_map(s->rgba_map, inlink->format);
-
-    return 0;
-}
-
-static const AVFilterPad inputs[] = {
-    {
-        .name           = "default",
-        .type           = AVMEDIA_TYPE_VIDEO,
-        .filter_frame   = filter_frame,
-        .config_props   = config_input,
-        .needs_writable = 1,
-    },
-    { NULL }
-};
-
-static const AVFilterPad outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_VIDEO,
-    },
-    { NULL }
-};
-
-#define OFFSET(x) offsetof(ColorTemperatureContext, x)
-#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption colortemperature_options[] = {
-    { "temperature", "set the temperature in Kelvin",          OFFSET(temperature), AV_OPT_TYPE_FLOAT, {.dbl=6500}, 1000,  40000, VF },
-    { "mix",         "set the mix with filtered output",       OFFSET(mix),         AV_OPT_TYPE_FLOAT, {.dbl=1},       0,      1, VF },
-    { "pl",          "set the amount of preserving lightness", OFFSET(preserve),    AV_OPT_TYPE_FLOAT, {.dbl=0},       0,      1, VF },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(colortemperature);
-
-AVFilter ff_vf_colortemperature = {
-    .name          = "colortemperature",
-    .description   = NULL_IF_CONFIG_SMALL("Adjust color temperature of video."),
-    .priv_size     = sizeof(ColorTemperatureContext),
-    .priv_class    = &colortemperature_class,
-    .query_formats = query_formats,
-    .inputs        = inputs,
-    .outputs       = outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 0b7356b..3674f5b 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -110,7 +110,7 @@
 static void filter16_prewitt(uint8_t *dstp, int width,
                              float scale, float delta, const int *const matrix,
                              const uint8_t *c[], int peak, int radius,
-                             int dstride, int stride, int size)
+                             int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -128,7 +128,7 @@
 static void filter16_roberts(uint8_t *dstp, int width,
                              float scale, float delta, const int *const matrix,
                              const uint8_t *c[], int peak, int radius,
-                             int dstride, int stride, int size)
+                             int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -144,7 +144,7 @@
 static void filter16_sobel(uint8_t *dstp, int width,
                            float scale, float delta, const int *const matrix,
                            const uint8_t *c[], int peak, int radius,
-                           int dstride, int stride, int size)
+                           int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -159,59 +159,10 @@
     }
 }
 
-static void filter16_kirsch(uint8_t *dstp, int width,
-                            float scale, float delta, const int *const matrix,
-                            const uint8_t *c[], int peak, int radius,
-                            int dstride, int stride, int size)
-{
-    uint16_t *dst = (uint16_t *)dstp;
-    const uint16_t *c0 = (const uint16_t *)c[0], *c1 = (const uint16_t *)c[1], *c2 = (const uint16_t *)c[2];
-    const uint16_t *c3 = (const uint16_t *)c[3], *c5 = (const uint16_t *)c[5];
-    const uint16_t *c6 = (const uint16_t *)c[6], *c7 = (const uint16_t *)c[7], *c8 = (const uint16_t *)c[8];
-    int x;
-
-    for (x = 0; x < width; x++) {
-        int sum0 = c0[x] *  5 + c1[x] *  5 + c2[x] *  5 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
-        int sum1 = c0[x] * -3 + c1[x] *  5 + c2[x] *  5 +
-                   c3[x] *  5 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
-        int sum2 = c0[x] * -3 + c1[x] * -3 + c2[x] *  5 +
-                   c3[x] *  5 + c5[x] *  5 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
-        int sum3 = c0[x] * -3 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] *  5 + c5[x] *  5 +
-                   c6[x] *  5 + c7[x] * -3 + c8[x] * -3;
-        int sum4 = c0[x] * -3 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] *  5 +
-                   c6[x] *  5 + c7[x] *  5 + c8[x] * -3;
-        int sum5 = c0[x] * -3 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] *  5 + c7[x] *  5 + c8[x] *  5;
-        int sum6 = c0[x] *  5 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] *  5 + c8[x] *  5;
-        int sum7 = c0[x] *  5 + c1[x] *  5 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] *  5;
-
-        sum0 = FFMAX(sum0, sum1);
-        sum2 = FFMAX(sum2, sum3);
-        sum4 = FFMAX(sum4, sum5);
-        sum6 = FFMAX(sum6, sum7);
-        sum0 = FFMAX(sum0, sum2);
-        sum4 = FFMAX(sum4, sum6);
-        sum0 = FFMAX(sum0, sum4);
-
-        dst[x] = av_clip(FFABS(sum0) * scale + delta, 0, peak);
-    }
-}
-
 static void filter_prewitt(uint8_t *dst, int width,
                            float scale, float delta, const int *const matrix,
                            const uint8_t *c[], int peak, int radius,
-                           int dstride, int stride, int size)
+                           int dstride, int stride)
 {
     const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
     const uint8_t *c3 = c[3], *c5 = c[5];
@@ -231,7 +182,7 @@
 static void filter_roberts(uint8_t *dst, int width,
                            float scale, float delta, const int *const matrix,
                            const uint8_t *c[], int peak, int radius,
-                           int dstride, int stride, int size)
+                           int dstride, int stride)
 {
     int x;
 
@@ -246,7 +197,7 @@
 static void filter_sobel(uint8_t *dst, int width,
                          float scale, float delta, const int *const matrix,
                          const uint8_t *c[], int peak, int radius,
-                         int dstride, int stride, int size)
+                         int dstride, int stride)
 {
     const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
     const uint8_t *c3 = c[3], *c5 = c[5];
@@ -263,58 +214,10 @@
     }
 }
 
-static void filter_kirsch(uint8_t *dst, int width,
-                          float scale, float delta, const int *const matrix,
-                          const uint8_t *c[], int peak, int radius,
-                          int dstride, int stride, int size)
-{
-    const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
-    const uint8_t *c3 = c[3], *c5 = c[5];
-    const uint8_t *c6 = c[6], *c7 = c[7], *c8 = c[8];
-    int x;
-
-    for (x = 0; x < width; x++) {
-        int sum0 = c0[x] *  5 + c1[x] *  5 + c2[x] *  5 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
-        int sum1 = c0[x] * -3 + c1[x] *  5 + c2[x] *  5 +
-                   c3[x] *  5 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
-        int sum2 = c0[x] * -3 + c1[x] * -3 + c2[x] *  5 +
-                   c3[x] *  5 + c5[x] *  5 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
-        int sum3 = c0[x] * -3 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] *  5 + c5[x] *  5 +
-                   c6[x] *  5 + c7[x] * -3 + c8[x] * -3;
-        int sum4 = c0[x] * -3 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] *  5 +
-                   c6[x] *  5 + c7[x] *  5 + c8[x] * -3;
-        int sum5 = c0[x] * -3 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] *  5 + c7[x] *  5 + c8[x] *  5;
-        int sum6 = c0[x] *  5 + c1[x] * -3 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] *  5 + c8[x] *  5;
-        int sum7 = c0[x] *  5 + c1[x] *  5 + c2[x] * -3 +
-                   c3[x] * -3 + c5[x] * -3 +
-                   c6[x] * -3 + c7[x] * -3 + c8[x] *  5;
-
-        sum0 = FFMAX(sum0, sum1);
-        sum2 = FFMAX(sum2, sum3);
-        sum4 = FFMAX(sum4, sum5);
-        sum6 = FFMAX(sum6, sum7);
-        sum0 = FFMAX(sum0, sum2);
-        sum4 = FFMAX(sum4, sum6);
-        sum0 = FFMAX(sum0, sum4);
-
-        dst[x] = av_clip_uint8(FFABS(sum0) * scale + delta);
-    }
-}
-
 static void filter16_3x3(uint8_t *dstp, int width,
                          float rdiv, float bias, const int *const matrix,
                          const uint8_t *c[], int peak, int radius,
-                         int dstride, int stride, int size)
+                         int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -337,7 +240,7 @@
 static void filter16_5x5(uint8_t *dstp, int width,
                          float rdiv, float bias, const int *const matrix,
                          const uint8_t *c[], int peak, int radius,
-                         int dstride, int stride, int size)
+                         int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -356,7 +259,7 @@
 static void filter16_7x7(uint8_t *dstp, int width,
                          float rdiv, float bias, const int *const matrix,
                          const uint8_t *c[], int peak, int radius,
-                         int dstride, int stride, int size)
+                         int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -375,7 +278,7 @@
 static void filter16_row(uint8_t *dstp, int width,
                          float rdiv, float bias, const int *const matrix,
                          const uint8_t *c[], int peak, int radius,
-                         int dstride, int stride, int size)
+                         int dstride, int stride)
 {
     uint16_t *dst = (uint16_t *)dstp;
     int x;
@@ -394,24 +297,19 @@
 static void filter16_column(uint8_t *dstp, int height,
                             float rdiv, float bias, const int *const matrix,
                             const uint8_t *c[], int peak, int radius,
-                            int dstride, int stride, int size)
+                            int dstride, int stride)
 {
-    DECLARE_ALIGNED(64, int, sum)[16];
     uint16_t *dst = (uint16_t *)dstp;
-    const int width = FFMIN(16, size);
+    int y;
 
-    for (int y = 0; y < height; y++) {
+    for (y = 0; y < height; y++) {
+        int i, sum = 0;
 
-        memset(sum, 0, sizeof(sum));
-        for (int i = 0; i < 2 * radius + 1; i++) {
-            for (int off16 = 0; off16 < width; off16++)
-                sum[off16] += AV_RN16A(&c[i][0 + y * stride + off16 * 2]) * matrix[i];
-        }
+        for (i = 0; i < 2 * radius + 1; i++)
+            sum += AV_RN16A(&c[i][0 + y * stride]) * matrix[i];
 
-        for (int off16 = 0; off16 < width; off16++) {
-            sum[off16] = (int)(sum[off16] * rdiv + bias + 0.5f);
-            dst[off16] = av_clip(sum[off16], 0, peak);
-        }
+        sum = (int)(sum * rdiv + bias + 0.5f);
+        dst[0] = av_clip(sum, 0, peak);
         dst += dstride / 2;
     }
 }
@@ -419,7 +317,7 @@
 static void filter_7x7(uint8_t *dst, int width,
                        float rdiv, float bias, const int *const matrix,
                        const uint8_t *c[], int peak, int radius,
-                       int dstride, int stride, int size)
+                       int dstride, int stride)
 {
     int x;
 
@@ -437,7 +335,7 @@
 static void filter_5x5(uint8_t *dst, int width,
                        float rdiv, float bias, const int *const matrix,
                        const uint8_t *c[], int peak, int radius,
-                       int dstride, int stride, int size)
+                       int dstride, int stride)
 {
     int x;
 
@@ -455,7 +353,7 @@
 static void filter_3x3(uint8_t *dst, int width,
                        float rdiv, float bias, const int *const matrix,
                        const uint8_t *c[], int peak, int radius,
-                       int dstride, int stride, int size)
+                       int dstride, int stride)
 {
     const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
     const uint8_t *c3 = c[3], *c4 = c[4], *c5 = c[5];
@@ -474,7 +372,7 @@
 static void filter_row(uint8_t *dst, int width,
                        float rdiv, float bias, const int *const matrix,
                        const uint8_t *c[], int peak, int radius,
-                       int dstride, int stride, int size)
+                       int dstride, int stride)
 {
     int x;
 
@@ -492,22 +390,18 @@
 static void filter_column(uint8_t *dst, int height,
                           float rdiv, float bias, const int *const matrix,
                           const uint8_t *c[], int peak, int radius,
-                          int dstride, int stride, int size)
+                          int dstride, int stride)
 {
-    DECLARE_ALIGNED(64, int, sum)[16];
+    int y;
 
-    for (int y = 0; y < height; y++) {
-        memset(sum, 0, sizeof(sum));
+    for (y = 0; y < height; y++) {
+        int i, sum = 0;
 
-        for (int i = 0; i < 2 * radius + 1; i++) {
-            for (int off16 = 0; off16 < 16; off16++)
-                sum[off16] += c[i][0 + y * stride + off16] * matrix[i];
-        }
+        for (i = 0; i < 2 * radius + 1; i++)
+            sum += c[i][0 + y * stride] * matrix[i];
 
-        for (int off16 = 0; off16 < 16; off16++) {
-            sum[off16] = (int)(sum[off16] * rdiv + bias + 0.5f);
-            dst[off16] = av_clip_uint8(sum[off16]);
-        }
+        sum = (int)(sum * rdiv + bias + 0.5f);
+        dst[0] = av_clip_uint8(sum);
         dst += dstride;
     }
 }
@@ -614,7 +508,6 @@
         const int dst_pos = slice_start * (mode == MATRIX_COLUMN ? bpc : dstride);
         uint8_t *dst = out->data[plane] + dst_pos;
         const int *matrix = s->matrix[plane];
-        const int step = mode == MATRIX_COLUMN ? 16 : 1;
         const uint8_t *c[49];
         int y, x;
 
@@ -627,31 +520,32 @@
                                     width * bpc, slice_end - slice_start);
             continue;
         }
-        for (y = slice_start; y < slice_end; y += step) {
+
+        for (y = slice_start; y < slice_end; y++) {
             const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : radius * bpc;
-            const int yoff = mode == MATRIX_COLUMN ? radius * dstride : 0;
+            const int yoff = mode == MATRIX_COLUMN ? radius * stride : 0;
 
             for (x = 0; x < radius; x++) {
                 const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : x * bpc;
-                const int yoff = mode == MATRIX_COLUMN ? x * dstride : 0;
+                const int yoff = mode == MATRIX_COLUMN ? x * stride : 0;
 
                 s->setup[plane](radius, c, src, stride, x, width, y, height, bpc);
                 s->filter[plane](dst + yoff + xoff, 1, rdiv,
                                  bias, matrix, c, s->max, radius,
-                                 dstride, stride, slice_end - step);
+                                 dstride, stride);
             }
             s->setup[plane](radius, c, src, stride, radius, width, y, height, bpc);
             s->filter[plane](dst + yoff + xoff, sizew - 2 * radius,
                              rdiv, bias, matrix, c, s->max, radius,
-                             dstride, stride, slice_end - step);
+                             dstride, stride);
             for (x = sizew - radius; x < sizew; x++) {
                 const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : x * bpc;
-                const int yoff = mode == MATRIX_COLUMN ? x * dstride : 0;
+                const int yoff = mode == MATRIX_COLUMN ? x * stride : 0;
 
                 s->setup[plane](radius, c, src, stride, x, width, y, height, bpc);
                 s->filter[plane](dst + yoff + xoff, 1, rdiv,
                                  bias, matrix, c, s->max, radius,
-                                 dstride, stride, slice_end - step);
+                                 dstride, stride);
             }
             if (mode != MATRIX_COLUMN)
                 dst += dstride;
@@ -710,10 +604,6 @@
         if (s->depth > 8)
             for (p = 0; p < s->nb_planes; p++)
                 s->filter[p] = filter16_sobel;
-    } else if (!strcmp(ctx->filter->name, "kirsch")) {
-        if (s->depth > 8)
-            for (p = 0; p < s->nb_planes; p++)
-                s->filter[p] = filter16_kirsch;
     }
 
     return 0;
@@ -854,17 +744,6 @@
             s->rdiv[i] = s->scale;
             s->bias[i] = s->delta;
         }
-    } else if (!strcmp(ctx->filter->name, "kirsch")) {
-        for (i = 0; i < 4; i++) {
-            if ((1 << i) & s->planes)
-                s->filter[i] = filter_kirsch;
-            else
-                s->copy[i] = 1;
-            s->size[i] = 3;
-            s->setup[i] = setup_3x3;
-            s->rdiv[i] = s->scale;
-            s->bias[i] = s->delta;
-        }
     }
 
     return 0;
@@ -917,18 +796,15 @@
 
 #endif /* CONFIG_CONVOLUTION_FILTER */
 
-#if CONFIG_PREWITT_FILTER || CONFIG_ROBERTS_FILTER || CONFIG_SOBEL_FILTER
+#if CONFIG_PREWITT_FILTER
 
-static const AVOption prewitt_roberts_sobel_options[] = {
+static const AVOption prewitt_options[] = {
     { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,  {.i64=15}, 0, 15, FLAGS},
     { "scale",  "set scale",            OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0,  65535, FLAGS},
     { "delta",  "set delta",            OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
     { NULL }
 };
 
-#if CONFIG_PREWITT_FILTER
-
-#define prewitt_options prewitt_roberts_sobel_options
 AVFILTER_DEFINE_CLASS(prewitt);
 
 AVFilter ff_vf_prewitt = {
@@ -948,7 +824,13 @@
 
 #if CONFIG_SOBEL_FILTER
 
-#define sobel_options prewitt_roberts_sobel_options
+static const AVOption sobel_options[] = {
+    { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,  {.i64=15}, 0, 15, FLAGS},
+    { "scale",  "set scale",            OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0,  65535, FLAGS},
+    { "delta",  "set delta",            OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(sobel);
 
 AVFilter ff_vf_sobel = {
@@ -968,7 +850,13 @@
 
 #if CONFIG_ROBERTS_FILTER
 
-#define roberts_options prewitt_roberts_sobel_options
+static const AVOption roberts_options[] = {
+    { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,  {.i64=15}, 0, 15, FLAGS},
+    { "scale",  "set scale",            OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0,  65535, FLAGS},
+    { "delta",  "set delta",            OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(roberts);
 
 AVFilter ff_vf_roberts = {
@@ -985,25 +873,3 @@
 };
 
 #endif /* CONFIG_ROBERTS_FILTER */
-
-#if CONFIG_KIRSCH_FILTER
-
-#define kirsch_options prewitt_roberts_sobel_options
-AVFILTER_DEFINE_CLASS(kirsch);
-
-AVFilter ff_vf_kirsch = {
-    .name          = "kirsch",
-    .description   = NULL_IF_CONFIG_SMALL("Apply kirsch operator."),
-    .priv_size     = sizeof(ConvolutionContext),
-    .priv_class    = &kirsch_class,
-    .init          = init,
-    .query_formats = query_formats,
-    .inputs        = convolution_inputs,
-    .outputs       = convolution_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
-};
-
-#endif /* CONFIG_KIRSCH_FILTER */
-
-#endif /* CONFIG_PREWITT_FILTER || CONFIG_ROBERTS_FILTER || CONFIG_SOBEL_FILTER */
diff --git a/libavfilter/vf_copy.c b/libavfilter/vf_copy.c
index 78bb510..e82feb4 100644
--- a/libavfilter/vf_copy.c
+++ b/libavfilter/vf_copy.c
@@ -30,12 +30,17 @@
 static int query_formats(AVFilterContext *ctx)
 {
     AVFilterFormats *formats = NULL;
-    int ret;
+    int fmt;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_HWACCEL);
-    if (ret < 0)
-        return ret;
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        int ret;
+        if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
+            continue;
+        if ((ret = ff_add_format(&formats, fmt)) < 0)
+            return ret;
+    }
+
     return ff_set_common_formats(ctx, formats);
 }
 
diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c
index 3524fef..883cc1c 100644
--- a/libavfilter/vf_curves.c
+++ b/libavfilter/vf_curves.c
@@ -69,10 +69,8 @@
     uint8_t rgba_map[4];
     int step;
     char *plot_filename;
-    int saved_plot;
     int is_16bit;
     int depth;
-    int parsed_psfile;
 
     int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
 } CurvesContext;
@@ -82,20 +80,20 @@
 } ThreadData;
 
 #define OFFSET(x) offsetof(CurvesContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption curves_options[] = {
     { "preset", "select a color curves preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64=PRESET_NONE}, PRESET_NONE, NB_PRESETS-1, FLAGS, "preset_name" },
-        { "none",               NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NONE},                 0, 0, FLAGS, "preset_name" },
-        { "color_negative",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE},       0, 0, FLAGS, "preset_name" },
-        { "cross_process",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_CROSS_PROCESS},        0, 0, FLAGS, "preset_name" },
-        { "darker",             NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_DARKER},               0, 0, FLAGS, "preset_name" },
-        { "increase_contrast",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_INCREASE_CONTRAST},    0, 0, FLAGS, "preset_name" },
-        { "lighter",            NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LIGHTER},              0, 0, FLAGS, "preset_name" },
-        { "linear_contrast",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LINEAR_CONTRAST},      0, 0, FLAGS, "preset_name" },
-        { "medium_contrast",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_MEDIUM_CONTRAST},      0, 0, FLAGS, "preset_name" },
-        { "negative",           NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NEGATIVE},             0, 0, FLAGS, "preset_name" },
-        { "strong_contrast",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_STRONG_CONTRAST},      0, 0, FLAGS, "preset_name" },
-        { "vintage",            NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_VINTAGE},              0, 0, FLAGS, "preset_name" },
+        { "none",               NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NONE},                 INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "color_negative",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE},       INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "cross_process",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_CROSS_PROCESS},        INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "darker",             NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_DARKER},               INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "increase_contrast",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_INCREASE_CONTRAST},    INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "lighter",            NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LIGHTER},              INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "linear_contrast",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LINEAR_CONTRAST},      INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "medium_contrast",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_MEDIUM_CONTRAST},      INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "negative",           NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NEGATIVE},             INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "strong_contrast",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_STRONG_CONTRAST},      INT_MIN, INT_MAX, FLAGS, "preset_name" },
+        { "vintage",            NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_VINTAGE},              INT_MIN, INT_MAX, FLAGS, "preset_name" },
     { "master","set master points coordinates",OFFSET(comp_points_str[NB_COMP]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
     { "m",     "set master points coordinates",OFFSET(comp_points_str[NB_COMP]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
     { "red",   "set red points coordinates",   OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
@@ -488,11 +486,10 @@
         }
     }
 
-    if (curves->psfile && !curves->parsed_psfile) {
+    if (curves->psfile) {
         ret = parse_psfile(ctx, curves->psfile);
         if (ret < 0)
             return ret;
-        curves->parsed_psfile = 1;
     }
 
     if (curves->preset != PRESET_NONE) {
@@ -507,7 +504,6 @@
         SET_COMP_IF_NOT_SET(1, g);
         SET_COMP_IF_NOT_SET(2, b);
         SET_COMP_IF_NOT_SET(3, master);
-        curves->preset = PRESET_NONE;
     }
 
     return 0;
@@ -668,8 +664,7 @@
     curves->filter_slice = desc->flags & AV_PIX_FMT_FLAG_PLANAR ? filter_slice_planar : filter_slice_packed;
 
     for (i = 0; i < NB_COMP + 1; i++) {
-        if (!curves->graph[i])
-            curves->graph[i] = av_mallocz_array(curves->lut_size, sizeof(*curves->graph[0]));
+        curves->graph[i] = av_mallocz_array(curves->lut_size, sizeof(*curves->graph[0]));
         if (!curves->graph[i])
             return AVERROR(ENOMEM);
         ret = parse_points_str(ctx, comp_points + i, curves->comp_points_str[i], curves->lut_size);
@@ -704,10 +699,8 @@
         }
     }
 
-    if (curves->plot_filename && !curves->saved_plot) {
+    if (curves->plot_filename)
         dump_curves(curves->plot_filename, curves->graph, comp_points, curves->lut_size);
-        curves->saved_plot = 1;
-    }
 
     for (i = 0; i < NB_COMP + 1; i++) {
         struct keypoint *point = comp_points[i];
@@ -750,42 +743,6 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    CurvesContext *curves = ctx->priv;
-    int ret;
-
-    if (!strcmp(cmd, "plot")) {
-        curves->saved_plot = 0;
-    } else if (!strcmp(cmd, "all") || !strcmp(cmd, "preset") || !strcmp(cmd, "psfile")) {
-        if (!strcmp(cmd, "psfile"))
-            curves->parsed_psfile = 0;
-        av_freep(&curves->comp_points_str_all);
-        av_freep(&curves->comp_points_str[0]);
-        av_freep(&curves->comp_points_str[1]);
-        av_freep(&curves->comp_points_str[2]);
-        av_freep(&curves->comp_points_str[NB_COMP]);
-    } else if (!strcmp(cmd, "red") || !strcmp(cmd, "r")) {
-        av_freep(&curves->comp_points_str[0]);
-    } else if (!strcmp(cmd, "green") || !strcmp(cmd, "g")) {
-        av_freep(&curves->comp_points_str[1]);
-    } else if (!strcmp(cmd, "blue") || !strcmp(cmd, "b")) {
-        av_freep(&curves->comp_points_str[2]);
-    } else if (!strcmp(cmd, "master") || !strcmp(cmd, "m")) {
-        av_freep(&curves->comp_points_str[NB_COMP]);
-    }
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    ret = curves_init(ctx);
-    if (ret < 0)
-        return ret;
-    return config_input(ctx->inputs[0]);
-}
-
 static av_cold void curves_uninit(AVFilterContext *ctx)
 {
     int i;
@@ -824,5 +781,4 @@
     .outputs       = curves_outputs,
     .priv_class    = &curves_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 88007c9..16fafd5 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -37,7 +37,6 @@
     int mode;
     int dformat;
     int axis;
-    int components;
     float opacity;
 
     int nb_planes;
@@ -61,18 +60,17 @@
 static const AVOption datascope_options[] = {
     { "size", "set output size", OFFSET(ow),   AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
     { "s",    "set output size", OFFSET(ow),   AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
-    { "x",    "set x offset", OFFSET(x),    AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGSR },
-    { "y",    "set y offset", OFFSET(y),    AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGSR },
-    { "mode", "set scope mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGSR, "mode" },
-    {   "mono",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGSR, "mode" },
-    {   "color",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGSR, "mode" },
-    {   "color2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGSR, "mode" },
-    { "axis",    "draw column/row numbers", OFFSET(axis), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGSR },
-    { "opacity", "set background opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGSR },
-    { "format", "set display number format", OFFSET(dformat), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGSR, "format" },
-    {   "hex",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGSR, "format" },
-    {   "dec",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGSR, "format" },
-    { "components", "set components to display", OFFSET(components), AV_OPT_TYPE_INT, {.i64=15}, 1, 15, FLAGSR },
+    { "x",    "set x offset", OFFSET(x),    AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+    { "y",    "set y offset", OFFSET(y),    AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+    { "mode", "set scope mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
+    {   "mono",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
+    {   "color",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
+    {   "color2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode" },
+    { "axis",    "draw column/row numbers", OFFSET(axis), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
+    { "opacity", "set background opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
+    { "format", "set display number format", OFFSET(dformat), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "format" },
+    {   "hex",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "format" },
+    {   "dec",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "format" },
     { NULL }
 };
 
@@ -171,7 +169,7 @@
 
 typedef struct ThreadData {
     AVFrame *in, *out;
-    int xoff, yoff, PP;
+    int xoff, yoff;
 } ThreadData;
 
 static int filter_color2(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@@ -182,14 +180,13 @@
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const int PP = td->PP;
     const int xoff = td->xoff;
     const int yoff = td->yoff;
     const int P = FFMAX(s->nb_planes, s->nb_comps);
     const int C = s->chars;
     const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
     const int W = (outlink->w - xoff) / (C * 10);
-    const int H = (outlink->h - yoff) / (PP * 12);
+    const int H = (outlink->h - yoff) / (P * 12);
     const char *format[4] = {"%02X\n", "%04X\n", "%03d\n", "%05d\n"};
     const int slice_start = (W * jobnr) / nb_jobs;
     const int slice_end = (W * (jobnr+1)) / nb_jobs;
@@ -199,21 +196,18 @@
         for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
             FFDrawColor color = { { 0 } };
             FFDrawColor reverse = { { 0 } };
-            int value[4] = { 0 }, pp = 0;
+            int value[4] = { 0 };
 
             s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
             s->reverse_color(&s->draw, &color, &reverse);
             ff_fill_rectangle(&s->draw, &color, out->data, out->linesize,
-                              xoff + x * C * 10, yoff + y * PP * 12, C * 10, PP * 12);
+                              xoff + x * C * 10, yoff + y * P * 12, C * 10, P * 12);
 
             for (p = 0; p < P; p++) {
                 char text[256];
 
-                if (!(s->components & (1 << p)))
-                    continue;
                 snprintf(text, sizeof(text), format[D], value[p]);
-                draw_text(&s->draw, out, &reverse, xoff + x * C * 10 + 2, yoff + y * PP * 12 + pp * 10 + 2, text, 0);
-                pp++;
+                draw_text(&s->draw, out, &reverse, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
             }
         }
     }
@@ -229,14 +223,13 @@
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const int PP = td->PP;
     const int xoff = td->xoff;
     const int yoff = td->yoff;
     const int P = FFMAX(s->nb_planes, s->nb_comps);
     const int C = s->chars;
     const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
     const int W = (outlink->w - xoff) / (C * 10);
-    const int H = (outlink->h - yoff) / (PP * 12);
+    const int H = (outlink->h - yoff) / (P * 12);
     const char *format[4] = {"%02X\n", "%04X\n", "%03d\n", "%05d\n"};
     const int slice_start = (W * jobnr) / nb_jobs;
     const int slice_end = (W * (jobnr+1)) / nb_jobs;
@@ -245,18 +238,15 @@
     for (y = 0; y < H && (y + s->y < inlink->h); y++) {
         for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
             FFDrawColor color = { { 0 } };
-            int value[4] = { 0 }, pp = 0;
+            int value[4] = { 0 };
 
             s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
 
             for (p = 0; p < P; p++) {
                 char text[256];
 
-                if (!(s->components & (1 << p)))
-                    continue;
                 snprintf(text, sizeof(text), format[D], value[p]);
-                draw_text(&s->draw, out, &color, xoff + x * C * 10 + 2, yoff + y * PP * 12 + pp * 10 + 2, text, 0);
-                pp++;
+                draw_text(&s->draw, out, &color, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
             }
         }
     }
@@ -272,14 +262,13 @@
     ThreadData *td = arg;
     AVFrame *in = td->in;
     AVFrame *out = td->out;
-    const int PP = td->PP;
     const int xoff = td->xoff;
     const int yoff = td->yoff;
     const int P = FFMAX(s->nb_planes, s->nb_comps);
     const int C = s->chars;
     const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
     const int W = (outlink->w - xoff) / (C * 10);
-    const int H = (outlink->h - yoff) / (PP * 12);
+    const int H = (outlink->h - yoff) / (P * 12);
     const char *format[4] = {"%02X\n", "%04X\n", "%03d\n", "%05d\n"};
     const int slice_start = (W * jobnr) / nb_jobs;
     const int slice_end = (W * (jobnr+1)) / nb_jobs;
@@ -288,17 +277,14 @@
     for (y = 0; y < H && (y + s->y < inlink->h); y++) {
         for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
             FFDrawColor color = { { 0 } };
-            int value[4] = { 0 }, pp = 0;
+            int value[4] = { 0 };
 
             s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
             for (p = 0; p < P; p++) {
                 char text[256];
 
-                if (!(s->components & (1 << p)))
-                    continue;
                 snprintf(text, sizeof(text), format[D], value[p]);
-                draw_text(&s->draw, out, &s->white, xoff + x * C * 10 + 2, yoff + y * PP * 12 + pp * 10 + 2, text, 0);
-                pp++;
+                draw_text(&s->draw, out, &s->white, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
             }
         }
     }
@@ -311,11 +297,9 @@
     AVFilterContext *ctx  = inlink->dst;
     DatascopeContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    const int P = FFMAX(s->nb_planes, s->nb_comps);
     ThreadData td = { 0 };
     int ymaxlen = 0;
     int xmaxlen = 0;
-    int PP = 0;
     AVFrame *out;
 
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
@@ -328,15 +312,10 @@
     ff_fill_rectangle(&s->draw, &s->black, out->data, out->linesize,
                       0, 0, outlink->w, outlink->h);
 
-    for (int p = 0; p < P; p++) {
-        if (s->components & (1 << p))
-            PP++;
-    }
-    PP = FFMAX(PP, 1);
-
     if (s->axis) {
+        const int P = FFMAX(s->nb_planes, s->nb_comps);
         const int C = s->chars;
-        int Y = outlink->h / (PP * 12);
+        int Y = outlink->h / (P * 12);
         int X = outlink->w / (C * 10);
         char text[256] = { 0 };
         int x, y;
@@ -348,16 +327,16 @@
         xmaxlen = strlen(text);
         xmaxlen *= 10;
 
-        Y = (outlink->h - xmaxlen) / (PP * 12);
+        Y = (outlink->h - xmaxlen) / (P * 12);
         X = (outlink->w - ymaxlen) / (C * 10);
 
         for (y = 0; y < Y; y++) {
             snprintf(text, sizeof(text), "%d", s->y + y);
 
             ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
-                              0, xmaxlen + y * PP * 12 + (PP + 1) * PP - 2, ymaxlen, 10);
+                              0, xmaxlen + y * P * 12 + (P + 1) * P - 2, ymaxlen, 10);
 
-            draw_text(&s->draw, out, &s->yellow, 2, xmaxlen + y * PP * 12 + (PP + 1) * PP, text, 0);
+            draw_text(&s->draw, out, &s->yellow, 2, xmaxlen + y * P * 12 + (P + 1) * P, text, 0);
         }
 
         for (x = 0; x < X; x++) {
@@ -370,7 +349,7 @@
         }
     }
 
-    td.in = in; td.out = out, td.yoff = xmaxlen, td.xoff = ymaxlen, td.PP = PP;
+    td.in = in; td.out = out, td.yoff = xmaxlen, td.xoff = ymaxlen;
     ctx->internal->execute(ctx, s->filter, &td, NULL, FFMIN(ff_filter_get_nb_threads(ctx), FFMAX(outlink->w / 20, 1)));
 
     av_frame_free(&in);
@@ -419,18 +398,6 @@
     return 0;
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_input(ctx->inputs[0]);
-}
-
 static const AVFilterPad inputs[] = {
     {
         .name         = "default",
@@ -459,7 +426,6 @@
     .inputs        = inputs,
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 typedef struct PixscopeContext {
@@ -494,13 +460,13 @@
 #define POFFSET(x) offsetof(PixscopeContext, x)
 
 static const AVOption pixscope_options[] = {
-    { "x",  "set scope x offset",  POFFSET(xpos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,  1, FLAGSR },
-    { "y",  "set scope y offset",  POFFSET(ypos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,  1, FLAGSR },
-    { "w",  "set scope width",     POFFSET(w),    AV_OPT_TYPE_INT,   {.i64=7},   1, 80, FLAGSR },
-    { "h",  "set scope height",    POFFSET(h),    AV_OPT_TYPE_INT,   {.i64=7},   1, 80, FLAGSR },
-    { "o",  "set window opacity",  POFFSET(o),    AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,  1, FLAGSR },
-    { "wx", "set window x offset", POFFSET(wx),   AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1,  1, FLAGSR },
-    { "wy", "set window y offset", POFFSET(wy),   AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1,  1, FLAGSR },
+    { "x",  "set scope x offset",  POFFSET(xpos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,  1, FLAGS },
+    { "y",  "set scope y offset",  POFFSET(ypos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,  1, FLAGS },
+    { "w",  "set scope width",     POFFSET(w),    AV_OPT_TYPE_INT,   {.i64=7},   1, 80, FLAGS },
+    { "h",  "set scope height",    POFFSET(h),    AV_OPT_TYPE_INT,   {.i64=7},   1, 80, FLAGS },
+    { "o",  "set window opacity",  POFFSET(o),    AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,  1, FLAGS },
+    { "wx", "set window x offset", POFFSET(wx),   AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1,  1, FLAGS },
+    { "wy", "set window y offset", POFFSET(wy),   AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1,  1, FLAGS },
     { NULL }
 };
 
@@ -709,18 +675,6 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int pixscope_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                                    char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return pixscope_config_input(ctx->inputs[0]);
-}
-
 static const AVFilterPad pixscope_inputs[] = {
     {
         .name           = "default",
@@ -748,7 +702,6 @@
     .inputs        = pixscope_inputs,
     .outputs       = pixscope_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
-    .process_command = pixscope_process_command,
 };
 
 typedef struct PixelValues {
diff --git a/libavfilter/vf_dblur.c b/libavfilter/vf_dblur.c
index c4c37de..cc127da 100644
--- a/libavfilter/vf_dblur.c
+++ b/libavfilter/vf_dblur.c
@@ -40,6 +40,7 @@
     int planeheight[4];
     float *buffer;
     int nb_planes;
+    void (*horiz_slice)(float *buffer, int width, int height, int steps, float nu, float bscale);
 } DBlurContext;
 
 #define OFFSET(x) offsetof(DBlurContext, x)
diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
index a89f263..cdbe5f8 100644
--- a/libavfilter/vf_dctdnoiz.c
+++ b/libavfilter/vf_dctdnoiz.c
@@ -30,7 +30,6 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/eval.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "internal.h"
 
diff --git a/libavfilter/vf_deband.c b/libavfilter/vf_deband.c
index c05225d..330792f 100644
--- a/libavfilter/vf_deband.c
+++ b/libavfilter/vf_deband.c
@@ -49,7 +49,7 @@
 } DebandContext;
 
 #define OFFSET(x) offsetof(DebandContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption deband_options[] = {
     { "1thr",      "set 1st plane threshold", OFFSET(threshold[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02},  0.00003,     0.5, FLAGS },
@@ -117,7 +117,7 @@
 
 static float frand(int x, int y)
 {
-    const float r = sinf(x * 12.9898f + y * 78.233f) * 43758.545f;
+    const float r = sinf(x * 12.9898 + y * 78.233) * 43758.545;
 
     return r - floorf(r);
 }
@@ -389,10 +389,8 @@
     s->thr[2] = ((1 << desc->comp[2].depth) - 1) * s->threshold[2];
     s->thr[3] = ((1 << desc->comp[3].depth) - 1) * s->threshold[3];
 
-    if (!s->x_pos)
-        s->x_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->x_pos));
-    if (!s->y_pos)
-        s->y_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->y_pos));
+    s->x_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->x_pos));
+    s->y_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->y_pos));
     if (!s->x_pos || !s->y_pos)
         return AVERROR(ENOMEM);
 
@@ -434,17 +432,6 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-
-    if (ret < 0)
-        return ret;
-
-    return config_input(ctx->inputs[0]);
-}
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
     DebandContext *s = ctx->priv;
@@ -481,5 +468,4 @@
     .inputs        = avfilter_vf_deband_inputs,
     .outputs       = avfilter_vf_deband_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
diff --git a/libavfilter/vf_deblock.c b/libavfilter/vf_deblock.c
index 0671a64..77c681e 100644
--- a/libavfilter/vf_deblock.c
+++ b/libavfilter/vf_deblock.c
@@ -285,14 +285,14 @@
     if (s->depth <= 8 && s->filter == WEAK) {
         s->deblockh = deblockh8_weak;
         s->deblockv = deblockv8_weak;
-    } else if (s->depth > 8 && s->filter == WEAK) {
+    } else if (s->depth >= 8 && s->filter == WEAK) {
         s->deblockh = deblockh16_weak;
         s->deblockv = deblockv16_weak;
     }
     if (s->depth <= 8 && s->filter == STRONG) {
         s->deblockh = deblockh8_strong;
         s->deblockv = deblockv8_strong;
-    } else if (s->depth > 8 && s->filter == STRONG) {
+    } else if (s->depth >= 8 && s->filter == STRONG) {
         s->deblockh = deblockh16_strong;
         s->deblockv = deblockv16_strong;
     }
@@ -367,20 +367,8 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_output(ctx->outputs[0]);
-}
-
 #define OFFSET(x) offsetof(DeblockContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption deblock_options[] = {
     { "filter",    "set type of filter",          OFFSET(filter),    AV_OPT_TYPE_INT,   {.i64=STRONG},0, 1,  FLAGS, "filter" },
@@ -424,5 +412,4 @@
     .inputs        = inputs,
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
-    .process_command = process_command,
 };
diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index a76711f..549b281 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -23,7 +23,6 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/timestamp.h"
 #include "avfilter.h"
-#include "filters.h"
 #include "internal.h"
 
 #define INPUT_MAIN     0
@@ -44,7 +43,6 @@
     AVFrame **clean_src;    ///< frame queue for the clean source
     int got_frame[2];       ///< frame request flag for each input stream
     AVRational ts_unit;     ///< timestamp units for the output frames
-    int64_t last_pts;       ///< last output timestamp
     int64_t start_pts;      ///< base for output timestamps
     uint32_t eof;           ///< bitmask for end of stream
     int hsub, vsub;         ///< chroma subsampling values
@@ -167,11 +165,11 @@
     dm->got_frame[INPUT_MAIN] = dm->got_frame[INPUT_CLEANSRC] = 0;
 
     if (dm->ppsrc)
-        in = dm->queue[dm->fid].frame;
+        in = dm->clean_src[dm->fid];
 
     if (in) {
         /* update frame metrics */
-        prv = dm->fid ? dm->queue[dm->fid - 1].frame : dm->last;
+        prv = dm->fid ? (dm->ppsrc ? dm->clean_src[dm->fid - 1] : dm->queue[dm->fid - 1].frame) : dm->last;
         if (!prv) {
             dm->queue[dm->fid].maxbdiff = INT64_MAX;
             dm->queue[dm->fid].totdiff  = INT64_MAX;
@@ -225,13 +223,10 @@
             if (dm->ppsrc) {
                 av_frame_free(&frame);
                 frame = dm->clean_src[i];
-                if (!frame)
-                    continue;
                 dm->clean_src[i] = NULL;
             }
             frame->pts = av_rescale_q(outlink->frame_count_in, dm->ts_unit, (AVRational){1,1}) +
                          (dm->start_pts == AV_NOPTS_VALUE ? 0 : dm->start_pts);
-            dm->last_pts = frame->pts;
             ret = ff_filter_frame(outlink, frame);
             if (ret < 0)
                 break;
@@ -241,63 +236,36 @@
     return ret;
 }
 
-static int activate(AVFilterContext *ctx)
+static int config_input(AVFilterLink *inlink)
 {
+    int max_value;
+    AVFilterContext *ctx = inlink->dst;
     DecimateContext *dm = ctx->priv;
-    AVFrame *frame = NULL;
-    int ret = 0, status;
-    int64_t pts;
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
+    const int w = inlink->w;
+    const int h = inlink->h;
 
-    FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
+    dm->hsub      = pix_desc->log2_chroma_w;
+    dm->vsub      = pix_desc->log2_chroma_h;
+    dm->depth     = pix_desc->comp[0].depth;
+    max_value     = (1 << dm->depth) - 1;
+    dm->scthresh  = (int64_t)(((int64_t)max_value *          w * h          * dm->scthresh_flt)  / 100);
+    dm->dupthresh = (int64_t)(((int64_t)max_value * dm->blockx * dm->blocky * dm->dupthresh_flt) / 100);
+    dm->nxblocks  = (w + dm->blockx/2 - 1) / (dm->blockx/2);
+    dm->nyblocks  = (h + dm->blocky/2 - 1) / (dm->blocky/2);
+    dm->bdiffsize = dm->nxblocks * dm->nyblocks;
+    dm->bdiffs    = av_malloc_array(dm->bdiffsize, sizeof(*dm->bdiffs));
+    dm->queue     = av_calloc(dm->cycle, sizeof(*dm->queue));
 
-    if ((dm->got_frame[INPUT_MAIN] == 0) && !(dm->eof & (1 << INPUT_MAIN)) &&
-        (ret = ff_inlink_consume_frame(ctx->inputs[INPUT_MAIN], &frame)) > 0) {
-        ret = filter_frame(ctx->inputs[INPUT_MAIN], frame);
-        if (ret < 0)
-            return ret;
-    }
-    if (ret < 0)
-        return ret;
-    if (dm->ppsrc &&
-        (dm->got_frame[INPUT_CLEANSRC] == 0) && !(dm->eof & (1 << INPUT_CLEANSRC)) &&
-        (ret = ff_inlink_consume_frame(ctx->inputs[INPUT_CLEANSRC], &frame)) > 0) {
-        ret = filter_frame(ctx->inputs[INPUT_CLEANSRC], frame);
-        if (ret < 0)
-            return ret;
-    }
-    if (ret < 0) {
-        return ret;
-    } else if (dm->eof == ((1 << INPUT_MAIN) | (dm->ppsrc << INPUT_CLEANSRC))) {
-        ff_outlink_set_status(ctx->outputs[0], AVERROR_EOF, dm->last_pts);
-        return 0;
-    } else if (!(dm->eof & (1 << INPUT_MAIN)) && ff_inlink_acknowledge_status(ctx->inputs[INPUT_MAIN], &status, &pts)) {
-        if (status == AVERROR_EOF) { // flushing
-            dm->eof |= 1 << INPUT_MAIN;
-            if (dm->ppsrc)
-                filter_frame(ctx->inputs[INPUT_CLEANSRC], NULL);
-            filter_frame(ctx->inputs[INPUT_MAIN], NULL);
-            ff_outlink_set_status(ctx->outputs[0], AVERROR_EOF, dm->last_pts);
-            return 0;
-        }
-    } else if (dm->ppsrc && !(dm->eof & (1 << INPUT_CLEANSRC)) && ff_inlink_acknowledge_status(ctx->inputs[INPUT_CLEANSRC], &status, &pts)) {
-        if (status == AVERROR_EOF) { // flushing
-            dm->eof |= 1 << INPUT_CLEANSRC;
-            filter_frame(ctx->inputs[INPUT_MAIN], NULL);
-            filter_frame(ctx->inputs[INPUT_CLEANSRC], NULL);
-            ff_outlink_set_status(ctx->outputs[0], AVERROR_EOF, dm->last_pts);
-            return 0;
-        }
+    if (!dm->bdiffs || !dm->queue)
+        return AVERROR(ENOMEM);
+
+    if (dm->ppsrc) {
+        dm->clean_src = av_calloc(dm->cycle, sizeof(*dm->clean_src));
+        if (!dm->clean_src)
+            return AVERROR(ENOMEM);
     }
 
-    if (ff_inlink_queued_frames(ctx->inputs[INPUT_MAIN]) > 0 &&
-        (dm->ppsrc && ff_inlink_queued_frames(ctx->inputs[INPUT_CLEANSRC]) > 0)) {
-        ff_filter_set_ready(ctx, 100);
-    } else if (ff_outlink_frame_wanted(ctx->outputs[0])) {
-        if (dm->got_frame[INPUT_MAIN] == 0)
-            ff_inlink_request_frame(ctx->inputs[INPUT_MAIN]);
-        if (dm->ppsrc && (dm->got_frame[INPUT_CLEANSRC] == 0))
-            ff_inlink_request_frame(ctx->inputs[INPUT_CLEANSRC]);
-    }
     return 0;
 }
 
@@ -307,6 +275,8 @@
     AVFilterPad pad = {
         .name         = "main",
         .type         = AVMEDIA_TYPE_VIDEO,
+        .filter_frame = filter_frame,
+        .config_props = config_input,
     };
     int ret;
 
@@ -350,6 +320,38 @@
     av_freep(&dm->clean_src);
 }
 
+static int request_inlink(AVFilterContext *ctx, int lid)
+{
+    int ret = 0;
+    DecimateContext *dm = ctx->priv;
+
+    if (!dm->got_frame[lid]) {
+        AVFilterLink *inlink = ctx->inputs[lid];
+        ret = ff_request_frame(inlink);
+        if (ret == AVERROR_EOF) { // flushing
+            dm->eof |= 1 << lid;
+            ret = filter_frame(inlink, NULL);
+        }
+    }
+    return ret;
+}
+
+static int request_frame(AVFilterLink *outlink)
+{
+    int ret;
+    AVFilterContext *ctx = outlink->src;
+    DecimateContext *dm = ctx->priv;
+    const uint32_t eof_mask = 1<<INPUT_MAIN | dm->ppsrc<<INPUT_CLEANSRC;
+
+    if ((dm->eof & eof_mask) == eof_mask) // flush done?
+        return AVERROR_EOF;
+    if ((ret = request_inlink(ctx, INPUT_MAIN)) < 0)
+        return ret;
+    if (dm->ppsrc && (ret = request_inlink(ctx, INPUT_CLEANSRC)) < 0)
+        return ret;
+    return 0;
+}
+
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pix_fmts[] = {
@@ -357,12 +359,8 @@
 #define PF_ALPHA(suf)   AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
 #define PF(suf)         PF_NOALPHA(suf), PF_ALPHA(suf)
         PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
-        AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV440P12,
         AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
-        AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_GRAY16,
+        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
         AV_PIX_FMT_NONE
     };
     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
@@ -375,33 +373,9 @@
 {
     AVFilterContext *ctx = outlink->src;
     DecimateContext *dm = ctx->priv;
-    const AVFilterLink *inlink = ctx->inputs[INPUT_MAIN];
+    const AVFilterLink *inlink =
+        ctx->inputs[dm->ppsrc ? INPUT_CLEANSRC : INPUT_MAIN];
     AVRational fps = inlink->frame_rate;
-    int max_value;
-    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
-    const int w = inlink->w;
-    const int h = inlink->h;
-
-    dm->hsub      = pix_desc->log2_chroma_w;
-    dm->vsub      = pix_desc->log2_chroma_h;
-    dm->depth     = pix_desc->comp[0].depth;
-    max_value     = (1 << dm->depth) - 1;
-    dm->scthresh  = (int64_t)(((int64_t)max_value *          w * h          * dm->scthresh_flt)  / 100);
-    dm->dupthresh = (int64_t)(((int64_t)max_value * dm->blockx * dm->blocky * dm->dupthresh_flt) / 100);
-    dm->nxblocks  = (w + dm->blockx/2 - 1) / (dm->blockx/2);
-    dm->nyblocks  = (h + dm->blocky/2 - 1) / (dm->blocky/2);
-    dm->bdiffsize = dm->nxblocks * dm->nyblocks;
-    dm->bdiffs    = av_malloc_array(dm->bdiffsize, sizeof(*dm->bdiffs));
-    dm->queue     = av_calloc(dm->cycle, sizeof(*dm->queue));
-
-    if (!dm->bdiffs || !dm->queue)
-        return AVERROR(ENOMEM);
-
-    if (dm->ppsrc) {
-        dm->clean_src = av_calloc(dm->cycle, sizeof(*dm->clean_src));
-        if (!dm->clean_src)
-            return AVERROR(ENOMEM);
-    }
 
     if (!fps.num || !fps.den) {
         av_log(ctx, AV_LOG_ERROR, "The input needs a constant frame rate; "
@@ -414,13 +388,8 @@
     outlink->time_base  = inlink->time_base;
     outlink->frame_rate = fps;
     outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
-    if (dm->ppsrc) {
-        outlink->w = ctx->inputs[INPUT_CLEANSRC]->w;
-        outlink->h = ctx->inputs[INPUT_CLEANSRC]->h;
-    } else {
-        outlink->w = inlink->w;
-        outlink->h = inlink->h;
-    }
+    outlink->w = inlink->w;
+    outlink->h = inlink->h;
     dm->ts_unit = av_inv_q(av_mul_q(fps, outlink->time_base));
     return 0;
 }
@@ -429,6 +398,7 @@
     {
         .name          = "default",
         .type          = AVMEDIA_TYPE_VIDEO,
+        .request_frame = request_frame,
         .config_props  = config_output,
     },
     { NULL }
@@ -438,7 +408,6 @@
     .name          = "decimate",
     .description   = NULL_IF_CONFIG_SMALL("Decimate frames (post field matching filter)."),
     .init          = decimate_init,
-    .activate      = activate,
     .uninit        = decimate_uninit,
     .priv_size     = sizeof(DecimateContext),
     .query_formats = query_formats,
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index 89a282f..80217c8 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -202,20 +202,16 @@
         }
     }
 
-    if (err < 0)
-        return ff_qsvvpp_print_error(ctx, err, "Error getting the session handle");
-    else if (err > 0) {
-        ff_qsvvpp_print_warning(ctx, err, "Warning in getting the session handle");
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error getting the session handle\n");
         return AVERROR_UNKNOWN;
     }
 
     /* create a "slave" session with those same properties, to be used for
      * actual deinterlacing */
     err = MFXInit(impl, &ver, &s->session);
-    if (err < 0)
-        return ff_qsvvpp_print_error(ctx, err, "Error initializing a session for deinterlacing");
-    else if (err > 0) {
-        ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization");
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error initializing a session for deinterlacing\n");
         return AVERROR_UNKNOWN;
     }
 
@@ -313,17 +309,9 @@
         par.vpp.Out.FrameRateExtD = ctx->outputs[0]->time_base.den;
     }
 
-    /* Print input memory mode */
-    ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0x0F, "VPP");
-    /* Print output memory mode */
-    ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0xF0, "VPP");
     err = MFXVideoVPP_Init(s->session, &par);
-    if (err < 0)
-        return ff_qsvvpp_print_error(ctx, err,
-                                     "Error opening the VPP for deinterlacing");
-    else if (err > 0) {
-        ff_qsvvpp_print_warning(ctx, err,
-                                "Warning in VPP initialization");
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error opening the VPP for deinterlacing: %d\n", err);
         return AVERROR_UNKNOWN;
     }
 
@@ -494,13 +482,8 @@
         return QSVDEINT_MORE_INPUT;
     }
 
-    if (err < 0 && err != MFX_ERR_MORE_SURFACE) {
-        ret = ff_qsvvpp_print_error(ctx, err, "Error during deinterlacing");
-        goto fail;
-    }
-
-    if (!sync) {
-        av_log(ctx, AV_LOG_ERROR, "No sync during deinterlacing\n");
+    if ((err < 0 && err != MFX_ERR_MORE_SURFACE) || !sync) {
+        av_log(ctx, AV_LOG_ERROR, "Error during deinterlacing: %d\n", err);
         ret = AVERROR_UNKNOWN;
         goto fail;
     }
@@ -511,7 +494,8 @@
         err = MFXVideoCORE_SyncOperation(s->session, sync, 1000);
     } while (err == MFX_WRN_IN_EXECUTION);
     if (err < 0) {
-        ret = ff_qsvvpp_print_error(ctx, err, "Error synchronizing the operation");
+        av_log(ctx, AV_LOG_ERROR, "Error synchronizing the operation: %d\n", err);
+        ret = AVERROR_UNKNOWN;
         goto fail;
     }
 
diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c
index 7814fc1..77dd401 100644
--- a/libavfilter/vf_derain.c
+++ b/libavfilter/vf_derain.c
@@ -27,14 +27,18 @@
 #include "libavformat/avio.h"
 #include "libavutil/opt.h"
 #include "avfilter.h"
-#include "dnn_filter_common.h"
+#include "dnn_interface.h"
 #include "formats.h"
 #include "internal.h"
 
 typedef struct DRContext {
     const AVClass *class;
-    DnnContext dnnctx;
+
     int                filter_type;
+    char              *model_filename;
+    DNNBackendType     backend_type;
+    DNNModule         *dnn_module;
+    DNNModel          *model;
 } DRContext;
 
 #define OFFSET(x) offsetof(DRContext, x)
@@ -43,14 +47,12 @@
     { "filter_type", "filter type(derain/dehaze)",  OFFSET(filter_type),    AV_OPT_TYPE_INT,    { .i64 = 0 },    0, 1, FLAGS, "type" },
     { "derain",      "derain filter flag",          0,                      AV_OPT_TYPE_CONST,  { .i64 = 0 },    0, 0, FLAGS, "type" },
     { "dehaze",      "dehaze filter flag",          0,                      AV_OPT_TYPE_CONST,  { .i64 = 1 },    0, 0, FLAGS, "type" },
-    { "dnn_backend", "DNN backend",                 OFFSET(dnnctx.backend_type),   AV_OPT_TYPE_INT,    { .i64 = 0 },    0, 1, FLAGS, "backend" },
+    { "dnn_backend", "DNN backend",                 OFFSET(backend_type),   AV_OPT_TYPE_INT,    { .i64 = 0 },    0, 1, FLAGS, "backend" },
     { "native",      "native backend flag",         0,                      AV_OPT_TYPE_CONST,  { .i64 = 0 },    0, 0, FLAGS, "backend" },
 #if (CONFIG_LIBTENSORFLOW == 1)
     { "tensorflow",  "tensorflow backend flag",     0,                      AV_OPT_TYPE_CONST,  { .i64 = 1 },    0, 0, FLAGS, "backend" },
 #endif
-    { "model",       "path to model file",          OFFSET(dnnctx.model_filename),   AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },
-    { "input",       "input name of the model",     OFFSET(dnnctx.model_inputname),  AV_OPT_TYPE_STRING,    { .str = "x" },  0, 0, FLAGS },
-    { "output",      "output name of the model",    OFFSET(dnnctx.model_outputname), AV_OPT_TYPE_STRING,    { .str = "y" },  0, 0, FLAGS },
+    { "model",       "path to model file",          OFFSET(model_filename), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
     { NULL }
 };
 
@@ -75,6 +77,7 @@
     AVFilterLink *outlink = ctx->outputs[0];
     DRContext *dr_context = ctx->priv;
     DNNReturnType dnn_result;
+    const char *model_output_name = "y";
     AVFrame *out;
 
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
@@ -85,7 +88,7 @@
     }
     av_frame_copy_props(out, in);
 
-    dnn_result = ff_dnn_execute_model(&dr_context->dnnctx, in, out);
+    dnn_result = (dr_context->dnn_module->execute_model)(dr_context->model, "x", in, &model_output_name, 1, out);
     if (dnn_result != DNN_SUCCESS){
         av_log(ctx, AV_LOG_ERROR, "failed to execute model\n");
         av_frame_free(&in);
@@ -100,13 +103,38 @@
 static av_cold int init(AVFilterContext *ctx)
 {
     DRContext *dr_context = ctx->priv;
-    return ff_dnn_init(&dr_context->dnnctx, DFT_PROCESS_FRAME, ctx);
+
+    dr_context->dnn_module = ff_get_dnn_module(dr_context->backend_type);
+    if (!dr_context->dnn_module) {
+        av_log(ctx, AV_LOG_ERROR, "could not create DNN module for requested backend\n");
+        return AVERROR(ENOMEM);
+    }
+    if (!dr_context->model_filename) {
+        av_log(ctx, AV_LOG_ERROR, "model file for network is not specified\n");
+        return AVERROR(EINVAL);
+    }
+    if (!dr_context->dnn_module->load_model) {
+        av_log(ctx, AV_LOG_ERROR, "load_model for network is not specified\n");
+        return AVERROR(EINVAL);
+    }
+
+    dr_context->model = (dr_context->dnn_module->load_model)(dr_context->model_filename, NULL, NULL);
+    if (!dr_context->model) {
+        av_log(ctx, AV_LOG_ERROR, "could not load DNN model\n");
+        return AVERROR(EINVAL);
+    }
+
+    return 0;
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
 {
     DRContext *dr_context = ctx->priv;
-    ff_dnn_uninit(&dr_context->dnnctx);
+
+    if (dr_context->dnn_module) {
+        (dr_context->dnn_module->free_model)(&dr_context->model);
+        av_freep(&dr_context->dnn_module);
+    }
 }
 
 static const AVFilterPad derain_inputs[] = {
diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c
index f02f85d..0199214 100644
--- a/libavfilter/vf_detelecine.c
+++ b/libavfilter/vf_detelecine.c
@@ -124,16 +124,19 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-    AVFilterFormats *formats = NULL;
-    int ret;
+    AVFilterFormats *pix_fmts = NULL;
+    int fmt, ret;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_BITSTREAM |
-                                    AV_PIX_FMT_FLAG_PAL |
-                                    AV_PIX_FMT_FLAG_HWACCEL);
-    if (ret < 0)
-        return ret;
-    return ff_set_common_formats(ctx, formats);
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
+              desc->flags & AV_PIX_FMT_FLAG_PAL     ||
+              desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
+             (ret = ff_add_format(&pix_fmts, fmt)) < 0)
+            return ret;
+    }
+
+    return ff_set_common_formats(ctx, pix_fmts);
 }
 
 static int config_input(AVFilterLink *inlink)
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index 88e95e8..334243b 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -28,21 +28,29 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
-#include "filters.h"
-#include "dnn_filter_common.h"
+#include "avfilter.h"
+#include "dnn_interface.h"
 #include "formats.h"
 #include "internal.h"
 #include "libswscale/swscale.h"
-#include "libavutil/time.h"
 
 typedef struct DnnProcessingContext {
     const AVClass *class;
-    DnnContext dnnctx;
+
+    char *model_filename;
+    DNNBackendType backend_type;
+    char *model_inputname;
+    char *model_outputname;
+    char *backend_options;
+
+    DNNModule *dnn_module;
+    DNNModel *model;
+
     struct SwsContext *sws_uv_scale;
     int sws_uv_height;
 } DnnProcessingContext;
 
-#define OFFSET(x) offsetof(DnnProcessingContext, dnnctx.x)
+#define OFFSET(x) offsetof(DnnProcessingContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption dnn_processing_options[] = {
     { "dnn_backend", "DNN backend",                OFFSET(backend_type),     AV_OPT_TYPE_INT,       { .i64 = 0 },    INT_MIN, INT_MAX, FLAGS, "backend" },
@@ -53,7 +61,10 @@
 #if (CONFIG_LIBOPENVINO == 1)
     { "openvino",    "openvino backend flag",      0,                        AV_OPT_TYPE_CONST,     { .i64 = 2 },    0, 0, FLAGS, "backend" },
 #endif
-    DNN_COMMON_OPTIONS
+    { "model",       "path to model file",         OFFSET(model_filename),   AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },
+    { "input",       "input name of the model",    OFFSET(model_inputname),  AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },
+    { "output",      "output name of the model",   OFFSET(model_outputname), AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },
+    { "options",     "backend options",            OFFSET(backend_options),  AV_OPT_TYPE_STRING,    { .str = NULL }, 0, 0, FLAGS },
     { NULL }
 };
 
@@ -62,7 +73,37 @@
 static av_cold int init(AVFilterContext *context)
 {
     DnnProcessingContext *ctx = context->priv;
-    return ff_dnn_init(&ctx->dnnctx, DFT_PROCESS_FRAME, context);
+
+    if (!ctx->model_filename) {
+        av_log(ctx, AV_LOG_ERROR, "model file for network is not specified\n");
+        return AVERROR(EINVAL);
+    }
+    if (!ctx->model_inputname) {
+        av_log(ctx, AV_LOG_ERROR, "input name of the model network is not specified\n");
+        return AVERROR(EINVAL);
+    }
+    if (!ctx->model_outputname) {
+        av_log(ctx, AV_LOG_ERROR, "output name of the model network is not specified\n");
+        return AVERROR(EINVAL);
+    }
+
+    ctx->dnn_module = ff_get_dnn_module(ctx->backend_type);
+    if (!ctx->dnn_module) {
+        av_log(ctx, AV_LOG_ERROR, "could not create DNN module for requested backend\n");
+        return AVERROR(ENOMEM);
+    }
+    if (!ctx->dnn_module->load_model) {
+        av_log(ctx, AV_LOG_ERROR, "load_model for network is not specified\n");
+        return AVERROR(EINVAL);
+    }
+
+    ctx->model = (ctx->dnn_module->load_model)(ctx->model_filename, ctx->backend_options, ctx);
+    if (!ctx->model) {
+        av_log(ctx, AV_LOG_ERROR, "could not load DNN model\n");
+        return AVERROR(EINVAL);
+    }
+
+    return 0;
 }
 
 static int query_formats(AVFilterContext *context)
@@ -72,7 +113,6 @@
         AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAYF32,
         AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
         AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_NV12,
         AV_PIX_FMT_NONE
     };
     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
@@ -103,7 +143,7 @@
         return AVERROR(EIO);
     }
     if (model_input->dt != DNN_FLOAT) {
-        avpriv_report_missing_feature(ctx, "data type rather than DNN_FLOAT");
+        av_log(ctx, AV_LOG_ERROR, "only support dnn models with input data type as float32.\n");
         return AVERROR(EIO);
     }
 
@@ -121,14 +161,13 @@
     case AV_PIX_FMT_YUV444P:
     case AV_PIX_FMT_YUV410P:
     case AV_PIX_FMT_YUV411P:
-    case AV_PIX_FMT_NV12:
         if (model_input->channels != 1) {
             LOG_FORMAT_CHANNEL_MISMATCH();
             return AVERROR(EIO);
         }
         return 0;
     default:
-        avpriv_report_missing_feature(ctx, "%s", av_get_pix_fmt_name(fmt));
+        av_log(ctx, AV_LOG_ERROR, "%s not supported.\n", av_get_pix_fmt_name(fmt));
         return AVERROR(EIO);
     }
 
@@ -143,7 +182,7 @@
     DNNData model_input;
     int check;
 
-    result = ff_dnn_get_input(&ctx->dnnctx, &model_input);
+    result = ctx->model->get_input(ctx->model->model, &model_input, ctx->model_inputname);
     if (result != DNN_SUCCESS) {
         av_log(ctx, AV_LOG_ERROR, "could not get input from the model\n");
         return AVERROR(EIO);
@@ -173,22 +212,15 @@
 
     if (isPlanarYUV(fmt)) {
         if (inlink->w != outlink->w || inlink->h != outlink->h) {
-            if (fmt == AV_PIX_FMT_NV12) {
-                ctx->sws_uv_scale = sws_getContext(inlink->w >> 1, inlink->h >> 1, AV_PIX_FMT_YA8,
-                                                   outlink->w >> 1, outlink->h >> 1, AV_PIX_FMT_YA8,
-                                                   SWS_BICUBIC, NULL, NULL, NULL);
-                ctx->sws_uv_height = inlink->h >> 1;
-            } else {
-                const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
-                int sws_src_h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-                int sws_src_w = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-                int sws_dst_h = AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h);
-                int sws_dst_w = AV_CEIL_RSHIFT(outlink->w, desc->log2_chroma_w);
-                ctx->sws_uv_scale = sws_getContext(sws_src_w, sws_src_h, AV_PIX_FMT_GRAY8,
-                                                   sws_dst_w, sws_dst_h, AV_PIX_FMT_GRAY8,
-                                                   SWS_BICUBIC, NULL, NULL, NULL);
-                ctx->sws_uv_height = sws_src_h;
-            }
+            const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+            int sws_src_h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
+            int sws_src_w = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
+            int sws_dst_h = AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h);
+            int sws_dst_w = AV_CEIL_RSHIFT(outlink->w, desc->log2_chroma_w);
+            ctx->sws_uv_scale = sws_getContext(sws_src_w, sws_src_h, AV_PIX_FMT_GRAY8,
+                                               sws_dst_w, sws_dst_h, AV_PIX_FMT_GRAY8,
+                                               SWS_BICUBIC, NULL, NULL, NULL);
+            ctx->sws_uv_height = sws_src_h;
         }
     }
 
@@ -203,7 +235,8 @@
     AVFilterLink *inlink = context->inputs[0];
 
     // have a try run in case that the dnn model resize the frame
-    result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &outlink->w, &outlink->h);
+    result = ctx->model->get_output(ctx->model->model, ctx->model_inputname, inlink->w, inlink->h,
+                                    ctx->model_outputname, &outlink->w, &outlink->h);
     if (result != DNN_SUCCESS) {
         av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
         return AVERROR(EIO);
@@ -229,9 +262,6 @@
                                 in->data[i], in->linesize[i],
                                 bytewidth, uv_height);
         }
-    } else if (in->format == AV_PIX_FMT_NV12) {
-        sws_scale(ctx->sws_uv_scale, (const uint8_t **)(in->data + 1), in->linesize + 1,
-                  0, ctx->sws_uv_height, out->data + 1, out->linesize + 1);
     } else {
         sws_scale(ctx->sws_uv_scale, (const uint8_t **)(in->data + 1), in->linesize + 1,
                   0, ctx->sws_uv_height, out->data + 1, out->linesize + 1);
@@ -257,7 +287,8 @@
     }
     av_frame_copy_props(out, in);
 
-    dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, out);
+    dnn_result = (ctx->dnn_module->execute_model)(ctx->model, ctx->model_inputname, in,
+                                                  (const char **)&ctx->model_outputname, 1, out);
     if (dnn_result != DNN_SUCCESS){
         av_log(ctx, AV_LOG_ERROR, "failed to execute model\n");
         av_frame_free(&in);
@@ -272,158 +303,16 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int activate_sync(AVFilterContext *filter_ctx)
-{
-    AVFilterLink *inlink = filter_ctx->inputs[0];
-    AVFilterLink *outlink = filter_ctx->outputs[0];
-    AVFrame *in = NULL;
-    int64_t pts;
-    int ret, status;
-    int got_frame = 0;
-
-    FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
-
-    do {
-        // drain all input frames
-        ret = ff_inlink_consume_frame(inlink, &in);
-        if (ret < 0)
-            return ret;
-        if (ret > 0) {
-            ret = filter_frame(inlink, in);
-            if (ret < 0)
-                return ret;
-            got_frame = 1;
-        }
-    } while (ret > 0);
-
-    // if frame got, schedule to next filter
-    if (got_frame)
-        return 0;
-
-    if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
-        if (status == AVERROR_EOF) {
-            ff_outlink_set_status(outlink, status, pts);
-            return ret;
-        }
-    }
-
-    FF_FILTER_FORWARD_WANTED(outlink, inlink);
-
-    return FFERROR_NOT_READY;
-}
-
-static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
-{
-    DnnProcessingContext *ctx = outlink->src->priv;
-    int ret;
-    DNNAsyncStatusType async_state;
-
-    ret = ff_dnn_flush(&ctx->dnnctx);
-    if (ret != DNN_SUCCESS) {
-        return -1;
-    }
-
-    do {
-        AVFrame *in_frame = NULL;
-        AVFrame *out_frame = NULL;
-        async_state = ff_dnn_get_async_result(&ctx->dnnctx, &in_frame, &out_frame);
-        if (out_frame) {
-            if (isPlanarYUV(in_frame->format))
-                copy_uv_planes(ctx, out_frame, in_frame);
-            av_frame_free(&in_frame);
-            ret = ff_filter_frame(outlink, out_frame);
-            if (ret < 0)
-                return ret;
-            if (out_pts)
-                *out_pts = out_frame->pts + pts;
-        }
-        av_usleep(5000);
-    } while (async_state >= DAST_NOT_READY);
-
-    return 0;
-}
-
-static int activate_async(AVFilterContext *filter_ctx)
-{
-    AVFilterLink *inlink = filter_ctx->inputs[0];
-    AVFilterLink *outlink = filter_ctx->outputs[0];
-    DnnProcessingContext *ctx = filter_ctx->priv;
-    AVFrame *in = NULL, *out = NULL;
-    int64_t pts;
-    int ret, status;
-    int got_frame = 0;
-    int async_state;
-
-    FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
-
-    do {
-        // drain all input frames
-        ret = ff_inlink_consume_frame(inlink, &in);
-        if (ret < 0)
-            return ret;
-        if (ret > 0) {
-            out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-            if (!out) {
-                av_frame_free(&in);
-                return AVERROR(ENOMEM);
-            }
-            av_frame_copy_props(out, in);
-            if (ff_dnn_execute_model_async(&ctx->dnnctx, in, out) != DNN_SUCCESS) {
-                return AVERROR(EIO);
-            }
-        }
-    } while (ret > 0);
-
-    // drain all processed frames
-    do {
-        AVFrame *in_frame = NULL;
-        AVFrame *out_frame = NULL;
-        async_state = ff_dnn_get_async_result(&ctx->dnnctx, &in_frame, &out_frame);
-        if (out_frame) {
-            if (isPlanarYUV(in_frame->format))
-                copy_uv_planes(ctx, out_frame, in_frame);
-            av_frame_free(&in_frame);
-            ret = ff_filter_frame(outlink, out_frame);
-            if (ret < 0)
-                return ret;
-            got_frame = 1;
-        }
-    } while (async_state == DAST_SUCCESS);
-
-    // if frame got, schedule to next filter
-    if (got_frame)
-        return 0;
-
-    if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
-        if (status == AVERROR_EOF) {
-            int64_t out_pts = pts;
-            ret = flush_frame(outlink, pts, &out_pts);
-            ff_outlink_set_status(outlink, status, out_pts);
-            return ret;
-        }
-    }
-
-    FF_FILTER_FORWARD_WANTED(outlink, inlink);
-
-    return 0;
-}
-
-static int activate(AVFilterContext *filter_ctx)
-{
-    DnnProcessingContext *ctx = filter_ctx->priv;
-
-    if (ctx->dnnctx.async)
-        return activate_async(filter_ctx);
-    else
-        return activate_sync(filter_ctx);
-}
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
     DnnProcessingContext *context = ctx->priv;
 
     sws_freeContext(context->sws_uv_scale);
-    ff_dnn_uninit(&context->dnnctx);
+
+    if (context->dnn_module)
+        (context->dnn_module->free_model)(&context->model);
+
+    av_freep(&context->dnn_module);
 }
 
 static const AVFilterPad dnn_processing_inputs[] = {
@@ -431,6 +320,7 @@
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .config_props = config_input,
+        .filter_frame = filter_frame,
     },
     { NULL }
 };
@@ -454,5 +344,4 @@
     .inputs        = dnn_processing_inputs,
     .outputs       = dnn_processing_outputs,
     .priv_class    = &dnn_processing_class,
-    .activate      = activate,
 };
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index 6151db4..21d520e 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -322,7 +322,7 @@
     { "c",         "set color of the box",                         OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, 0, 0, FLAGS },
     { "thickness", "set the box thickness",                        OFFSET(t_expr),    AV_OPT_TYPE_STRING, { .str="3" },       0, 0, FLAGS },
     { "t",         "set the box thickness",                        OFFSET(t_expr),    AV_OPT_TYPE_STRING, { .str="3" },       0, 0, FLAGS },
-    { "replace",   "replace color & alpha",                        OFFSET(replace),   AV_OPT_TYPE_BOOL,   { .i64=0   },       0, 1, FLAGS },
+    { "replace",   "replace color & alpha",                        OFFSET(replace),   AV_OPT_TYPE_BOOL,   { .i64=0 },         0,        1,        FLAGS },
     { NULL }
 };
 
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 7b1000e..abe1ca6 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -568,11 +568,6 @@
     return err;
 }
 
-static inline int is_newline(uint32_t c)
-{
-    return c == '\n' || c == '\r' || c == '\f' || c == '\v';
-}
-
 static int load_textfile(AVFilterContext *ctx)
 {
     DrawTextContext *s = ctx->priv;
@@ -588,8 +583,6 @@
         return err;
     }
 
-    if (textbuf_size > 0 && is_newline(textbuf[textbuf_size - 1]))
-        textbuf_size--;
     if (textbuf_size > SIZE_MAX - 1 || !(tmp = av_realloc(s->text, textbuf_size + 1))) {
         av_file_unmap(textbuf, textbuf_size);
         return AVERROR(ENOMEM);
@@ -602,6 +595,11 @@
     return 0;
 }
 
+static inline int is_newline(uint32_t c)
+{
+    return c == '\n' || c == '\r' || c == '\f' || c == '\v';
+}
+
 #if CONFIG_LIBFRIBIDI
 static int shape_text(AVFilterContext *ctx)
 {
diff --git a/libavfilter/vf_epx.c b/libavfilter/vf_epx.c
deleted file mode 100644
index 65b8975..0000000
--- a/libavfilter/vf_epx.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/opt.h"
-#include "libavutil/avassert.h"
-#include "libavutil/pixdesc.h"
-#include "internal.h"
-
-typedef struct EPXContext {
-    const AVClass *class;
-
-    int n;
-
-    int (*epx_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
-} EPXContext;
-
-typedef struct ThreadData {
-    AVFrame *in, *out;
-} ThreadData;
-
-#define OFFSET(x) offsetof(EPXContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
-static const AVOption epx_options[] = {
-    { "n", "set scale factor", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 3}, 2, 3, .flags = FLAGS },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(epx);
-
-static int epx2_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    const AVFrame *in = td->in;
-    AVFrame *out = td->out;
-    const int slice_start = (in->height *  jobnr   ) / nb_jobs;
-    const int slice_end   = (in->height * (jobnr+1)) / nb_jobs;
-
-    for (int p = 0; p < 1; p++) {
-        const int width = in->width;
-        const int height = in->height;
-        const int src_linesize = in->linesize[p] / 4;
-        const int dst_linesize = out->linesize[p] / 4;
-        const uint32_t *src = (const uint32_t *)in->data[p];
-        uint32_t *dst = (uint32_t *)out->data[p];
-        const uint32_t *src_line[3];
-
-        src_line[0] = src + src_linesize * FFMAX(slice_start - 1, 0);
-        src_line[1] = src + src_linesize * slice_start;
-        src_line[2] = src + src_linesize * FFMIN(slice_start + 1, height-1);
-
-        for (int y = slice_start; y < slice_end; y++) {
-            uint32_t *dst_line[2];
-
-            dst_line[0] = dst + dst_linesize*2*y;
-            dst_line[1] = dst + dst_linesize*(2*y+1);
-
-            for (int x = 0; x < width; x++) {
-                uint32_t E0, E1, E2, E3;
-                uint32_t B, D, E, F, H;
-
-                B = src_line[0][x];
-                D = src_line[1][FFMAX(x-1, 0)];
-                E = src_line[1][x];
-                F = src_line[1][FFMIN(x+1, width - 1)];
-                H = src_line[2][x];
-
-                if (B != H && D != F) {
-                    E0 = D == B ? D : E;
-                    E1 = B == F ? F : E;
-                    E2 = D == H ? D : E;
-                    E3 = H == F ? F : E;
-                } else {
-                    E0 = E;
-                    E1 = E;
-                    E2 = E;
-                    E3 = E;
-                }
-
-                dst_line[0][x*2]   = E0;
-                dst_line[0][x*2+1] = E1;
-                dst_line[1][x*2]   = E2;
-                dst_line[1][x*2+1] = E3;
-            }
-
-            src_line[0] = src_line[1];
-            src_line[1] = src_line[2];
-            src_line[2] = src_line[1];
-
-            if (y < height - 1)
-                src_line[2] += src_linesize;
-        }
-    }
-
-    return 0;
-}
-
-static int epx3_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    const AVFrame *in = td->in;
-    AVFrame *out = td->out;
-    const int slice_start = (in->height *  jobnr   ) / nb_jobs;
-    const int slice_end   = (in->height * (jobnr+1)) / nb_jobs;
-
-    for (int p = 0; p < 1; p++) {
-        const int width = in->width;
-        const int height = in->height;
-        const int src_linesize = in->linesize[p] / 4;
-        const int dst_linesize = out->linesize[p] / 4;
-        const uint32_t *src = (const uint32_t *)in->data[p];
-        uint32_t *dst = (uint32_t *)out->data[p];
-        const uint32_t *src_line[3];
-
-        src_line[0] = src + src_linesize * FFMAX(slice_start - 1, 0);
-        src_line[1] = src + src_linesize * slice_start;
-        src_line[2] = src + src_linesize * FFMIN(slice_start + 1, height-1);
-
-        for (int y = slice_start; y < slice_end; y++) {
-            uint32_t *dst_line[3];
-
-            dst_line[0] = dst + dst_linesize*3*y;
-            dst_line[1] = dst + dst_linesize*(3*y+1);
-            dst_line[2] = dst + dst_linesize*(3*y+2);
-
-            for (int x = 0; x < width; x++) {
-                uint32_t E0, E1, E2, E3, E4, E5, E6, E7, E8;
-                uint32_t A, B, C, D, E, F, G, H, I;
-
-                A = src_line[0][FFMAX(x-1, 0)];
-                B = src_line[0][x];
-                C = src_line[0][FFMIN(x+1, width - 1)];
-                D = src_line[1][FFMAX(x-1, 0)];
-                E = src_line[1][x];
-                F = src_line[1][FFMIN(x+1, width - 1)];
-                G = src_line[2][FFMAX(x-1, 0)];
-                H = src_line[2][x];
-                I = src_line[2][FFMIN(x+1, width - 1)];
-
-                if (B != H && D != F) {
-                    E0 = D == B ? D : E;
-                    E1 = (D == B && E != C) || (B == F && E != A) ? B : E;
-                    E2 = B == F ? F : E;
-                    E3 = (D == B && E != G) || (D == H && E != A) ? D : E;
-                    E4 = E;
-                    E5 = (B == F && E != I) || (H == F && E != C) ? F : E;
-                    E6 = D == H ? D : E;
-                    E7 = (D == H && E != I) || (H == F && E != G) ? H : E;
-                    E8 = H == F ? F : E;
-                } else {
-                    E0 = E;
-                    E1 = E;
-                    E2 = E;
-                    E3 = E;
-                    E4 = E;
-                    E5 = E;
-                    E6 = E;
-                    E7 = E;
-                    E8 = E;
-                }
-
-                dst_line[0][x*3]   = E0;
-                dst_line[0][x*3+1] = E1;
-                dst_line[0][x*3+2] = E2;
-                dst_line[1][x*3]   = E3;
-                dst_line[1][x*3+1] = E4;
-                dst_line[1][x*3+2] = E5;
-                dst_line[2][x*3]   = E6;
-                dst_line[2][x*3+1] = E7;
-                dst_line[2][x*3+2] = E8;
-            }
-
-            src_line[0] = src_line[1];
-            src_line[1] = src_line[2];
-            src_line[2] = src_line[1];
-
-            if (y < height - 1)
-                src_line[2] += src_linesize;
-        }
-    }
-
-    return 0;
-}
-
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    EPXContext *s = ctx->priv;
-    AVFilterLink *inlink = ctx->inputs[0];
-    const AVPixFmtDescriptor *desc;
-
-    desc = av_pix_fmt_desc_get(outlink->format);
-    if (!desc)
-        return AVERROR_BUG;
-
-    outlink->w = inlink->w * s->n;
-    outlink->h = inlink->h * s->n;
-
-    switch (s->n) {
-    case 2:
-        s->epx_slice = epx2_slice;
-        break;
-    case 3:
-        s->epx_slice = epx3_slice;
-        break;
-    }
-
-    return 0;
-}
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA, AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR,
-        AV_PIX_FMT_NONE,
-    };
-
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-    if (!fmts_list)
-        return AVERROR(ENOMEM);
-    return ff_set_common_formats(ctx, fmts_list);
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-    AVFilterContext *ctx = inlink->dst;
-    AVFilterLink *outlink = ctx->outputs[0];
-    EPXContext *s = ctx->priv;
-    ThreadData td;
-
-    AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    if (!out) {
-        av_frame_free(&in);
-        return AVERROR(ENOMEM);
-    }
-
-    av_frame_copy_props(out, in);
-
-    td.in = in, td.out = out;
-    ctx->internal->execute(ctx, s->epx_slice, &td, NULL, FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
-
-    av_frame_free(&in);
-    return ff_filter_frame(outlink, out);
-}
-
-static const AVFilterPad inputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .filter_frame = filter_frame,
-    },
-    { NULL }
-};
-
-static const AVFilterPad outputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_output,
-    },
-    { NULL }
-};
-
-AVFilter ff_vf_epx = {
-    .name          = "epx",
-    .description   = NULL_IF_CONFIG_SMALL("Scale the input using EPX algorithm."),
-    .inputs        = inputs,
-    .outputs       = outputs,
-    .query_formats = query_formats,
-    .priv_size     = sizeof(EPXContext),
-    .priv_class    = &epx_class,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS,
-};
diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c
deleted file mode 100644
index abe90a1..0000000
--- a/libavfilter/vf_estdif.c
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/common.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct ESTDIFContext {
-    const AVClass *class;
-
-    int mode;             ///< 0 is frame, 1 is field
-    int parity;           ///< frame field parity
-    int deint;            ///< which frames to deinterlace
-    int rslope;           ///< best edge slope search radius
-    int redge;            ///< best edge match search radius
-    int interp;           ///< type of interpolation
-    int linesize[4];      ///< bytes of pixel data per line for each plane
-    int planewidth[4];    ///< width of each plane
-    int planeheight[4];   ///< height of each plane
-    int field;            ///< which field are we on, 0 or 1
-    int eof;
-    int depth;
-    int half;
-    int nb_planes;
-    int nb_threads;
-    int64_t pts;
-    AVFrame *prev;
-
-    void (*interpolate)(struct ESTDIFContext *s, uint8_t *dst,
-                        const uint8_t *prev_line,  const uint8_t *next_line,
-                        const uint8_t *prev2_line, const uint8_t *next2_line,
-                        const uint8_t *prev3_line, const uint8_t *next3_line,
-                        int x, int width, int rslope, int redge, unsigned half,
-                        int depth, int *K);
-
-    unsigned (*mid_8[3])(const uint8_t *const prev,
-                         const uint8_t *const next,
-                         const uint8_t *const prev2,
-                         const uint8_t *const next2,
-                         const uint8_t *const prev3,
-                         const uint8_t *const next3,
-                         int end, int x, int k, int depth);
-
-    unsigned (*mid_16[3])(const uint16_t *const prev,
-                          const uint16_t *const next,
-                          const uint16_t *const prev2,
-                          const uint16_t *const next2,
-                          const uint16_t *const prev3,
-                          const uint16_t *const next3,
-                          int end, int x, int k, int depth);
-} ESTDIFContext;
-
-#define MAX_R 15
-#define S     (MAX_R * 2 + 1)
-
-#define OFFSET(x) offsetof(ESTDIFContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
-
-static const AVOption estdif_options[] = {
-    { "mode", "specify the mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "mode" },
-    CONST("frame", "send one frame for each frame", 0, "mode"),
-    CONST("field", "send one frame for each field", 1, "mode"),
-    { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, "parity" },
-    CONST("tff",  "assume top field first",    0, "parity"),
-    CONST("bff",  "assume bottom field first", 1, "parity"),
-    CONST("auto", "auto detect parity",       -1, "parity"),
-    { "deint",  "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
-    CONST("all",        "deinterlace all frames",                       0, "deint"),
-    CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
-    { "rslope", "specify the search radius for edge slope tracing", OFFSET(rslope), AV_OPT_TYPE_INT, {.i64=1}, 1, MAX_R, FLAGS, },
-    { "redge",  "specify the search radius for best edge matching", OFFSET(redge),  AV_OPT_TYPE_INT, {.i64=2}, 0, MAX_R, FLAGS, },
-    { "interp", "specify the type of interpolation",                OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 2,     FLAGS, "interp" },
-    CONST("2p", "two-point interpolation",  0, "interp"),
-    CONST("4p", "four-point interpolation", 1, "interp"),
-    CONST("6p", "six-point interpolation",  2, "interp"),
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(estdif);
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
-        AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
-        AV_PIX_FMT_GRAY8,
-        AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-        AV_PIX_FMT_GBRAP10,   AV_PIX_FMT_GBRAP12,    AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-    if (!fmts_list)
-        return AVERROR(ENOMEM);
-    return ff_set_common_formats(ctx, fmts_list);
-}
-
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    AVFilterLink *inlink = ctx->inputs[0];
-
-    outlink->time_base.num = inlink->time_base.num;
-    outlink->time_base.den = inlink->time_base.den * 2;
-    outlink->frame_rate.num = inlink->frame_rate.num * 2;
-    outlink->frame_rate.den = inlink->frame_rate.den;
-
-    return 0;
-}
-
-typedef struct ThreadData {
-    AVFrame *out, *in;
-} ThreadData;
-
-#define MIDL(type, ss)                                         \
-static unsigned midl_##ss(const type *const prev,              \
-                          const type *const next,              \
-                          int end, int x, int k)               \
-{                                                              \
-    return (prev[av_clip(x + k, 0, end)] +                     \
-            next[av_clip(x - k, 0, end)] + 1) >> 1;            \
-}
-
-MIDL(uint8_t, 8)
-MIDL(uint16_t, 16)
-
-#define MID2(type, ss)                                         \
-static unsigned mid2_##ss(const type *const prev,              \
-                          const type *const next,              \
-                          const type *const prev2,             \
-                          const type *const next2,             \
-                          const type *const prev3,             \
-                          const type *const next3,             \
-                          int end, int x, int k, int depth)    \
-{                                                              \
-    return (prev[av_clip(x + k, 0, end)] +                     \
-            next[av_clip(x - k, 0, end)] + 1) >> 1;            \
-}
-
-MID2(uint8_t, 8)
-MID2(uint16_t, 16)
-
-#define MID4(type, ss)                                         \
-static unsigned mid4_##ss(const type *const prev,              \
-                          const type *const next,              \
-                          const type *const prev2,             \
-                          const type *const next2,             \
-                          const type *const prev3,             \
-                          const type *const next3,             \
-                          int end, int x, int k, int depth)    \
-{                                                              \
-    return av_clip_uintp2_c((                                  \
-            9 * (prev[av_clip(x + k, 0, end)] +                \
-                 next[av_clip(x - k, 0, end)]) -               \
-            1 * (prev2[av_clip(x + k*3, 0, end)] +             \
-                 next2[av_clip(x - k*3, 0, end)]) + 8) >> 4,   \
-                 depth);                                       \
-}
-
-MID4(uint8_t, 8)
-MID4(uint16_t, 16)
-
-#define MID6(type, ss)                                         \
-static unsigned mid6_##ss(const type *const prev,              \
-                          const type *const next,              \
-                          const type *const prev2,             \
-                          const type *const next2,             \
-                          const type *const prev3,             \
-                          const type *const next3,             \
-                          int end, int x, int k, int depth)    \
-{                                                              \
-    return av_clip_uintp2_c((                                  \
-           20 * (prev[av_clip(x + k, 0, end)] +                \
-                 next[av_clip(x - k, 0, end)]) -               \
-            5 * (prev2[av_clip(x + k*3, 0, end)] +             \
-                 next2[av_clip(x - k*3, 0, end)]) +            \
-            1 * (prev3[av_clip(x + k*5, 0, end)] +             \
-                 next3[av_clip(x - k*5, 0, end)]) + 16) >> 5,  \
-                 depth);                                       \
-}
-
-MID6(uint8_t, 8)
-MID6(uint16_t, 16)
-
-#define DIFF(type, ss)                                         \
-static unsigned diff_##ss(const type *const prev,              \
-                          const type *const next,              \
-                          int end, int x, int k, int j)        \
-{                                                              \
-    return FFABS(prev[av_clip(x + k + j, 0, end)] -            \
-                 next[av_clip(x - k + j, 0, end)]);            \
-}
-
-DIFF(uint8_t, 8)
-DIFF(uint16_t, 16)
-
-#define COST(type, ss)                                         \
-static unsigned cost_##ss(const type *const prev,              \
-                          const type *const next,              \
-                          int end, int x, int k)               \
-{                                                              \
-    const int m = midl_##ss(prev, next, end, x, k);            \
-    const int p = prev[x];                                     \
-    const int n = next[x];                                     \
-                                                               \
-    return FFABS(p - m) + FFABS(n - m);                        \
-}
-
-COST(uint8_t, 8)
-COST(uint16_t, 16)
-
-#define INTERPOLATE(type, atype, max, ss)                                      \
-static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst,                  \
-                             const uint8_t *const pprev_line,                  \
-                             const uint8_t *const nnext_line,                  \
-                             const uint8_t *const pprev2_line,                 \
-                             const uint8_t *const nnext2_line,                 \
-                             const uint8_t *const pprev3_line,                 \
-                             const uint8_t *const nnext3_line,                 \
-                             int x, int width, int rslope,                     \
-                             int redge, unsigned h, int depth,                 \
-                             int *K)                                           \
-{                                                                              \
-    type *dst = (type *)ddst;                                                  \
-    const type *const prev_line = (const type *const)pprev_line;               \
-    const type *const prev2_line = (const type *const)pprev2_line;             \
-    const type *const prev3_line = (const type *const)pprev3_line;             \
-    const type *const next_line = (const type *const)nnext_line;               \
-    const type *const next2_line = (const type *const)nnext2_line;             \
-    const type *const next3_line = (const type *const)nnext3_line;             \
-    const int interp = s->interp;                                              \
-    const int end = width - 1;                                                 \
-    const atype f = redge + 2;                                                 \
-    atype sd[S], sD[S], di = 0;                                                \
-    atype dmin = max;                                                          \
-    int k = *K;                                                                \
-                                                                               \
-    for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) {               \
-        atype sum = 0;                                                         \
-                                                                               \
-        for (int j = -redge; j <= redge; j++) {                                \
-            sum += diff_##ss(prev_line,  next_line,  end, x, i, j);            \
-            sum += diff_##ss(prev2_line, prev_line,  end, x, i, j);            \
-            sum += diff_##ss(next_line,  next2_line, end, x, i, j);            \
-        }                                                                      \
-                                                                               \
-        sD[i + rslope]  =     sum;                                             \
-        sD[i + rslope] += f * cost_##ss(prev_line,  next_line,  end, x, i);    \
-        sD[i + rslope] += h * abs(i);                                          \
-                                                                               \
-        dmin = FFMIN(sD[i + rslope], dmin);                                    \
-    }                                                                          \
-                                                                               \
-    for (int i = -rslope; i <= rslope; i++) {                                  \
-        atype sum = 0;                                                         \
-                                                                               \
-        for (int j = -redge; j <= redge; j++) {                                \
-            sum += diff_##ss(prev_line,  next_line,  end, x, k + i, j);        \
-            sum += diff_##ss(prev2_line, prev_line,  end, x, k + i, j);        \
-            sum += diff_##ss(next_line,  next2_line, end, x, k + i, j);        \
-        }                                                                      \
-                                                                               \
-        sd[i + rslope]  =     sum;                                             \
-        sd[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, k + i);  \
-        sd[i + rslope] += h * abs(k + i);                                      \
-                                                                               \
-        dmin = FFMIN(sd[i + rslope], dmin);                                    \
-    }                                                                          \
-                                                                               \
-    for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) {               \
-        if (dmin == sD[i + rslope]) {                                          \
-            di = 1;                                                            \
-            k = i;                                                             \
-            break;                                                             \
-        }                                                                      \
-    }                                                                          \
-                                                                               \
-    for (int i = -rslope; i <= rslope && !di; i++) {                           \
-        if (dmin == sd[i + rslope]) {                                          \
-            k += i;                                                            \
-            break;                                                             \
-        }                                                                      \
-    }                                                                          \
-                                                                               \
-    dst[x] = s->mid_##ss[interp](prev_line, next_line,                         \
-                                 prev2_line, next2_line,                       \
-                                 prev3_line, next3_line,                       \
-                                 end, x, k, depth);                            \
-                                                                               \
-    *K = k;                                                                    \
-}
-
-INTERPOLATE(uint8_t,  unsigned, UINT_MAX, 8)
-INTERPOLATE(uint16_t, uint64_t, UINT64_MAX, 16)
-
-static int deinterlace_slice(AVFilterContext *ctx, void *arg,
-                             int jobnr, int nb_jobs)
-{
-    ESTDIFContext *s = ctx->priv;
-    ThreadData *td = arg;
-    AVFrame *out = td->out;
-    AVFrame *in = td->in;
-    const int rslope = s->rslope;
-    const int redge = s->redge;
-    const int half = s->half;
-    const int depth = s->depth;
-    const int interlaced = in->interlaced_frame;
-    const int tff = (s->field == (s->parity == -1 ? interlaced ? in->top_field_first : 1 :
-                                  s->parity ^ 1));
-
-    for (int plane = 0; plane < s->nb_planes; plane++) {
-        const uint8_t *src_data = in->data[plane];
-        uint8_t *dst_data = out->data[plane];
-        const int linesize = s->linesize[plane];
-        const int width = s->planewidth[plane];
-        const int height = s->planeheight[plane];
-        const int src_linesize = in->linesize[plane];
-        const int dst_linesize = out->linesize[plane];
-        const int start = (height * jobnr) / nb_jobs;
-        const int end = (height * (jobnr+1)) / nb_jobs;
-        const uint8_t *prev_line, *prev2_line, *next_line, *next2_line, *in_line;
-        const uint8_t *prev3_line, *next3_line;
-        uint8_t *out_line;
-        int y_out;
-
-        y_out = start + (tff ^ (start & 1));
-
-        in_line  = src_data + (y_out * src_linesize);
-        out_line = dst_data + (y_out * dst_linesize);
-
-        while (y_out < end) {
-            memcpy(out_line, in_line, linesize);
-            y_out += 2;
-            in_line  += src_linesize * 2;
-            out_line += dst_linesize * 2;
-        }
-
-        y_out = start + ((!tff) ^ (start & 1));
-        out_line = dst_data + (y_out * dst_linesize);
-
-        for (int y = y_out; y < end; y += 2) {
-            int y_prev3_in = y - 5;
-            int y_next3_in = y + 5;
-            int y_prev2_in = y - 3;
-            int y_next2_in = y + 3;
-            int y_prev_in = y - 1;
-            int y_next_in = y + 1;
-            int k;
-
-            while (y_prev3_in < 0)
-                y_prev3_in += 2;
-
-            while (y_next3_in >= height)
-                y_next3_in -= 2;
-
-            while (y_prev2_in < 0)
-                y_prev2_in += 2;
-
-            while (y_next2_in >= height)
-                y_next2_in -= 2;
-
-            while (y_prev_in < 0)
-                y_prev_in += 2;
-
-            while (y_next_in >= height)
-                y_next_in -= 2;
-
-            prev3_line = src_data + (y_prev3_in * src_linesize);
-            next3_line = src_data + (y_next3_in * src_linesize);
-
-            prev2_line = src_data + (y_prev2_in * src_linesize);
-            next2_line = src_data + (y_next2_in * src_linesize);
-
-            prev_line = src_data + (y_prev_in * src_linesize);
-            next_line = src_data + (y_next_in * src_linesize);
-
-            k = 0;
-
-            for (int x = 0; x < width; x++) {
-                s->interpolate(s, out_line,
-                               prev_line, next_line,
-                               prev2_line, next2_line,
-                               prev3_line, next3_line,
-                               x, width, rslope, redge, half, depth, &k);
-            }
-
-            out_line += 2 * dst_linesize;
-        }
-    }
-
-    return 0;
-}
-
-static int filter(AVFilterContext *ctx, int is_second, AVFrame *in)
-{
-    ESTDIFContext *s = ctx->priv;
-    AVFilterLink *outlink = ctx->outputs[0];
-    AVFrame *out;
-    ThreadData td;
-
-    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    if (!out)
-        return AVERROR(ENOMEM);
-    av_frame_copy_props(out, in);
-    out->interlaced_frame = 0;
-    out->pts = s->pts;
-
-    td.out = out; td.in = in;
-    ctx->internal->execute(ctx, deinterlace_slice, &td, NULL,
-                           FFMIN(s->planeheight[1] / 2, s->nb_threads));
-
-    if (s->mode)
-        s->field = !s->field;
-
-    return ff_filter_frame(outlink, out);
-}
-
-static int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ESTDIFContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int ret;
-
-    if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
-        return ret;
-
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-    s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0] = s->planewidth[3] = inlink->w;
-
-    if (inlink->h < 3) {
-        av_log(ctx, AV_LOG_ERROR, "Video of less than 3 lines is not supported\n");
-        return AVERROR(EINVAL);
-    }
-
-    s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
-    s->depth = desc->comp[0].depth;
-    s->interpolate = s->depth <= 8 ? interpolate_8 : interpolate_16;
-    s->mid_8[0] = mid2_8;
-    s->mid_8[1] = mid4_8;
-    s->mid_8[2] = mid6_8;
-    s->mid_16[0] = mid2_16;
-    s->mid_16[1] = mid4_16;
-    s->mid_16[2] = mid6_16;
-    s->half = 1 << (s->depth - 1);
-
-    return 0;
-}
- static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ESTDIFContext *s = ctx->priv;
-    int ret;
-
-    if (!s->prev) {
-        s->prev = in;
-        return 0;
-    }
-
-    if ((s->deint && !in->interlaced_frame) || ctx->is_disabled) {
-        s->prev->pts *= 2;
-        ret = ff_filter_frame(ctx->outputs[0], s->prev);
-        s->prev = in;
-        return ret;
-    }
-
-    s->pts = s->prev->pts * 2;
-    ret = filter(ctx, 0, s->prev);
-    if (ret < 0 || s->mode == 0) {
-        av_frame_free(&s->prev);
-        s->prev = in;
-        return ret;
-    }
-
-    s->pts = s->prev->pts + in->pts;
-    ret = filter(ctx, 1, s->prev);
-    av_frame_free(&s->prev);
-    s->prev = in;
-    return ret;
-}
-
-static int request_frame(AVFilterLink *link)
-{
-    AVFilterContext *ctx = link->src;
-    ESTDIFContext *s = ctx->priv;
-    int ret;
-
-    if (s->eof)
-        return AVERROR_EOF;
-
-    ret = ff_request_frame(ctx->inputs[0]);
-
-    if (ret == AVERROR_EOF && s->prev) {
-        AVFrame *next = av_frame_clone(s->prev);
-
-        if (!next)
-            return AVERROR(ENOMEM);
-
-        next->pts = s->prev->pts + av_rescale_q(1, av_inv_q(ctx->outputs[0]->frame_rate),
-                                                ctx->outputs[0]->time_base);
-        s->eof = 1;
-        ret = filter_frame(ctx->inputs[0], next);
-    } else if (ret < 0) {
-        return ret;
-    }
-
-    return ret;
-}
-
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    ESTDIFContext *s = ctx->priv;
-
-    av_frame_free(&s->prev);
-}
-
-static const AVFilterPad estdif_inputs[] = {
-    {
-        .name          = "default",
-        .type          = AVMEDIA_TYPE_VIDEO,
-        .filter_frame  = filter_frame,
-        .config_props  = config_input,
-    },
-    { NULL }
-};
-
-static const AVFilterPad estdif_outputs[] = {
-    {
-        .name          = "default",
-        .type          = AVMEDIA_TYPE_VIDEO,
-        .config_props  = config_output,
-        .request_frame = request_frame,
-    },
-    { NULL }
-};
-
-AVFilter ff_vf_estdif = {
-    .name          = "estdif",
-    .description   = NULL_IF_CONFIG_SMALL("Apply Edge Slope Tracing deinterlace."),
-    .priv_size     = sizeof(ESTDIFContext),
-    .priv_class    = &estdif_class,
-    .uninit        = uninit,
-    .query_formats = query_formats,
-    .inputs        = estdif_inputs,
-    .outputs       = estdif_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_exposure.c b/libavfilter/vf_exposure.c
deleted file mode 100644
index b7ad075..0000000
--- a/libavfilter/vf_exposure.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <float.h>
-
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct ExposureContext {
-    const AVClass *class;
-
-    float exposure;
-    float black;
-
-    float scale;
-    int (*do_slice)(AVFilterContext *s, void *arg,
-                    int jobnr, int nb_jobs);
-} ExposureContext;
-
-static int exposure_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ExposureContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const float black = s->black;
-    const float scale = s->scale;
-
-    for (int p = 0; p < 3; p++) {
-        const int linesize = frame->linesize[p] / 4;
-        float *ptr = (float *)frame->data[p] + slice_start * linesize;
-        for (int y = slice_start; y < slice_end; y++) {
-            for (int x = 0; x < width; x++)
-                ptr[x] = (ptr[x] - black) * scale;
-
-            ptr += linesize;
-        }
-    }
-
-    return 0;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ExposureContext *s = ctx->priv;
-
-    s->scale = 1.f / (exp2f(-s->exposure) - s->black);
-    ctx->internal->execute(ctx, s->do_slice, frame, NULL,
-                           FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
-
-    return ff_filter_frame(ctx->outputs[0], frame);
-}
-
-static av_cold int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *formats = NULL;
-
-    formats = ff_make_format_list(pixel_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-
-    return ff_set_common_formats(ctx, formats);
-}
-
-static av_cold int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ExposureContext *s = ctx->priv;
-
-    s->do_slice = exposure_slice;
-
-    return 0;
-}
-
-static const AVFilterPad exposure_inputs[] = {
-    {
-        .name           = "default",
-        .type           = AVMEDIA_TYPE_VIDEO,
-        .needs_writable = 1,
-        .filter_frame   = filter_frame,
-        .config_props   = config_input,
-    },
-    { NULL }
-};
-
-static const AVFilterPad exposure_outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_VIDEO,
-    },
-    { NULL }
-};
-
-#define OFFSET(x) offsetof(ExposureContext, x)
-#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption exposure_options[] = {
-    { "exposure", "set the exposure correction",    OFFSET(exposure), AV_OPT_TYPE_FLOAT, {.dbl=0}, -3, 3, VF },
-    { "black",    "set the black level correction", OFFSET(black),    AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(exposure);
-
-AVFilter ff_vf_exposure = {
-    .name          = "exposure",
-    .description   = NULL_IF_CONFIG_SMALL("Adjust exposure of the video stream."),
-    .priv_size     = sizeof(ExposureContext),
-    .priv_class    = &exposure_class,
-    .query_formats = query_formats,
-    .inputs        = exposure_inputs,
-    .outputs       = exposure_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c
index 01ce4d1..b10cd13 100644
--- a/libavfilter/vf_extractplanes.c
+++ b/libavfilter/vf_extractplanes.c
@@ -115,22 +115,16 @@
         AV_PIX_FMT_YUV422P14##suf,                             \
         AV_PIX_FMT_YUV444P14##suf
 
-#define FLOAT_FORMATS(suf)                                     \
-        AV_PIX_FMT_GRAYF32##suf,                               \
-        AV_PIX_FMT_GBRPF32##suf, AV_PIX_FMT_GBRAPF32##suf      \
-
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat in_pixfmts_le[] = {
         EIGHTBIT_FORMATS,
         HIGHDEPTH_FORMATS(LE),
-        FLOAT_FORMATS(LE),
         AV_PIX_FMT_NONE,
     };
     static const enum AVPixelFormat in_pixfmts_be[] = {
         EIGHTBIT_FORMATS,
         HIGHDEPTH_FORMATS(BE),
-        FLOAT_FORMATS(BE),
         AV_PIX_FMT_NONE,
     };
     static const enum AVPixelFormat out8_pixfmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
@@ -144,8 +138,6 @@
     static const enum AVPixelFormat out14be_pixfmts[] = { AV_PIX_FMT_GRAY14BE, AV_PIX_FMT_NONE };
     static const enum AVPixelFormat out16le_pixfmts[] = { AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_NONE };
     static const enum AVPixelFormat out16be_pixfmts[] = { AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE };
-    static const enum AVPixelFormat out32le_pixfmts[] = { AV_PIX_FMT_GRAYF32LE, AV_PIX_FMT_NONE };
-    static const enum AVPixelFormat out32be_pixfmts[] = { AV_PIX_FMT_GRAYF32BE, AV_PIX_FMT_NONE };
     const enum AVPixelFormat *out_pixfmts, *in_pixfmts;
     const AVPixFmtDescriptor *desc;
     AVFilterFormats *avff;
@@ -195,14 +187,10 @@
         out_pixfmts = out14le_pixfmts;
     else if (be && depth == 14)
         out_pixfmts = out14be_pixfmts;
-    else if (be && depth == 16)
+    else if (be)
         out_pixfmts = out16be_pixfmts;
-    else if (!be && depth == 16)
-        out_pixfmts = out16le_pixfmts;
-    else if (be && depth == 32)
-        out_pixfmts = out32be_pixfmts;
     else
-        out_pixfmts = out32le_pixfmts;
+        out_pixfmts = out16le_pixfmts;
 
     for (i = 0; i < ctx->nb_outputs; i++)
         if ((ret = ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->incfg.formats)) < 0)
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index dcd08da..c120bb0 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -77,16 +77,19 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-    AVFilterFormats *formats = NULL;
-    int ret;
+    AVFilterFormats *pix_fmts = NULL;
+    int fmt, ret;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_HWACCEL |
-                                    AV_PIX_FMT_FLAG_BITSTREAM |
-                                    AV_PIX_FMT_FLAG_PAL);
-    if (ret < 0)
-        return ret;
-    return ff_set_common_formats(ctx, formats);
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
+              desc->flags & AV_PIX_FMT_FLAG_PAL     ||
+              desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
+            (ret = ff_add_format(&pix_fmts, fmt)) < 0)
+            return ret;
+    }
+
+    return ff_set_common_formats(ctx, pix_fmts);
 }
 
 static int config_input(AVFilterLink *inlink)
diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
index 528f943..57ecf73 100644
--- a/libavfilter/vf_fieldmatch.c
+++ b/libavfilter/vf_fieldmatch.c
@@ -951,8 +951,8 @@
     fm->tpitchuv = FFALIGN(w >> 1, 16);
 
     fm->tbuffer = av_calloc((h/2 + 4) * fm->tpitchy, sizeof(*fm->tbuffer));
-    fm->c_array = av_malloc_array((((w + fm->blockx/2)/fm->blockx)+1) *
-                            (((h + fm->blocky/2)/fm->blocky)+1),
+    fm->c_array = av_malloc((((w + fm->blockx/2)/fm->blockx)+1) *
+                            (((h + fm->blocky/2)/fm->blocky)+1) *
                             4 * sizeof(*fm->c_array));
     if (!fm->tbuffer || !fm->c_array)
         return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_fillborders.c b/libavfilter/vf_fillborders.c
index d703cbe..a5a0cb3 100644
--- a/libavfilter/vf_fillborders.c
+++ b/libavfilter/vf_fillborders.c
@@ -18,7 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/avassert.h"
 #include "libavutil/colorspace.h"
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
@@ -32,7 +31,7 @@
 enum { Y, U, V, A };
 enum { R, G, B };
 
-enum FillMode { FM_SMEAR, FM_MIRROR, FM_FIXED, FM_REFLECT, FM_WRAP, FM_FADE, FM_NB_MODES };
+enum FillMode { FM_SMEAR, FM_MIRROR, FM_FIXED, FM_NB_MODES };
 
 typedef struct Borders {
     int left, right, top, bottom;
@@ -270,231 +269,6 @@
     }
 }
 
-static void reflect_borders8(FillBordersContext *s, AVFrame *frame)
-{
-    int p, y, x;
-
-    for (p = 0; p < s->nb_planes; p++) {
-        uint8_t *ptr = frame->data[p];
-        int linesize = frame->linesize[p];
-
-        for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
-            for (x = 0; x < s->borders[p].left; x++) {
-                ptr[y * linesize + x] = ptr[y * linesize + s->borders[p].left * 2 - x];
-            }
-
-            for (x = 0; x < s->borders[p].right; x++) {
-                ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
-                    ptr[y * linesize + s->planewidth[p] - s->borders[p].right - 2 - x];
-            }
-        }
-
-        for (y = 0; y < s->borders[p].top; y++) {
-            memcpy(ptr + y * linesize,
-                   ptr + (s->borders[p].top * 2 - y) * linesize,
-                   s->planewidth[p]);
-        }
-
-        for (y = 0; y < s->borders[p].bottom; y++) {
-            memcpy(ptr + (s->planeheight[p] - s->borders[p].bottom + y) * linesize,
-                   ptr + (s->planeheight[p] - s->borders[p].bottom - 2 - y) * linesize,
-                   s->planewidth[p]);
-        }
-    }
-}
-
-static void reflect_borders16(FillBordersContext *s, AVFrame *frame)
-{
-    int p, y, x;
-
-    for (p = 0; p < s->nb_planes; p++) {
-        uint16_t *ptr = (uint16_t *)frame->data[p];
-        int linesize = frame->linesize[p] / 2;
-
-        for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
-            for (x = 0; x < s->borders[p].left; x++) {
-                ptr[y * linesize + x] = ptr[y * linesize + s->borders[p].left * 2 - x];
-            }
-
-            for (x = 0; x < s->borders[p].right; x++) {
-                ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
-                    ptr[y * linesize + s->planewidth[p] - s->borders[p].right - 2 - x];
-            }
-        }
-
-        for (y = 0; y < s->borders[p].top; y++) {
-            memcpy(ptr + y * linesize,
-                   ptr + (s->borders[p].top * 2 - y) * linesize,
-                   s->planewidth[p] * 2);
-        }
-
-        for (y = 0; y < s->borders[p].bottom; y++) {
-            memcpy(ptr + (s->planeheight[p] - s->borders[p].bottom + y) * linesize,
-                   ptr + (s->planeheight[p] - s->borders[p].bottom - 2 - y) * linesize,
-                   s->planewidth[p] * 2);
-        }
-    }
-}
-
-static void wrap_borders8(FillBordersContext *s, AVFrame *frame)
-{
-    int p, y, x;
-
-    for (p = 0; p < s->nb_planes; p++) {
-        uint8_t *ptr = frame->data[p];
-        int linesize = frame->linesize[p];
-
-        for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
-            for (x = 0; x < s->borders[p].left; x++) {
-                ptr[y * linesize + x] = ptr[y * linesize + s->planewidth[p] - s->borders[p].right - s->borders[p].left + x];
-            }
-
-            for (x = 0; x < s->borders[p].right; x++) {
-                ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
-                    ptr[y * linesize + s->borders[p].left + x];
-            }
-        }
-
-        for (y = 0; y < s->borders[p].top; y++) {
-            memcpy(ptr + y * linesize,
-                   ptr + (s->planeheight[p] - s->borders[p].bottom - s->borders[p].top + y) * linesize,
-                   s->planewidth[p]);
-        }
-
-        for (y = 0; y < s->borders[p].bottom; y++) {
-            memcpy(ptr + (s->planeheight[p] - s->borders[p].bottom + y) * linesize,
-                   ptr + (s->borders[p].top + y) * linesize,
-                   s->planewidth[p]);
-        }
-    }
-}
-
-static void wrap_borders16(FillBordersContext *s, AVFrame *frame)
-{
-    int p, y, x;
-
-    for (p = 0; p < s->nb_planes; p++) {
-        uint16_t *ptr = (uint16_t *)frame->data[p];
-        int linesize = frame->linesize[p] / 2;
-
-        for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
-            for (x = 0; x < s->borders[p].left; x++) {
-                ptr[y * linesize + x] = ptr[y * linesize + s->planewidth[p] - s->borders[p].right - s->borders[p].left + x];
-            }
-
-            for (x = 0; x < s->borders[p].right; x++) {
-                ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
-                    ptr[y * linesize + s->borders[p].left + x];
-            }
-        }
-
-        for (y = 0; y < s->borders[p].top; y++) {
-            memcpy(ptr + y * linesize,
-                   ptr + (s->planeheight[p] - s->borders[p].bottom - s->borders[p].top + y) * linesize,
-                   s->planewidth[p] * 2);
-        }
-
-        for (y = 0; y < s->borders[p].bottom; y++) {
-            memcpy(ptr + (s->planeheight[p] - s->borders[p].bottom + y) * linesize,
-                   ptr + (s->borders[p].top + y) * linesize,
-                   s->planewidth[p] * 2);
-        }
-    }
-}
-
-static int lerp8(int fill, int src, int pos, int size)
-{
-    return av_clip_uint8(((fill * 256 * pos / size) + (src * 256 * (size - pos) / size)) >> 8);
-}
-
-static int lerp16(int fill, int src, int pos, int size, int depth)
-{
-    return av_clip_uintp2_c(((fill * (1LL << depth) * pos / size) + (src * (1LL << depth) * (size - pos) / size)) >> depth, depth);
-}
-
-static void fade_borders8(FillBordersContext *s, AVFrame *frame)
-{
-    int p, y, x;
-
-    for (p = 0; p < s->nb_planes; p++) {
-        uint8_t *ptr = frame->data[p];
-        const uint8_t fill = s->fill[p];
-        const int linesize = frame->linesize[p];
-        const int start_left = s->borders[p].left;
-        const int start_right = s->planewidth[p] - s->borders[p].right;
-        const int start_top = s->borders[p].top;
-        const int start_bottom = s->planeheight[p] - s->borders[p].bottom;
-
-        for (y = 0; y < start_top; y++) {
-            for (x = 0; x < s->planewidth[p]; x++) {
-                int src = ptr[y * linesize + x];
-                ptr[y * linesize + x] = lerp8(fill, src, start_top - y, start_top);
-            }
-        }
-
-        for (y = start_bottom; y < s->planeheight[p]; y++) {
-            for (x = 0; x < s->planewidth[p]; x++) {
-                int src = ptr[y * linesize + x];
-                ptr[y * linesize + x] = lerp8(fill, src, y - start_bottom, s->borders[p].bottom);
-            }
-        }
-
-        for (y = 0; y < s->planeheight[p]; y++) {
-            for (x = 0; x < start_left; x++) {
-                int src = ptr[y * linesize + x];
-                ptr[y * linesize + x] = lerp8(fill, src, start_left - x, start_left);
-            }
-
-            for (x = 0; x < s->borders[p].right; x++) {
-                int src = ptr[y * linesize + start_right + x];
-                ptr[y * linesize + start_right + x] = lerp8(fill, src, x, s->borders[p].right);
-            }
-        }
-    }
-}
-
-static void fade_borders16(FillBordersContext *s, AVFrame *frame)
-{
-    const int depth = s->depth;
-    int p, y, x;
-
-    for (p = 0; p < s->nb_planes; p++) {
-        uint16_t *ptr = (uint16_t *)frame->data[p];
-        const uint16_t fill = s->fill[p] << (depth - 8);
-        const int linesize = frame->linesize[p] / 2;
-        const int start_left = s->borders[p].left;
-        const int start_right = s->planewidth[p] - s->borders[p].right;
-        const int start_top = s->borders[p].top;
-        const int start_bottom = s->planeheight[p] - s->borders[p].bottom;
-
-        for (y = 0; y < start_top; y++) {
-            for (x = 0; x < s->planewidth[p]; x++) {
-                int src = ptr[y * linesize + x];
-                ptr[y * linesize + x] = lerp16(fill, src, start_top - y, start_top, depth);
-            }
-        }
-
-        for (y = start_bottom; y < s->planeheight[p]; y++) {
-            for (x = 0; x < s->planewidth[p]; x++) {
-                int src = ptr[y * linesize + x];
-                ptr[y * linesize + x] = lerp16(fill, src, y - start_bottom, s->borders[p].bottom, depth);
-            }
-        }
-
-        for (y = 0; y < s->planeheight[p]; y++) {
-            for (x = 0; x < start_left; x++) {
-                int src = ptr[y * linesize + x];
-                ptr[y * linesize + x] = lerp16(fill, src, start_left - x, start_left, depth);
-            }
-
-            for (x = 0; x < s->borders[p].right; x++) {
-                int src = ptr[y * linesize + start_right + x];
-                ptr[y * linesize + start_right + x] = lerp16(fill, src, x, s->borders[p].right, depth);
-            }
-        }
-    }
-}
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 {
     FillBordersContext *s = inlink->dst->priv;
@@ -551,10 +325,6 @@
     case FM_SMEAR:  s->fillborders = s->depth <= 8 ? smear_borders8  : smear_borders16;  break;
     case FM_MIRROR: s->fillborders = s->depth <= 8 ? mirror_borders8 : mirror_borders16; break;
     case FM_FIXED:  s->fillborders = s->depth <= 8 ? fixed_borders8  : fixed_borders16;  break;
-    case FM_REFLECT:s->fillborders = s->depth <= 8 ? reflect_borders8: reflect_borders16;break;
-    case FM_WRAP:   s->fillborders = s->depth <= 8 ? wrap_borders8   : wrap_borders16;   break;
-    case FM_FADE:   s->fillborders = s->depth <= 8 ? fade_borders8   : fade_borders16;   break;
-    default: av_assert0(0);
     }
 
     s->yuv_color[Y] = RGB_TO_Y_CCIR(s->rgba_color[R], s->rgba_color[G], s->rgba_color[B]);
@@ -600,10 +370,7 @@
         { "smear",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_SMEAR},  0, 0, FLAGS, "mode" },
         { "mirror", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_MIRROR}, 0, 0, FLAGS, "mode" },
         { "fixed",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_FIXED},  0, 0, FLAGS, "mode" },
-        { "reflect",NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_REFLECT},0, 0, FLAGS, "mode" },
-        { "wrap",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_WRAP},   0, 0, FLAGS, "mode" },
-        { "fade",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_FADE},   0, 0, FLAGS, "mode" },
-    { "color",  "set the color for the fixed/fade mode", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
+    { "color",  "set the color for the fixed mode", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
     { NULL }
 };
 
diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c
index 3da80cf..b5d877c 100644
--- a/libavfilter/vf_framepack.c
+++ b/libavfilter/vf_framepack.c
@@ -44,7 +44,6 @@
 typedef struct FramepackContext {
     const AVClass *class;
 
-    int depth;
     const AVPixFmtDescriptor *pix_desc; ///< agreed pixel format
 
     enum AVStereo3DType format;         ///< frame pack type output
@@ -53,29 +52,9 @@
 } FramepackContext;
 
 static const enum AVPixelFormat formats_supported[] = {
-    AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
-    AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-    AV_PIX_FMT_GRAY16,
-    AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-    AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-    AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-    AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-    AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-    AV_PIX_FMT_YUVJ411P,
-    AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-    AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-    AV_PIX_FMT_YUV440P10,
-    AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-    AV_PIX_FMT_YUV440P12,
-    AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-    AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-    AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
-    AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-    AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-    AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-    AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-    AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-    AV_PIX_FMT_GBRAP,     AV_PIX_FMT_GBRAP10,    AV_PIX_FMT_GBRAP12,    AV_PIX_FMT_GBRAP16,
+    AV_PIX_FMT_YUV420P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV444P,
+    AV_PIX_FMT_YUV410P,  AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVJ420P,
+    AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
     AV_PIX_FMT_NONE
 };
 
@@ -134,7 +113,6 @@
     s->pix_desc = av_pix_fmt_desc_get(outlink->format);
     if (!s->pix_desc)
         return AVERROR_BUG;
-    s->depth = s->pix_desc->comp[0].depth;
 
     // modify output properties as needed
     switch (s->format) {
@@ -171,7 +149,7 @@
     FramepackContext *s = ctx->priv;
     int i, plane;
 
-    if (interleaved && s->depth <= 8) {
+    if (interleaved) {
         const uint8_t *leftp  = s->input_views[LEFT]->data[0];
         const uint8_t *rightp = s->input_views[RIGHT]->data[0];
         uint8_t *dstp         = out->data[0];
@@ -206,53 +184,17 @@
                 }
             }
         }
-    } else if (interleaved && s->depth > 8) {
-        const uint16_t *leftp  = (const uint16_t *)s->input_views[LEFT]->data[0];
-        const uint16_t *rightp = (const uint16_t *)s->input_views[RIGHT]->data[0];
-        uint16_t *dstp         = (uint16_t *)out->data[0];
-        int length = out->width / 2;
-        int lines  = out->height;
-
-        for (plane = 0; plane < s->pix_desc->nb_components; plane++) {
-            if (plane == 1 || plane == 2) {
-                length = AV_CEIL_RSHIFT(out->width / 2, s->pix_desc->log2_chroma_w);
-                lines  = AV_CEIL_RSHIFT(out->height,    s->pix_desc->log2_chroma_h);
-            }
-            for (i = 0; i < lines; i++) {
-                int j;
-                leftp  = (const uint16_t *)s->input_views[LEFT]->data[plane] +
-                         s->input_views[LEFT]->linesize[plane] * i / 2;
-                rightp = (const uint16_t *)s->input_views[RIGHT]->data[plane] +
-                         s->input_views[RIGHT]->linesize[plane] * i / 2;
-                dstp   = (uint16_t *)out->data[plane] + out->linesize[plane] * i / 2;
-                for (j = 0; j < length; j++) {
-                    // interpolate chroma as necessary
-                    if ((s->pix_desc->log2_chroma_w ||
-                         s->pix_desc->log2_chroma_h) &&
-                        (plane == 1 || plane == 2)) {
-                        *dstp++ = (*leftp + *rightp) / 2;
-                        *dstp++ = (*leftp + *rightp) / 2;
-                    } else {
-                        *dstp++ = *leftp;
-                        *dstp++ = *rightp;
-                    }
-                    leftp += 1;
-                    rightp += 1;
-                }
-            }
-        }
     } else {
         for (i = 0; i < 2; i++) {
-            const int psize = 1 + (s->depth > 8);
             const uint8_t *src[4];
             uint8_t *dst[4];
-            int sub_w = psize * s->input_views[i]->width >> s->pix_desc->log2_chroma_w;
+            int sub_w = s->input_views[i]->width >> s->pix_desc->log2_chroma_w;
 
             src[0] = s->input_views[i]->data[0];
             src[1] = s->input_views[i]->data[1];
             src[2] = s->input_views[i]->data[2];
 
-            dst[0] = out->data[0] + i * s->input_views[i]->width * psize;
+            dst[0] = out->data[0] + i * s->input_views[i]->width;
             dst[1] = out->data[1] + i * sub_w;
             dst[2] = out->data[2] + i * sub_w;
 
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index f508570..6c8d01c 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -170,9 +170,7 @@
         return 0;
 
     if (!s->f0) {
-        av_assert1(s->flush);
-        s->work = s->f1;
-        s->f1 = NULL;
+        s->work = av_frame_clone(s->f1);
     } else {
         if (work_pts >= s->pts1 + s->delta && s->flush)
             return 0;
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 2ec4707..c084d5b 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -424,7 +424,6 @@
     .inputs        = avfilter_vf_frei0r_inputs,
     .outputs       = avfilter_vf_frei0r_outputs,
     .process_command = process_command,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
 
 static av_cold int source_init(AVFilterContext *ctx)
diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c
index d70952a..c698904 100644
--- a/libavfilter/vf_fspp.c
+++ b/libavfilter/vf_fspp.c
@@ -37,11 +37,9 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
-#include "qp_table.h"
 #include "vf_fspp.h"
 
 #define OFFSET(x) offsetof(FSPPContext, x)
@@ -527,6 +525,13 @@
     if (!fspp->temp || !fspp->src)
         return AVERROR(ENOMEM);
 
+    if (!fspp->use_bframe_qp && !fspp->qp) {
+        fspp->non_b_qp_alloc_size = AV_CEIL_RSHIFT(inlink->w, 4) * AV_CEIL_RSHIFT(inlink->h, 4);
+        fspp->non_b_qp_table = av_calloc(fspp->non_b_qp_alloc_size, sizeof(*fspp->non_b_qp_table));
+        if (!fspp->non_b_qp_table)
+            return AVERROR(ENOMEM);
+    }
+
     fspp->store_slice  = store_slice_c;
     fspp->store_slice2 = store_slice2_c;
     fspp->mul_thrmat   = mul_thrmat_c;
@@ -548,9 +553,8 @@
     AVFrame *out = in;
 
     int qp_stride = 0;
-    int8_t *qp_table = NULL;
+    uint8_t *qp_table = NULL;
     int i, bias;
-    int ret = 0;
     int custom_threshold_m[64];
 
     bias = (1 << 4) + fspp->strength;
@@ -577,25 +581,38 @@
      * the quantizers from the B-frames (B-frames often have a higher QP), we
      * need to save the qp table from the last non B-frame; this is what the
      * following code block does */
-    if (!fspp->qp && (fspp->use_bframe_qp || in->pict_type != AV_PICTURE_TYPE_B)) {
-        ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL, &fspp->qscale_type);
-        if (ret < 0) {
-            av_frame_free(&in);
-            return ret;
-        }
+    if (!fspp->qp) {
+        qp_table = av_frame_get_qp_table(in, &qp_stride, &fspp->qscale_type);
 
-        if (!fspp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
-            av_freep(&fspp->non_b_qp_table);
-            fspp->non_b_qp_table  = qp_table;
-            fspp->non_b_qp_stride = qp_stride;
+        if (qp_table && !fspp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
+            int w, h;
+
+            /* if the qp stride is not set, it means the QP are only defined on
+             * a line basis */
+           if (!qp_stride) {
+                w = AV_CEIL_RSHIFT(inlink->w, 4);
+                h = 1;
+            } else {
+                w = qp_stride;
+                h = AV_CEIL_RSHIFT(inlink->h, 4);
+            }
+            if (w * h > fspp->non_b_qp_alloc_size) {
+                int ret = av_reallocp_array(&fspp->non_b_qp_table, w, h);
+                if (ret < 0) {
+                    fspp->non_b_qp_alloc_size = 0;
+                    return ret;
+                }
+                fspp->non_b_qp_alloc_size = w * h;
+            }
+
+            av_assert0(w * h <= fspp->non_b_qp_alloc_size);
+            memcpy(fspp->non_b_qp_table, qp_table, w * h);
         }
     }
 
     if (fspp->log2_count && !ctx->is_disabled) {
-        if (!fspp->use_bframe_qp && fspp->non_b_qp_table) {
+        if (!fspp->use_bframe_qp && fspp->non_b_qp_table)
             qp_table = fspp->non_b_qp_table;
-            qp_stride = fspp->non_b_qp_stride;
-        }
 
         if (qp_table || fspp->qp) {
             const int cw = AV_CEIL_RSHIFT(inlink->w, fspp->hsub);
@@ -610,8 +627,7 @@
                 out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
                 if (!out) {
                     av_frame_free(&in);
-                    ret = AVERROR(ENOMEM);
-                    goto finish;
+                    return AVERROR(ENOMEM);
                 }
                 av_frame_copy_props(out, in);
                 out->width = in->width;
@@ -635,11 +651,7 @@
                                 inlink->w, inlink->h);
         av_frame_free(&in);
     }
-    ret = ff_filter_frame(outlink, out);
-finish:
-    if (qp_table != fspp->non_b_qp_table)
-        av_freep(&qp_table);
-    return ret;
+    return ff_filter_frame(outlink, out);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
diff --git a/libavfilter/vf_fspp.h b/libavfilter/vf_fspp.h
index 6623af4..73d8c7c 100644
--- a/libavfilter/vf_fspp.h
+++ b/libavfilter/vf_fspp.h
@@ -65,8 +65,8 @@
     int prev_q;
     uint8_t *src;
     int16_t *temp;
-    int8_t  *non_b_qp_table;
-    int non_b_qp_stride;
+    uint8_t *non_b_qp_table;
+    int non_b_qp_alloc_size;
     int use_bframe_qp;
 
     void (*store_slice)(uint8_t *dst, int16_t *src,
diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index 86c765b..2e587f6 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -25,8 +25,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <float.h>
-
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -54,15 +52,6 @@
     int width;
 } ThreadData;
 
-static void postscale_c(float *buffer, int length,
-                        float postscale, float min, float max)
-{
-    for (int i = 0; i < length; i++) {
-        buffer[i] *= postscale;
-        buffer[i] = av_clipf(buffer[i], min, max);
-    }
-}
-
 static void horiz_slice_c(float *buffer, int width, int height, int steps,
                           float nu, float bscale)
 {
@@ -163,22 +152,25 @@
     return 0;
 }
 
+
 static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
     GBlurContext *s = ctx->priv;
     ThreadData *td = arg;
-    const float max = s->flt ?  FLT_MAX : (1 << s->depth) - 1;
-    const float min = s->flt ? -FLT_MAX : 0.f;
+    const float max = (1 << s->depth) - 1;
     const int height = td->height;
     const int width = td->width;
-    const int awidth = FFALIGN(width, 64);
-    const int slice_start = (height *  jobnr   ) / nb_jobs;
-    const int slice_end   = (height * (jobnr+1)) / nb_jobs;
+    const int64_t numpixels = width * (int64_t)height;
+    const unsigned slice_start = (numpixels *  jobnr   ) / nb_jobs;
+    const unsigned slice_end   = (numpixels * (jobnr+1)) / nb_jobs;
     const float postscale = s->postscale * s->postscaleV;
-    const int slice_size = slice_end - slice_start;
+    float *buffer = s->buffer;
+    unsigned i;
 
-    s->postscale_slice(s->buffer + slice_start * awidth,
-                       slice_size * awidth, postscale, min, max);
+    for (i = slice_start; i < slice_end; i++) {
+        buffer[i] *= postscale;
+        buffer[i] = av_clipf(buffer[i], 0.f, max);
+    }
 
     return 0;
 }
@@ -222,8 +214,6 @@
         AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
         AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
         AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
-        AV_PIX_FMT_GRAYF32,
         AV_PIX_FMT_NONE
     };
 
@@ -233,8 +223,7 @@
 void ff_gblur_init(GBlurContext *s)
 {
     s->horiz_slice = horiz_slice_c;
-    s->postscale_slice = postscale_c;
-    if (ARCH_X86)
+    if (ARCH_X86_64)
         ff_gblur_init_x86(s);
 }
 
@@ -244,7 +233,6 @@
     GBlurContext *s = inlink->dst->priv;
 
     s->depth = desc->comp[0].depth;
-    s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
     s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
     s->planewidth[0] = s->planewidth[3] = inlink->w;
     s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
@@ -252,7 +240,7 @@
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
-    s->buffer = av_malloc_array(FFALIGN(inlink->w, 64), FFALIGN(inlink->h, 64) * sizeof(*s->buffer));
+    s->buffer = av_malloc_array(FFALIGN(inlink->w, 16), FFALIGN(inlink->h, 16) * sizeof(*s->buffer));
     if (!s->buffer)
         return AVERROR(ENOMEM);
 
@@ -315,11 +303,7 @@
             continue;
         }
 
-        if (s->flt) {
-            av_image_copy_plane((uint8_t *)bptr, width * sizeof(float),
-                                in->data[plane], in->linesize[plane],
-                                width * sizeof(float), height);
-        } else if (s->depth == 8) {
+        if (s->depth == 8) {
             for (y = 0; y < height; y++) {
                 for (x = 0; x < width; x++) {
                     bptr[x] = src[x];
@@ -340,11 +324,7 @@
         gaussianiir2d(ctx, plane);
 
         bptr = s->buffer;
-        if (s->flt) {
-            av_image_copy_plane(out->data[plane], out->linesize[plane],
-                                (uint8_t *)bptr, width * sizeof(float),
-                                width * sizeof(float), height);
-        } else if (s->depth == 8) {
+        if (s->depth == 8) {
             for (y = 0; y < height; y++) {
                 for (x = 0; x < width; x++) {
                     dst[x] = bptr[x];
diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c
index 072cef3..d7abf96 100644
--- a/libavfilter/vf_geq.c
+++ b/libavfilter/vf_geq.c
@@ -270,7 +270,7 @@
     }
 
     for (plane = 0; plane < NB_PLANES; plane++) {
-        static double (*const p[])(void *, double, double) = {
+        static double (*p[])(void *, double, double) = {
             lum   , cb   , cr   , alpha   ,
             lumsum, cbsum, crsub, alphasum,
         };
@@ -283,7 +283,7 @@
             "gsum", "bsum", "rsum", "alphasum", "psum",
             NULL };
         const char *const *func2_names       = geq->is_rgb ? func2_rgb_names : func2_yuv_names;
-        double (*const func2[])(void *, double, double) = {
+        double (*func2[])(void *, double, double) = {
             lum   , cb   , cr   , alpha   , p[plane],
             lumsum, cbsum, crsub, alphasum, p[plane + 4],
             NULL };
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index 28da37f..f63128d 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -35,7 +35,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/common.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
diff --git a/libavfilter/vf_identity.c b/libavfilter/vf_identity.c
deleted file mode 100644
index 60d02e3..0000000
--- a/libavfilter/vf_identity.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Caculate the Identity between two input videos.
- */
-
-#include "libavutil/avstring.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "avfilter.h"
-#include "drawutils.h"
-#include "formats.h"
-#include "framesync.h"
-#include "internal.h"
-#include "video.h"
-#include "scene_sad.h"
-
-typedef struct IdentityContext {
-    const AVClass *class;
-    FFFrameSync fs;
-    double score, min_score, max_score, score_comp[4];
-    uint64_t nb_frames;
-    int is_rgb;
-    int is_msad;
-    uint8_t rgba_map[4];
-    int max[4];
-    char comps[4];
-    int nb_components;
-    int nb_threads;
-    int planewidth[4];
-    int planeheight[4];
-    uint64_t **scores;
-    unsigned (*filter_line)(const uint8_t *buf, const uint8_t *ref, int w);
-    int (*filter_slice)(AVFilterContext *ctx, void *arg,
-                        int jobnr, int nb_jobs);
-    ff_scene_sad_fn sad;
-} IdentityContext;
-
-#define OFFSET(x) offsetof(IdentityContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
-
-static unsigned identity_line_8bit(const uint8_t *main_line,  const uint8_t *ref_line, int outw)
-{
-    unsigned score = 0;
-
-    for (int j = 0; j < outw; j++)
-        score += main_line[j] == ref_line[j];
-
-    return score;
-}
-
-static unsigned identity_line_16bit(const uint8_t *mmain_line, const uint8_t *rref_line, int outw)
-{
-    const uint16_t *main_line = (const uint16_t *)mmain_line;
-    const uint16_t *ref_line = (const uint16_t *)rref_line;
-    unsigned score = 0;
-
-    for (int j = 0; j < outw; j++)
-        score += main_line[j] == ref_line[j];
-
-    return score;
-}
-
-typedef struct ThreadData {
-    const uint8_t *main_data[4];
-    const uint8_t *ref_data[4];
-    int main_linesize[4];
-    int ref_linesize[4];
-    int planewidth[4];
-    int planeheight[4];
-    uint64_t **score;
-    int nb_components;
-} ThreadData;
-
-static
-int compute_images_msad(AVFilterContext *ctx, void *arg,
-                        int jobnr, int nb_jobs)
-{
-    IdentityContext *s = ctx->priv;
-    ThreadData *td = arg;
-    uint64_t *score = td->score[jobnr];
-
-    for (int c = 0; c < td->nb_components; c++) {
-        const int outw = td->planewidth[c];
-        const int outh = td->planeheight[c];
-        const int slice_start = (outh * jobnr) / nb_jobs;
-        const int slice_end = (outh * (jobnr+1)) / nb_jobs;
-        const int ref_linesize = td->ref_linesize[c];
-        const int main_linesize = td->main_linesize[c];
-        const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
-        const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
-        uint64_t m = 0;
-
-        s->sad(main_line, main_linesize, ref_line, ref_linesize,
-               outw, slice_end - slice_start, &m);
-
-        score[c] = m;
-    }
-
-    return 0;
-}
-
-static
-int compute_images_identity(AVFilterContext *ctx, void *arg,
-                            int jobnr, int nb_jobs)
-{
-    IdentityContext *s = ctx->priv;
-    ThreadData *td = arg;
-    uint64_t *score = td->score[jobnr];
-
-    for (int c = 0; c < td->nb_components; c++) {
-        const int outw = td->planewidth[c];
-        const int outh = td->planeheight[c];
-        const int slice_start = (outh * jobnr) / nb_jobs;
-        const int slice_end = (outh * (jobnr+1)) / nb_jobs;
-        const int ref_linesize = td->ref_linesize[c];
-        const int main_linesize = td->main_linesize[c];
-        const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
-        const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
-        uint64_t m = 0;
-
-        for (int i = slice_start; i < slice_end; i++) {
-            m += s->filter_line(main_line, ref_line, outw);
-            ref_line += ref_linesize;
-            main_line += main_linesize;
-        }
-        score[c] = m;
-    }
-
-    return 0;
-}
-
-static void set_meta(AVFilterContext *ctx,
-                     AVDictionary **metadata, const char *key, char comp, float d)
-{
-    char value[128];
-    snprintf(value, sizeof(value), "%f", d);
-    if (comp) {
-        char key2[128];
-        snprintf(key2, sizeof(key2), "lavfi.%s.%s%s%c",
-                 ctx->filter->name, ctx->filter->name, key, comp);
-        av_dict_set(metadata, key2, value, 0);
-    } else {
-        char key2[128];
-        snprintf(key2, sizeof(key2), "lavfi.%s.%s%s",
-                 ctx->filter->name, ctx->filter->name, key);
-        av_dict_set(metadata, key2, value, 0);
-    }
-}
-
-static int do_identity(FFFrameSync *fs)
-{
-    AVFilterContext *ctx = fs->parent;
-    IdentityContext *s = ctx->priv;
-    AVFrame *master, *ref;
-    double comp_score[4], score = 0.;
-    uint64_t comp_sum[4] = { 0 };
-    AVDictionary **metadata;
-    ThreadData td;
-    int ret;
-
-    ret = ff_framesync_dualinput_get(fs, &master, &ref);
-    if (ret < 0)
-        return ret;
-    if (ctx->is_disabled || !ref)
-        return ff_filter_frame(ctx->outputs[0], master);
-    metadata = &master->metadata;
-
-    td.nb_components = s->nb_components;
-    td.score = s->scores;
-    for (int c = 0; c < s->nb_components; c++) {
-        td.main_data[c] = master->data[c];
-        td.ref_data[c] = ref->data[c];
-        td.main_linesize[c] = master->linesize[c];
-        td.ref_linesize[c] = ref->linesize[c];
-        td.planewidth[c] = s->planewidth[c];
-        td.planeheight[c] = s->planeheight[c];
-    }
-
-    ctx->internal->execute(ctx, s->filter_slice, &td, NULL, FFMIN(s->planeheight[1], s->nb_threads));
-
-    for (int j = 0; j < s->nb_threads; j++) {
-        for (int c = 0; c < s->nb_components; c++)
-            comp_sum[c] += s->scores[j][c];
-    }
-
-    for (int c = 0; c < s->nb_components; c++)
-        comp_score[c] = comp_sum[c] / ((double)s->planewidth[c] * s->planeheight[c]);
-
-    for (int c = 0; c < s->nb_components && s->is_msad; c++)
-        comp_score[c] /= (double)s->max[c];
-
-    for (int c = 0; c < s->nb_components; c++)
-        score += comp_score[c];
-    score /= s->nb_components;
-
-    s->min_score = FFMIN(s->min_score, score);
-    s->max_score = FFMAX(s->max_score, score);
-
-    s->score += score;
-
-    for (int j = 0; j < s->nb_components; j++)
-        s->score_comp[j] += comp_score[j];
-    s->nb_frames++;
-
-    for (int j = 0; j < s->nb_components; j++) {
-        int c = s->is_rgb ? s->rgba_map[j] : j;
-        set_meta(ctx, metadata, ".", s->comps[j], comp_score[c]);
-    }
-    set_meta(ctx, metadata, "_avg", 0, score);
-
-    return ff_filter_frame(ctx->outputs[0], master);
-}
-
-static av_cold int init(AVFilterContext *ctx)
-{
-    IdentityContext *s = ctx->priv;
-
-    s->fs.on_event = do_identity;
-
-    return 0;
-}
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
-#define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf,  AV_PIX_FMT_YUV422##suf,  AV_PIX_FMT_YUV444##suf
-#define PF_ALPHA(suf)   AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
-#define PF(suf)         PF_NOALPHA(suf), PF_ALPHA(suf)
-        PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
-        AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
-        AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-    if (!fmts_list)
-        return AVERROR(ENOMEM);
-    return ff_set_common_formats(ctx, fmts_list);
-}
-
-static int config_input_ref(AVFilterLink *inlink)
-{
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    AVFilterContext *ctx  = inlink->dst;
-    IdentityContext *s = ctx->priv;
-
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
-    s->nb_components = desc->nb_components;
-    if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
-        ctx->inputs[0]->h != ctx->inputs[1]->h) {
-        av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
-        return AVERROR(EINVAL);
-    }
-    if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
-        av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
-        return AVERROR(EINVAL);
-    }
-
-    s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
-    s->comps[0] = s->is_rgb ? 'R' : 'Y' ;
-    s->comps[1] = s->is_rgb ? 'G' : 'U' ;
-    s->comps[2] = s->is_rgb ? 'B' : 'V' ;
-    s->comps[3] = 'A';
-
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-    s->planewidth[1]  = s->planewidth[2]  = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0]  = s->planewidth[3]  = inlink->w;
-
-    s->scores = av_calloc(s->nb_threads, sizeof(*s->scores));
-    if (!s->scores)
-        return AVERROR(ENOMEM);
-
-    for (int t = 0; t < s->nb_threads && s->scores; t++) {
-        s->scores[t] = av_calloc(s->nb_components, sizeof(*s->scores[0]));
-        if (!s->scores[t])
-            return AVERROR(ENOMEM);
-    }
-
-    s->min_score = +INFINITY;
-    s->max_score = -INFINITY;
-
-    s->max[0] = (1 << desc->comp[0].depth) - 1;
-    s->max[1] = (1 << desc->comp[1].depth) - 1;
-    s->max[2] = (1 << desc->comp[2].depth) - 1;
-    s->max[3] = (1 << desc->comp[3].depth) - 1;
-
-    s->is_msad = !strcmp(ctx->filter->name, "msad");
-    s->filter_slice = !s->is_msad ? compute_images_identity : compute_images_msad;
-    s->filter_line = desc->comp[0].depth > 8 ? identity_line_16bit : identity_line_8bit;
-
-    s->sad = ff_scene_sad_get_fn(desc->comp[0].depth <= 8 ? 8 : 16);
-    if (!s->sad)
-        return AVERROR(EINVAL);
-
-    return 0;
-}
-
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    IdentityContext *s = ctx->priv;
-    AVFilterLink *mainlink = ctx->inputs[0];
-    int ret;
-
-    ret = ff_framesync_init_dualinput(&s->fs, ctx);
-    if (ret < 0)
-        return ret;
-    outlink->w = mainlink->w;
-    outlink->h = mainlink->h;
-    outlink->time_base = mainlink->time_base;
-    outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
-    outlink->frame_rate = mainlink->frame_rate;
-    if ((ret = ff_framesync_configure(&s->fs)) < 0)
-        return ret;
-
-    outlink->time_base = s->fs.time_base;
-
-    if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
-        av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
-        av_log(ctx, AV_LOG_WARNING, "not matching timebases found between first input: %d/%d and second input %d/%d, results may be incorrect!\n",
-               mainlink->time_base.num, mainlink->time_base.den,
-               ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
-
-    return 0;
-}
-
-static int activate(AVFilterContext *ctx)
-{
-    IdentityContext *s = ctx->priv;
-    return ff_framesync_activate(&s->fs);
-}
-
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    IdentityContext *s = ctx->priv;
-
-    if (s->nb_frames > 0) {
-        char buf[256];
-
-        buf[0] = 0;
-        for (int j = 0; j < s->nb_components; j++) {
-            int c = s->is_rgb ? s->rgba_map[j] : j;
-            av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[j], s->score_comp[c] / s->nb_frames);
-        }
-
-        av_log(ctx, AV_LOG_INFO, "%s%s average:%f min:%f max:%f\n",
-               ctx->filter->name,
-               buf,
-               s->score / s->nb_frames,
-               s->min_score,
-               s->max_score);
-    }
-
-    ff_framesync_uninit(&s->fs);
-    for (int t = 0; t < s->nb_threads && s->scores; t++)
-        av_freep(&s->scores[t]);
-    av_freep(&s->scores);
-}
-
-static const AVFilterPad identity_inputs[] = {
-    {
-        .name         = "main",
-        .type         = AVMEDIA_TYPE_VIDEO,
-    },{
-        .name         = "reference",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_input_ref,
-    },
-    { NULL }
-};
-
-static const AVFilterPad identity_outputs[] = {
-    {
-        .name          = "default",
-        .type          = AVMEDIA_TYPE_VIDEO,
-        .config_props  = config_output,
-    },
-    { NULL }
-};
-
-static const AVOption options[] = {
-    { NULL }
-};
-
-#if CONFIG_IDENTITY_FILTER
-
-#define identity_options options
-FRAMESYNC_DEFINE_CLASS(identity, IdentityContext, fs);
-
-AVFilter ff_vf_identity = {
-    .name          = "identity",
-    .description   = NULL_IF_CONFIG_SMALL("Calculate the Identity between two video streams."),
-    .preinit       = identity_framesync_preinit,
-    .init          = init,
-    .uninit        = uninit,
-    .query_formats = query_formats,
-    .activate      = activate,
-    .priv_size     = sizeof(IdentityContext),
-    .priv_class    = &identity_class,
-    .inputs        = identity_inputs,
-    .outputs       = identity_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-};
-
-#endif /* CONFIG_IDENTITY_FILTER */
-
-#if CONFIG_MSAD_FILTER
-
-#define msad_options options
-FRAMESYNC_DEFINE_CLASS(msad, IdentityContext, fs);
-
-AVFilter ff_vf_msad = {
-    .name          = "msad",
-    .description   = NULL_IF_CONFIG_SMALL("Calculate the MSAD between two video streams."),
-    .preinit       = msad_framesync_preinit,
-    .init          = init,
-    .uninit        = uninit,
-    .query_formats = query_formats,
-    .activate      = activate,
-    .priv_size     = sizeof(IdentityContext),
-    .priv_class    = &msad_class,
-    .inputs        = identity_inputs,
-    .outputs       = identity_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-};
-
-#endif /* CONFIG_MSAD_FILTER */
diff --git a/libavfilter/vf_il.c b/libavfilter/vf_il.c
index 46af57f..6cd5f89 100644
--- a/libavfilter/vf_il.c
+++ b/libavfilter/vf_il.c
@@ -84,13 +84,16 @@
 static int query_formats(AVFilterContext *ctx)
 {
     AVFilterFormats *formats = NULL;
-    int ret;
+    int fmt, ret;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_PAL |
-                                    AV_PIX_FMT_FLAG_HWACCEL);
-    if (ret < 0)
-        return ret;
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) &&
+            !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
+            (ret = ff_add_format(&formats, fmt)) < 0)
+            return ret;
+    }
+
     return ff_set_common_formats(ctx, formats);
 }
 
diff --git a/libavfilter/vf_lagfun.c b/libavfilter/vf_lagfun.c
index 36b19b3..1fbc889 100644
--- a/libavfilter/vf_lagfun.c
+++ b/libavfilter/vf_lagfun.c
@@ -30,16 +30,16 @@
 
 typedef struct LagfunContext {
     const AVClass *class;
+    const AVPixFmtDescriptor *desc;
     float decay;
     int planes;
 
     int depth;
     int nb_planes;
     int linesize[4];
-    int planewidth[4];
-    int planeheight[4];
+    int height[4];
 
-    float *old[4];
+    AVFrame *old;
 
     int (*lagfun)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
 } LagfunContext;
@@ -74,87 +74,100 @@
 }
 
 typedef struct ThreadData {
-    AVFrame *in, *out;
+    AVFrame *in, *out, *old;
 } ThreadData;
 
-#define LAGFUN(name, type)                                                \
-static int lagfun_frame##name(AVFilterContext *ctx, void *arg,            \
-                              int jobnr, int nb_jobs)                     \
-{                                                                         \
-    LagfunContext *s = ctx->priv;                                         \
-    const float decay = s->decay;                                         \
-    ThreadData *td = arg;                                                 \
-    AVFrame *in = td->in;                                                 \
-    AVFrame *out = td->out;                                               \
-                                                                          \
-    for (int p = 0; p < s->nb_planes; p++) {                              \
-        const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs;    \
-        const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs;  \
-        const type *src = (const type *)in->data[p] +                     \
-                          slice_start * in->linesize[p] / sizeof(type);   \
-        float *osrc = s->old[p] + slice_start * s->planewidth[p];         \
-        type *dst = (type *)out->data[p] +                                \
-                    slice_start * out->linesize[p] / sizeof(type);        \
-                                                                          \
-        if (!((1 << p) & s->planes)) {                                    \
-            av_image_copy_plane((uint8_t *)dst, out->linesize[p],         \
-                                (const uint8_t *)src, in->linesize[p],    \
-                                s->linesize[p], slice_end - slice_start); \
-            continue;                                                     \
-        }                                                                 \
-                                                                          \
-        for (int y = slice_start; y < slice_end; y++) {                   \
-            for (int x = 0; x < s->planewidth[p]; x++) {                  \
-                float v = FFMAX(src[x], osrc[x] * decay);                 \
-                                                                          \
-                osrc[x] = v;                                              \
-                if (ctx->is_disabled) {                                   \
-                    dst[x] = src[x];                                      \
-                } else {                                                  \
-                    dst[x] = lrintf(v);                                   \
-                }                                                         \
-            }                                                             \
-                                                                          \
-            src += in->linesize[p] / sizeof(type);                        \
-            osrc += s->planewidth[p];                                     \
-            dst += out->linesize[p] / sizeof(type);                       \
-        }                                                                 \
-    }                                                                     \
-                                                                          \
-    return 0;                                                             \
+static int lagfun_frame8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+    LagfunContext *s = ctx->priv;
+    const float decay = s->decay;
+    ThreadData *td = arg;
+    AVFrame *in = td->in;
+    AVFrame *out = td->out;
+    AVFrame *old = td->old;
+
+    for (int p = 0; p < s->nb_planes; p++) {
+        const int slice_start = (s->height[p] * jobnr) / nb_jobs;
+        const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs;
+        const uint8_t *src = in->data[p] + slice_start * in->linesize[p];
+        const uint8_t *osrc = old->data[p] + slice_start * old->linesize[p];
+        uint8_t *dst = out->data[p] + slice_start * out->linesize[p];
+
+        if (!((1 << p) & s->planes)) {
+            av_image_copy_plane(dst, out->linesize[p],
+                                src, in->linesize[p],
+                                s->linesize[p], slice_end - slice_start);
+            continue;
+        }
+
+        for (int y = slice_start; y < slice_end; y++) {
+            for (int x = 0; x < s->linesize[p]; x++)
+                dst[x] = FFMAX(src[x], osrc[x] * decay);
+
+            src += in->linesize[p];
+            osrc += old->linesize[p];
+            dst += out->linesize[p];
+        }
+    }
+
+    return 0;
 }
 
-LAGFUN(8, uint8_t)
-LAGFUN(16, uint16_t)
+static int lagfun_frame16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+    LagfunContext *s = ctx->priv;
+    const float decay = s->decay;
+    ThreadData *td = arg;
+    AVFrame *in = td->in;
+    AVFrame *out = td->out;
+    AVFrame *old = td->old;
+
+    for (int p = 0; p < s->nb_planes; p++) {
+        const int slice_start = (s->height[p] * jobnr) / nb_jobs;
+        const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs;
+        const uint16_t *src = (const uint16_t *)in->data[p] + slice_start * in->linesize[p] / 2;
+        const uint16_t *osrc = (const uint16_t *)old->data[p] + slice_start * old->linesize[p] / 2;
+        uint16_t *dst = (uint16_t *)out->data[p] + slice_start * out->linesize[p] / 2;
+
+        if (!((1 << p) & s->planes)) {
+            av_image_copy_plane((uint8_t *)dst, out->linesize[p],
+                                (uint8_t *)src, in->linesize[p],
+                                s->linesize[p], slice_end - slice_start);
+            continue;
+        }
+
+        for (int y = slice_start; y < slice_end; y++) {
+            for (int x = 0; x < s->linesize[p] / 2; x++)
+                dst[x] = FFMAX(src[x], osrc[x] * decay);
+
+            src += in->linesize[p] / 2;
+            osrc += old->linesize[p] / 2;
+            dst += out->linesize[p] / 2;
+        }
+    }
+
+    return 0;
+}
 
 static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     LagfunContext *s = ctx->priv;
     AVFilterLink *inlink = ctx->inputs[0];
-    const AVPixFmtDescriptor *desc;
     int ret;
 
-    desc = av_pix_fmt_desc_get(outlink->format);
-    if (!desc)
+    s->desc = av_pix_fmt_desc_get(outlink->format);
+    if (!s->desc)
         return AVERROR_BUG;
     s->nb_planes = av_pix_fmt_count_planes(outlink->format);
-    s->depth = desc->comp[0].depth;
+    s->depth = s->desc->comp[0].depth;
     s->lagfun = s->depth <= 8 ? lagfun_frame8 : lagfun_frame16;
 
     if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
         return ret;
 
-    s->planewidth[1]  = s->planewidth[2]  = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0]  = s->planewidth[3]  = inlink->w;
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-
-    for (int p = 0; p < s->nb_planes; p++) {
-        s->old[p] = av_calloc(s->planewidth[p] * s->planeheight[p], sizeof(*s->old[0]));
-        if (!s->old[p])
-            return AVERROR(ENOMEM);
-    }
+    s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, s->desc->log2_chroma_h);
+    s->height[0] = s->height[3] = inlink->h;
 
     return 0;
 }
@@ -167,6 +180,11 @@
     ThreadData td;
     AVFrame *out;
 
+    if (!s->old) {
+        s->old = av_frame_clone(in);
+        return ff_filter_frame(outlink, in);
+    }
+
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out) {
         av_frame_free(&in);
@@ -176,9 +194,12 @@
 
     td.out = out;
     td.in = in;
-    ctx->internal->execute(ctx, s->lagfun, &td, NULL, FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+    td.old = s->old;
+    ctx->internal->execute(ctx, s->lagfun, &td, NULL, FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
 
+    av_frame_free(&s->old);
     av_frame_free(&in);
+    s->old = av_frame_clone(out);
     return ff_filter_frame(outlink, out);
 }
 
@@ -186,12 +207,11 @@
 {
     LagfunContext *s = ctx->priv;
 
-    for (int p = 0; p < s->nb_planes; p++)
-        av_freep(&s->old[p]);
+    av_frame_free(&s->old);
 }
 
 #define OFFSET(x) offsetof(LagfunContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption lagfun_options[] = {
     { "decay",  "set decay",                 OFFSET(decay),  AV_OPT_TYPE_FLOAT, {.dbl=.95},  0,  1,  FLAGS },
@@ -228,6 +248,5 @@
     .uninit        = uninit,
     .outputs       = outputs,
     .inputs        = inputs,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-    .process_command = ff_filter_process_command,
+    .flags         = AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c
index 9386f79..bb8ea37 100644
--- a/libavfilter/vf_lenscorrection.c
+++ b/libavfilter/vf_lenscorrection.c
@@ -26,43 +26,30 @@
 #include <stdlib.h>
 #include <math.h>
 
-#include "libavutil/colorspace.h"
 #include "libavutil/opt.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
 
 #include "avfilter.h"
-#include "drawutils.h"
 #include "internal.h"
 #include "video.h"
 
 typedef struct LenscorrectionCtx {
     const AVClass *av_class;
-    int planewidth[4];
-    int planeheight[4];
-    int depth;
+    int width;
+    int height;
+    int hsub, vsub;
     int nb_planes;
     double cx, cy, k1, k2;
-    int interpolation;
-    uint8_t fill_rgba[4];
-    int fill_color[4];
-
     int32_t *correction[4];
-
-    int (*filter_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs, int plane);
 } LenscorrectionCtx;
 
-#define OFFSET(x) offsetof(LenscorrectionCtx, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption lenscorrection_options[] = {
-    { "cx", "set relative center x", OFFSET(cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS },
-    { "cy", "set relative center y", OFFSET(cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS },
-    { "k1", "set quadratic distortion factor", OFFSET(k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS },
-    { "k2", "set double quadratic distortion factor", OFFSET(k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS },
-    { "i",  "set interpolation type", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=0}, 0, 64, .flags=FLAGS, "i" },
-    {  "nearest",  "nearest neighbour", 0,                   AV_OPT_TYPE_CONST, {.i64=0},0, 0, .flags=FLAGS, "i" },
-    {  "bilinear", "bilinear",          0,                   AV_OPT_TYPE_CONST, {.i64=1},0, 0, .flags=FLAGS, "i" },
-    { "fc", "set the color of the unmapped pixels", OFFSET(fill_rgba), AV_OPT_TYPE_COLOR, {.str="black@0"}, .flags = FLAGS },
+    { "cx",     "set relative center x", offsetof(LenscorrectionCtx, cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS },
+    { "cy",     "set relative center y", offsetof(LenscorrectionCtx, cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS },
+    { "k1",     "set quadratic distortion factor", offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS },
+    { "k2",     "set double quadratic distortion factor", offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS },
     { NULL }
 };
 
@@ -70,137 +57,54 @@
 
 typedef struct ThreadData {
     AVFrame *in, *out;
+    int w, h;
+    int plane;
+    int xcenter, ycenter;
+    int32_t *correction;
 } ThreadData;
 
-#define NEAREST(type, name)                                                    \
-static int filter##name##_slice(AVFilterContext *ctx, void *arg, int job,      \
-                                int nb_jobs, int plane)                        \
-{                                                                              \
-    LenscorrectionCtx *rect = ctx->priv;                                       \
-    ThreadData *td = arg;                                                      \
-    AVFrame *in = td->in;                                                      \
-    AVFrame *out = td->out;                                                    \
-                                                                               \
-    const int32_t *correction = rect->correction[plane];                       \
-    const int fill_color = rect->fill_color[plane];                            \
-    const int w = rect->planewidth[plane], h = rect->planeheight[plane];       \
-    const int xcenter = rect->cx * w;                                          \
-    const int ycenter = rect->cy * h;                                          \
-    const int start = (h *  job   ) / nb_jobs;                                 \
-    const int end   = (h * (job+1)) / nb_jobs;                                 \
-    const int inlinesize = in->linesize[plane] / sizeof(type);                 \
-    const int outlinesize = out->linesize[plane] / sizeof(type);               \
-    const type *indata = (const type *)in->data[plane];                        \
-    type *outrow = (type *)out->data[plane] + start * outlinesize;             \
-    for (int i = start; i < end; i++, outrow += outlinesize) {                 \
-        const int off_y = i - ycenter;                                         \
-        type *out = outrow;                                                    \
-        for (int j = 0; j < w; j++) {                                          \
-            const int off_x = j - xcenter;                                     \
-            const int64_t radius_mult = correction[j + i*w];                   \
-            const int x = xcenter + ((radius_mult * off_x + (1<<23))>>24);     \
-            const int y = ycenter + ((radius_mult * off_y + (1<<23))>>24);     \
-            const char isvalid = x >= 0 && x < w && y >= 0 && y < h;           \
-            *out++ =  isvalid ? indata[y * inlinesize + x] : fill_color;       \
-        }                                                                      \
-    }                                                                          \
-    return 0;                                                                  \
+static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
+{
+    ThreadData *td = arg;
+    AVFrame *in = td->in;
+    AVFrame *out = td->out;
+
+    const int w = td->w, h = td->h;
+    const int xcenter = td->xcenter;
+    const int ycenter = td->ycenter;
+    const int start = (h *  job   ) / nb_jobs;
+    const int end   = (h * (job+1)) / nb_jobs;
+    const int plane = td->plane;
+    const int inlinesize = in->linesize[plane];
+    const int outlinesize = out->linesize[plane];
+    const uint8_t *indata = in->data[plane];
+    uint8_t *outrow = out->data[plane] + start * outlinesize;
+    int i;
+    for (i = start; i < end; i++, outrow += outlinesize) {
+        const int off_y = i - ycenter;
+        uint8_t *out = outrow;
+        int j;
+        for (j = 0; j < w; j++) {
+            const int off_x = j - xcenter;
+            const int64_t radius_mult = td->correction[j + i*w];
+            const int x = xcenter + ((radius_mult * off_x + (1<<23))>>24);
+            const int y = ycenter + ((radius_mult * off_y + (1<<23))>>24);
+            const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1;
+            *out++ =  isvalid ? indata[y * inlinesize + x] : 0;
+        }
+    }
+    return 0;
 }
 
-
-NEAREST(uint8_t, 8)
-NEAREST(uint16_t, 16)
-
-#define BILINEAR(type, name)                                                   \
-static int filter##name##_slice_bilinear(AVFilterContext *ctx, void *arg,      \
-                                         int job, int nb_jobs, int plane)      \
-{                                                                              \
-    LenscorrectionCtx *rect = ctx->priv;                                       \
-    ThreadData *td = arg;                                                      \
-    AVFrame *in = td->in;                                                      \
-    AVFrame *out = td->out;                                                    \
-                                                                               \
-    const int32_t *correction = rect->correction[plane];                       \
-    const int fill_color = rect->fill_color[plane];                            \
-    const int depth = rect->depth;                                             \
-    const uint64_t max = (1 << 24) - 1;                                        \
-    const uint64_t add = (1 << 23);                                            \
-    const int w = rect->planewidth[plane], h = rect->planeheight[plane];       \
-    const int xcenter = rect->cx * w;                                          \
-    const int ycenter = rect->cy * h;                                          \
-    const int start = (h *  job   ) / nb_jobs;                                 \
-    const int end   = (h * (job+1)) / nb_jobs;                                 \
-    const int inlinesize = in->linesize[plane] / sizeof(type);                 \
-    const int outlinesize = out->linesize[plane] / sizeof(type);               \
-    const type *indata = (const type *)in->data[plane];                        \
-    type *outrow = (type *)out->data[plane] + start * outlinesize;             \
-                                                                               \
-    for (int i = start; i < end; i++, outrow += outlinesize) {                 \
-        const int off_y = i - ycenter;                                         \
-        type *out = outrow;                                                    \
-                                                                               \
-        for (int j = 0; j < w; j++) {                                          \
-            const int off_x = j - xcenter;                                     \
-            const int64_t radius_mult = correction[j + i*w];                   \
-            const int x = xcenter + ((radius_mult * off_x + (1<<23)) >> 24);   \
-            const int y = ycenter + ((radius_mult * off_y + (1<<23)) >> 24);   \
-            const char isvalid = x >= 0 && x <= w - 1 && y >= 0 && y <= h - 1; \
-                                                                               \
-            if (isvalid) {                                                     \
-                const int nx = FFMIN(x + 1, w - 1);                            \
-                const int ny = FFMIN(y + 1, h - 1);                            \
-                const uint64_t du = off_x >= 0 ? (radius_mult * off_x + add) & max : max - ((radius_mult * -off_x + add) & max); \
-                const uint64_t dv = off_y >= 0 ? (radius_mult * off_y + add) & max : max - ((radius_mult * -off_y + add) & max); \
-                const uint64_t p0 = indata[ y * inlinesize +  x];              \
-                const uint64_t p1 = indata[ y * inlinesize + nx];              \
-                const uint64_t p2 = indata[ny * inlinesize +  x];              \
-                const uint64_t p3 = indata[ny * inlinesize + nx];              \
-                uint64_t sum = 0;                                              \
-                                                                               \
-                sum += (max - du) * (max - dv) * p0;                           \
-                sum += (      du) * (max - dv) * p1;                           \
-                sum += (max - du) * (      dv) * p2;                           \
-                sum += (      du) * (      dv) * p3;                           \
-                                                                               \
-                out[j] = av_clip_uintp2_c((sum + (1ULL << 47)) >> 48, depth);  \
-            } else {                                                           \
-                out[j] = fill_color;                                           \
-            }                                                                  \
-        }                                                                      \
-    }                                                                          \
-                                                                               \
-    return 0;                                                                  \
-}
-
-BILINEAR(uint8_t, 8)
-BILINEAR(uint16_t, 16)
-
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
-        AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
-        AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-        AV_PIX_FMT_GBRAP,     AV_PIX_FMT_GBRAP10,    AV_PIX_FMT_GBRAP12,    AV_PIX_FMT_GBRAP16,
+        AV_PIX_FMT_YUV410P,
+        AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUVJ444P,
+        AV_PIX_FMT_YUV420P,  AV_PIX_FMT_YUVJ420P,
+        AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P,
+        AV_PIX_FMT_YUV422P,
+        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
         AV_PIX_FMT_NONE
     };
     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
@@ -219,86 +123,17 @@
     }
 }
 
-static void calc_correction(AVFilterContext *ctx, int plane)
-{
-    LenscorrectionCtx *rect = ctx->priv;
-    int w = rect->planewidth[plane];
-    int h = rect->planeheight[plane];
-    int xcenter = rect->cx * w;
-    int ycenter = rect->cy * h;
-    int k1 = rect->k1 * (1<<24);
-    int k2 = rect->k2 * (1<<24);
-    const int64_t r2inv = (4LL<<60) / (w * w + h * h);
-
-    for (int j = 0; j < h; j++) {
-        const int off_y = j - ycenter;
-        const int off_y2 = off_y * off_y;
-        for (int i = 0; i < w; i++) {
-            const int off_x = i - xcenter;
-            const int64_t r2 = ((off_x * off_x + off_y2) * r2inv + (1LL<<31)) >> 32;
-            const int64_t r4 = (r2 * r2 + (1<<27)) >> 28;
-            const int radius_mult = (r2 * k1 + r4 * k2 + (1LL<<27) + (1LL<<52))>>28;
-            rect->correction[plane][j * w + i] = radius_mult;
-        }
-    }
-}
-
-static int config_output(AVFilterLink *outlink)
+static int config_props(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     LenscorrectionCtx *rect = ctx->priv;
     AVFilterLink *inlink = ctx->inputs[0];
     const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format);
-    int is_rgb = !!(pixdesc->flags & AV_PIX_FMT_FLAG_RGB);
-    uint8_t rgba_map[4];
-    int factor;
-
-    ff_fill_rgba_map(rgba_map, inlink->format);
-    rect->depth = pixdesc->comp[0].depth;
-    factor = 1 << (rect->depth - 8);
-    rect->planeheight[1] = rect->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, pixdesc->log2_chroma_h);
-    rect->planeheight[0] = rect->planeheight[3] = inlink->h;
-    rect->planewidth[1]  = rect->planewidth[2]  = AV_CEIL_RSHIFT(inlink->w, pixdesc->log2_chroma_w);
-    rect->planewidth[0]  = rect->planewidth[3]  = inlink->w;
+    rect->hsub = pixdesc->log2_chroma_w;
+    rect->vsub = pixdesc->log2_chroma_h;
+    outlink->w = rect->width = inlink->w;
+    outlink->h = rect->height = inlink->h;
     rect->nb_planes = av_pix_fmt_count_planes(inlink->format);
-    rect->filter_slice = rect->depth <= 8 ? filter8_slice : filter16_slice;
-    if (rect->interpolation)
-        rect->filter_slice = rect->depth <= 8 ? filter8_slice_bilinear : filter16_slice_bilinear;
-
-    if (is_rgb) {
-        rect->fill_color[rgba_map[0]] = rect->fill_rgba[0] * factor;
-        rect->fill_color[rgba_map[1]] = rect->fill_rgba[1] * factor;
-        rect->fill_color[rgba_map[2]] = rect->fill_rgba[2] * factor;
-        rect->fill_color[rgba_map[3]] = rect->fill_rgba[3] * factor;
-    } else {
-        rect->fill_color[0] = RGB_TO_Y_BT709(rect->fill_rgba[0], rect->fill_rgba[1], rect->fill_rgba[2]) * factor;
-        rect->fill_color[1] = RGB_TO_U_BT709(rect->fill_rgba[0], rect->fill_rgba[1], rect->fill_rgba[2], 0) * factor;
-        rect->fill_color[2] = RGB_TO_V_BT709(rect->fill_rgba[0], rect->fill_rgba[1], rect->fill_rgba[2], 0) * factor;
-        rect->fill_color[3] = rect->fill_rgba[3] * factor;
-    }
-
-    for (int plane = 0; plane < rect->nb_planes; plane++) {
-        int w = rect->planewidth[plane];
-        int h = rect->planeheight[plane];
-
-        if (!rect->correction[plane])
-            rect->correction[plane] = av_malloc_array(w, h * sizeof(**rect->correction));
-        if (!rect->correction[plane])
-            return AVERROR(ENOMEM);
-        calc_correction(ctx, plane);
-    }
-
-    return 0;
-}
-
-static int filter_slice(AVFilterContext *ctx, void *arg, int job,
-                        int nb_jobs)
-{
-    LenscorrectionCtx *rect = ctx->priv;
-
-    for (int plane = 0; plane < rect->nb_planes; plane++)
-        rect->filter_slice(ctx, arg, job, nb_jobs, plane);
-
     return 0;
 }
 
@@ -306,9 +141,9 @@
 {
     AVFilterContext *ctx = inlink->dst;
     AVFilterLink *outlink = ctx->outputs[0];
-    LenscorrectionCtx *rect = ctx->priv;
+    LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv;
     AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    ThreadData td;
+    int plane;
 
     if (!out) {
         av_frame_free(&in);
@@ -317,28 +152,52 @@
 
     av_frame_copy_props(out, in);
 
-    td.in = in; td.out = out;
-    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(rect->planeheight[1], ff_filter_get_nb_threads(ctx)));
+    for (plane = 0; plane < rect->nb_planes; ++plane) {
+        int hsub = plane == 1 || plane == 2 ? rect->hsub : 0;
+        int vsub = plane == 1 || plane == 2 ? rect->vsub : 0;
+        int w = AV_CEIL_RSHIFT(rect->width, hsub);
+        int h = AV_CEIL_RSHIFT(rect->height, vsub);
+        int xcenter = rect->cx * w;
+        int ycenter = rect->cy * h;
+        int k1 = rect->k1 * (1<<24);
+        int k2 = rect->k2 * (1<<24);
+        ThreadData td = {
+            .in = in,
+            .out  = out,
+            .w  = w,
+            .h  = h,
+            .xcenter = xcenter,
+            .ycenter = ycenter,
+            .plane = plane};
+
+        if (!rect->correction[plane]) {
+            int i,j;
+            const int64_t r2inv = (4LL<<60) / (w * w + h * h);
+
+            rect->correction[plane] = av_malloc_array(w, h * sizeof(**rect->correction));
+            if (!rect->correction[plane])
+                return AVERROR(ENOMEM);
+            for (j = 0; j < h; j++) {
+                const int off_y = j - ycenter;
+                const int off_y2 = off_y * off_y;
+                for (i = 0; i < w; i++) {
+                    const int off_x = i - xcenter;
+                    const int64_t r2 = ((off_x * off_x + off_y2) * r2inv + (1LL<<31)) >> 32;
+                    const int64_t r4 = (r2 * r2 + (1<<27)) >> 28;
+                    const int radius_mult = (r2 * k1 + r4 * k2 + (1LL<<27) + (1LL<<52))>>28;
+                    rect->correction[plane][j * w + i] = radius_mult;
+                }
+            }
+        }
+
+        td.correction = rect->correction[plane];
+        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ff_filter_get_nb_threads(ctx)));
+    }
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx,
-                           const char *cmd,
-                           const char *arg,
-                           char *res,
-                           int res_len,
-                           int flags)
-{
-    int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
-
-    if (ret < 0)
-        return ret;
-
-    return config_output(ctx->outputs[0]);
-}
-
 static const AVFilterPad lenscorrection_inputs[] = {
     {
         .name         = "default",
@@ -352,7 +211,7 @@
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_output,
+        .config_props = config_props,
     },
     { NULL }
 };
@@ -366,6 +225,5 @@
     .outputs       = lenscorrection_outputs,
     .priv_class    = &lenscorrection_class,
     .uninit        = uninit,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
+    .flags         = AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_lensfun.c b/libavfilter/vf_lensfun.c
index 430daa9..089121e 100644
--- a/libavfilter/vf_lensfun.c
+++ b/libavfilter/vf_lensfun.c
@@ -136,36 +136,27 @@
     const lfCamera **cameras;
     const lfLens **lenses;
 
-    db = lf_db_create();
+    if (!lensfun->make) {
+        av_log(ctx, AV_LOG_FATAL, "Option \"make\" not specified\n");
+        return AVERROR(EINVAL);
+    } else if (!lensfun->model) {
+        av_log(ctx, AV_LOG_FATAL, "Option \"model\" not specified\n");
+        return AVERROR(EINVAL);
+    } else if (!lensfun->lens_model) {
+        av_log(ctx, AV_LOG_FATAL, "Option \"lens_model\" not specified\n");
+        return AVERROR(EINVAL);
+    }
+
+    lensfun->lens = lf_lens_new();
+    lensfun->camera = lf_camera_new();
+
+    db = lf_db_new();
     if (lf_db_load(db) != LF_NO_ERROR) {
         lf_db_destroy(db);
         av_log(ctx, AV_LOG_FATAL, "Failed to load lensfun database\n");
         return AVERROR_INVALIDDATA;
     }
 
-    if (!lensfun->make || !lensfun->model) {
-        const lfCamera *const *cameras = lf_db_get_cameras(db);
-
-        av_log(ctx, AV_LOG_FATAL, "Option \"make\" or option \"model\" not specified\n");
-        av_log(ctx, AV_LOG_INFO, "Available values for \"make\" and \"model\":\n");
-        for (int i = 0; cameras && cameras[i]; i++)
-            av_log(ctx, AV_LOG_INFO, "\t%s\t%s\n", cameras[i]->Maker, cameras[i]->Model);
-        lf_db_destroy(db);
-        return AVERROR(EINVAL);
-    } else if (!lensfun->lens_model) {
-        const lfLens *const *lenses = lf_db_get_lenses(db);
-
-        av_log(ctx, AV_LOG_FATAL, "Option \"lens_model\" not specified\n");
-        av_log(ctx, AV_LOG_INFO, "Available values for \"lens_model\":\n");
-        for (int i = 0; lenses && lenses[i]; i++)
-            av_log(ctx, AV_LOG_INFO, "\t%s\t(make %s)\n", lenses[i]->Model, lenses[i]->Maker);
-        lf_db_destroy(db);
-        return AVERROR(EINVAL);
-    }
-
-    lensfun->lens = lf_lens_create();
-    lensfun->camera = lf_camera_create();
-
     cameras = lf_db_find_cameras(db, lensfun->make, lensfun->model);
     if (cameras && *cameras) {
         lf_camera_copy(lensfun->camera, *cameras);
@@ -178,7 +169,7 @@
     }
     lf_free(cameras);
 
-    lenses = lf_db_find_lenses(db, lensfun->camera, NULL, lensfun->lens_model, 0);
+    lenses = lf_db_find_lenses_hd(db, lensfun->camera, NULL, lensfun->lens_model, 0);
     if (lenses && *lenses) {
         lf_lens_copy(lensfun->lens, *lenses);
         av_log(ctx, AV_LOG_INFO, "Using lens %s\n", lensfun->lens->Model);
@@ -219,23 +210,30 @@
     LensfunContext *lensfun = ctx->priv;
     int index;
     float a;
+    int lensfun_mode = 0;
 
     if (!lensfun->modifier) {
         if (lensfun->camera && lensfun->lens) {
-            lensfun->modifier = lf_modifier_create(lensfun->lens,
-                                                   lensfun->focal_length,
-                                                   lensfun->camera->CropFactor,
-                                                   inlink->w,
-                                                   inlink->h, LF_PF_U8, lensfun->reverse);
+            lensfun->modifier = lf_modifier_new(lensfun->lens,
+                                                lensfun->camera->CropFactor,
+                                                inlink->w,
+                                                inlink->h);
             if (lensfun->mode & VIGNETTING)
-                lf_modifier_enable_vignetting_correction(lensfun->modifier, lensfun->aperture, lensfun->focus_distance);
-            if (lensfun->mode & GEOMETRY_DISTORTION) {
-                lf_modifier_enable_distortion_correction(lensfun->modifier);
-                lf_modifier_enable_projection_transform(lensfun->modifier, lensfun->target_geometry);
-                lf_modifier_enable_scaling(lensfun->modifier, lensfun->scale);
-            }
+                lensfun_mode |= LF_MODIFY_VIGNETTING;
+            if (lensfun->mode & GEOMETRY_DISTORTION)
+                lensfun_mode |= LF_MODIFY_DISTORTION | LF_MODIFY_GEOMETRY | LF_MODIFY_SCALE;
             if (lensfun->mode & SUBPIXEL_DISTORTION)
-                lf_modifier_enable_tca_correction(lensfun->modifier);
+                lensfun_mode |= LF_MODIFY_TCA;
+            lf_modifier_initialize(lensfun->modifier,
+                                   lensfun->lens,
+                                   LF_PF_U8,
+                                   lensfun->focal_length,
+                                   lensfun->aperture,
+                                   lensfun->focus_distance,
+                                   lensfun->scale,
+                                   lensfun->target_geometry,
+                                   lensfun_mode,
+                                   lensfun->reverse);
         } else {
             // lensfun->camera and lensfun->lens should have been initialized
             return AVERROR_BUG;
diff --git a/libavfilter/vf_limiter.c b/libavfilter/vf_limiter.c
index 1779c63..8db28fe 100644
--- a/libavfilter/vf_limiter.c
+++ b/libavfilter/vf_limiter.c
@@ -46,7 +46,7 @@
 } LimiterContext;
 
 #define OFFSET(x) offsetof(LimiterContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption limiter_options[] = {
     { "min",    "set min value", OFFSET(min),    AV_OPT_TYPE_INT, {.i64=0},     0, 65535, .flags = FLAGS },
@@ -133,7 +133,7 @@
     }
 }
 
-static int config_input(AVFilterLink *inlink)
+static int config_props(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
     LimiterContext *s = ctx->priv;
@@ -230,24 +230,12 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_input(ctx->inputs[0]);
-}
-
 static const AVFilterPad inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = filter_frame,
-        .config_props = config_input,
+        .config_props = config_props,
     },
     { NULL }
 };
@@ -270,5 +258,4 @@
     .inputs        = inputs,
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index 1a94e1c..1fdc5e1 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -81,7 +81,7 @@
 #define A 3
 
 #define OFFSET(x) offsetof(LutContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption options[] = {
     { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]),  AV_OPT_TYPE_STRING, { .str = "clipval" }, .flags = FLAGS },
@@ -566,17 +566,6 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-
-    if (ret < 0)
-        return ret;
-
-    return config_props(ctx->inputs[0]);
-}
-
 static const AVFilterPad inputs[] = {
     { .name         = "default",
       .type         = AVMEDIA_TYPE_VIDEO,
@@ -603,9 +592,7 @@
         .query_formats = query_formats,                                 \
         .inputs        = inputs,                                        \
         .outputs       = outputs,                                       \
-        .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |       \
-                         AVFILTER_FLAG_SLICE_THREADS,                   \
-        .process_command = process_command,                             \
+        .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,        \
     }
 
 #if CONFIG_LUT_FILTER
@@ -667,12 +654,17 @@
 static av_cold int negate_init(AVFilterContext *ctx)
 {
     LutContext *s = ctx->priv;
+    int i;
 
-    for (int i = 0; i < 4; i++) {
+    av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", s->negate_alpha);
+
+    for (i = 0; i < 4; i++) {
         s->comp_expr_str[i] = av_strdup((i == 3 && !s->negate_alpha) ?
                                           "val" : "negval");
-        if (!s->comp_expr_str[i])
+        if (!s->comp_expr_str[i]) {
+            uninit(ctx);
             return AVERROR(ENOMEM);
+        }
     }
 
     return 0;
diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c
index 8de8e11..1f8bc5d 100644
--- a/libavfilter/vf_lut2.c
+++ b/libavfilter/vf_lut2.c
@@ -79,13 +79,12 @@
 
 #define OFFSET(x) offsetof(LUT2Context, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
-#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption options[] = {
-    { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
-    { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
-    { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
-    { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
+    { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
+    { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
+    { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
+    { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
     { "d",  "set output depth",            OFFSET(odepth),            AV_OPT_TYPE_INT,    { .i64 =  0  }, 0, 16, .flags = FLAGS },
     { NULL }
 };
@@ -354,8 +353,7 @@
     }
 
     for (p = 0; p < s->nb_planes; p++) {
-        if (!s->lut[p])
-            s->lut[p] = av_malloc_array(1 << s->depth, sizeof(uint16_t));
+        s->lut[p] = av_malloc_array(1 << s->depth, sizeof(uint16_t));
         if (!s->lut[p])
             return AVERROR(ENOMEM);
     }
@@ -545,17 +543,6 @@
     { NULL }
 };
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-
-    if (ret < 0)
-        return ret;
-
-    return config_output(ctx->outputs[0]);
-}
-
 #define lut2_options options
 
 FRAMESYNC_DEFINE_CLASS(lut2, LUT2Context, fs);
@@ -573,7 +560,6 @@
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
                      AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 #if CONFIG_TLUT2_FILTER
@@ -624,10 +610,10 @@
 }
 
 static const AVOption tlut2_options[] = {
-    { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
-    { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
-    { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
-    { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
+    { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
+    { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
+    { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
+    { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]),  AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
     { NULL }
 };
 
@@ -664,7 +650,6 @@
     .outputs       = tlut2_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
                      AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 #endif
diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index 8b1aeb7..172d6df 100644
--- a/libavfilter/vf_lut3d.c
+++ b/libavfilter/vf_lut3d.c
@@ -49,8 +49,6 @@
     INTERPOLATE_NEAREST,
     INTERPOLATE_TRILINEAR,
     INTERPOLATE_TETRAHEDRAL,
-    INTERPOLATE_PYRAMID,
-    INTERPOLATE_PRISM,
     NB_INTERP_MODE
 };
 
@@ -100,14 +98,11 @@
 
 #define OFFSET(x) offsetof(LUT3DContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
-#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 #define COMMON_OPTIONS \
-    { "interp", "select interpolation mode", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERPOLATE_TETRAHEDRAL}, 0, NB_INTERP_MODE-1, TFLAGS, "interp_mode" }, \
-        { "nearest",     "use values from the nearest defined points",            0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_NEAREST},     0, 0, TFLAGS, "interp_mode" }, \
-        { "trilinear",   "interpolate values using the 8 points defining a cube", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_TRILINEAR},   0, 0, TFLAGS, "interp_mode" }, \
-        { "tetrahedral", "interpolate values using a tetrahedron",                0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_TETRAHEDRAL}, 0, 0, TFLAGS, "interp_mode" }, \
-        { "pyramid",     "interpolate values using a pyramid",                    0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_PYRAMID},     0, 0, TFLAGS, "interp_mode" }, \
-        { "prism",       "interpolate values using a prism",                      0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_PRISM},       0, 0, TFLAGS, "interp_mode" }, \
+    { "interp", "select interpolation mode", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERPOLATE_TETRAHEDRAL}, 0, NB_INTERP_MODE-1, FLAGS, "interp_mode" }, \
+        { "nearest",     "use values from the nearest defined points",            0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_NEAREST},     INT_MIN, INT_MAX, FLAGS, "interp_mode" }, \
+        { "trilinear",   "interpolate values using the 8 points defining a cube", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_TRILINEAR},   INT_MIN, INT_MAX, FLAGS, "interp_mode" }, \
+        { "tetrahedral", "interpolate values using a tetrahedron",                0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_TETRAHEDRAL}, INT_MIN, INT_MAX, FLAGS, "interp_mode" }, \
     { NULL }
 
 #define EXPONENT_MASK 0x7F800000
@@ -190,101 +185,6 @@
     return c;
 }
 
-static inline struct rgbvec interp_pyramid(const LUT3DContext *lut3d,
-                                           const struct rgbvec *s)
-{
-    const int lutsize2 = lut3d->lutsize2;
-    const int lutsize  = lut3d->lutsize;
-    const int prev[] = {PREV(s->r), PREV(s->g), PREV(s->b)};
-    const int next[] = {NEXT(s->r), NEXT(s->g), NEXT(s->b)};
-    const struct rgbvec d = {s->r - prev[0], s->g - prev[1], s->b - prev[2]};
-    const struct rgbvec c000 = lut3d->lut[prev[0] * lutsize2 + prev[1] * lutsize + prev[2]];
-    const struct rgbvec c111 = lut3d->lut[next[0] * lutsize2 + next[1] * lutsize + next[2]];
-    struct rgbvec c;
-
-    if (d.g > d.r && d.b > d.r) {
-        const struct rgbvec c001 = lut3d->lut[prev[0] * lutsize2 + prev[1] * lutsize + next[2]];
-        const struct rgbvec c010 = lut3d->lut[prev[0] * lutsize2 + next[1] * lutsize + prev[2]];
-        const struct rgbvec c011 = lut3d->lut[prev[0] * lutsize2 + next[1] * lutsize + next[2]];
-
-        c.r = c000.r + (c111.r - c011.r) * d.r + (c010.r - c000.r) * d.g + (c001.r - c000.r) * d.b +
-              (c011.r - c001.r - c010.r + c000.r) * d.g * d.b;
-        c.g = c000.g + (c111.g - c011.g) * d.r + (c010.g - c000.g) * d.g + (c001.g - c000.g) * d.b +
-              (c011.g - c001.g - c010.g + c000.g) * d.g * d.b;
-        c.b = c000.b + (c111.b - c011.b) * d.r + (c010.b - c000.b) * d.g + (c001.b - c000.b) * d.b +
-              (c011.b - c001.b - c010.b + c000.b) * d.g * d.b;
-    } else if (d.r > d.g && d.b > d.g) {
-        const struct rgbvec c001 = lut3d->lut[prev[0] * lutsize2 + prev[1] * lutsize + next[2]];
-        const struct rgbvec c100 = lut3d->lut[next[0] * lutsize2 + prev[1] * lutsize + prev[2]];
-        const struct rgbvec c101 = lut3d->lut[next[0] * lutsize2 + prev[1] * lutsize + next[2]];
-
-        c.r = c000.r + (c100.r - c000.r) * d.r + (c111.r - c101.r) * d.g + (c001.r - c000.r) * d.b +
-              (c101.r - c001.r - c100.r + c000.r) * d.r * d.b;
-        c.g = c000.g + (c100.g - c000.g) * d.r + (c111.g - c101.g) * d.g + (c001.g - c000.g) * d.b +
-              (c101.g - c001.g - c100.g + c000.g) * d.r * d.b;
-        c.b = c000.b + (c100.b - c000.b) * d.r + (c111.b - c101.b) * d.g + (c001.b - c000.b) * d.b +
-              (c101.b - c001.b - c100.b + c000.b) * d.r * d.b;
-    } else {
-        const struct rgbvec c010 = lut3d->lut[prev[0] * lutsize2 + next[1] * lutsize + prev[2]];
-        const struct rgbvec c110 = lut3d->lut[next[0] * lutsize2 + next[1] * lutsize + prev[2]];
-        const struct rgbvec c100 = lut3d->lut[next[0] * lutsize2 + prev[1] * lutsize + prev[2]];
-
-        c.r = c000.r + (c100.r - c000.r) * d.r + (c010.r - c000.r) * d.g + (c111.r - c110.r) * d.b +
-              (c110.r - c100.r - c010.r + c000.r) * d.r * d.g;
-        c.g = c000.g + (c100.g - c000.g) * d.r + (c010.g - c000.g) * d.g + (c111.g - c110.g) * d.b +
-              (c110.g - c100.g - c010.g + c000.g) * d.r * d.g;
-        c.b = c000.b + (c100.b - c000.b) * d.r + (c010.b - c000.b) * d.g + (c111.b - c110.b) * d.b +
-              (c110.b - c100.b - c010.b + c000.b) * d.r * d.g;
-    }
-
-    return c;
-}
-
-static inline struct rgbvec interp_prism(const LUT3DContext *lut3d,
-                                         const struct rgbvec *s)
-{
-    const int lutsize2 = lut3d->lutsize2;
-    const int lutsize  = lut3d->lutsize;
-    const int prev[] = {PREV(s->r), PREV(s->g), PREV(s->b)};
-    const int next[] = {NEXT(s->r), NEXT(s->g), NEXT(s->b)};
-    const struct rgbvec d = {s->r - prev[0], s->g - prev[1], s->b - prev[2]};
-    const struct rgbvec c000 = lut3d->lut[prev[0] * lutsize2 + prev[1] * lutsize + prev[2]];
-    const struct rgbvec c010 = lut3d->lut[prev[0] * lutsize2 + next[1] * lutsize + prev[2]];
-    const struct rgbvec c101 = lut3d->lut[next[0] * lutsize2 + prev[1] * lutsize + next[2]];
-    const struct rgbvec c111 = lut3d->lut[next[0] * lutsize2 + next[1] * lutsize + next[2]];
-    struct rgbvec c;
-
-    if (d.b > d.r) {
-        const struct rgbvec c001 = lut3d->lut[prev[0] * lutsize2 + prev[1] * lutsize + next[2]];
-        const struct rgbvec c011 = lut3d->lut[prev[0] * lutsize2 + next[1] * lutsize + next[2]];
-
-        c.r = c000.r + (c001.r - c000.r) * d.b + (c101.r - c001.r) * d.r + (c010.r - c000.r) * d.g +
-              (c000.r - c010.r - c001.r + c011.r) * d.b * d.g +
-              (c001.r - c011.r - c101.r + c111.r) * d.r * d.g;
-        c.g = c000.g + (c001.g - c000.g) * d.b + (c101.g - c001.g) * d.r + (c010.g - c000.g) * d.g +
-              (c000.g - c010.g - c001.g + c011.g) * d.b * d.g +
-              (c001.g - c011.g - c101.g + c111.g) * d.r * d.g;
-        c.b = c000.b + (c001.b - c000.b) * d.b + (c101.b - c001.b) * d.r + (c010.b - c000.b) * d.g +
-              (c000.b - c010.b - c001.b + c011.b) * d.b * d.g +
-              (c001.b - c011.b - c101.b + c111.b) * d.r * d.g;
-    } else {
-        const struct rgbvec c110 = lut3d->lut[next[0] * lutsize2 + next[1] * lutsize + prev[2]];
-        const struct rgbvec c100 = lut3d->lut[next[0] * lutsize2 + prev[1] * lutsize + prev[2]];
-
-        c.r = c000.r + (c101.r - c100.r) * d.b + (c100.r - c000.r) * d.r + (c010.r - c000.r) * d.g +
-              (c100.r - c110.r - c101.r + c111.r) * d.b * d.g +
-              (c000.r - c010.r - c100.r + c110.r) * d.r * d.g;
-        c.g = c000.g + (c101.g - c100.g) * d.b + (c100.g - c000.g) * d.r + (c010.g - c000.g) * d.g +
-              (c100.g - c110.g - c101.g + c111.g) * d.b * d.g +
-              (c000.g - c010.g - c100.g + c110.g) * d.r * d.g;
-        c.b = c000.b + (c101.b - c100.b) * d.b + (c100.b - c000.b) * d.r + (c010.b - c000.b) * d.g +
-              (c100.b - c110.b - c101.b + c111.b) * d.b * d.g +
-              (c000.b - c010.b - c100.b + c110.b) * d.r * d.g;
-    }
-
-    return c;
-}
-
 /**
  * Tetrahedral interpolation. Based on code found in Truelight Software Library paper.
  * @see http://www.filmlight.ltd.uk/pdf/whitepapers/FL-TL-TN-0057-SoftwareLib.pdf
@@ -437,38 +337,26 @@
 DEFINE_INTERP_FUNC_PLANAR(nearest,     8, 8)
 DEFINE_INTERP_FUNC_PLANAR(trilinear,   8, 8)
 DEFINE_INTERP_FUNC_PLANAR(tetrahedral, 8, 8)
-DEFINE_INTERP_FUNC_PLANAR(pyramid,     8, 8)
-DEFINE_INTERP_FUNC_PLANAR(prism,       8, 8)
 
 DEFINE_INTERP_FUNC_PLANAR(nearest,     16, 9)
 DEFINE_INTERP_FUNC_PLANAR(trilinear,   16, 9)
 DEFINE_INTERP_FUNC_PLANAR(tetrahedral, 16, 9)
-DEFINE_INTERP_FUNC_PLANAR(pyramid,     16, 9)
-DEFINE_INTERP_FUNC_PLANAR(prism,       16, 9)
 
 DEFINE_INTERP_FUNC_PLANAR(nearest,     16, 10)
 DEFINE_INTERP_FUNC_PLANAR(trilinear,   16, 10)
 DEFINE_INTERP_FUNC_PLANAR(tetrahedral, 16, 10)
-DEFINE_INTERP_FUNC_PLANAR(pyramid,     16, 10)
-DEFINE_INTERP_FUNC_PLANAR(prism,       16, 10)
 
 DEFINE_INTERP_FUNC_PLANAR(nearest,     16, 12)
 DEFINE_INTERP_FUNC_PLANAR(trilinear,   16, 12)
 DEFINE_INTERP_FUNC_PLANAR(tetrahedral, 16, 12)
-DEFINE_INTERP_FUNC_PLANAR(pyramid,     16, 12)
-DEFINE_INTERP_FUNC_PLANAR(prism,       16, 12)
 
 DEFINE_INTERP_FUNC_PLANAR(nearest,     16, 14)
 DEFINE_INTERP_FUNC_PLANAR(trilinear,   16, 14)
 DEFINE_INTERP_FUNC_PLANAR(tetrahedral, 16, 14)
-DEFINE_INTERP_FUNC_PLANAR(pyramid,     16, 14)
-DEFINE_INTERP_FUNC_PLANAR(prism,       16, 14)
 
 DEFINE_INTERP_FUNC_PLANAR(nearest,     16, 16)
 DEFINE_INTERP_FUNC_PLANAR(trilinear,   16, 16)
 DEFINE_INTERP_FUNC_PLANAR(tetrahedral, 16, 16)
-DEFINE_INTERP_FUNC_PLANAR(pyramid,     16, 16)
-DEFINE_INTERP_FUNC_PLANAR(prism,       16, 16)
 
 #define DEFINE_INTERP_FUNC_PLANAR_FLOAT(name, depth)                                                   \
 static int interp_##name##_pf##depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)          \
@@ -534,8 +422,6 @@
 DEFINE_INTERP_FUNC_PLANAR_FLOAT(nearest,     32)
 DEFINE_INTERP_FUNC_PLANAR_FLOAT(trilinear,   32)
 DEFINE_INTERP_FUNC_PLANAR_FLOAT(tetrahedral, 32)
-DEFINE_INTERP_FUNC_PLANAR_FLOAT(pyramid,     32)
-DEFINE_INTERP_FUNC_PLANAR_FLOAT(prism,       32)
 
 #define DEFINE_INTERP_FUNC(name, nbits)                                                             \
 static int interp_##nbits##_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)         \
@@ -589,14 +475,10 @@
 DEFINE_INTERP_FUNC(nearest,     8)
 DEFINE_INTERP_FUNC(trilinear,   8)
 DEFINE_INTERP_FUNC(tetrahedral, 8)
-DEFINE_INTERP_FUNC(pyramid,     8)
-DEFINE_INTERP_FUNC(prism,       8)
 
 DEFINE_INTERP_FUNC(nearest,     16)
 DEFINE_INTERP_FUNC(trilinear,   16)
 DEFINE_INTERP_FUNC(tetrahedral, 16)
-DEFINE_INTERP_FUNC(pyramid,     16)
-DEFINE_INTERP_FUNC(prism,       16)
 
 #define MAX_LINE_SIZE 512
 
@@ -1204,8 +1086,6 @@
     case INTERPOLATE_NEAREST:     SET_FUNC(nearest);        break;
     case INTERPOLATE_TRILINEAR:   SET_FUNC(trilinear);      break;
     case INTERPOLATE_TETRAHEDRAL: SET_FUNC(tetrahedral);    break;
-    case INTERPOLATE_PYRAMID:     SET_FUNC(pyramid);        break;
-    case INTERPOLATE_PRISM:       SET_FUNC(prism);          break;
     default:
         av_assert0(0);
     }
@@ -1251,18 +1131,6 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return config_input(ctx->inputs[0]);
-}
-
 #if CONFIG_LUT3D_FILTER
 static const AVOption lut3d_options[] = {
     { "file", "set 3D LUT file name", OFFSET(file), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
@@ -1364,7 +1232,6 @@
     .outputs       = lut3d_outputs,
     .priv_class    = &lut3d_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 #endif
 
@@ -1633,7 +1500,6 @@
     .outputs       = haldclut_outputs,
     .priv_class    = &haldclut_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 #endif
 
@@ -1813,13 +1679,13 @@
 }
 
 static const AVOption lut1d_options[] = {
-    { "file", "set 1D LUT file name", OFFSET(file), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = TFLAGS },
-    { "interp", "select interpolation mode", OFFSET(interpolation),    AV_OPT_TYPE_INT, {.i64=INTERPOLATE_1D_LINEAR}, 0, NB_INTERP_1D_MODE-1, TFLAGS, "interp_mode" },
-        { "nearest", "use values from the nearest defined points", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_NEAREST},   0, 0, TFLAGS, "interp_mode" },
-        { "linear",  "use values from the linear interpolation",   0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_LINEAR},    0, 0, TFLAGS, "interp_mode" },
-        { "cosine",  "use values from the cosine interpolation",   0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_COSINE},    0, 0, TFLAGS, "interp_mode" },
-        { "cubic",   "use values from the cubic interpolation",    0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_CUBIC},     0, 0, TFLAGS, "interp_mode" },
-        { "spline",  "use values from the spline interpolation",   0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_SPLINE},    0, 0, TFLAGS, "interp_mode" },
+    { "file", "set 1D LUT file name", OFFSET(file), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
+    { "interp", "select interpolation mode", OFFSET(interpolation),    AV_OPT_TYPE_INT, {.i64=INTERPOLATE_1D_LINEAR}, 0, NB_INTERP_1D_MODE-1, FLAGS, "interp_mode" },
+        { "nearest", "use values from the nearest defined points", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_NEAREST},   INT_MIN, INT_MAX, FLAGS, "interp_mode" },
+        { "linear",  "use values from the linear interpolation",   0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_LINEAR},    INT_MIN, INT_MAX, FLAGS, "interp_mode" },
+        { "cosine",  "use values from the cosine interpolation",   0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_COSINE},    INT_MIN, INT_MAX, FLAGS, "interp_mode" },
+        { "cubic",   "use values from the cubic interpolation",    0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_CUBIC},     INT_MIN, INT_MAX, FLAGS, "interp_mode" },
+        { "spline",  "use values from the spline interpolation",   0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_SPLINE},    INT_MIN, INT_MAX, FLAGS, "interp_mode" },
     { NULL }
 };
 
@@ -2249,24 +2115,6 @@
     return ff_filter_frame(outlink, out);
 }
 
-static int lut1d_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    LUT1DContext *lut1d = ctx->priv;
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    ret = lut1d_init(ctx);
-    if (ret < 0) {
-        set_identity_matrix_1d(lut1d, 32);
-        return ret;
-    }
-    return config_input_1d(ctx->inputs[0]);
-}
-
 static const AVFilterPad lut1d_inputs[] = {
     {
         .name         = "default",
@@ -2295,6 +2143,5 @@
     .outputs       = lut1d_outputs,
     .priv_class    = &lut1d_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = lut1d_process_command,
 };
 #endif
diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c
index af2793b..52392c4 100644
--- a/libavfilter/vf_maskedclamp.c
+++ b/libavfilter/vf_maskedclamp.c
@@ -29,7 +29,7 @@
 #include "maskedclamp.h"
 
 #define OFFSET(x) offsetof(MaskedClampContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 typedef struct ThreadData {
     AVFrame *b, *o, *m, *d;
@@ -327,5 +327,4 @@
     .outputs       = maskedclamp_outputs,
     .priv_class    = &maskedclamp_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c
index 2f83fb5..82f55e6 100644
--- a/libavfilter/vf_maskedmerge.c
+++ b/libavfilter/vf_maskedmerge.c
@@ -28,7 +28,7 @@
 #include "maskedmerge.h"
 
 #define OFFSET(x) offsetof(MaskedMergeContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption maskedmerge_options[] = {
     { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
@@ -46,7 +46,7 @@
         AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
         AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
         AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV440P10,
+        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
         AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12,
         AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
         AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
@@ -328,5 +328,4 @@
     .outputs       = maskedmerge_outputs,
     .priv_class    = &maskedmerge_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_maskedminmax.c b/libavfilter/vf_maskedminmax.c
index 9014082..0685c8a 100644
--- a/libavfilter/vf_maskedminmax.c
+++ b/libavfilter/vf_maskedminmax.c
@@ -28,7 +28,7 @@
 #include "framesync.h"
 
 #define OFFSET(x) offsetof(MaskedMinMaxContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 typedef struct ThreadData {
     AVFrame *src, *f1, *f2, *dst;
@@ -50,7 +50,7 @@
 } MaskedMinMaxContext;
 
 static const AVOption maskedminmax_options[] = {
-    { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
+    { "planes",     "set planes",     OFFSET(planes),     AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF,        FLAGS },
     { NULL }
 };
 
@@ -340,7 +340,6 @@
     .inputs        = maskedminmax_inputs,
     .outputs       = maskedminmax_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
 };
 
 #define maskedmax_options maskedminmax_options
@@ -358,5 +357,4 @@
     .inputs        = maskedminmax_inputs,
     .outputs       = maskedminmax_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_maskedthreshold.c b/libavfilter/vf_maskedthreshold.c
index 5a6ebb1..d925819 100644
--- a/libavfilter/vf_maskedthreshold.c
+++ b/libavfilter/vf_maskedthreshold.c
@@ -43,7 +43,7 @@
 } MaskedThresholdContext;
 
 #define OFFSET(x) offsetof(MaskedThresholdContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 typedef struct ThreadData {
     AVFrame *src, *ref, *dst;
@@ -295,5 +295,4 @@
     .inputs        = maskedthreshold_inputs,
     .outputs       = maskedthreshold_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_maskfun.c b/libavfilter/vf_maskfun.c
index 55a4c57..4ceb21b 100644
--- a/libavfilter/vf_maskfun.c
+++ b/libavfilter/vf_maskfun.c
@@ -47,14 +47,14 @@
 } MaskFunContext;
 
 #define OFFSET(x) offsetof(MaskFunContext, x)
-#define VFT AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption maskfun_options[] = {
-    { "low",    "set low threshold",  OFFSET(low),    AV_OPT_TYPE_INT, {.i64=10},  0, UINT16_MAX, VFT },
-    { "high",   "set high threshold", OFFSET(high),   AV_OPT_TYPE_INT, {.i64=10},  0, UINT16_MAX, VFT },
-    { "planes", "set planes",         OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF,        VFT },
-    { "fill",   "set fill value",     OFFSET(fill),   AV_OPT_TYPE_INT, {.i64=0},   0, UINT16_MAX, VFT },
-    { "sum",    "set sum value",      OFFSET(sum),    AV_OPT_TYPE_INT, {.i64=10},  0, UINT16_MAX, VFT },
+    { "low",    "set low threshold",  OFFSET(low),    AV_OPT_TYPE_INT, {.i64=10},  0, UINT16_MAX, VF },
+    { "high",   "set high threshold", OFFSET(high),   AV_OPT_TYPE_INT, {.i64=10},  0, UINT16_MAX, VF },
+    { "planes", "set planes",         OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF,        VF },
+    { "fill",   "set fill value",     OFFSET(fill),   AV_OPT_TYPE_INT, {.i64=0},   0, UINT16_MAX, VF },
+    { "sum",    "set sum value",      OFFSET(sum),    AV_OPT_TYPE_INT, {.i64=10},  0, UINT16_MAX, VF },
     { NULL }
 };
 
@@ -182,45 +182,6 @@
 MASKFUN(8, uint8_t, 1)
 MASKFUN(16, uint16_t, 2)
 
-static void fill_frame(AVFilterContext *ctx)
-{
-    MaskFunContext *s = ctx->priv;
-
-    s->fill = FFMIN(s->fill, s->max);
-    if (s->depth == 8) {
-        for (int p = 0; p < s->nb_planes; p++) {
-            uint8_t *dst = s->empty->data[p];
-
-            for (int y = 0; y < s->height[p]; y++) {
-                memset(dst, s->fill, s->width[p]);
-                dst += s->empty->linesize[p];
-            }
-        }
-    } else {
-        for (int p = 0; p < s->nb_planes; p++) {
-            uint16_t *dst = (uint16_t *)s->empty->data[p];
-
-            for (int y = 0; y < s->height[p]; y++) {
-                for (int x = 0; x < s->width[p]; x++)
-                    dst[x] = s->fill;
-                dst += s->empty->linesize[p] / 2;
-            }
-        }
-    }
-}
-
-static void set_max_sum(AVFilterContext *ctx)
-{
-    MaskFunContext *s = ctx->priv;
-
-    s->max_sum = 0;
-    for (int p = 0; p < s->nb_planes; p++) {
-        if (!((1 << p) & s->planes))
-            continue;
-        s->max_sum += (uint64_t)s->sum * s->width[p] * s->height[p];
-    }
-}
-
 static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
@@ -242,6 +203,7 @@
 
     s->depth = desc->comp[0].depth;
     s->max = (1 << s->depth) - 1;
+    s->fill = FFMIN(s->fill, s->max);
 
     if (s->depth == 8) {
         s->maskfun = maskfun8;
@@ -255,30 +217,33 @@
     if (!s->empty)
         return AVERROR(ENOMEM);
 
-    fill_frame(ctx);
+    if (s->depth == 8) {
+        for (int p = 0; p < s->nb_planes; p++) {
+            uint8_t *dst = s->empty->data[p];
 
-    set_max_sum(ctx);
+            for (int y = 0; y < s->height[p]; y++) {
+                memset(dst, s->fill, s->width[p]);
+                dst += s->empty->linesize[p];
+            }
+        }
+    } else {
+        for (int p = 0; p < s->nb_planes; p++) {
+            uint16_t *dst = (uint16_t *)s->empty->data[p];
 
-    return 0;
-}
+            for (int y = 0; y < s->height[p]; y++) {
+                for (int x = 0; x < s->width[p]; x++)
+                    dst[x] = s->fill;
+                dst += s->empty->linesize[p] / 2;
+            }
+        }
+    }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    MaskFunContext *s = ctx->priv;
-    int fill = s->fill;
-    int sum = s->sum;
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    if (sum != s->sum)
-        set_max_sum(ctx);
-
-    if (fill != s->fill)
-        fill_frame(ctx);
+    s->max_sum = 0;
+    for (int p = 0; p < s->nb_planes; p++) {
+        if (!((1 << p) & s->planes))
+            continue;
+        s->max_sum += (uint64_t)s->sum * s->width[p] * s->height[p];
+    }
 
     return 0;
 }
@@ -319,5 +284,4 @@
     .outputs       = maskfun_outputs,
     .priv_class    = &maskfun_class,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index ee4d957..bdb67d8 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -55,56 +55,26 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-    AVFilterFormats *formats = NULL;
-    int ret;
+    AVFilterFormats *pix_fmts = NULL;
+    int fmt, ret;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_BITSTREAM |
-                                    AV_PIX_FMT_FLAG_PAL |
-                                    AV_PIX_FMT_FLAG_HWACCEL);
-    if (ret < 0)
-        return ret;
-    return ff_set_common_formats(ctx, formats);
-}
-
-static int parse_weights(AVFilterContext *ctx)
-{
-    MixContext *s = ctx->priv;
-    char *p, *arg, *saveptr = NULL;
-    int i, last = 0;
-
-    s->wfactor = 0.f;
-    p = s->weights_str;
-    for (i = 0; i < s->nb_inputs; i++) {
-        if (!(arg = av_strtok(p, " |", &saveptr)))
-            break;
-
-        p = NULL;
-        if (av_sscanf(arg, "%f", &s->weights[i]) != 1) {
-            av_log(ctx, AV_LOG_ERROR, "Invalid syntax for weights[%d].\n", i);
-            return AVERROR(EINVAL);
-        }
-        s->wfactor += s->weights[i];
-        last = i;
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
+              desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
+              desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
+            (ret = ff_add_format(&pix_fmts, fmt)) < 0)
+            return ret;
     }
 
-    for (; i < s->nb_inputs; i++) {
-        s->weights[i] = s->weights[last];
-        s->wfactor += s->weights[i];
-    }
-    if (s->scale == 0) {
-        s->wfactor = 1 / s->wfactor;
-    } else {
-        s->wfactor = s->scale;
-    }
-
-    return 0;
+    return ff_set_common_formats(ctx, pix_fmts);
 }
 
 static av_cold int init(AVFilterContext *ctx)
 {
     MixContext *s = ctx->priv;
-    int ret;
+    char *p, *arg, *saveptr = NULL;
+    int i, ret, last = 0;
 
     s->tmix = !strcmp(ctx->filter->name, "tmix");
 
@@ -117,7 +87,7 @@
         return AVERROR(ENOMEM);
 
     if (!s->tmix) {
-        for (int i = 0; i < s->nb_inputs; i++) {
+        for (i = 0; i < s->nb_inputs; i++) {
             AVFilterPad pad = { 0 };
 
             pad.type = AVMEDIA_TYPE_VIDEO;
@@ -132,7 +102,30 @@
         }
     }
 
-    return parse_weights(ctx);
+    p = s->weights_str;
+    for (i = 0; i < s->nb_inputs; i++) {
+        if (!(arg = av_strtok(p, " ", &saveptr)))
+            break;
+
+        p = NULL;
+        if (av_sscanf(arg, "%f", &s->weights[i]) != 1) {
+            av_log(ctx, AV_LOG_ERROR, "Invalid syntax for weights[%d].\n", i);
+            return AVERROR(EINVAL);
+        }
+        s->wfactor += s->weights[i];
+        last = i;
+    }
+    for (; i < s->nb_inputs; i++) {
+        s->weights[i] = s->weights[last];
+        s->wfactor += s->weights[i];
+    }
+    if (s->scale == 0) {
+        s->wfactor = 1 / s->wfactor;
+    } else {
+        s->wfactor = s->scale;
+    }
+
+    return 0;
 }
 
 typedef struct ThreadData {
@@ -211,14 +204,6 @@
             return ret;
     }
 
-    if (ctx->is_disabled) {
-        out = av_frame_clone(s->frames[0]);
-        if (!out)
-            return AVERROR(ENOMEM);
-        out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
-        return ff_filter_frame(outlink, out);
-    }
-
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out)
         return AVERROR(ENOMEM);
@@ -313,18 +298,6 @@
     av_freep(&s->frames);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    return parse_weights(ctx);
-}
-
 static int activate(AVFilterContext *ctx)
 {
     MixContext *s = ctx->priv;
@@ -333,12 +306,11 @@
 
 #define OFFSET(x) offsetof(MixContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
-#define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption mix_options[] = {
     { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT16_MAX, .flags = FLAGS },
-    { "weights", "set weight for each input", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, .flags = TFLAGS },
-    { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = TFLAGS },
+    { "weights", "set weight for each input", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, .flags = FLAGS },
+    { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = FLAGS },
     { "duration", "how to determine end of stream", OFFSET(duration), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, .flags = FLAGS, "duration" },
         { "longest",  "Duration of longest input",  0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "duration" },
         { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "duration" },
@@ -368,9 +340,7 @@
     .init          = init,
     .uninit        = uninit,
     .activate      = activate,
-    .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS |
-                     AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-    .process_command = process_command,
+    .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS,
 };
 
 #endif /* CONFIG_MIX_FILTER */
@@ -419,8 +389,8 @@
 
 static const AVOption tmix_options[] = {
     { "frames", "set number of successive frames to mix", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 1, 128, .flags = FLAGS },
-    { "weights", "set weight for each frame", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1 1"}, 0, 0, .flags = TFLAGS },
-    { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = TFLAGS },
+    { "weights", "set weight for each frame", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1 1"}, 0, 0, .flags = FLAGS },
+    { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = FLAGS },
     { NULL },
 };
 
@@ -446,7 +416,6 @@
     .init          = init,
     .uninit        = uninit,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 #endif /* CONFIG_TMIX_FILTER */
diff --git a/libavfilter/vf_monochrome.c b/libavfilter/vf_monochrome.c
deleted file mode 100644
index 8faa068..0000000
--- a/libavfilter/vf_monochrome.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <float.h>
-
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct MonochromeContext {
-    const AVClass *class;
-
-    float b, r;
-    float size;
-    float high;
-
-    int depth;
-    int subw, subh;
-
-    int (*do_slice)(AVFilterContext *s, void *arg,
-                    int jobnr, int nb_jobs);
-    int (*clear_uv)(AVFilterContext *s, void *arg,
-                    int jobnr, int nb_jobs);
-} MonochromeContext;
-
-static float envelope(const float x)
-{
-    const float beta = 0.6f;
-
-    if (x < beta) {
-        const float tmp = fabsf(x / beta - 1.f);
-
-        return 1.f - tmp * tmp;
-    } else {
-        const float tmp = (1.f - x) / (1.f - beta);
-
-        return tmp * tmp * (3.f - 2.f * tmp);
-    }
-}
-
-static float filter(float b, float r, float u, float v, float size)
-{
-    return expf(-av_clipf(((b - u) * (b - u) +
-                           (r - v) * (r - v)) *
-                            size, 0.f, 1.f));
-}
-
-#define PROCESS()                            \
-    const int cx = x >> subw;                \
-    float y = yptr[x] * imax;                \
-    float u = uptr[cx] * imax - .5f;         \
-    float v = vptr[cx] * imax - .5f;         \
-    float tt, t, ny;                         \
-                                             \
-    ny = filter(b, r, u, v, size);           \
-    tt = envelope(y);                        \
-    t = tt + (1.f - tt) * ihigh;             \
-    ny = (1.f - t) * y + t * ny * y;
-
-static int monochrome_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    MonochromeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const int subw = s->subw;
-    const int subh = s->subh;
-    const float max = (1 << depth) - 1;
-    const float imax = 1.f / max;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ylinesize = frame->linesize[0];
-    const int ulinesize = frame->linesize[1];
-    const int vlinesize = frame->linesize[2];
-    uint8_t *yptr = frame->data[0] + slice_start * ylinesize;
-    const float ihigh = 1.f - s->high;
-    const float size = 1.f / s->size;
-    const float b = s->b * .5f;
-    const float r = s->r * .5f;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        const int cy = y >> subh;
-        uint8_t *uptr = frame->data[1] + cy * ulinesize;
-        uint8_t *vptr = frame->data[2] + cy * vlinesize;
-
-        for (int x = 0; x < width; x++) {
-            PROCESS()
-
-            yptr[x] = av_clip_uint8(ny * max);
-        }
-
-        yptr += ylinesize;
-    }
-
-    return 0;
-}
-
-static int monochrome_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    MonochromeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const int subw = s->subw;
-    const int subh = s->subh;
-    const float max = (1 << depth) - 1;
-    const float imax = 1.f / max;
-    const int width = frame->width;
-    const int height = frame->height;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ylinesize = frame->linesize[0] / 2;
-    const int ulinesize = frame->linesize[1] / 2;
-    const int vlinesize = frame->linesize[2] / 2;
-    uint16_t *yptr = (uint16_t *)frame->data[0] + slice_start * ylinesize;
-    const float ihigh = 1.f - s->high;
-    const float size = 1.f / s->size;
-    const float b = s->b * .5f;
-    const float r = s->r * .5f;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        const int cy = y >> subh;
-        uint16_t *uptr = (uint16_t *)frame->data[1] + cy * ulinesize;
-        uint16_t *vptr = (uint16_t *)frame->data[2] + cy * vlinesize;
-
-        for (int x = 0; x < width; x++) {
-            PROCESS()
-
-            yptr[x] = av_clip_uintp2_c(ny * max, depth);
-        }
-
-        yptr += ylinesize;
-    }
-
-    return 0;
-}
-
-static int clear_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    MonochromeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const int half = 1 << (depth - 1);
-    const int subw = s->subw;
-    const int subh = s->subh;
-    const int width = AV_CEIL_RSHIFT(frame->width, subw);
-    const int height = AV_CEIL_RSHIFT(frame->height, subh);
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ulinesize = frame->linesize[1];
-    const int vlinesize = frame->linesize[2];
-
-    for (int y = slice_start; y < slice_end; y++) {
-        uint8_t *uptr = frame->data[1] + y * ulinesize;
-        uint8_t *vptr = frame->data[2] + y * vlinesize;
-
-        memset(uptr, half, width);
-        memset(vptr, half, width);
-    }
-
-    return 0;
-}
-
-static int clear_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    MonochromeContext *s = ctx->priv;
-    AVFrame *frame = arg;
-    const int depth = s->depth;
-    const int half = 1 << (depth - 1);
-    const int subw = s->subw;
-    const int subh = s->subh;
-    const int width = AV_CEIL_RSHIFT(frame->width, subw);
-    const int height = AV_CEIL_RSHIFT(frame->height, subh);
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int ulinesize = frame->linesize[1] / 2;
-    const int vlinesize = frame->linesize[2] / 2;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        uint16_t *uptr = (uint16_t *)frame->data[1] + y * ulinesize;
-        uint16_t *vptr = (uint16_t *)frame->data[2] + y * vlinesize;
-
-        for (int x = 0; x < width; x++) {
-            uptr[x] = half;
-            vptr[x] = half;
-        }
-    }
-
-    return 0;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
-{
-    AVFilterContext *ctx = inlink->dst;
-    MonochromeContext *s = ctx->priv;
-
-    ctx->internal->execute(ctx, s->do_slice, frame, NULL,
-                           FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
-    ctx->internal->execute(ctx, s->clear_uv, frame, NULL,
-                           FFMIN(frame->height >> s->subh, ff_filter_get_nb_threads(ctx)));
-
-    return ff_filter_frame(ctx->outputs[0], frame);
-}
-
-static av_cold int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *formats = NULL;
-
-    formats = ff_make_format_list(pixel_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-
-    return ff_set_common_formats(ctx, formats);
-}
-
-static av_cold int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    MonochromeContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-
-    s->depth = desc->comp[0].depth;
-    s->do_slice = s->depth <= 8 ? monochrome_slice8 : monochrome_slice16;
-    s->clear_uv = s->depth <= 8 ? clear_slice8 : clear_slice16;
-    s->subw = desc->log2_chroma_w;
-    s->subh = desc->log2_chroma_h;
-
-    return 0;
-}
-
-static const AVFilterPad monochrome_inputs[] = {
-    {
-        .name           = "default",
-        .type           = AVMEDIA_TYPE_VIDEO,
-        .needs_writable = 1,
-        .filter_frame   = filter_frame,
-        .config_props   = config_input,
-    },
-    { NULL }
-};
-
-static const AVFilterPad monochrome_outputs[] = {
-    {
-        .name = "default",
-        .type = AVMEDIA_TYPE_VIDEO,
-    },
-    { NULL }
-};
-
-#define OFFSET(x) offsetof(MonochromeContext, x)
-#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption monochrome_options[] = {
-    { "cb",   "set the chroma blue spot",    OFFSET(b),    AV_OPT_TYPE_FLOAT, {.dbl=0},-1, 1, VF },
-    { "cr",   "set the chroma red spot",     OFFSET(r),    AV_OPT_TYPE_FLOAT, {.dbl=0},-1, 1, VF },
-    { "size", "set the color filter size",   OFFSET(size), AV_OPT_TYPE_FLOAT, {.dbl=1},.1,10, VF },
-    { "high", "set the highlights strength", OFFSET(high), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 1, VF },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(monochrome);
-
-AVFilter ff_vf_monochrome = {
-    .name          = "monochrome",
-    .description   = NULL_IF_CONFIG_SMALL("Convert video to gray using custom color filter."),
-    .priv_size     = sizeof(MonochromeContext),
-    .priv_class    = &monochrome_class,
-    .query_formats = query_formats,
-    .inputs        = monochrome_inputs,
-    .outputs       = monochrome_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
-};
diff --git a/libavfilter/vf_neighbor.c b/libavfilter/vf_neighbor.c
index 9cd9001..17a9b88 100644
--- a/libavfilter/vf_neighbor.c
+++ b/libavfilter/vf_neighbor.c
@@ -371,44 +371,60 @@
     .process_command = ff_filter_process_command,            \
 }
 
-/* The following options are shared between all filters here;
- * the de/inflate filters only use the threshold* options. */
-#define DEINFLATE_OPTIONS_OFFSET (CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER)
-static const AVOption options[] = {
-#if CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER
-    { "coordinates", "set coordinates",               OFFSET(coordinates),    AV_OPT_TYPE_INT, {.i64=255},   0, 255,   FLAGS },
-#endif
+#if CONFIG_EROSION_FILTER
+
+static const AVOption erosion_options[] = {
     { "threshold0",  "set threshold for 1st plane",   OFFSET(threshold[0]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
     { "threshold1",  "set threshold for 2nd plane",   OFFSET(threshold[1]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
     { "threshold2",  "set threshold for 3rd plane",   OFFSET(threshold[2]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
     { "threshold3",  "set threshold for 4th plane",   OFFSET(threshold[3]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "coordinates", "set coordinates",               OFFSET(coordinates),    AV_OPT_TYPE_INT, {.i64=255},   0, 255,   FLAGS },
     { NULL }
 };
 
-#if CONFIG_EROSION_FILTER
-
-#define erosion_options options
 DEFINE_NEIGHBOR_FILTER(erosion, "Apply erosion effect.");
 
 #endif /* CONFIG_EROSION_FILTER */
 
 #if CONFIG_DILATION_FILTER
 
-#define dilation_options options
+static const AVOption dilation_options[] = {
+    { "threshold0",  "set threshold for 1st plane",   OFFSET(threshold[0]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold1",  "set threshold for 2nd plane",   OFFSET(threshold[1]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold2",  "set threshold for 3rd plane",   OFFSET(threshold[2]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold3",  "set threshold for 4th plane",   OFFSET(threshold[3]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "coordinates", "set coordinates",               OFFSET(coordinates),    AV_OPT_TYPE_INT, {.i64=255},   0, 255,   FLAGS },
+    { NULL }
+};
+
 DEFINE_NEIGHBOR_FILTER(dilation, "Apply dilation effect.");
 
 #endif /* CONFIG_DILATION_FILTER */
 
 #if CONFIG_DEFLATE_FILTER
 
-#define deflate_options &options[DEINFLATE_OPTIONS_OFFSET]
+static const AVOption deflate_options[] = {
+    { "threshold0", "set threshold for 1st plane",   OFFSET(threshold[0]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold1", "set threshold for 2nd plane",   OFFSET(threshold[1]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold2", "set threshold for 3rd plane",   OFFSET(threshold[2]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold3", "set threshold for 4th plane",   OFFSET(threshold[3]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { NULL }
+};
+
 DEFINE_NEIGHBOR_FILTER(deflate, "Apply deflate effect.");
 
 #endif /* CONFIG_DEFLATE_FILTER */
 
 #if CONFIG_INFLATE_FILTER
 
-#define inflate_options &options[DEINFLATE_OPTIONS_OFFSET]
+static const AVOption inflate_options[] = {
+    { "threshold0", "set threshold for 1st plane",   OFFSET(threshold[0]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold1", "set threshold for 2nd plane",   OFFSET(threshold[1]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold2", "set threshold for 3rd plane",   OFFSET(threshold[2]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { "threshold3", "set threshold for 4th plane",   OFFSET(threshold[3]),   AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
+    { NULL }
+};
+
 DEFINE_NEIGHBOR_FILTER(inflate, "Apply inflate effect.");
 
 #endif /* CONFIG_INFLATE_FILTER */
diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c
index b273c13..33ff503 100644
--- a/libavfilter/vf_nnedi.c
+++ b/libavfilter/vf_nnedi.c
@@ -21,11 +21,9 @@
 
 #include <float.h>
 
-#include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
@@ -33,59 +31,44 @@
 #include "internal.h"
 #include "video.h"
 
-static const size_t NNEDI_WEIGHTS_SIZE = 13574928;
-static const uint8_t NNEDI_XDIM[] = { 8, 16, 32, 48, 8, 16, 32 };
-static const uint8_t NNEDI_YDIM[] = { 6, 6, 6, 6, 4, 4, 4 };
-static const uint16_t NNEDI_NNS[] = { 16, 32, 64, 128, 256 };
+typedef struct FrameData {
+    uint8_t *paddedp[3];
+    int padded_stride[3];
+    int padded_width[3];
+    int padded_height[3];
 
-typedef struct PrescreenerCoefficients {
-    DECLARE_ALIGNED(32, float, kernel_l0)[4][16 * 4];
-    DECLARE_ALIGNED(32, float, bias_l0)[4];
+    uint8_t *dstp[3];
+    int dst_stride[3];
 
-    DECLARE_ALIGNED(32, float, kernel_l1)[4][4];
-    DECLARE_ALIGNED(32, float, bias_l1)[4];
+    int field[3];
 
-    DECLARE_ALIGNED(32, float, kernel_l2)[4][8];
-    DECLARE_ALIGNED(32, float, bias_l2)[4];
-} PrescreenerCoefficients;
-
-typedef struct PredictorCoefficients {
-    int xdim, ydim, nns, nsize;
-    float *data;
-    float *softmax_q1;
-    float *elliott_q1;
-    float *softmax_bias_q1;
-    float *elliott_bias_q1;
-    float *softmax_q2;
-    float *elliott_q2;
-    float *softmax_bias_q2;
-    float *elliott_bias_q2;
-} PredictorCoefficients;
+    int32_t *lcount[3];
+    float *input;
+    float *temp;
+} FrameData;
 
 typedef struct NNEDIContext {
     const AVClass *class;
 
     char *weights_file;
 
-    AVFrame *prev;
+    AVFrame *src;
+    AVFrame *second;
+    AVFrame *dst;
     int eof;
-    int64_t pts;
+    int64_t cur_pts;
 
     AVFloatDSPContext *fdsp;
-    int depth;
     int nb_planes;
-    int nb_threads;
     int linesize[4];
-    int planewidth[4];
     int planeheight[4];
-    int field_n;
 
-    PrescreenerCoefficients prescreener[4];
-    PredictorCoefficients coeffs[2][5][7];
-
-    float half;
-    float in_scale;
-    float out_scale;
+    float *weights0;
+    float *weights1[2];
+    int asize;
+    int nns;
+    int xdia;
+    int ydia;
 
     // Parameters
     int deint;
@@ -96,85 +79,104 @@
     int qual;
     int etype;
     int pscrn;
+    int fapprox;
 
-    int input_size;
-    uint8_t **prescreen_buf;
-    float **input_buf;
-    float **output_buf;
+    int max_value;
 
-    void (*read)(const uint8_t *src, float *dst,
-                 int src_stride, int dst_stride,
-                 int width, int height, float scale);
-    void (*write)(const float *src, uint8_t *dst,
-                  int src_stride, int dst_stride,
-                  int width, int height, int depth, float scale);
-    void (*prescreen[2])(AVFilterContext *ctx,
-                         const void *src, ptrdiff_t src_stride,
-                         uint8_t *prescreen, int N,
-                         const PrescreenerCoefficients *const coeffs);
+    void (*copy_pad)(const AVFrame *, FrameData *, struct NNEDIContext *, int);
+    void (*evalfunc_0)(struct NNEDIContext *, FrameData *);
+    void (*evalfunc_1)(struct NNEDIContext *, FrameData *);
+
+    // Functions used in evalfunc_0
+    void (*readpixels)(const uint8_t *, const int, float *);
+    void (*compute_network0)(struct NNEDIContext *s, const float *, const float *, uint8_t *);
+    int32_t (*process_line0)(const uint8_t *, int, uint8_t *, const uint8_t *, const int, const int, const int);
+
+    // Functions used in evalfunc_1
+    void (*extract)(const uint8_t *, const int, const int, const int, float *, float *);
+    void (*dot_prod)(struct NNEDIContext *, const float *, const float *, float *, const int, const int, const float *);
+    void (*expfunc)(float *, const int);
+    void (*wae5)(const float *, const int, float *);
+
+    FrameData frame_data;
 } NNEDIContext;
 
 #define OFFSET(x) offsetof(NNEDIContext, x)
-#define RFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption nnedi_options[] = {
     {"weights",  "set weights file", OFFSET(weights_file),  AV_OPT_TYPE_STRING, {.str="nnedi3_weights.bin"}, 0, 0, FLAGS },
-    {"deint",         "set which frames to deinterlace", OFFSET(deint),         AV_OPT_TYPE_INT, {.i64=0}, 0, 1, RFLAGS, "deint" },
-        {"all",        "deinterlace all frames",                       0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "deint" },
-        {"interlaced", "only deinterlace frames marked as interlaced", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "deint" },
-    {"field",  "set mode of operation", OFFSET(field),         AV_OPT_TYPE_INT, {.i64=-1}, -2, 3, RFLAGS, "field" },
-        {"af", "use frame flags, both fields",  0, AV_OPT_TYPE_CONST, {.i64=-2}, 0, 0, RFLAGS, "field" },
-        {"a",  "use frame flags, single field", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, RFLAGS, "field" },
-        {"t",  "use top field only",            0, AV_OPT_TYPE_CONST, {.i64=0},  0, 0, RFLAGS, "field" },
-        {"b",  "use bottom field only",         0, AV_OPT_TYPE_CONST, {.i64=1},  0, 0, RFLAGS, "field" },
-        {"tf", "use both fields, top first",    0, AV_OPT_TYPE_CONST, {.i64=2},  0, 0, RFLAGS, "field" },
-        {"bf", "use both fields, bottom first", 0, AV_OPT_TYPE_CONST, {.i64=3},  0, 0, RFLAGS, "field" },
-    {"planes", "set which planes to process", OFFSET(process_plane), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, RFLAGS },
-    {"nsize",  "set size of local neighborhood around each pixel, used by the predictor neural network", OFFSET(nsize), AV_OPT_TYPE_INT, {.i64=6}, 0, 6, RFLAGS, "nsize" },
-        {"s8x6",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "nsize" },
-        {"s16x6",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "nsize" },
-        {"s32x6",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "nsize" },
-        {"s48x6",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "nsize" },
-        {"s8x4",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, RFLAGS, "nsize" },
-        {"s16x4",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=5}, 0, 0, RFLAGS, "nsize" },
-        {"s32x4",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=6}, 0, 0, RFLAGS, "nsize" },
-    {"nns",    "set number of neurons in predictor neural network", OFFSET(nnsparam), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, RFLAGS, "nns" },
-        {"n16",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "nns" },
-        {"n32",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "nns" },
-        {"n64",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "nns" },
-        {"n128",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "nns" },
-        {"n256",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, RFLAGS, "nns" },
-    {"qual",  "set quality", OFFSET(qual), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, RFLAGS, "qual" },
-        {"fast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "qual" },
-        {"slow", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "qual" },
-    {"etype", "set which set of weights to use in the predictor", OFFSET(etype), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, RFLAGS, "etype" },
-        {"a",  "weights trained to minimize absolute error", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "etype" },
-        {"abs","weights trained to minimize absolute error", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "etype" },
-        {"s",  "weights trained to minimize squared error",  0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "etype" },
-        {"mse","weights trained to minimize squared error",  0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "etype" },
-    {"pscrn", "set prescreening", OFFSET(pscrn), AV_OPT_TYPE_INT, {.i64=2}, 0, 4, RFLAGS, "pscrn" },
-        {"none",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "pscrn" },
-        {"original",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "pscrn" },
-        {"new",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "pscrn" },
-        {"new2",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "pscrn" },
-        {"new3",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, RFLAGS, "pscrn" },
+    {"deint",         "set which frames to deinterlace", OFFSET(deint),         AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
+        {"all",        "deinterlace all frames",                       0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "deint" },
+        {"interlaced", "only deinterlace frames marked as interlaced", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "deint" },
+    {"field",  "set mode of operation", OFFSET(field),         AV_OPT_TYPE_INT, {.i64=-1}, -2, 3, FLAGS, "field" },
+        {"af", "use frame flags, both fields",  0, AV_OPT_TYPE_CONST, {.i64=-2}, 0, 0, FLAGS, "field" },
+        {"a",  "use frame flags, single field", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, "field" },
+        {"t",  "use top field only",            0, AV_OPT_TYPE_CONST, {.i64=0},  0, 0, FLAGS, "field" },
+        {"b",  "use bottom field only",         0, AV_OPT_TYPE_CONST, {.i64=1},  0, 0, FLAGS, "field" },
+        {"tf", "use both fields, top first",    0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "field" },
+        {"bf", "use both fields, bottom first", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "field" },
+    {"planes", "set which planes to process", OFFSET(process_plane), AV_OPT_TYPE_INT, {.i64=7}, 0, 7, FLAGS },
+    {"nsize",  "set size of local neighborhood around each pixel, used by the predictor neural network", OFFSET(nsize), AV_OPT_TYPE_INT, {.i64=6}, 0, 6, FLAGS, "nsize" },
+        {"s8x6",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "nsize" },
+        {"s16x6",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "nsize" },
+        {"s32x6",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "nsize" },
+        {"s48x6",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "nsize" },
+        {"s8x4",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "nsize" },
+        {"s16x4",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=5}, 0, 0, FLAGS, "nsize" },
+        {"s32x4",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=6}, 0, 0, FLAGS, "nsize" },
+    {"nns",    "set number of neurons in predictor neural network", OFFSET(nnsparam), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, FLAGS, "nns" },
+        {"n16",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "nns" },
+        {"n32",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "nns" },
+        {"n64",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "nns" },
+        {"n128",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "nns" },
+        {"n256",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "nns" },
+    {"qual",  "set quality", OFFSET(qual), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS, "qual" },
+        {"fast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "qual" },
+        {"slow", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "qual" },
+    {"etype", "set which set of weights to use in the predictor", OFFSET(etype), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "etype" },
+        {"a",  "weights trained to minimize absolute error", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "etype" },
+        {"s",  "weights trained to minimize squared error",  0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "etype" },
+    {"pscrn", "set prescreening", OFFSET(pscrn), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "pscrn" },
+        {"none",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "pscrn" },
+        {"original",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "pscrn" },
+        {"new",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "pscrn" },
+    {"fapprox",       NULL, OFFSET(fapprox),       AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
     { NULL }
 };
 
 AVFILTER_DEFINE_CLASS(nnedi);
 
+static int config_input(AVFilterLink *inlink)
+{
+    AVFilterContext *ctx = inlink->dst;
+    NNEDIContext *s = ctx->priv;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
+    int ret;
+
+    s->nb_planes = av_pix_fmt_count_planes(inlink->format);
+    if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
+        return ret;
+
+    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
+    s->planeheight[0] = s->planeheight[3] = inlink->h;
+
+    return 0;
+}
+
 static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
+    NNEDIContext *s = ctx->priv;
 
     outlink->time_base.num = ctx->inputs[0]->time_base.num;
     outlink->time_base.den = ctx->inputs[0]->time_base.den * 2;
     outlink->w             = ctx->inputs[0]->w;
     outlink->h             = ctx->inputs[0]->h;
 
-    outlink->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
-                                   (AVRational){2, 1});
+    if (s->field > 1 || s->field == -2)
+        outlink->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
+                                       (AVRational){2, 1});
 
     return 0;
 }
@@ -182,28 +184,14 @@
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8,
-        AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
         AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
         AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
         AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
         AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
         AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
         AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-        AV_PIX_FMT_GBRAP10,   AV_PIX_FMT_GBRAP12,    AV_PIX_FMT_GBRAP16,
+        AV_PIX_FMT_GBRP,
+        AV_PIX_FMT_GRAY8,
         AV_PIX_FMT_NONE
     };
 
@@ -213,508 +201,679 @@
     return ff_set_common_formats(ctx, fmts_list);
 }
 
-static float dot_dsp(const NNEDIContext *const s, const float *kernel, const float *input,
-                     int n, float scale, float bias)
+static void copy_pad(const AVFrame *src, FrameData *frame_data, NNEDIContext *s, int fn)
 {
-    float sum, y;
+    const int off = 1 - fn;
+    int plane, y, x;
 
-    sum = s->fdsp->scalarproduct_float(kernel, input, n);
+    for (plane = 0; plane < s->nb_planes; plane++) {
+        const uint8_t *srcp = (const uint8_t *)src->data[plane];
+        uint8_t *dstp = (uint8_t *)frame_data->paddedp[plane];
 
-    y = sum * scale + bias + 1e-20f;
+        const int src_stride = src->linesize[plane];
+        const int dst_stride = frame_data->padded_stride[plane];
 
-    return y;
-}
+        const int src_height = s->planeheight[plane];
+        const int dst_height = frame_data->padded_height[plane];
 
-static float elliott(float x)
-{
-    return x / (1.0f + fabsf(x));
-}
+        const int src_width = s->linesize[plane];
+        const int dst_width = frame_data->padded_width[plane];
 
-static void transform_elliott(float *input, int size)
-{
-    for (int i = 0; i < size; i++)
-        input[i] = elliott(input[i]);
-}
+        int c = 4;
 
-static void process_old(AVFilterContext *ctx,
-                        const void *src, ptrdiff_t src_stride,
-                        uint8_t *prescreen, int N,
-                        const PrescreenerCoefficients *const m_data)
-{
-    NNEDIContext *s = ctx->priv;
-    const float *src_p = src;
+        if (!(s->process_plane & (1 << plane)))
+            continue;
 
-    // Adjust source pointer to point to top-left of filter window.
-    const float *window = src_p - 2 * src_stride - 5;
+        // Copy.
+        for (y = off; y < src_height; y += 2)
+            memcpy(dstp + 32 + (6 + y) * dst_stride,
+                   srcp + y * src_stride,
+                   src_width * sizeof(uint8_t));
 
-    for (int j = 0; j < N; j++) {
-        LOCAL_ALIGNED_32(float, input, [48]);
-        float state[12];
+        // And pad.
+        dstp += (6 + off) * dst_stride;
+        for (y = 6 + off; y < dst_height - 6; y += 2) {
+            int c = 2;
 
-        for (int i = 0; i < 4; i++)
-            memcpy(input + i * 12, window + i * src_stride + j, 12 * sizeof(float));
+            for (x = 0; x < 32; x++)
+                dstp[x] = dstp[64 - x];
 
-        // Layer 0.
-        for (int n = 0; n < 4; n++)
-            state[n] = dot_dsp(s, m_data->kernel_l0[n], input, 48, 1.0f, m_data->bias_l0[n]);
-        transform_elliott(state + 1, 3);
+            for (x = dst_width - 32; x < dst_width; x++, c += 2)
+                dstp[x] = dstp[x - c];
 
-        // Layer 1.
-        for (int n = 0; n < 4; n++)
-            state[n + 4] = dot_dsp(s, m_data->kernel_l1[n], state, 4, 1.0f, m_data->bias_l1[n]);
-        transform_elliott(state + 4, 3);
-
-        // Layer 2.
-        for (int n = 0; n < 4; n++)
-            state[n + 8] = dot_dsp(s, m_data->kernel_l2[n], state, 8, 1.0f, m_data->bias_l2[n]);
-
-        prescreen[j] = FFMAX(state[10], state[11]) <= FFMAX(state[8], state[9]) ? 255 : 0;
-    }
-}
-
-static void process_new(AVFilterContext *ctx,
-                        const void *src, ptrdiff_t src_stride,
-                        uint8_t *prescreen, int N,
-                        const PrescreenerCoefficients *const m_data)
-{
-    NNEDIContext *s = ctx->priv;
-    const float *src_p = src;
-
-    // Adjust source pointer to point to top-left of filter window.
-    const float *window = src_p - 2 * src_stride - 6;
-
-    for (int j = 0; j < N; j += 4) {
-        LOCAL_ALIGNED_32(float, input, [64]);
-        float state[8];
-
-        for (int i = 0; i < 4; i++)
-            memcpy(input + i * 16, window + i * src_stride + j, 16 * sizeof(float));
-
-        for (int n = 0; n < 4; n++)
-            state[n] = dot_dsp(s, m_data->kernel_l0[n], input, 64, 1.0f, m_data->bias_l0[n]);
-        transform_elliott(state, 4);
-
-        for (int n = 0; n < 4; n++)
-            state[n + 4] = dot_dsp(s, m_data->kernel_l1[n], state, 4, 1.0f, m_data->bias_l1[n]);
-
-        for (int n = 0; n < 4; n++)
-            prescreen[j + n] = state[n + 4] > 0.f;
-    }
-}
-
-static int filter_offset(int nn, const PredictorCoefficients *const model)
-{
-    return nn * model->nsize;
-}
-
-static const float *softmax_q1_filter(int nn,
-                                      const PredictorCoefficients *const model)
-{
-    return model->softmax_q1 + filter_offset(nn, model);
-}
-
-static const float *elliott_q1_filter(int nn,
-                                      const PredictorCoefficients *const model)
-{
-    return model->elliott_q1 + filter_offset(nn, model);
-}
-
-static const float *softmax_q2_filter(int nn,
-                                      const PredictorCoefficients *const model)
-{
-    return model->softmax_q2 + filter_offset(nn, model);
-}
-
-static const float *elliott_q2_filter(int nn,
-                                      const PredictorCoefficients *const model)
-{
-    return model->elliott_q2 + filter_offset(nn, model);
-}
-
-static void gather_input(const float *src, ptrdiff_t src_stride,
-                         float *buf, float mstd[4],
-                         const PredictorCoefficients *const model)
-{
-    const float scale = 1.f / model->nsize;
-    float sum = 0.f;
-    float sum_sq = 0.f;
-    float tmp;
-
-    for (int i = 0; i < model->ydim; i++) {
-        memcpy(buf, src, model->xdim * sizeof(float));
-
-        for (int j = 0; j < model->xdim; j++) {
-            const float val = src[j];
-
-            sum += val;
-            sum_sq += val * val;
+            dstp += dst_stride * 2;
         }
 
-        src += src_stride;
-        buf += model->xdim;
+        dstp = (uint8_t *)frame_data->paddedp[plane];
+        for (y = off; y < 6; y += 2)
+            memcpy(dstp + y * dst_stride,
+                   dstp + (12 + 2 * off - y) * dst_stride,
+                   dst_width * sizeof(uint8_t));
+
+        for (y = dst_height - 6 + off; y < dst_height; y += 2, c += 4)
+            memcpy(dstp + y * dst_stride,
+                   dstp + (y - c) * dst_stride,
+                   dst_width * sizeof(uint8_t));
+    }
+}
+
+static void elliott(float *data, const int n)
+{
+    int i;
+
+    for (i = 0; i < n; i++)
+        data[i] = data[i] / (1.0f + FFABS(data[i]));
+}
+
+static void dot_prod(NNEDIContext *s, const float *data, const float *weights, float *vals, const int n, const int len, const float *scale)
+{
+    int i;
+
+    for (i = 0; i < n; i++) {
+        float sum;
+
+        sum = s->fdsp->scalarproduct_float(data, &weights[i * len], len);
+
+        vals[i] = sum * scale[0] + weights[n * len + i];
+    }
+}
+
+static void dot_prods(NNEDIContext *s, const float *dataf, const float *weightsf, float *vals, const int n, const int len, const float *scale)
+{
+    const int16_t *data = (int16_t *)dataf;
+    const int16_t *weights = (int16_t *)weightsf;
+    const float *wf = (float *)&weights[n * len];
+    int i, j;
+
+    for (i = 0; i < n; i++) {
+        int sum = 0, off = ((i >> 2) << 3) + (i & 3);
+        for (j = 0; j < len; j++)
+            sum += data[j] * weights[i * len + j];
+
+        vals[i] = sum * wf[off] * scale[0] + wf[off + 4];
+    }
+}
+
+static void compute_network0(NNEDIContext *s, const float *input, const float *weights, uint8_t *d)
+{
+    float t, temp[12], scale = 1.0f;
+
+    dot_prod(s, input, weights, temp, 4, 48, &scale);
+    t = temp[0];
+    elliott(temp, 4);
+    temp[0] = t;
+    dot_prod(s, temp, weights + 4 * 49, temp + 4, 4, 4, &scale);
+    elliott(temp + 4, 4);
+    dot_prod(s, temp, weights + 4 * 49 + 4 * 5, temp + 8, 4, 8, &scale);
+    if (FFMAX(temp[10], temp[11]) <= FFMAX(temp[8], temp[9]))
+        d[0] = 1;
+    else
+        d[0] = 0;
+}
+
+static void compute_network0_i16(NNEDIContext *s, const float *inputf, const float *weightsf, uint8_t *d)
+{
+    const float *wf = weightsf + 2 * 48;
+    float t, temp[12], scale = 1.0f;
+
+    dot_prods(s, inputf, weightsf, temp, 4, 48, &scale);
+    t = temp[0];
+    elliott(temp, 4);
+    temp[0] = t;
+    dot_prod(s, temp, wf + 8, temp + 4, 4, 4, &scale);
+    elliott(temp + 4, 4);
+    dot_prod(s, temp, wf + 8 + 4 * 5, temp + 8, 4, 8, &scale);
+    if (FFMAX(temp[10], temp[11]) <= FFMAX(temp[8], temp[9]))
+        d[0] = 1;
+    else
+        d[0] = 0;
+}
+
+static void pixel2float48(const uint8_t *t8, const int pitch, float *p)
+{
+    const uint8_t *t = (const uint8_t *)t8;
+    int y, x;
+
+    for (y = 0; y < 4; y++)
+        for (x = 0; x < 12; x++)
+            p[y * 12 + x] = t[y * pitch * 2 + x];
+}
+
+static void byte2word48(const uint8_t *t, const int pitch, float *pf)
+{
+    int16_t *p = (int16_t *)pf;
+    int y, x;
+
+    for (y = 0; y < 4; y++)
+        for (x = 0; x < 12; x++)
+            p[y * 12 + x] = t[y * pitch * 2 + x];
+}
+
+static int32_t process_line0(const uint8_t *tempu, int width, uint8_t *dstp8, const uint8_t *src3p8, const int src_pitch, const int max_value, const int chroma)
+{
+    uint8_t *dstp = (uint8_t *)dstp8;
+    const uint8_t *src3p = (const uint8_t *)src3p8;
+    int minimum = 0;
+    int maximum = max_value - 1; // Technically the -1 is only needed for 8 and 16 bit input.
+    int count = 0, x;
+    for (x = 0; x < width; x++) {
+        if (tempu[x]) {
+            int tmp = 19 * (src3p[x + src_pitch * 2] + src3p[x + src_pitch * 4]) - 3 * (src3p[x] + src3p[x + src_pitch * 6]);
+            tmp /= 32;
+            dstp[x] = FFMAX(FFMIN(tmp, maximum), minimum);
+        } else {
+            dstp[x] = 255;
+            count++;
+        }
+    }
+    return count;
+}
+
+// new prescreener functions
+static void byte2word64(const uint8_t *t, const int pitch, float *p)
+{
+    int16_t *ps = (int16_t *)p;
+    int y, x;
+
+    for (y = 0; y < 4; y++)
+        for (x = 0; x < 16; x++)
+            ps[y * 16 + x] = t[y * pitch * 2 + x];
+}
+
+static void compute_network0new(NNEDIContext *s, const float *datai, const float *weights, uint8_t *d)
+{
+    int16_t *data = (int16_t *)datai;
+    int16_t *ws = (int16_t *)weights;
+    float *wf = (float *)&ws[4 * 64];
+    float vals[8];
+    int mask, i, j;
+
+    for (i = 0; i < 4; i++) {
+        int sum = 0;
+        float t;
+
+        for (j = 0; j < 64; j++)
+            sum += data[j] * ws[(i << 3) + ((j >> 3) << 5) + (j & 7)];
+        t = sum * wf[i] + wf[4 + i];
+        vals[i] = t / (1.0f + FFABS(t));
     }
 
-    mstd[0] = sum * scale;
-    mstd[3] = 0.f;
+    for (i = 0; i < 4; i++) {
+        float sum = 0.0f;
 
-    tmp = sum_sq * scale - mstd[0] * mstd[0];
-    if (tmp < FLT_EPSILON) {
-        mstd[1] = 0.0f;
-        mstd[2] = 0.0f;
-    } else {
-        mstd[1] = sqrtf(tmp);
+        for (j = 0; j < 4; j++)
+            sum += vals[j] * wf[8 + i + (j << 2)];
+        vals[4 + i] = sum + wf[8 + 16 + i];
+    }
+
+    mask = 0;
+    for (i = 0; i < 4; i++) {
+        if (vals[4 + i] > 0.0f)
+            mask |= (0x1 << (i << 3));
+    }
+
+    ((int *)d)[0] = mask;
+}
+
+static void evalfunc_0(NNEDIContext *s, FrameData *frame_data)
+{
+    float *input = frame_data->input;
+    const float *weights0 = s->weights0;
+    float *temp = frame_data->temp;
+    uint8_t *tempu = (uint8_t *)temp;
+    int plane, x, y;
+
+    // And now the actual work.
+    for (plane = 0; plane < s->nb_planes; plane++) {
+        const uint8_t *srcp = (const uint8_t *)frame_data->paddedp[plane];
+        const int src_stride = frame_data->padded_stride[plane] / sizeof(uint8_t);
+
+        const int width = frame_data->padded_width[plane];
+        const int height = frame_data->padded_height[plane];
+
+        uint8_t *dstp = (uint8_t *)frame_data->dstp[plane];
+        const int dst_stride = frame_data->dst_stride[plane] / sizeof(uint8_t);
+        const uint8_t *src3p;
+        int ystart, ystop;
+        int32_t *lcount;
+
+        if (!(s->process_plane & (1 << plane)))
+            continue;
+
+        for (y = 1 - frame_data->field[plane]; y < height - 12; y += 2) {
+            memcpy(dstp + y * dst_stride,
+                   srcp + 32 + (6 + y) * src_stride,
+                   (width - 64) * sizeof(uint8_t));
+
+        }
+
+        ystart = 6 + frame_data->field[plane];
+        ystop = height - 6;
+        srcp += ystart * src_stride;
+        dstp += (ystart - 6) * dst_stride - 32;
+        src3p = srcp - src_stride * 3;
+        lcount = frame_data->lcount[plane] - 6;
+
+        if (s->pscrn == 1) { // original
+            for (y = ystart; y < ystop; y += 2) {
+                for (x = 32; x < width - 32; x++) {
+                    s->readpixels((const uint8_t *)(src3p + x - 5), src_stride, input);
+                    s->compute_network0(s, input, weights0, tempu+x);
+                }
+                lcount[y] += s->process_line0(tempu + 32, width - 64, (uint8_t *)(dstp + 32), (const uint8_t *)(src3p + 32), src_stride, s->max_value, plane);
+                src3p += src_stride * 2;
+                dstp += dst_stride * 2;
+            }
+        } else if (s->pscrn > 1) { // new
+            for (y = ystart; y < ystop; y += 2) {
+                for (x = 32; x < width - 32; x += 4) {
+                    s->readpixels((const uint8_t *)(src3p + x - 6), src_stride, input);
+                    s->compute_network0(s, input, weights0, tempu + x);
+                }
+                lcount[y] += s->process_line0(tempu + 32, width - 64, (uint8_t *)(dstp + 32), (const uint8_t *)(src3p + 32), src_stride, s->max_value, plane);
+                src3p += src_stride * 2;
+                dstp += dst_stride * 2;
+            }
+        } else { // no prescreening
+            for (y = ystart; y < ystop; y += 2) {
+                memset(dstp + 32, 255, (width - 64) * sizeof(uint8_t));
+                lcount[y] += width - 64;
+                dstp += dst_stride * 2;
+            }
+        }
+    }
+}
+
+static void extract_m8(const uint8_t *srcp8, const int stride, const int xdia, const int ydia, float *mstd, float *input)
+{
+    // uint8_t or uint16_t or float
+    const uint8_t *srcp = (const uint8_t *)srcp8;
+    float scale;
+    double tmp;
+
+    // int32_t or int64_t or double
+    int64_t sum = 0, sumsq = 0;
+    int y, x;
+
+    for (y = 0; y < ydia; y++) {
+        const uint8_t *srcpT = srcp + y * stride * 2;
+
+        for (x = 0; x < xdia; x++) {
+            sum += srcpT[x];
+            sumsq += (uint32_t)srcpT[x] * (uint32_t)srcpT[x];
+            input[x] = srcpT[x];
+        }
+        input += xdia;
+    }
+    scale = 1.0f / (xdia * ydia);
+    mstd[0] = sum * scale;
+    tmp = (double)sumsq * scale - (double)mstd[0] * mstd[0];
+    mstd[3] = 0.0f;
+    if (tmp <= FLT_EPSILON)
+        mstd[1] = mstd[2] = 0.0f;
+    else {
+        mstd[1] = sqrt(tmp);
         mstd[2] = 1.0f / mstd[1];
     }
 }
 
-static float softmax_exp(float x)
+static void extract_m8_i16(const uint8_t *srcp, const int stride, const int xdia, const int ydia, float *mstd, float *inputf)
 {
-    return expf(av_clipf(x, -80.f, 80.f));
+    int16_t *input = (int16_t *)inputf;
+    float scale;
+    int sum = 0, sumsq = 0;
+    int y, x;
+
+    for (y = 0; y < ydia; y++) {
+        const uint8_t *srcpT = srcp + y * stride * 2;
+        for (x = 0; x < xdia; x++) {
+            sum += srcpT[x];
+            sumsq += srcpT[x] * srcpT[x];
+            input[x] = srcpT[x];
+        }
+        input += xdia;
+    }
+    scale = 1.0f / (float)(xdia * ydia);
+    mstd[0] = sum * scale;
+    mstd[1] = sumsq * scale - mstd[0] * mstd[0];
+    mstd[3] = 0.0f;
+    if (mstd[1] <= FLT_EPSILON)
+        mstd[1] = mstd[2] = 0.0f;
+    else {
+        mstd[1] = sqrt(mstd[1]);
+        mstd[2] = 1.0f / mstd[1];
+    }
 }
 
-static void transform_softmax_exp(float *input, int size)
+
+static const float exp_lo = -80.0f;
+static const float exp_hi = +80.0f;
+
+static void e2_m16(float *s, const int n)
 {
-    for (int i = 0; i < size; i++)
-        input[i] = softmax_exp(input[i]);
+    int i;
+
+    for (i = 0; i < n; i++)
+        s[i] = exp(av_clipf(s[i], exp_lo, exp_hi));
 }
 
-static void wae5(const float *softmax, const float *el,
-                 int n, float mstd[4])
+const float min_weight_sum = 1e-10f;
+
+static void weighted_avg_elliott_mul5_m16(const float *w, const int n, float *mstd)
 {
     float vsum = 0.0f, wsum = 0.0f;
+    int i;
 
-    for (int i = 0; i < n; i++) {
-        vsum += softmax[i] * elliott(el[i]);
-        wsum += softmax[i];
+    for (i = 0; i < n; i++) {
+        vsum += w[i] * (w[n + i] / (1.0f + FFABS(w[n + i])));
+        wsum += w[i];
     }
-
-    if (wsum > 1e-10f)
-        mstd[3] += (5.0f * vsum) / wsum * mstd[1] + mstd[0];
+    if (wsum > min_weight_sum)
+        mstd[3] += ((5.0f * vsum) / wsum) * mstd[1] + mstd[0];
     else
         mstd[3] += mstd[0];
 }
 
-static void predictor(AVFilterContext *ctx,
-                      const void *src, ptrdiff_t src_stride, void *dst,
-                      const uint8_t *prescreen, int N,
-                      const PredictorCoefficients *const model, int use_q2)
+
+static void evalfunc_1(NNEDIContext *s, FrameData *frame_data)
 {
-    const NNEDIContext *const s = ctx->priv;
-    const float *src_p = src;
-    float *dst_p = dst;
+    float *input = frame_data->input;
+    float *temp = frame_data->temp;
+    float **weights1 = s->weights1;
+    const int qual = s->qual;
+    const int asize = s->asize;
+    const int nns = s->nns;
+    const int xdia = s->xdia;
+    const int xdiad2m1 = (xdia / 2) - 1;
+    const int ydia = s->ydia;
+    const float scale = 1.0f / (float)qual;
+    int plane, y, x, i;
 
-    // Adjust source pointer to point to top-left of filter window.
-    const float *window = src_p - (model->ydim / 2) * src_stride - (model->xdim / 2 - 1);
-    const int filter_size = model->nsize;
-    const int nns = model->nns;
+    for (plane = 0; plane < s->nb_planes; plane++) {
+        const uint8_t *srcp = (const uint8_t *)frame_data->paddedp[plane];
+        const int src_stride = frame_data->padded_stride[plane] / sizeof(uint8_t);
 
-    for (int i = 0; i < N; i++) {
-        LOCAL_ALIGNED_32(float, input, [48 * 6]);
-        float activation[256 * 2];
-        float mstd[4];
-        float scale;
+        const int width = frame_data->padded_width[plane];
+        const int height = frame_data->padded_height[plane];
 
-        if (prescreen[i])
+        uint8_t *dstp = (uint8_t *)frame_data->dstp[plane];
+        const int dst_stride = frame_data->dst_stride[plane] / sizeof(uint8_t);
+
+        const int ystart = frame_data->field[plane];
+        const int ystop = height - 12;
+        const uint8_t *srcpp;
+
+        if (!(s->process_plane & (1 << plane)))
             continue;
 
-        gather_input(window + i, src_stride, input, mstd, model);
-        scale = mstd[2];
+        srcp += (ystart + 6) * src_stride;
+        dstp += ystart * dst_stride - 32;
+        srcpp = srcp - (ydia - 1) * src_stride - xdiad2m1;
 
-        for (int nn = 0; nn < nns; nn++)
-            activation[nn] = dot_dsp(s, softmax_q1_filter(nn, model), input, filter_size, scale, model->softmax_bias_q1[nn]);
+        for (y = ystart; y < ystop; y += 2) {
+            for (x = 32; x < width - 32; x++) {
+                float mstd[4];
 
-        for (int nn = 0; nn < nns; nn++)
-            activation[nns + nn] = dot_dsp(s, elliott_q1_filter(nn, model), input, filter_size, scale, model->elliott_bias_q1[nn]);
+                if (dstp[x] != 255)
+                    continue;
 
-        transform_softmax_exp(activation, nns);
-        wae5(activation, activation + nns, nns, mstd);
+                s->extract((const uint8_t *)(srcpp + x), src_stride, xdia, ydia, mstd, input);
+                for (i = 0; i < qual; i++) {
+                    s->dot_prod(s, input, weights1[i], temp, nns * 2, asize, mstd + 2);
+                    s->expfunc(temp, nns);
+                    s->wae5(temp, nns, mstd);
+                }
 
-        if (use_q2) {
-            for (int nn = 0; nn < nns; nn++)
-                activation[nn] = dot_dsp(s, softmax_q2_filter(nn, model), input, filter_size, scale, model->softmax_bias_q2[nn]);
-
-            for (int nn = 0; nn < nns; nn++)
-                activation[nns + nn] = dot_dsp(s, elliott_q2_filter(nn, model), input, filter_size, scale, model->elliott_bias_q2[nn]);
-
-            transform_softmax_exp(activation, nns);
-            wae5(activation, activation + nns, nns, mstd);
+                dstp[x] = FFMIN(FFMAX((int)(mstd[3] * scale + 0.5f), 0), s->max_value);
+            }
+            srcpp += src_stride * 2;
+            dstp += dst_stride * 2;
         }
-
-        dst_p[i] = mstd[3] * (use_q2 ? 0.5f : 1.f);
     }
 }
 
-static void read_bytes(const uint8_t *src, float *dst,
-                       int src_stride, int dst_stride,
-                       int width, int height, float scale)
+#define NUM_NSIZE 7
+#define NUM_NNS 5
+
+static int roundds(const double f)
 {
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < 32; x++)
-            dst[-x - 1] = src[x];
-
-        for (int x = 0; x < width; x++)
-            dst[x] = src[x];
-
-        for (int x = 0; x < 32; x++)
-            dst[width + x] = src[width - x - 1];
-
-        dst += dst_stride;
-        src += src_stride;
-    }
+    if (f - floor(f) >= 0.5)
+        return FFMIN((int)ceil(f), 32767);
+    return FFMAX((int)floor(f), -32768);
 }
 
-static void read_words(const uint8_t *srcp, float *dst,
-                       int src_stride, int dst_stride,
-                       int width, int height, float scale)
+static void select_functions(NNEDIContext *s)
 {
-    const uint16_t *src = (const uint16_t *)srcp;
+    s->copy_pad = copy_pad;
+    s->evalfunc_0 = evalfunc_0;
+    s->evalfunc_1 = evalfunc_1;
 
-    src_stride /= 2;
+    // evalfunc_0
+    s->process_line0 = process_line0;
 
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < 32; x++)
-            dst[-x - 1] = src[x] * scale;
-
-        for (int x = 0; x < width; x++)
-            dst[x] = src[x] * scale;
-
-        for (int x = 0; x < 32; x++)
-            dst[width + x] = src[width - x - 1] * scale;
-
-        dst += dst_stride;
-        src += src_stride;
-    }
-}
-
-static void write_bytes(const float *src, uint8_t *dst,
-                        int src_stride, int dst_stride,
-                        int width, int height, int depth,
-                        float scale)
-{
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_uint8(src[x]);
-
-        dst += dst_stride;
-        src += src_stride;
-    }
-}
-
-static void write_words(const float *src, uint8_t *dstp,
-                        int src_stride, int dst_stride,
-                        int width, int height, int depth,
-                        float scale)
-{
-    uint16_t *dst = (uint16_t *)dstp;
-
-    dst_stride /= 2;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_uintp2_c(src[x] * scale, depth);
-
-        dst += dst_stride;
-        src += src_stride;
-    }
-}
-
-static void interpolation(const void *src, ptrdiff_t src_stride,
-                          void *dst, const uint8_t *prescreen, int n)
-{
-    const float *src_p = src;
-    float *dst_p = dst;
-    const float *window = src_p - 2 * src_stride;
-
-    for (int i = 0; i < n; i++) {
-        float accum = 0.0f;
-
-        if (!prescreen[i])
-            continue;
-
-        accum += (-3.0f / 32.0f) * window[0 * src_stride + i];
-        accum += (19.0f / 32.0f) * window[1 * src_stride + i];
-        accum += (19.0f / 32.0f) * window[2 * src_stride + i];
-        accum += (-3.0f / 32.0f) * window[3 * src_stride + i];
-
-        dst_p[i] = accum;
-    }
-}
-
-static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    const NNEDIContext *const s = ctx->priv;
-    AVFrame *out = arg;
-    AVFrame *in = s->prev;
-    const float in_scale = s->in_scale;
-    const float out_scale = s->out_scale;
-    const int depth = s->depth;
-    const int interlaced = in->interlaced_frame;
-    const int tff = s->field_n == (s->field < 0 ? interlaced ? in->top_field_first : 1 :
-                                  (s->field & 1) ^ 1);
-
-
-    for (int p = 0; p < s->nb_planes; p++) {
-        const int height = s->planeheight[p];
-        const int width = s->planewidth[p];
-        const int slice_start = 2 * ((height / 2 * jobnr) / nb_jobs);
-        const int slice_end = 2 * ((height / 2 * (jobnr+1)) / nb_jobs);
-        const uint8_t *src_data = in->data[p];
-        uint8_t *dst_data = out->data[p];
-        uint8_t *dst = out->data[p] + slice_start * out->linesize[p];
-        const int src_linesize = in->linesize[p];
-        const int dst_linesize = out->linesize[p];
-        uint8_t *prescreen_buf = s->prescreen_buf[jobnr];
-        float *srcbuf = s->input_buf[jobnr];
-        const int srcbuf_stride = width + 64;
-        float *dstbuf = s->output_buf[jobnr];
-        const int dstbuf_stride = width;
-        const int slice_height = (slice_end - slice_start) / 2;
-        const int last_slice = slice_end == height;
-        const uint8_t *in_line;
-        uint8_t *out_line;
-        int y_out;
-
-        if (!(s->process_plane & (1 << p))) {
-            av_image_copy_plane(dst, out->linesize[p],
-                                in->data[p] + slice_start * in->linesize[p],
-                                in->linesize[p],
-                                s->linesize[p], slice_end - slice_start);
-            continue;
+    if (s->pscrn < 2) { // original prescreener
+        if (s->fapprox & 1) { // int16 dot products
+            s->readpixels = byte2word48;
+            s->compute_network0 = compute_network0_i16;
+        } else {
+            s->readpixels = pixel2float48;
+            s->compute_network0 = compute_network0;
         }
-
-        y_out    = slice_start + (tff ^ (slice_start & 1));
-        in_line  = src_data + (y_out * src_linesize);
-        out_line = dst_data + (y_out * dst_linesize);
-
-        while (y_out < slice_end) {
-            memcpy(out_line, in_line, s->linesize[p]);
-            y_out += 2;
-            in_line  += src_linesize * 2;
-            out_line += dst_linesize * 2;
-        }
-
-        y_out = slice_start + ((!tff) ^ (slice_start & 1));
-
-        s->read(src_data + FFMAX(y_out - 5, tff) * src_linesize,
-                srcbuf + 32,
-                src_linesize * 2, srcbuf_stride,
-                width, 1, in_scale);
-        srcbuf += srcbuf_stride;
-
-        s->read(src_data + FFMAX(y_out - 3, tff) * src_linesize,
-                srcbuf + 32,
-                src_linesize * 2, srcbuf_stride,
-                width, 1, in_scale);
-        srcbuf += srcbuf_stride;
-
-        s->read(src_data + FFMAX(y_out - 1, tff) * src_linesize,
-                srcbuf + 32,
-                src_linesize * 2, srcbuf_stride,
-                width, 1, in_scale);
-        srcbuf += srcbuf_stride;
-
-        in_line  = src_data + FFMIN(y_out + 1, height - 1 - !tff) * src_linesize;
-        out_line = dst_data + (y_out * dst_linesize);
-
-        s->read(in_line, srcbuf + 32, src_linesize * 2, srcbuf_stride,
-                width, slice_height - last_slice, in_scale);
-
-        y_out += (slice_height - last_slice) * 2;
-
-        s->read(src_data + FFMIN(y_out + 1, height - 1 - !tff) * src_linesize,
-                srcbuf + 32 + srcbuf_stride * (slice_height - last_slice),
-                src_linesize * 2, srcbuf_stride,
-                width, 1, in_scale);
-
-        s->read(src_data + FFMIN(y_out + 3, height - 1 - !tff) * src_linesize,
-                srcbuf + 32 + srcbuf_stride * (slice_height + 1 - last_slice),
-                src_linesize * 2, srcbuf_stride,
-                width, 1, in_scale);
-
-        s->read(src_data + FFMIN(y_out + 5, height - 1 - !tff) * src_linesize,
-                srcbuf + 32 + srcbuf_stride * (slice_height + 2 - last_slice),
-                src_linesize * 2, srcbuf_stride,
-                width, 1, in_scale);
-
-        for (int y = 0; y < slice_end - slice_start; y += 2) {
-            if (s->pscrn > 0)
-                s->prescreen[s->pscrn > 1](ctx, srcbuf + (y / 2) * srcbuf_stride + 32,
-                             srcbuf_stride, prescreen_buf, width,
-                             &s->prescreener[s->pscrn - 1]);
-
-            predictor(ctx,
-                      srcbuf + (y / 2) * srcbuf_stride + 32,
-                      srcbuf_stride,
-                      dstbuf + (y / 2) * dstbuf_stride,
-                      prescreen_buf, width,
-                      &s->coeffs[s->etype][s->nnsparam][s->nsize], s->qual == 2);
-
-            if (s->pscrn > 0)
-                interpolation(srcbuf + (y / 2) * srcbuf_stride + 32,
-                              srcbuf_stride,
-                              dstbuf + (y / 2) * dstbuf_stride,
-                              prescreen_buf, width);
-        }
-
-        s->write(dstbuf, out_line, dstbuf_stride, dst_linesize * 2,
-                 width, slice_height, depth, out_scale);
+    } else { // new prescreener
+        // only int16 dot products
+        s->readpixels = byte2word64;
+        s->compute_network0 = compute_network0new;
     }
 
-    return 0;
+    // evalfunc_1
+    s->wae5 = weighted_avg_elliott_mul5_m16;
+
+    if (s->fapprox & 2) { // use int16 dot products
+        s->extract = extract_m8_i16;
+        s->dot_prod = dot_prods;
+    } else { // use float dot products
+        s->extract = extract_m8;
+        s->dot_prod = dot_prod;
+    }
+
+    s->expfunc = e2_m16;
+}
+
+static int modnpf(const int m, const int n)
+{
+    if ((m % n) == 0)
+        return m;
+    return m + n - (m % n);
 }
 
 static int get_frame(AVFilterContext *ctx, int is_second)
 {
     NNEDIContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    AVFrame *dst;
+    AVFrame *src = s->src;
+    FrameData *frame_data;
+    int effective_field = s->field;
+    size_t temp_size;
+    int field_n;
+    int plane;
 
-    dst = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    if (!dst)
+    if (effective_field > 1)
+        effective_field -= 2;
+    else if (effective_field < 0)
+        effective_field += 2;
+
+    if (s->field < 0 && src->interlaced_frame && src->top_field_first == 0)
+        effective_field = 0;
+    else if (s->field < 0 && src->interlaced_frame && src->top_field_first == 1)
+        effective_field = 1;
+    else
+        effective_field = !effective_field;
+
+    if (s->field > 1 || s->field == -2) {
+        if (is_second) {
+            field_n = (effective_field == 0);
+        } else {
+            field_n = (effective_field == 1);
+        }
+    } else {
+        field_n = effective_field;
+    }
+
+    s->dst = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+    if (!s->dst)
         return AVERROR(ENOMEM);
-    av_frame_copy_props(dst, s->prev);
-    dst->interlaced_frame = 0;
-    dst->pts = s->pts;
+    av_frame_copy_props(s->dst, src);
+    s->dst->interlaced_frame = 0;
 
-    ctx->internal->execute(ctx, filter_slice, dst, NULL, FFMIN(s->planeheight[1] / 2, s->nb_threads));
+    frame_data = &s->frame_data;
 
-    if (s->field == -2 || s->field > 1)
-        s->field_n = !s->field_n;
+    for (plane = 0; plane < s->nb_planes; plane++) {
+        int dst_height = s->planeheight[plane];
+        int dst_width = s->linesize[plane];
 
-    return ff_filter_frame(outlink, dst);
+        const int min_alignment = 16;
+        const int min_pad = 10;
+
+        if (!(s->process_plane & (1 << plane))) {
+            av_image_copy_plane(s->dst->data[plane], s->dst->linesize[plane],
+                                src->data[plane], src->linesize[plane],
+                                s->linesize[plane],
+                                s->planeheight[plane]);
+            continue;
+        }
+
+        frame_data->padded_width[plane]  = dst_width + 64;
+        frame_data->padded_height[plane] = dst_height + 12;
+        frame_data->padded_stride[plane] = modnpf(frame_data->padded_width[plane] + min_pad, min_alignment); // TODO: maybe min_pad is in pixels too?
+        if (!frame_data->paddedp[plane]) {
+            frame_data->paddedp[plane] = av_malloc_array(frame_data->padded_stride[plane], frame_data->padded_height[plane]);
+            if (!frame_data->paddedp[plane])
+                return AVERROR(ENOMEM);
+        }
+
+        frame_data->dstp[plane] = s->dst->data[plane];
+        frame_data->dst_stride[plane] = s->dst->linesize[plane];
+
+        if (!frame_data->lcount[plane]) {
+            frame_data->lcount[plane] = av_calloc(dst_height, sizeof(int32_t) * 16);
+            if (!frame_data->lcount[plane])
+                return AVERROR(ENOMEM);
+        } else {
+            memset(frame_data->lcount[plane], 0, dst_height * sizeof(int32_t) * 16);
+        }
+
+        frame_data->field[plane] = field_n;
+    }
+
+    if (!frame_data->input) {
+        frame_data->input = av_malloc(512 * sizeof(float));
+        if (!frame_data->input)
+            return AVERROR(ENOMEM);
+    }
+    // evalfunc_0 requires at least padded_width[0] bytes.
+    // evalfunc_1 requires at least 512 floats.
+    if (!frame_data->temp) {
+        temp_size = FFMAX(frame_data->padded_width[0], 512 * sizeof(float));
+        frame_data->temp = av_malloc(temp_size);
+        if (!frame_data->temp)
+            return AVERROR(ENOMEM);
+    }
+
+    // Copy src to a padded "frame" in frame_data and mirror the edges.
+    s->copy_pad(src, frame_data, s, field_n);
+
+    // Handles prescreening and the cubic interpolation.
+    s->evalfunc_0(s, frame_data);
+
+    // The rest.
+    s->evalfunc_1(s, frame_data);
+
+    return 0;
 }
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+static int filter_frame(AVFilterLink *inlink, AVFrame *src)
 {
     AVFilterContext *ctx = inlink->dst;
+    AVFilterLink *outlink = ctx->outputs[0];
     NNEDIContext *s = ctx->priv;
     int ret;
 
-    if (!s->prev) {
-        s->prev = in;
-        return 0;
+    if ((s->field > 1 ||
+         s->field == -2) && !s->second) {
+        goto second;
+    } else if (s->field > 1 ||
+               s->field == -2) {
+        AVFrame *dst;
+
+        s->src = s->second;
+        ret = get_frame(ctx, 1);
+        if (ret < 0) {
+            av_frame_free(&s->dst);
+            av_frame_free(&s->second);
+            s->src = NULL;
+            return ret;
+        }
+        dst = s->dst;
+
+        if (src->pts != AV_NOPTS_VALUE &&
+            dst->pts != AV_NOPTS_VALUE)
+            dst->pts += src->pts;
+        else
+            dst->pts = AV_NOPTS_VALUE;
+
+        ret = ff_filter_frame(outlink, dst);
+        if (ret < 0)
+            return ret;
+        if (s->eof)
+            return 0;
+        s->cur_pts = s->second->pts;
+        av_frame_free(&s->second);
+second:
+        if ((s->deint && src->interlaced_frame &&
+             !ctx->is_disabled) ||
+            (!s->deint && !ctx->is_disabled)) {
+            s->second = src;
+        }
     }
 
-    if ((s->deint && !in->interlaced_frame) || ctx->is_disabled) {
-        s->prev->pts *= 2;
-        ret = ff_filter_frame(ctx->outputs[0], s->prev);
-        s->prev = in;
-        return ret;
+    if ((s->deint && !src->interlaced_frame) || ctx->is_disabled) {
+        AVFrame *dst = av_frame_clone(src);
+        if (!dst) {
+            av_frame_free(&src);
+            av_frame_free(&s->second);
+            return AVERROR(ENOMEM);
+        }
+
+        if (s->field > 1 || s->field == -2) {
+            av_frame_free(&s->second);
+            if ((s->deint && src->interlaced_frame) ||
+                (!s->deint))
+                s->second = src;
+        } else {
+            av_frame_free(&src);
+        }
+        if (dst->pts != AV_NOPTS_VALUE)
+            dst->pts *= 2;
+        return ff_filter_frame(outlink, dst);
     }
 
-    s->pts = s->prev->pts * 2;
+    s->src = src;
     ret = get_frame(ctx, 0);
-    if (ret < 0 || (s->field > -2 && s->field < 2)) {
-        av_frame_free(&s->prev);
-        s->prev = in;
+    if (ret < 0) {
+        av_frame_free(&s->dst);
+        av_frame_free(&s->src);
+        av_frame_free(&s->second);
         return ret;
     }
 
-    s->pts = s->prev->pts + in->pts;
-    ret = get_frame(ctx, 1);
-    av_frame_free(&s->prev);
-    s->prev = in;
-    return ret;
+    if (src->pts != AV_NOPTS_VALUE)
+        s->dst->pts = src->pts * 2;
+    if (s->field <= 1 && s->field > -2) {
+        av_frame_free(&src);
+        s->src = NULL;
+    }
+
+    return ff_filter_frame(outlink, s->dst);
 }
 
 static int request_frame(AVFilterLink *link)
@@ -728,241 +887,40 @@
 
     ret  = ff_request_frame(ctx->inputs[0]);
 
-    if (ret == AVERROR_EOF && s->prev) {
-        AVFrame *next = av_frame_clone(s->prev);
+    if (ret == AVERROR_EOF && s->second) {
+        AVFrame *next = av_frame_clone(s->second);
 
         if (!next)
             return AVERROR(ENOMEM);
 
-        next->pts = s->prev->pts + av_rescale_q(1, av_inv_q(ctx->outputs[0]->frame_rate),
-                                                ctx->outputs[0]->time_base);
+        next->pts = s->second->pts * 2 - s->cur_pts;
         s->eof = 1;
 
-        ret = filter_frame(ctx->inputs[0], next);
+        filter_frame(ctx->inputs[0], next);
     } else if (ret < 0) {
         return ret;
     }
 
-    return ret;
-}
-
-static void copy_weights(float *dst, int n, const float **data)
-{
-    memcpy(dst, *data, n * sizeof(float));
-    *data += n;
-}
-
-static float *allocate(float **ptr, int size)
-{
-    float *ret = *ptr;
-
-    *ptr += size;
-
-    return ret;
-}
-
-static int allocate_model(PredictorCoefficients *coeffs, int xdim, int ydim, int nns)
-{
-    int filter_size = nns * xdim * ydim;
-    int bias_size = nns;
-    float *data;
-
-    data = av_calloc(filter_size + bias_size, 4 * sizeof(float));
-    if (!data)
-        return AVERROR(ENOMEM);
-
-    coeffs->data = data;
-    coeffs->xdim = xdim;
-    coeffs->ydim = ydim;
-    coeffs->nsize = xdim * ydim;
-    coeffs->nns  = nns;
-
-    coeffs->softmax_q1 = allocate(&data, filter_size);
-    coeffs->elliott_q1 = allocate(&data, filter_size);
-    coeffs->softmax_bias_q1 = allocate(&data, bias_size);
-    coeffs->elliott_bias_q1 = allocate(&data, bias_size);
-
-    coeffs->softmax_q2 = allocate(&data, filter_size);
-    coeffs->elliott_q2 = allocate(&data, filter_size);
-    coeffs->softmax_bias_q2 = allocate(&data, bias_size);
-    coeffs->elliott_bias_q2 = allocate(&data, bias_size);
-
     return 0;
 }
 
-static int read_weights(AVFilterContext *ctx, const float *bdata)
-{
-    NNEDIContext *s = ctx->priv;
-    int ret;
-
-    copy_weights(&s->prescreener[0].kernel_l0[0][0], 4 * 48, &bdata);
-    copy_weights(s->prescreener[0].bias_l0, 4, &bdata);
-
-    copy_weights(&s->prescreener[0].kernel_l1[0][0], 4 * 4, &bdata);
-    copy_weights(s->prescreener[0].bias_l1, 4, &bdata);
-
-    copy_weights(&s->prescreener[0].kernel_l2[0][0], 4 * 8, &bdata);
-    copy_weights(s->prescreener[0].bias_l2, 4, &bdata);
-
-    for (int i = 0; i < 3; i++) {
-        PrescreenerCoefficients *data = &s->prescreener[i + 1];
-        float kernel_l0_shuffled[4 * 64];
-        float kernel_l1_shuffled[4 * 4];
-
-        copy_weights(kernel_l0_shuffled, 4 * 64, &bdata);
-        copy_weights(data->bias_l0, 4, &bdata);
-
-        copy_weights(kernel_l1_shuffled, 4 * 4, &bdata);
-        copy_weights(data->bias_l1, 4, &bdata);
-
-        for (int n = 0; n < 4; n++) {
-            for (int k = 0; k < 64; k++)
-                data->kernel_l0[n][k] = kernel_l0_shuffled[(k / 8) * 32 + n * 8 + k % 8];
-            for (int k = 0; k < 4; k++)
-                data->kernel_l1[n][k] = kernel_l1_shuffled[k * 4 + n];
-        }
-    }
-
-    for (int m = 0; m < 2; m++) {
-        // Grouping by neuron count.
-        for (int i = 0; i < 5; i++) {
-            const int nns = NNEDI_NNS[i];
-
-            // Grouping by window size.
-            for (int j = 0; j < 7; j++) {
-                PredictorCoefficients *model = &s->coeffs[m][i][j];
-                const int xdim = NNEDI_XDIM[j];
-                const int ydim = NNEDI_YDIM[j];
-                const int filter_size = xdim * ydim;
-
-                ret = allocate_model(model, xdim, ydim, nns);
-                if (ret < 0)
-                    return ret;
-
-                // Quality 1 model. NNS[i] * (XDIM[j] * YDIM[j]) * 2 coefficients.
-                copy_weights(model->softmax_q1, nns * filter_size, &bdata);
-                copy_weights(model->elliott_q1, nns * filter_size, &bdata);
-
-                // Quality 1 model bias. NNS[i] * 2 coefficients.
-                copy_weights(model->softmax_bias_q1, nns, &bdata);
-                copy_weights(model->elliott_bias_q1, nns, &bdata);
-
-                // Quality 2 model. NNS[i] * (XDIM[j] * YDIM[j]) * 2 coefficients.
-                copy_weights(model->softmax_q2, nns * filter_size, &bdata);
-                copy_weights(model->elliott_q2, nns * filter_size, &bdata);
-
-                // Quality 2 model bias. NNS[i] * 2 coefficients.
-                copy_weights(model->softmax_bias_q2, nns, &bdata);
-                copy_weights(model->elliott_bias_q2, nns, &bdata);
-            }
-        }
-    }
-
-    return 0;
-}
-
-static float mean(const float *input, int size)
-{
-    float sum = 0.f;
-
-    for (int i = 0; i < size; i++)
-        sum += input[i];
-
-    return sum / size;
-}
-
-static void transform(float *input, int size, float mean, float half)
-{
-    for (int i = 0; i < size; i++)
-        input[i] = (input[i] - mean) / half;
-}
-
-static void subtract_mean_old(PrescreenerCoefficients *coeffs, float half)
-{
-    for (int n = 0; n < 4; n++) {
-        float m = mean(coeffs->kernel_l0[n], 48);
-
-        transform(coeffs->kernel_l0[n], 48, m, half);
-    }
-}
-
-static void subtract_mean_new(PrescreenerCoefficients *coeffs, float half)
-{
-    for (int n = 0; n < 4; n++) {
-        float m = mean(coeffs->kernel_l0[n], 64);
-
-        transform(coeffs->kernel_l0[n], 64, m, half);
-    }
-}
-
-static void subtract_mean_predictor(PredictorCoefficients *model)
-{
-    const int filter_size = model->nsize;
-    const int nns = model->nns;
-    const float scale = 1.f / nns;
-
-    double softmax_means[256]; // Average of individual softmax filters.
-    double elliott_means[256]; // Average of individual elliott filters.
-    double mean_filter[48 * 6] = { 0 }; // Pointwise average of all softmax filters.
-    double mean_bias;
-
-    // Quality 1.
-    for (int nn = 0; nn < nns; nn++) {
-        softmax_means[nn] = mean(model->softmax_q1 + nn * filter_size, filter_size);
-        elliott_means[nn] = mean(model->elliott_q1 + nn * filter_size, filter_size);
-
-        for (int k = 0; k < filter_size; k++)
-            mean_filter[k] += model->softmax_q1[nn * filter_size + k] - softmax_means[nn];
-    }
-
-    for (int k = 0; k < filter_size; k++)
-        mean_filter[k] *= scale;
-
-    mean_bias = mean(model->softmax_bias_q1, nns);
-
-    for (int nn = 0; nn < nns; nn++) {
-        for (int k = 0; k < filter_size; k++) {
-            model->softmax_q1[nn * filter_size + k] -= softmax_means[nn] + mean_filter[k];
-            model->elliott_q1[nn * filter_size + k] -= elliott_means[nn];
-        }
-        model->softmax_bias_q1[nn] -= mean_bias;
-    }
-
-    // Quality 2.
-    memset(mean_filter, 0, sizeof(mean_filter));
-
-    for (int nn = 0; nn < nns; nn++) {
-        softmax_means[nn] = mean(model->softmax_q2 + nn * filter_size, filter_size);
-        elliott_means[nn] = mean(model->elliott_q2 + nn * filter_size, filter_size);
-
-        for (int k = 0; k < filter_size; k++) {
-            mean_filter[k] += model->softmax_q2[nn * filter_size + k] - softmax_means[nn];
-        }
-    }
-
-    for (int k = 0; k < filter_size; k++)
-        mean_filter[k] *= scale;
-
-    mean_bias = mean(model->softmax_bias_q2, nns);
-
-    for (int nn = 0; nn < nns; nn++) {
-        for (int k = 0; k < filter_size; k++) {
-            model->softmax_q2[nn * filter_size + k] -= softmax_means[nn] + mean_filter[k];
-            model->elliott_q2[nn * filter_size + k] -= elliott_means[nn];
-        }
-
-        model->softmax_bias_q2[nn] -= mean_bias;
-    }
-}
-
 static av_cold int init(AVFilterContext *ctx)
 {
     NNEDIContext *s = ctx->priv;
     FILE *weights_file = NULL;
+    int64_t expected_size = 13574928;
     int64_t weights_size;
     float *bdata;
     size_t bytes_read;
-    int ret = 0;
+    const int xdia_table[NUM_NSIZE] = { 8, 16, 32, 48, 8, 16, 32 };
+    const int ydia_table[NUM_NSIZE] = { 6, 6, 6, 6, 4, 4, 4 };
+    const int nns_table[NUM_NNS] = { 16, 32, 64, 128, 256 };
+    const int dims0 = 49 * 4 + 5 * 4 + 9 * 4;
+    const int dims0new = 4 * 65 + 4 * 5;
+    const int dims1 = nns_table[s->nnsparam] * 2 * (xdia_table[s->nsize] * ydia_table[s->nsize] + 1);
+    int dims1tsize = 0;
+    int dims1offset = 0;
+    int ret = 0, i, j, k;
 
     weights_file = av_fopen_utf8(s->weights_file, "rb");
     if (!weights_file) {
@@ -982,7 +940,7 @@
         fclose(weights_file);
         av_log(ctx, AV_LOG_ERROR, "Couldn't get size of weights file.\n");
         return AVERROR(EINVAL);
-    } else if (weights_size != NNEDI_WEIGHTS_SIZE) {
+    } else if (weights_size != expected_size) {
         fclose(weights_file);
         av_log(ctx, AV_LOG_ERROR, "Unexpected weights file size.\n");
         return AVERROR(EINVAL);
@@ -994,14 +952,15 @@
         return AVERROR(EINVAL);
     }
 
-    bdata = av_malloc(NNEDI_WEIGHTS_SIZE);
+    bdata = (float *)av_malloc(expected_size);
     if (!bdata) {
         fclose(weights_file);
         return AVERROR(ENOMEM);
     }
 
-    bytes_read = fread(bdata, 1, NNEDI_WEIGHTS_SIZE, weights_file);
-    if (bytes_read != NNEDI_WEIGHTS_SIZE) {
+    bytes_read = fread(bdata, 1, expected_size, weights_file);
+
+    if (bytes_read != (size_t)expected_size) {
         fclose(weights_file);
         ret = AVERROR_INVALIDDATA;
         av_log(ctx, AV_LOG_ERROR, "Couldn't read weights file.\n");
@@ -1010,132 +969,212 @@
 
     fclose(weights_file);
 
-    s->fdsp = avpriv_float_dsp_alloc(0);
-    if (!s->fdsp) {
+    for (j = 0; j < NUM_NNS; j++) {
+        for (i = 0; i < NUM_NSIZE; i++) {
+            if (i == s->nsize && j == s->nnsparam)
+                dims1offset = dims1tsize;
+            dims1tsize += nns_table[j] * 2 * (xdia_table[i] * ydia_table[i] + 1) * 2;
+        }
+    }
+
+    s->weights0 = av_malloc_array(FFMAX(dims0, dims0new), sizeof(float));
+    if (!s->weights0) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }
 
-    ret = read_weights(ctx, bdata);
-    if (ret < 0)
-        goto fail;
+    for (i = 0; i < 2; i++) {
+        s->weights1[i] = av_malloc_array(dims1, sizeof(float));
+        if (!s->weights1[i]) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
+    }
+
+    // Adjust prescreener weights
+    if (s->pscrn >= 2) {// using new prescreener
+        const float *bdw;
+        int16_t *ws;
+        float *wf;
+        double mean[4] = { 0.0, 0.0, 0.0, 0.0 };
+        int *offt = av_calloc(4 * 64, sizeof(int));
+
+        if (!offt) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
+
+        for (j = 0; j < 4; j++)
+            for (k = 0; k < 64; k++)
+                offt[j * 64 + k] = ((k >> 3) << 5) + ((j & 3) << 3) + (k & 7);
+
+        bdw = bdata + dims0 + dims0new * (s->pscrn - 2);
+        ws = (int16_t *)s->weights0;
+        wf = (float *)&ws[4 * 64];
+        // Calculate mean weight of each first layer neuron
+        for (j = 0; j < 4; j++) {
+            double cmean = 0.0;
+            for (k = 0; k < 64; k++)
+                cmean += bdw[offt[j * 64 + k]];
+            mean[j] = cmean / 64.0;
+        }
+        // Factor mean removal and 1.0/127.5 scaling
+        // into first layer weights. scale to int16 range
+        for (j = 0; j < 4; j++) {
+            double scale, mval = 0.0;
+
+            for (k = 0; k < 64; k++)
+                mval = FFMAX(mval, FFABS((bdw[offt[j * 64 + k]] - mean[j]) / 127.5));
+            scale = 32767.0 / mval;
+            for (k = 0; k < 64; k++)
+                ws[offt[j * 64 + k]] = roundds(((bdw[offt[j * 64 + k]] - mean[j]) / 127.5) * scale);
+            wf[j] = (float)(mval / 32767.0);
+        }
+        memcpy(wf + 4, bdw + 4 * 64, (dims0new - 4 * 64) * sizeof(float));
+        av_free(offt);
+    } else { // using old prescreener
+        double mean[4] = { 0.0, 0.0, 0.0, 0.0 };
+        // Calculate mean weight of each first layer neuron
+        for (j = 0; j < 4; j++) {
+            double cmean = 0.0;
+            for (k = 0; k < 48; k++)
+                cmean += bdata[j * 48 + k];
+            mean[j] = cmean / 48.0;
+        }
+        if (s->fapprox & 1) {// use int16 dot products in first layer
+            int16_t *ws = (int16_t *)s->weights0;
+            float *wf = (float *)&ws[4 * 48];
+            // Factor mean removal and 1.0/127.5 scaling
+            // into first layer weights. scale to int16 range
+            for (j = 0; j < 4; j++) {
+                double scale, mval = 0.0;
+                for (k = 0; k < 48; k++)
+                    mval = FFMAX(mval, FFABS((bdata[j * 48 + k] - mean[j]) / 127.5));
+                scale = 32767.0 / mval;
+                for (k = 0; k < 48; k++)
+                    ws[j * 48 + k] = roundds(((bdata[j * 48 + k] - mean[j]) / 127.5) * scale);
+                wf[j] = (float)(mval / 32767.0);
+            }
+            memcpy(wf + 4, bdata + 4 * 48, (dims0 - 4 * 48) * sizeof(float));
+        } else {// use float dot products in first layer
+            double half = (1 << 8) - 1;
+
+            half /= 2;
+
+            // Factor mean removal and 1.0/half scaling
+            // into first layer weights.
+            for (j = 0; j < 4; j++)
+                for (k = 0; k < 48; k++)
+                    s->weights0[j * 48 + k] = (float)((bdata[j * 48 + k] - mean[j]) / half);
+            memcpy(s->weights0 + 4 * 48, bdata + 4 * 48, (dims0 - 4 * 48) * sizeof(float));
+        }
+    }
+
+    // Adjust prediction weights
+    for (i = 0; i < 2; i++) {
+        const float *bdataT = bdata + dims0 + dims0new * 3 + dims1tsize * s->etype + dims1offset + i * dims1;
+        const int nnst = nns_table[s->nnsparam];
+        const int asize = xdia_table[s->nsize] * ydia_table[s->nsize];
+        const int boff = nnst * 2 * asize;
+        double *mean = (double *)av_calloc(asize + 1 + nnst * 2, sizeof(double));
+
+        if (!mean) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
+
+        // Calculate mean weight of each neuron (ignore bias)
+        for (j = 0; j < nnst * 2; j++) {
+            double cmean = 0.0;
+            for (k = 0; k < asize; k++)
+                cmean += bdataT[j * asize + k];
+            mean[asize + 1 + j] = cmean / (double)asize;
+        }
+        // Calculate mean softmax neuron
+        for (j = 0; j < nnst; j++) {
+            for (k = 0; k < asize; k++)
+                mean[k] += bdataT[j * asize + k] - mean[asize + 1 + j];
+            mean[asize] += bdataT[boff + j];
+        }
+        for (j = 0; j < asize + 1; j++)
+            mean[j] /= (double)(nnst);
+
+        if (s->fapprox & 2) { // use int16 dot products
+            int16_t *ws = (int16_t *)s->weights1[i];
+            float *wf = (float *)&ws[nnst * 2 * asize];
+            // Factor mean removal into weights, remove global offset from
+            // softmax neurons, and scale weights to int16 range.
+            for (j = 0; j < nnst; j++) { // softmax neurons
+                double scale, mval = 0.0;
+                for (k = 0; k < asize; k++)
+                    mval = FFMAX(mval, FFABS(bdataT[j * asize + k] - mean[asize + 1 + j] - mean[k]));
+                scale = 32767.0 / mval;
+                for (k = 0; k < asize; k++)
+                    ws[j * asize + k] = roundds((bdataT[j * asize + k] - mean[asize + 1 + j] - mean[k]) * scale);
+                wf[(j >> 2) * 8 + (j & 3)] = (float)(mval / 32767.0);
+                wf[(j >> 2) * 8 + (j & 3) + 4] = (float)(bdataT[boff + j] - mean[asize]);
+            }
+            for (j = nnst; j < nnst * 2; j++) { // elliott neurons
+                double scale, mval = 0.0;
+                for (k = 0; k < asize; k++)
+                    mval = FFMAX(mval, FFABS(bdataT[j * asize + k] - mean[asize + 1 + j]));
+                scale = 32767.0 / mval;
+                for (k = 0; k < asize; k++)
+                    ws[j * asize + k] = roundds((bdataT[j * asize + k] - mean[asize + 1 + j]) * scale);
+                wf[(j >> 2) * 8 + (j & 3)] = (float)(mval / 32767.0);
+                wf[(j >> 2) * 8 + (j & 3) + 4] = bdataT[boff + j];
+            }
+        } else { // use float dot products
+            // Factor mean removal into weights, and remove global
+            // offset from softmax neurons.
+            for (j = 0; j < nnst * 2; j++) {
+                for (k = 0; k < asize; k++) {
+                    const double q = j < nnst ? mean[k] : 0.0;
+                    s->weights1[i][j * asize + k] = (float)(bdataT[j * asize + k] - mean[asize + 1 + j] - q);
+                }
+                s->weights1[i][boff + j] = (float)(bdataT[boff + j] - (j < nnst ? mean[asize] : 0.0));
+            }
+        }
+        av_free(mean);
+    }
+
+    s->nns = nns_table[s->nnsparam];
+    s->xdia = xdia_table[s->nsize];
+    s->ydia = ydia_table[s->nsize];
+    s->asize = xdia_table[s->nsize] * ydia_table[s->nsize];
+
+    s->max_value = 65535 >> 8;
+
+    select_functions(s);
+
+    s->fdsp = avpriv_float_dsp_alloc(0);
+    if (!s->fdsp)
+        ret = AVERROR(ENOMEM);
 
 fail:
     av_free(bdata);
     return ret;
 }
 
-static int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    NNEDIContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int ret;
-
-    s->depth = desc->comp[0].depth;
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
-    s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-    if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
-        return ret;
-
-    s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0] = s->planewidth[3] = inlink->w;
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-
-    s->half = ((1 << 8) - 1) / 2.f;
-    s->out_scale = 1 << (s->depth - 8);
-    s->in_scale = 1.f / s->out_scale;
-
-    switch (s->depth) {
-    case 8:
-        s->read  = read_bytes;
-        s->write = write_bytes;
-        break;
-    default:
-        s->read  = read_words;
-        s->write = write_words;
-        break;
-    }
-
-    subtract_mean_old(&s->prescreener[0], s->half);
-    subtract_mean_new(&s->prescreener[1], s->half);
-    subtract_mean_new(&s->prescreener[2], s->half);
-    subtract_mean_new(&s->prescreener[3], s->half);
-
-    s->prescreen[0] = process_old;
-    s->prescreen[1] = process_new;
-
-    for (int i = 0; i < 2; i++) {
-        for (int j = 0; j < 5; j++) {
-            for (int k = 0; k < 7; k++)
-                subtract_mean_predictor(&s->coeffs[i][j][k]);
-        }
-    }
-
-    s->input_size = (s->planewidth[0] + 64) * (s->planeheight[0] + 6);
-    s->input_buf = av_calloc(s->nb_threads, sizeof(*s->input_buf));
-    if (!s->input_buf)
-        return AVERROR(ENOMEM);
-
-    for (int i = 0; i < s->nb_threads; i++) {
-        s->input_buf[i] = av_calloc(s->input_size, sizeof(**s->input_buf));
-        if (!s->input_buf[i])
-            return AVERROR(ENOMEM);
-    }
-
-    s->output_buf = av_calloc(s->nb_threads, sizeof(*s->output_buf));
-    if (!s->output_buf)
-        return AVERROR(ENOMEM);
-
-    for (int i = 0; i < s->nb_threads; i++) {
-        s->output_buf[i] = av_calloc(s->input_size, sizeof(**s->output_buf));
-        if (!s->output_buf[i])
-            return AVERROR(ENOMEM);
-    }
-
-    s->prescreen_buf = av_calloc(s->nb_threads, sizeof(*s->prescreen_buf));
-    if (!s->prescreen_buf)
-        return AVERROR(ENOMEM);
-
-    for (int i = 0; i < s->nb_threads; i++) {
-        s->prescreen_buf[i] = av_calloc(s->planewidth[0], sizeof(**s->prescreen_buf));
-        if (!s->prescreen_buf[i])
-            return AVERROR(ENOMEM);
-    }
-
-    return 0;
-}
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
     NNEDIContext *s = ctx->priv;
+    int i;
 
-    for (int i = 0; i < s->nb_threads && s->prescreen_buf; i++)
-        av_freep(&s->prescreen_buf[i]);
+    av_freep(&s->weights0);
 
-    av_freep(&s->prescreen_buf);
+    for (i = 0; i < 2; i++)
+        av_freep(&s->weights1[i]);
 
-    for (int i = 0; i < s->nb_threads && s->input_buf; i++)
-        av_freep(&s->input_buf[i]);
-
-    av_freep(&s->input_buf);
-
-    for (int i = 0; i < s->nb_threads && s->output_buf; i++)
-        av_freep(&s->output_buf[i]);
-
-    av_freep(&s->output_buf);
-    av_freep(&s->fdsp);
-
-    for (int i = 0; i < 2; i++) {
-        for (int j = 0; j < 5; j++) {
-            for (int k = 0; k < 7; k++) {
-                av_freep(&s->coeffs[i][j][k].data);
-            }
-        }
+    for (i = 0; i < s->nb_planes; i++) {
+        av_freep(&s->frame_data.paddedp[i]);
+        av_freep(&s->frame_data.lcount[i]);
     }
 
-    av_frame_free(&s->prev);
+    av_freep(&s->frame_data.input);
+    av_freep(&s->frame_data.temp);
+    av_freep(&s->fdsp);
+    av_frame_free(&s->second);
 }
 
 static const AVFilterPad inputs[] = {
@@ -1168,6 +1207,5 @@
     .query_formats = query_formats,
     .inputs        = inputs,
     .outputs       = outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
+    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
 };
diff --git a/libavfilter/vf_owdenoise.c b/libavfilter/vf_owdenoise.c
index 7dfe10f..6d6c2a3 100644
--- a/libavfilter/vf_owdenoise.c
+++ b/libavfilter/vf_owdenoise.c
@@ -30,7 +30,6 @@
 
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "internal.h"
diff --git a/libavfilter/vf_phase.c b/libavfilter/vf_phase.c
index d4f580a..8536444 100644
--- a/libavfilter/vf_phase.c
+++ b/libavfilter/vf_phase.c
@@ -74,7 +74,7 @@
 } PhaseContext;
 
 #define OFFSET(x) offsetof(PhaseContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
 
 static const AVOption phase_options[] = {
@@ -245,5 +245,4 @@
     .inputs        = phase_inputs,
     .outputs       = phase_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_pp.c b/libavfilter/vf_pp.c
index 19a0f9f..524ef1b 100644
--- a/libavfilter/vf_pp.c
+++ b/libavfilter/vf_pp.c
@@ -26,9 +26,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/opt.h"
-
 #include "internal.h"
-#include "qp_table.h"
 
 #include "libpostproc/postprocess.h"
 
@@ -128,9 +126,8 @@
     const int aligned_w = FFALIGN(outlink->w, 8);
     const int aligned_h = FFALIGN(outlink->h, 8);
     AVFrame *outbuf;
-    int qstride = 0;
-    int8_t *qp_table = NULL;
-    int ret;
+    int qstride, qp_type;
+    int8_t *qp_table ;
 
     outbuf = ff_get_video_buffer(outlink, aligned_w, aligned_h);
     if (!outbuf) {
@@ -140,13 +137,7 @@
     av_frame_copy_props(outbuf, inbuf);
     outbuf->width  = inbuf->width;
     outbuf->height = inbuf->height;
-
-    ret = ff_qp_table_extract(inbuf, &qp_table, &qstride, NULL, NULL);
-    if (ret < 0) {
-        av_frame_free(&inbuf);
-        av_frame_free(&outbuf);
-        return ret;
-    }
+    qp_table = av_frame_get_qp_table(inbuf, &qstride, &qp_type);
 
     pp_postprocess((const uint8_t **)inbuf->data, inbuf->linesize,
                    outbuf->data,                 outbuf->linesize,
@@ -155,10 +146,9 @@
                    qstride,
                    pp->modes[pp->mode_id],
                    pp->pp_ctx,
-                   outbuf->pict_type | (qp_table ? PP_PICT_TYPE_QP2 : 0));
+                   outbuf->pict_type | (qp_type ? PP_PICT_TYPE_QP2 : 0));
 
     av_frame_free(&inbuf);
-    av_freep(&qp_table);
     return ff_filter_frame(outlink, outbuf);
 }
 
diff --git a/libavfilter/vf_pp7.c b/libavfilter/vf_pp7.c
index ade7feb..570a1c9 100644
--- a/libavfilter/vf_pp7.c
+++ b/libavfilter/vf_pp7.c
@@ -29,11 +29,9 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
-#include "qp_table.h"
 #include "vf_pp7.h"
 
 enum mode {
@@ -324,15 +322,10 @@
     AVFrame *out = in;
 
     int qp_stride = 0;
-    int8_t *qp_table = NULL;
+    uint8_t *qp_table = NULL;
 
-    if (!pp7->qp) {
-        int ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL, &pp7->qscale_type);
-        if (ret < 0) {
-            av_frame_free(&in);
-            return ret;
-        }
-    }
+    if (!pp7->qp)
+        qp_table = av_frame_get_qp_table(in, &qp_stride, &pp7->qscale_type);
 
     if (!ctx->is_disabled) {
         const int cw = AV_CEIL_RSHIFT(inlink->w, pp7->hsub);
@@ -347,7 +340,6 @@
             out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
             if (!out) {
                 av_frame_free(&in);
-                av_freep(&qp_table);
                 return AVERROR(ENOMEM);
             }
             av_frame_copy_props(out, in);
@@ -374,7 +366,6 @@
                                 inlink->w, inlink->h);
         av_frame_free(&in);
     }
-    av_freep(&qp_table);
     return ff_filter_frame(outlink, out);
 }
 
diff --git a/libavfilter/vf_pseudocolor.c b/libavfilter/vf_pseudocolor.c
index 6f67c02..e48b69c 100644
--- a/libavfilter/vf_pseudocolor.c
+++ b/libavfilter/vf_pseudocolor.c
@@ -59,112 +59,8 @@
     VAR_VARS_NB
 };
 
-enum Curves {
-    MAGMA,
-    INFERNO,
-    PLASMA,
-    VIRIDIS,
-    TURBO,
-    CIVIDIS,
-    NB_CURVES,
-};
-
-enum Presets {
-    PRESET_MAGMA,
-    PRESET_INFERNO,
-    PRESET_PLASMA,
-    PRESET_VIRIDIS,
-    PRESET_TURBO,
-    PRESET_CIVIDIS,
-    PRESET_RANGE1,
-    PRESET_RANGE2,
-    PRESET_SHADOWS,
-    PRESET_HIGHLIGHTS,
-    NB_PRESETS,
-};
-
-typedef struct Curve {
-    double coef[3][8];
-} Curve;
-
-typedef struct Fill {
-    float fill[4];
-} Fill;
-
-typedef struct Range {
-    int start, end;
-} Range;
-
-typedef struct Preset {
-    int nb_segments;
-    const Range *ranges;
-    const Curve *curves;
-    const Fill  *fills;
-} Preset;
-
-static const Range full_range   = {0, 256};
-static const Range spec1_range[] = {{0, 16}, {16, 236}, {236, 256}};
-static const Range spec2_range[] = {{0, 16}, {16, 22}, {22, 226}, {226, 236}, {236, 256}};
-static const Range shadows_range[] = {{0, 32}, {32, 256}};
-static const Range highlights_range[] = {{0, 214}, {214, 224}, {224, 256}};
-
-static const Fill spec1_fills[] = {{{0.5f, 0.f, .5f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 0.f, 0.f, 1.f}}};
-static const Fill spec2_fills[] = {{{0.5f, 0.f, .5f, 1.f}}, {{0.f, 1.f, 1.f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 1.f, 0.f, 1.f}}, {{1.f, 0.f, 0.f, 1.f}}};
-static const Fill shadows_fills[] = {{{0.8f, 0.4f, .8f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}};
-static const Fill highlights_fills[] = {{{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 0.3f, 0.6f, 1.f}}, {{1.f, 0.2f, .5f, 1.f}}};
-
-static const Curve curves[] =
-{
-    [MAGMA] = {{
-        {-7.5631093e-16,  7.4289183e-13, -2.8525484e-10,  5.4446085e-08, -5.5596238e-06,  3.0569325e-04, -2.3137421e-03,  1.2152095e-02 },
-        { 1.3217636e-15, -1.2214648e-12,  4.4319712e-10, -8.0197993e-08,  7.6598370e-06, -3.6523704e-04,  8.4836670e-03, -2.5536888e-02 },
-        {-1.1446568e-15,  1.0013446e-12, -3.5651575e-10,  6.6775016e-08, -6.7120346e-06,  2.7346619e-04,  4.7969657e-03,  1.1971441e-02 },
-    }},
-    [INFERNO] = {{
-        {-3.9848859e-18,  9.4821649e-14, -6.7371977e-11,  1.8469937e-08, -2.5359307e-06,  1.7959053e-04,  3.9782564e-04,  2.8845935e-04 },
-        { 6.8408539e-16, -6.5499979e-13,  2.4562526e-10, -4.5989298e-08,  4.5723324e-06, -2.2111913e-04,  5.2023164e-03, -1.1226064e-02 },
-        {-2.9921470e-15,  2.5864165e-12, -8.7403799e-10,  1.4713388e-07, -1.2701505e-05,  4.5159935e-04,  3.1087989e-03,  1.9122831e-02 },
-    }},
-    [PLASMA] = {{
-        { 3.6196089e-16, -3.3623041e-13,  1.2324010e-10, -2.2769060e-08,  2.2297792e-06, -1.2567829e-04,  9.9791629e-03,  5.7247918e-02 },
-        { 5.0262888e-16, -5.3193896e-13,  2.2451715e-10, -4.7529623e-08,  5.1374873e-06, -2.3260136e-04,  3.1502825e-03,  1.5362491e-02 },
-        {-1.7782261e-16,  2.2487839e-13, -1.0610236e-10,  2.4112644e-08, -2.6331623e-06,  8.9499751e-05,  2.1386328e-03,  5.3824268e-01 },
-    }},
-    [VIRIDIS] = {{
-        { 9.4850045e-16, -8.6629383e-13,  3.0310944e-10, -5.1340396e-08,  4.6024275e-06, -2.2744239e-04,  4.5559993e-03,  2.5662350e-01 },
-        { 9.6461041e-17, -6.9209477e-14,  1.7625397e-11, -2.0229773e-09,  1.4900110e-07, -1.9315187e-05,  5.8967339e-03,  3.9544827e-03 },
-        { 5.1785449e-16, -3.6663004e-13,  1.0249990e-10, -1.5431998e-08,  1.5007941e-06, -1.2001502e-04,  7.6951526e-03,  3.2292815e-01 },
-    }},
-    [TURBO] = {{
-        {-4.3683890e-15,  3.7020347e-12, -1.1712592e-09,  1.6401790e-07, -8.6842919e-06, -1.8542465e-06,  8.4485325e-03,  1.6267077e-01 },
-        {-4.0011069e-16,  2.7861423e-13, -6.3388921e-11,  5.8872238e-09, -5.4466522e-07,  1.8037114e-05,  1.0599869e-02,  7.6914696e-02 },
-        {-2.8242609e-15,  2.9234108e-12, -1.1726546e-09,  2.2552115e-07, -2.0059387e-05,  5.0595552e-04,  1.7714932e-02,  2.7271836e-01 },
-    }},
-    [CIVIDIS] = {{
-        {-9.5484131e-16,  9.6988184e-13, -4.0058766e-10,  8.5743924e-08, -9.9644797e-06,  5.9197908e-04, -1.0361579e-02,  3.3164429e-02 },
-        { 1.2731941e-17, -9.4238449e-15,  2.2808841e-12, -1.1548296e-10, -2.3888913e-08,  3.8986680e-06,  2.5879330e-03,  1.2769733e-01 },
-        { 4.6004608e-16, -5.0686849e-13,  2.2753449e-10, -5.3074099e-08,  6.7196096e-06, -4.4120020e-04,  1.3435551e-02,  2.8293355e-01 },
-    }},
-};
-
-static const Preset presets[] =
-{
-    [PRESET_MAGMA]   = { 1, &full_range, &curves[MAGMA],   NULL },
-    [PRESET_INFERNO] = { 1, &full_range, &curves[INFERNO], NULL },
-    [PRESET_PLASMA]  = { 1, &full_range, &curves[PLASMA],  NULL },
-    [PRESET_VIRIDIS] = { 1, &full_range, &curves[VIRIDIS], NULL },
-    [PRESET_TURBO]   = { 1, &full_range, &curves[TURBO],   NULL },
-    [PRESET_CIVIDIS] = { 1, &full_range, &curves[CIVIDIS], NULL },
-    [PRESET_RANGE1]  = { 3, spec1_range, NULL,             spec1_fills },
-    [PRESET_RANGE2]  = { 5, spec2_range, NULL,             spec2_fills },
-    [PRESET_SHADOWS] = { 2, shadows_range, NULL,           shadows_fills },
-    [PRESET_HIGHLIGHTS] = { 3, highlights_range, NULL,     highlights_fills },
-};
-
 typedef struct PseudoColorContext {
     const AVClass *class;
-    int preset;
-    float opacity;
     int max;
     int index;
     int nb_planes;
@@ -182,34 +78,18 @@
                       ptrdiff_t ilinesize,
                       ptrdiff_t slinesize,
                       ptrdiff_t dlinesize,
-                      float *lut,
-                      float opacity);
+                      float *lut);
 } PseudoColorContext;
 
 #define OFFSET(x) offsetof(PseudoColorContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption pseudocolor_options[] = {
     { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, {.str="val"},   .flags = FLAGS },
     { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, {.str="val"},   .flags = FLAGS },
     { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, {.str="val"},   .flags = FLAGS },
     { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, {.str="val"},   .flags = FLAGS },
-    { "index", "set component as base",    OFFSET(index),            AV_OPT_TYPE_INT,    {.i64=0}, 0, 3, .flags = FLAGS },
     { "i",  "set component as base",       OFFSET(index),            AV_OPT_TYPE_INT,    {.i64=0}, 0, 3, .flags = FLAGS },
-    { "preset", "set preset",              OFFSET(preset),           AV_OPT_TYPE_INT,    {.i64=-1},-1, NB_PRESETS-1, .flags = FLAGS, "preset" },
-    { "p",  "set preset",                  OFFSET(preset),           AV_OPT_TYPE_INT,    {.i64=-1},-1, NB_PRESETS-1, .flags = FLAGS, "preset" },
-    { "none",       NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=-1},             .flags = FLAGS, "preset" },
-    { "magma",      NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_MAGMA},   .flags = FLAGS, "preset" },
-    { "inferno",    NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_INFERNO}, .flags = FLAGS, "preset" },
-    { "plasma",     NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_PLASMA},  .flags = FLAGS, "preset" },
-    { "viridis",    NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_VIRIDIS}, .flags = FLAGS, "preset" },
-    { "turbo",      NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_TURBO},   .flags = FLAGS, "preset" },
-    { "cividis",    NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_CIVIDIS}, .flags = FLAGS, "preset" },
-    { "range1",     NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_RANGE1},  .flags = FLAGS, "preset" },
-    { "range2",     NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_RANGE2},  .flags = FLAGS, "preset" },
-    { "shadows",    NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_SHADOWS}, .flags = FLAGS, "preset" },
-    { "highlights", NULL,                  0,                        AV_OPT_TYPE_CONST,  {.i64=PRESET_HIGHLIGHTS},.flags=FLAGS, "preset" },
-    { "opacity", "set pseudocolor opacity",OFFSET(opacity),          AV_OPT_TYPE_FLOAT,  {.dbl=1}, 0, 1, .flags = FLAGS },
     { NULL }
 };
 
@@ -250,18 +130,6 @@
     return ff_set_common_formats(ctx, fmts_list);
 }
 
-static inline float lerpf(float v0, float v1, float f)
-{
-    return v0 + (v1 - v0) * f;
-}
-
-#define PCLIP(v, max, dst, src, x) \
-    if (v >= 0 && v <= max) {      \
-        dst[x] = lerpf(src[x], v, opacity);\
-    } else {                       \
-        dst[x] = src[x];           \
-    }
-
 static void pseudocolor_filter(int max, int width, int height,
                                const uint8_t *index,
                                const uint8_t *src,
@@ -269,8 +137,7 @@
                                ptrdiff_t ilinesize,
                                ptrdiff_t slinesize,
                                ptrdiff_t dlinesize,
-                               float *lut,
-                               float opacity)
+                               float *lut)
 {
     int x, y;
 
@@ -278,7 +145,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[x]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         index += ilinesize;
         src += slinesize;
@@ -293,8 +164,7 @@
                                   ptrdiff_t ilinesize,
                                   ptrdiff_t slinesize,
                                   ptrdiff_t dlinesize,
-                                  float *lut,
-                                  float opacity)
+                                  float *lut)
 {
     int x, y;
 
@@ -302,7 +172,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[(y << 1) * ilinesize + (x << 1)]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         src += slinesize;
         dst += dlinesize;
@@ -316,8 +190,7 @@
                                    ptrdiff_t ilinesize,
                                    ptrdiff_t slinesize,
                                    ptrdiff_t dlinesize,
-                                   float *lut,
-                                   float opacity)
+                                   float *lut)
 {
     int x, y;
 
@@ -325,7 +198,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[(y >> 1) * ilinesize + (x >> 1)]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         src += slinesize;
         dst += dlinesize;
@@ -339,8 +216,7 @@
                                   ptrdiff_t ilinesize,
                                   ptrdiff_t slinesize,
                                   ptrdiff_t dlinesize,
-                                  float *lut,
-                                  float opacity)
+                                  float *lut)
 {
     int x, y;
 
@@ -348,7 +224,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[x << 1]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         index += ilinesize;
         src += slinesize;
@@ -363,8 +243,7 @@
                                    ptrdiff_t ilinesize,
                                    ptrdiff_t slinesize,
                                    ptrdiff_t dlinesize,
-                                   float *lut,
-                                   float opacity)
+                                   float *lut)
 {
     int x, y;
 
@@ -372,7 +251,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[x >> 1]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         index += ilinesize;
         src += slinesize;
@@ -387,8 +270,7 @@
                                   ptrdiff_t ilinesize,
                                   ptrdiff_t slinesize,
                                   ptrdiff_t dlinesize,
-                                  float *lut,
-                                  float opacity)
+                                  float *lut)
 {
     const uint16_t *index = (const uint16_t *)iindex;
     const uint16_t *src = (const uint16_t *)ssrc;
@@ -399,7 +281,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[x]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         index += ilinesize / 2;
         src += slinesize / 2;
@@ -414,8 +300,7 @@
                                      ptrdiff_t ilinesize,
                                      ptrdiff_t slinesize,
                                      ptrdiff_t dlinesize,
-                                     float *lut,
-                                     float opacity)
+                                     float *lut)
 {
     const uint16_t *index = (const uint16_t *)iindex;
     const uint16_t *src = (const uint16_t *)ssrc;
@@ -426,7 +311,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[x << 1]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         index += ilinesize / 2;
         src += slinesize / 2;
@@ -441,8 +330,7 @@
                                       ptrdiff_t ilinesize,
                                       ptrdiff_t slinesize,
                                       ptrdiff_t dlinesize,
-                                      float *lut,
-                                      float opacity)
+                                      float *lut)
 {
     const uint16_t *index = (const uint16_t *)iindex;
     const uint16_t *src = (const uint16_t *)ssrc;
@@ -453,7 +341,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[x >> 1]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         index += ilinesize / 2;
         src += slinesize / 2;
@@ -468,8 +360,7 @@
                                      ptrdiff_t ilinesize,
                                      ptrdiff_t slinesize,
                                      ptrdiff_t dlinesize,
-                                     float *lut,
-                                     float opacity)
+                                     float *lut)
 {
     const uint16_t *index = (const uint16_t *)iindex;
     const uint16_t *src = (const uint16_t *)ssrc;
@@ -484,7 +375,11 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[(y << 1) * ilinesize + (x << 1)]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         src += slinesize;
         dst += dlinesize;
@@ -498,8 +393,7 @@
                                       ptrdiff_t ilinesize,
                                       ptrdiff_t slinesize,
                                       ptrdiff_t dlinesize,
-                                      float *lut,
-                                      float opacity)
+                                      float *lut)
 {
     const uint16_t *index = (const uint16_t *)iindex;
     const uint16_t *src = (const uint16_t *)ssrc;
@@ -514,46 +408,25 @@
         for (x = 0; x < width; x++) {
             int v = lut[index[(y >> 1) * ilinesize + (x >> 1)]];
 
-            PCLIP(v, max, dst, src, x);
+            if (v >= 0 && v <= max) {
+                dst[x] = v;
+            } else {
+                dst[x] = src[x];
+            }
         }
         src += slinesize;
         dst += dlinesize;
     }
 }
 
-#define RGB_TO_Y_BT709(r, g, b) \
-((0.21260*219.0/255.0) * (r) + (0.71520*219.0/255.0) * (g) + \
- (0.07220*219.0/255.0) * (b))
-
-#define RGB_TO_U_BT709(r1, g1, b1, max) \
-(-(0.11457*224.0/255.0) * r1 - (0.38543*224.0/255.0) * g1 + \
-    (0.50000*224.0/255.0) * b1 + max * 0.5)
-
-#define RGB_TO_V_BT709(r1, g1, b1, max) \
-((0.50000*224.0/255.0) * r1 - (0.45415*224.0/255.0) * g1 - \
-   (0.04585*224.0/255.0) * b1 + max * 0.5)
-
-static double poly_eval(const double *const poly, double x)
-{
-    double res = 0.;
-
-    for (int i = 0; i < 8; i++) {
-        res += pow(x, i) * poly[7-i];
-    }
-
-    return av_clipd(res, 0., 1.);
-}
-
 static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
     PseudoColorContext *s = ctx->priv;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int depth, ret, hsub, vsub, color, factor, rgb;
+    int depth, ret, hsub, vsub, color;
 
-    rgb = desc->flags & AV_PIX_FMT_FLAG_RGB;
     depth = desc->comp[0].depth;
-    factor = 1 << (depth - 8);
     s->max = (1 << depth) - 1;
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
@@ -584,7 +457,7 @@
     s->var_values[VAR_VMAX] = 240 * (1 << (depth - 8));
     s->var_values[VAR_AMAX] = s->max;
 
-    for (color = 0; color < s->nb_planes && s->preset < 0; color++) {
+    for (color = 0; color < s->nb_planes; color++) {
         double res;
         int val;
 
@@ -615,77 +488,6 @@
         }
     }
 
-    if (s->preset >= 0) {
-        int nb_segments = presets[s->preset].nb_segments;
-
-        for (int seg = 0; seg < nb_segments; seg++) {
-            int start = presets[s->preset].ranges[seg].start;
-            int end   = presets[s->preset].ranges[seg].end;
-
-            for (int i = start; i < end; i++) {
-                if (!presets[s->preset].curves) {
-                    const Fill fill = presets[s->preset].fills[seg];
-
-                    for (int j = 0; j < factor; j++) {
-                        double r, g, b, a;
-
-                        g = fill.fill[1];
-                        b = fill.fill[2];
-                        r = fill.fill[0];
-                        a = fill.fill[3];
-
-                        if (g >= 0.f && b >= 0.f && r >= 0.f) {
-                            g *= s->max;
-                            b *= s->max;
-                            r *= s->max;
-
-                            if (!rgb) {
-                                double y = RGB_TO_Y_BT709(r, g, b);
-                                double u = RGB_TO_U_BT709(r, g, b, s->max);
-                                double v = RGB_TO_V_BT709(r, g, b, s->max);
-
-                                r = v;
-                                g = y;
-                                b = u;
-                            }
-                        }
-
-                        s->lut[0][i*factor+j] = g;
-                        s->lut[1][i*factor+j] = b;
-                        s->lut[2][i*factor+j] = r;
-                        s->lut[3][i*factor+j] = a * s->max;
-                    }
-                } else {
-                    const Curve curve = presets[s->preset].curves[seg];
-
-                    for (int j = 0; j < factor; j++) {
-                        const double lf = j / (double)factor;
-                        double r, g, b;
-
-                        g = poly_eval(curve.coef[1], i + lf) * s->max;
-                        b = poly_eval(curve.coef[2], i + lf) * s->max;
-                        r = poly_eval(curve.coef[0], i + lf) * s->max;
-
-                        if (!rgb) {
-                            double y = RGB_TO_Y_BT709(r, g, b);
-                            double u = RGB_TO_U_BT709(r, g, b, s->max);
-                            double v = RGB_TO_V_BT709(r, g, b, s->max);
-
-                            r = v;
-                            g = y;
-                            b = u;
-                        }
-
-                        s->lut[0][i*factor+j] = g;
-                        s->lut[1][i*factor+j] = b;
-                        s->lut[2][i*factor+j] = r;
-                        s->lut[3][i*factor+j] = 1.f * s->max;
-                    }
-                }
-            }
-        }
-    }
-
     switch (inlink->format) {
     case AV_PIX_FMT_YUV444P:
     case AV_PIX_FMT_YUVA444P:
@@ -794,43 +596,13 @@
     return 0;
 }
 
-typedef struct ThreadData {
-    AVFrame *in, *out;
-} ThreadData;
-
-static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    PseudoColorContext *s = ctx->priv;
-    ThreadData *td = arg;
-    AVFrame *in = td->in;
-    AVFrame *out = td->out;
-
-    for (int plane = 0; plane < s->nb_planes; plane++) {
-        const int slice_start = (s->height[plane] * jobnr) / nb_jobs;
-        const int slice_end = (s->height[plane] * (jobnr+1)) / nb_jobs;
-        const int islice_start = (s->height[s->index] * jobnr) / nb_jobs;
-        ptrdiff_t ilinesize = in->linesize[s->index];
-        ptrdiff_t slinesize = in->linesize[plane];
-        ptrdiff_t dlinesize = out->linesize[plane];
-        const uint8_t *index = in->data[s->index] + islice_start * ilinesize;
-        const uint8_t *src = in->data[plane] + slice_start * slinesize;
-        uint8_t *dst = out->data[plane] + slice_start * dlinesize;
-
-        s->filter[plane](s->max, s->width[plane], slice_end - slice_start,
-                         index, src, dst, ilinesize, slinesize,
-                         dlinesize, s->lut[plane], s->opacity);
-    }
-
-    return 0;
-}
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     AVFilterContext *ctx = inlink->dst;
     PseudoColorContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    ThreadData td;
     AVFrame *out;
+    int plane;
 
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out) {
@@ -839,24 +611,23 @@
     }
     av_frame_copy_props(out, in);
 
-    td.out = out, td.in = in;
-    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+    for (plane = 0; plane < s->nb_planes; plane++) {
+        const uint8_t *index = in->data[s->index];
+        const uint8_t *src = in->data[plane];
+        uint8_t *dst = out->data[plane];
+        ptrdiff_t ilinesize = in->linesize[s->index];
+        ptrdiff_t slinesize = in->linesize[plane];
+        ptrdiff_t dlinesize = out->linesize[plane];
+
+        s->filter[plane](s->max, s->width[plane], s->height[plane],
+                         index, src, dst, ilinesize, slinesize,
+                         dlinesize, s->lut[plane]);
+    }
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-
-    if (ret < 0)
-        return ret;
-
-    return config_input(ctx->inputs[0]);
-}
-
 static const AVFilterPad inputs[] = {
     {
         .name         = "default",
@@ -897,6 +668,5 @@
     .query_formats = query_formats,
     .inputs        = inputs,
     .outputs       = outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
+    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 0d0c0f3..c9a673d 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -51,11 +51,9 @@
     uint8_t rgba_map[4];
     char comps[4];
     int nb_components;
-    int nb_threads;
     int planewidth[4];
     int planeheight[4];
     double planeweight[4];
-    uint64_t **score;
     PSNRDSPContext dsp;
 } PSNRContext;
 
@@ -106,50 +104,35 @@
     return m2;
 }
 
-typedef struct ThreadData {
-    const uint8_t *main_data[4];
-    const uint8_t *ref_data[4];
-    int main_linesize[4];
-    int ref_linesize[4];
-    int planewidth[4];
-    int planeheight[4];
-    uint64_t **score;
-    int nb_components;
-    PSNRDSPContext *dsp;
-} ThreadData;
-
-static
-int compute_images_mse(AVFilterContext *ctx, void *arg,
-                       int jobnr, int nb_jobs)
+static inline
+void compute_images_mse(PSNRContext *s,
+                        const uint8_t *main_data[4], const int main_linesizes[4],
+                        const uint8_t *ref_data[4], const int ref_linesizes[4],
+                        int w, int h, double mse[4])
 {
-    ThreadData *td = arg;
-    uint64_t *score = td->score[jobnr];
+    int i, c;
 
-    for (int c = 0; c < td->nb_components; c++) {
-        const int outw = td->planewidth[c];
-        const int outh = td->planeheight[c];
-        const int slice_start = (outh * jobnr) / nb_jobs;
-        const int slice_end = (outh * (jobnr+1)) / nb_jobs;
-        const int ref_linesize = td->ref_linesize[c];
-        const int main_linesize = td->main_linesize[c];
-        const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
-        const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
+    for (c = 0; c < s->nb_components; c++) {
+        const int outw = s->planewidth[c];
+        const int outh = s->planeheight[c];
+        const uint8_t *main_line = main_data[c];
+        const uint8_t *ref_line = ref_data[c];
+        const int ref_linesize = ref_linesizes[c];
+        const int main_linesize = main_linesizes[c];
         uint64_t m = 0;
-        for (int i = slice_start; i < slice_end; i++) {
-            m += td->dsp->sse_line(main_line, ref_line, outw);
+        for (i = 0; i < outh; i++) {
+            m += s->dsp.sse_line(main_line, ref_line, outw);
             ref_line += ref_linesize;
             main_line += main_linesize;
         }
-        score[c] = m;
+        mse[c] = m / (double)(outw * outh);
     }
-
-    return 0;
 }
 
 static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
 {
     char value[128];
-    snprintf(value, sizeof(value), "%f", d);
+    snprintf(value, sizeof(value), "%0.2f", d);
     if (comp) {
         char key2[128];
         snprintf(key2, sizeof(key2), "%s%c", key, comp);
@@ -164,55 +147,34 @@
     AVFilterContext *ctx = fs->parent;
     PSNRContext *s = ctx->priv;
     AVFrame *master, *ref;
-    double comp_mse[4], mse = 0.;
-    uint64_t comp_sum[4] = { 0 };
+    double comp_mse[4], mse = 0;
+    int ret, j, c;
     AVDictionary **metadata;
-    ThreadData td;
-    int ret;
 
     ret = ff_framesync_dualinput_get(fs, &master, &ref);
     if (ret < 0)
         return ret;
-    if (ctx->is_disabled || !ref)
+    if (!ref)
         return ff_filter_frame(ctx->outputs[0], master);
     metadata = &master->metadata;
 
-    td.nb_components = s->nb_components;
-    td.dsp = &s->dsp;
-    td.score = s->score;
-    for (int c = 0; c < s->nb_components; c++) {
-        td.main_data[c] = master->data[c];
-        td.ref_data[c] = ref->data[c];
-        td.main_linesize[c] = master->linesize[c];
-        td.ref_linesize[c] = ref->linesize[c];
-        td.planewidth[c] = s->planewidth[c];
-        td.planeheight[c] = s->planeheight[c];
-    }
+    compute_images_mse(s, (const uint8_t **)master->data, master->linesize,
+                          (const uint8_t **)ref->data, ref->linesize,
+                          master->width, master->height, comp_mse);
 
-    ctx->internal->execute(ctx, compute_images_mse, &td, NULL, FFMIN(s->planeheight[1], s->nb_threads));
-
-    for (int j = 0; j < s->nb_threads; j++) {
-        for (int c = 0; c < s->nb_components; c++)
-            comp_sum[c] += s->score[j][c];
-    }
-
-    for (int c = 0; c < s->nb_components; c++)
-        comp_mse[c] = comp_sum[c] / ((double)s->planewidth[c] * s->planeheight[c]);
-
-    for (int c = 0; c < s->nb_components; c++)
-        mse += comp_mse[c] * s->planeweight[c];
+    for (j = 0; j < s->nb_components; j++)
+        mse += comp_mse[j] * s->planeweight[j];
 
     s->min_mse = FFMIN(s->min_mse, mse);
     s->max_mse = FFMAX(s->max_mse, mse);
 
     s->mse += mse;
-
-    for (int j = 0; j < s->nb_components; j++)
+    for (j = 0; j < s->nb_components; j++)
         s->mse_comp[j] += comp_mse[j];
     s->nb_frames++;
 
-    for (int j = 0; j < s->nb_components; j++) {
-        int c = s->is_rgb ? s->rgba_map[j] : j;
+    for (j = 0; j < s->nb_components; j++) {
+        c = s->is_rgb ? s->rgba_map[j] : j;
         set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
         set_meta(metadata, "lavfi.psnr.psnr.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c]));
     }
@@ -223,16 +185,16 @@
         if (s->stats_version == 2 && !s->stats_header_written) {
             fprintf(s->stats_file, "psnr_log_version:2 fields:n");
             fprintf(s->stats_file, ",mse_avg");
-            for (int j = 0; j < s->nb_components; j++) {
+            for (j = 0; j < s->nb_components; j++) {
                 fprintf(s->stats_file, ",mse_%c", s->comps[j]);
             }
             fprintf(s->stats_file, ",psnr_avg");
-            for (int j = 0; j < s->nb_components; j++) {
+            for (j = 0; j < s->nb_components; j++) {
                 fprintf(s->stats_file, ",psnr_%c", s->comps[j]);
             }
             if (s->stats_add_max) {
                 fprintf(s->stats_file, ",max_avg");
-                for (int j = 0; j < s->nb_components; j++) {
+                for (j = 0; j < s->nb_components; j++) {
                     fprintf(s->stats_file, ",max_%c", s->comps[j]);
                 }
             }
@@ -240,20 +202,20 @@
             s->stats_header_written = 1;
         }
         fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ", s->nb_frames, mse);
-        for (int j = 0; j < s->nb_components; j++) {
-            int c = s->is_rgb ? s->rgba_map[j] : j;
+        for (j = 0; j < s->nb_components; j++) {
+            c = s->is_rgb ? s->rgba_map[j] : j;
             fprintf(s->stats_file, "mse_%c:%0.2f ", s->comps[j], comp_mse[c]);
         }
         fprintf(s->stats_file, "psnr_avg:%0.2f ", get_psnr(mse, 1, s->average_max));
-        for (int j = 0; j < s->nb_components; j++) {
-            int c = s->is_rgb ? s->rgba_map[j] : j;
+        for (j = 0; j < s->nb_components; j++) {
+            c = s->is_rgb ? s->rgba_map[j] : j;
             fprintf(s->stats_file, "psnr_%c:%0.2f ", s->comps[j],
                     get_psnr(comp_mse[c], 1, s->max[c]));
         }
         if (s->stats_version == 2 && s->stats_add_max) {
             fprintf(s->stats_file, "max_avg:%d ", s->average_max);
-            for (int j = 0; j < s->nb_components; j++) {
-                int c = s->is_rgb ? s->rgba_map[j] : j;
+            for (j = 0; j < s->nb_components; j++) {
+                c = s->is_rgb ? s->rgba_map[j] : j;
                 fprintf(s->stats_file, "max_%c:%d ", s->comps[j], s->max[c]);
             }
         }
@@ -327,7 +289,6 @@
     unsigned sum;
     int j;
 
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
     s->nb_components = desc->nb_components;
     if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
         ctx->inputs[0]->h != ctx->inputs[1]->h) {
@@ -368,16 +329,6 @@
     if (ARCH_X86)
         ff_psnr_init_x86(&s->dsp, desc->comp[0].depth);
 
-    s->score = av_calloc(s->nb_threads, sizeof(*s->score));
-    if (!s->score)
-        return AVERROR(ENOMEM);
-
-    for (int t = 0; t < s->nb_threads && s->score; t++) {
-        s->score[t] = av_calloc(s->nb_components, sizeof(*s->score[0]));
-        if (!s->score[t])
-            return AVERROR(ENOMEM);
-    }
-
     return 0;
 }
 
@@ -438,9 +389,6 @@
     }
 
     ff_framesync_uninit(&s->fs);
-    for (int t = 0; t < s->nb_threads && s->score; t++)
-        av_freep(&s->score[t]);
-    av_freep(&s->score);
 
     if (s->stats_file && s->stats_file != stdout)
         fclose(s->stats_file);
@@ -479,5 +427,4 @@
     .priv_class    = &psnr_class,
     .inputs        = psnr_inputs,
     .outputs       = psnr_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_qp.c b/libavfilter/vf_qp.c
index e2d60fd..33d3949 100644
--- a/libavfilter/vf_qp.c
+++ b/libavfilter/vf_qp.c
@@ -23,8 +23,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
-#include "libavutil/video_enc_params.h"
-
 #include "avfilter.h"
 #include "formats.h"
 #include "internal.h"
@@ -38,8 +36,6 @@
     int evaluate_per_mb;
 } QPContext;
 
-static const char *const var_names[] = { "known", "qp", "x", "y", "w", "h", NULL };
-
 #define OFFSET(x) offsetof(QPContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
@@ -57,6 +53,7 @@
     int i;
     int ret;
     AVExpr *e = NULL;
+    static const char *var_names[] = { "known", "qp", "x", "y", "w", "h", NULL };
 
     if (!s->qp_expr_str)
         return 0;
@@ -92,59 +89,39 @@
     AVFilterContext *ctx = inlink->dst;
     AVFilterLink *outlink = ctx->outputs[0];
     QPContext *s = ctx->priv;
+    AVBufferRef *out_qp_table_buf;
     AVFrame *out = NULL;
-    int ret;
-
-    AVFrameSideData *sd_in;
-    AVVideoEncParams *par_in = NULL;
-    int8_t in_qp_global = 0;
-
-    AVVideoEncParams *par_out;
+    const int8_t *in_qp_table;
+    int type, stride, ret;
 
     if (!s->qp_expr_str || ctx->is_disabled)
         return ff_filter_frame(outlink, in);
 
-    sd_in = av_frame_get_side_data(in, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
-    if (sd_in && sd_in->size >= sizeof(AVVideoEncParams)) {
-        par_in = (AVVideoEncParams*)sd_in->data;
-
-        // we accept the input QP table only if it is of the MPEG2 type
-        // and contains either no blocks at all or 16x16 macroblocks
-        if (par_in->type == AV_VIDEO_ENC_PARAMS_MPEG2 &&
-            (par_in->nb_blocks == s->h * s->qstride || !par_in->nb_blocks)) {
-            in_qp_global = par_in->qp;
-            if (!par_in->nb_blocks)
-                par_in = NULL;
-        } else
-            par_in = NULL;
+    out_qp_table_buf = av_buffer_alloc(s->h * s->qstride);
+    if (!out_qp_table_buf) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
     }
 
     out = av_frame_clone(in);
     if (!out) {
+        av_buffer_unref(&out_qp_table_buf);
         ret = AVERROR(ENOMEM);
         goto fail;
     }
 
-    par_out = av_video_enc_params_create_side_data(out, AV_VIDEO_ENC_PARAMS_MPEG2,
-                                                   (s->evaluate_per_mb || sd_in) ?
-                                                   s->h * s->qstride : 0);
-    if (!par_out) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
+    in_qp_table = av_frame_get_qp_table(in, &stride, &type);
+    av_frame_set_qp_table(out, out_qp_table_buf, s->qstride, type);
 
-#define BLOCK_QP_DELTA(block_idx) \
-    (par_in ? av_video_enc_params_block(par_in, block_idx)->delta_qp : 0)
 
     if (s->evaluate_per_mb) {
         int y, x;
 
         for (y = 0; y < s->h; y++)
             for (x = 0; x < s->qstride; x++) {
-                unsigned int block_idx = y * s->qstride + x;
-                AVVideoBlockParams *b = av_video_enc_params_block(par_out, block_idx);
-                int qp = sd_in ? in_qp_global + BLOCK_QP_DELTA(block_idx) : NAN;
-                double var_values[] = { !!sd_in, qp, x, y, s->qstride, s->h, 0};
+                int qp = in_qp_table ? in_qp_table[x + stride * y] : NAN;
+                double var_values[] = { !!in_qp_table, qp, x, y, s->qstride, s->h, 0};
+                static const char *var_names[] = { "known", "qp", "x", "y", "w", "h", NULL };
                 double temp_val;
 
                 ret = av_expr_parse_and_eval(&temp_val, s->qp_expr_str,
@@ -152,19 +129,21 @@
                                             NULL, NULL, NULL, NULL, 0, 0, ctx);
                 if (ret < 0)
                     goto fail;
-                b->delta_qp = lrintf(temp_val);
+                out_qp_table_buf->data[x + s->qstride * y] = lrintf(temp_val);
             }
-    } else if (sd_in) {
+    } else if (in_qp_table) {
         int y, x;
 
         for (y = 0; y < s->h; y++)
-            for (x = 0; x < s->qstride; x++) {
-                unsigned int block_idx = y * s->qstride + x;
-                AVVideoBlockParams *b = av_video_enc_params_block(par_out, block_idx);
-                b->delta_qp = s->lut[129 + (int8_t)(in_qp_global + BLOCK_QP_DELTA(block_idx))];
-            }
+            for (x = 0; x < s->qstride; x++)
+                out_qp_table_buf->data[x + s->qstride * y] = s->lut[129 +
+                    ((int8_t)in_qp_table[x + stride * y])];
     } else {
-        par_out->qp = s->lut[0];
+        int y, x, qp = s->lut[0];
+
+        for (y = 0; y < s->h; y++)
+            for (x = 0; x < s->qstride; x++)
+                out_qp_table_buf->data[x + s->qstride * y] = qp;
     }
 
     ret = ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c
index d4c3ca6..bd0a950 100644
--- a/libavfilter/vf_readeia608.c
+++ b/libavfilter/vf_readeia608.c
@@ -62,7 +62,7 @@
     int found;
     int white;
     int black;
-    uint64_t *histogram;
+    uint64_t histogram[256];
     uint8_t byte[2];
 
     CodeItem *code;
@@ -77,13 +77,8 @@
     int chp;
     int lp;
 
-    int depth;
-    int max;
     int nb_allocated;
     ScanItem *scan;
-
-    void (*read_line[2])(AVFrame *in, int nb_line,
-                         LineItem *line, int lp, int w);
 } ReadEIA608Context;
 
 #define OFFSET(x) offsetof(ReadEIA608Context, x)
@@ -103,26 +98,13 @@
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
-        AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_GRAY16,
+        AV_PIX_FMT_GRAY8,
         AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
         AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
         AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
         AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
         AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
         AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
         AV_PIX_FMT_NONE
     };
     AVFilterFormats *formats = ff_make_format_list(pixel_fmts);
@@ -160,13 +142,11 @@
     for (int i = 0; i < s->nb_allocated; i++) {
         ScanItem *scan = &s->scan[i];
 
-        if (!scan->histogram)
-            scan->histogram = av_calloc(s->max + 1, sizeof(*scan->histogram));
         if (!scan->line)
             scan->line = av_calloc(size, sizeof(*scan->line));
         if (!scan->code)
             scan->code = av_calloc(size, sizeof(*scan->code));
-        if (!scan->line || !scan->code || !scan->histogram)
+        if (!scan->line || !scan->code)
             return AVERROR(ENOMEM);
     }
 
@@ -176,9 +156,17 @@
     return 0;
 }
 
+static int config_input(AVFilterLink *inlink)
+{
+    AVFilterContext *ctx = inlink->dst;
+    ReadEIA608Context *s = ctx->priv;
+
+    return config_filter(ctx, s->start, s->end);
+}
+
 static void build_histogram(ReadEIA608Context *s, ScanItem *scan, const LineItem *line, int len)
 {
-    memset(scan->histogram, 0, (s->max + 1) * sizeof(*scan->histogram));
+    memset(scan->histogram, 0, sizeof(scan->histogram));
 
     for (int i = LAG; i < len + LAG; i++)
         scan->histogram[line[i].input]++;
@@ -186,19 +174,18 @@
 
 static void find_black_and_white(ReadEIA608Context *s, ScanItem *scan)
 {
-    const int max = s->max;
     int start = 0, end = 0, middle;
     int black = 0, white = 0;
     int cnt;
 
-    for (int i = 0; i <= max; i++) {
+    for (int i = 0; i < 256; i++) {
         if (scan->histogram[i]) {
             start = i;
             break;
         }
     }
 
-    for (int i = max; i >= 0; i--) {
+    for (int i = 255; i >= 0; i--) {
         if (scan->histogram[i]) {
             end = i;
             break;
@@ -321,54 +308,12 @@
     av_log(ctx, AV_LOG_DEBUG, "\n");
 }
 
-#define READ_LINE(type, name)                                                 \
-static void read_##name(AVFrame *in, int nb_line, LineItem *line, int lp, int w) \
-{                                                                             \
-    const type *src = (const type *)(&in->data[0][nb_line * in->linesize[0]]);\
-                                                                              \
-    if (lp) {                                                                 \
-        for (int i = 0; i < w; i++) {                                         \
-            int a = FFMAX(i - 3, 0);                                          \
-            int b = FFMAX(i - 2, 0);                                          \
-            int c = FFMAX(i - 1, 0);                                          \
-            int d = FFMIN(i + 3, w-1);                                        \
-            int e = FFMIN(i + 2, w-1);                                        \
-            int f = FFMIN(i + 1, w-1);                                        \
-                                                                              \
-            line[LAG + i].input = (src[a] + src[b] + src[c] + src[i] +        \
-                                   src[d] + src[e] + src[f] + 6) / 7;         \
-        }                                                                     \
-    } else {                                                                  \
-        for (int i = 0; i < w; i++) {                                         \
-            line[LAG + i].input = src[i];                                     \
-        }                                                                     \
-    }                                                                         \
-}
-
-READ_LINE(uint8_t, byte)
-READ_LINE(uint16_t, word)
-
-static int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ReadEIA608Context *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-
-    if (!desc)
-        return AVERROR_BUG;
-    s->depth = desc->comp[0].depth;
-    s->max = (1 << desc->comp[0].depth) - 1;
-    s->read_line[0] = read_byte;
-    s->read_line[1] = read_word;
-
-    return config_filter(ctx, s->start, s->end);
-}
-
 static void extract_line(AVFilterContext *ctx, AVFrame *in, ScanItem *scan, int w, int nb_line)
 {
     ReadEIA608Context *s = ctx->priv;
     LineItem *line = scan->line;
     int i, j, ch, len;
+    const uint8_t *src;
     uint8_t codes[19] = { 0 };
     float bit_size = 0.f;
     int parity;
@@ -377,7 +322,23 @@
     scan->byte[0] = scan->byte[1] = 0;
     scan->found = 0;
 
-    s->read_line[s->depth > 8](in, nb_line, line, s->lp, w);
+    src = &in->data[0][nb_line * in->linesize[0]];
+    if (s->lp) {
+        for (i = 0; i < w; i++) {
+            int a = FFMAX(i - 3, 0);
+            int b = FFMAX(i - 2, 0);
+            int c = FFMAX(i - 1, 0);
+            int d = FFMIN(i + 3, w-1);
+            int e = FFMIN(i + 2, w-1);
+            int f = FFMIN(i + 1, w-1);
+
+            line[LAG + i].input = (src[a] + src[b] + src[c] + src[i] + src[d] + src[e] + src[f] + 6) / 7;
+        }
+    } else {
+        for (i = 0; i < w; i++) {
+            line[LAG + i].input = src[i];
+        }
+    }
 
     build_histogram(s, scan, line, w);
     find_black_and_white(s, scan);
@@ -510,7 +471,6 @@
     for (int i = 0; i < s->nb_allocated; i++) {
         ScanItem *scan = &s->scan[i];
 
-        av_freep(&scan->histogram);
         av_freep(&scan->code);
         av_freep(&scan->line);
     }
diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c
index 4026bdd..aff2d12 100644
--- a/libavfilter/vf_removelogo.c
+++ b/libavfilter/vf_removelogo.c
@@ -342,8 +342,8 @@
 
     /* Calculate our bounding rectangles, which determine in what
      * region the logo resides for faster processing. */
-    ff_calculate_bounding_box(&s->full_mask_bbox, s->full_mask_data, w, w, h, 0, 8);
-    ff_calculate_bounding_box(&s->half_mask_bbox, s->half_mask_data, w/2, w/2, h/2, 0, 8);
+    ff_calculate_bounding_box(&s->full_mask_bbox, s->full_mask_data, w, w, h, 0);
+    ff_calculate_bounding_box(&s->half_mask_bbox, s->half_mask_data, w/2, w/2, h/2, 0);
 
 #define SHOW_LOGO_INFO(mask_type)                                       \
     av_log(ctx, AV_LOG_VERBOSE, #mask_type " x1:%d x2:%d y1:%d y2:%d max_mask_size:%d\n", \
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 2ac2373..5064dcb 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -313,10 +313,8 @@
         }
     }
 
-    if (err < 0)
-        return ff_qsvvpp_print_error(ctx, err, "Error getting the session handle");
-    else if (err > 0) {
-        ff_qsvvpp_print_warning(ctx, err, "Warning in getting the session handle");
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error getting the session handle\n");
         return AVERROR_UNKNOWN;
     }
 
@@ -432,17 +430,9 @@
     par.vpp.Out.FrameRateExtN = 25;
     par.vpp.Out.FrameRateExtD = 1;
 
-    /* Print input memory mode */
-    ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0x0F, "VPP");
-    /* Print output memory mode */
-    ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0xF0, "VPP");
     err = MFXVideoVPP_Init(s->session, &par);
-    if (err < 0)
-        return ff_qsvvpp_print_error(ctx, err,
-                                     "Error opening the VPP for scaling");
-    else if (err > 0) {
-        ff_qsvvpp_print_warning(ctx, err,
-                                "Warning in VPP initialization");
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error opening the VPP for scaling\n");
         return AVERROR_UNKNOWN;
     }
 
@@ -583,13 +573,8 @@
             av_usleep(1);
     } while (err == MFX_WRN_DEVICE_BUSY);
 
-    if (err < 0) {
-        ret = ff_qsvvpp_print_error(ctx, err, "Error during scaling");
-        goto fail;
-    }
-
-    if (!sync) {
-        av_log(ctx, AV_LOG_ERROR, "No sync during scaling\n");
+    if (err < 0 || !sync) {
+        av_log(ctx, AV_LOG_ERROR, "Error during scaling\n");
         ret = AVERROR_UNKNOWN;
         goto fail;
     }
@@ -598,7 +583,8 @@
         err = MFXVideoCORE_SyncOperation(s->session, sync, 1000);
     } while (err == MFX_WRN_IN_EXECUTION);
     if (err < 0) {
-        ret = ff_qsvvpp_print_error(ctx, err, "Error synchronizing the operation");
+        av_log(ctx, AV_LOG_ERROR, "Error synchronizing the operation: %d\n", err);
+        ret = AVERROR_UNKNOWN;
         goto fail;
     }
 
diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c
index 9bd79a3..d8f339d 100644
--- a/libavfilter/vf_selectivecolor.c
+++ b/libavfilter/vf_selectivecolor.c
@@ -61,7 +61,7 @@
     NB_CORRECTION_METHODS,
 };
 
-static const char *const color_names[NB_RANGES] = {
+static const char *color_names[NB_RANGES] = {
     "red", "yellow", "green", "cyan", "blue", "magenta", "white", "neutral", "black"
 };
 
diff --git a/libavfilter/vf_shear.c b/libavfilter/vf_shear.c
deleted file mode 100644
index de298af..0000000
--- a/libavfilter/vf_shear.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/avstring.h"
-#include "libavutil/opt.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/parseutils.h"
-#include "libavutil/pixdesc.h"
-
-#include "avfilter.h"
-#include "drawutils.h"
-#include "internal.h"
-#include "video.h"
-
-#include <float.h>
-
-typedef struct ShearContext {
-    const AVClass *class;
-
-    float shx, shy;
-    int interp;
-
-    uint8_t fillcolor[4];   ///< color expressed either in YUVA or RGBA colorspace for the padding area
-    char *fillcolor_str;
-    int fillcolor_enable;
-    int nb_planes;
-    int depth;
-    FFDrawContext draw;
-    FFDrawColor color;
-
-    int hsub, vsub;
-    int planewidth[4];
-    int planeheight[4];
-
-    int (*filter_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
-} ShearContext;
-
-typedef struct ThreadData {
-    AVFrame *in, *out;
-} ThreadData;
-
-#define OFFSET(x) offsetof(ShearContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
-
-static const AVOption shear_options[] = {
-    { "shx",       "set x shear factor",        OFFSET(shx),           AV_OPT_TYPE_FLOAT,  {.dbl=0.},     -2, 2, .flags=FLAGS },
-    { "shy",       "set y shear factor",        OFFSET(shy),           AV_OPT_TYPE_FLOAT,  {.dbl=0.},     -2, 2, .flags=FLAGS },
-    { "fillcolor", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, 0, 0, .flags=FLAGS },
-    { "c",         "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, 0, 0, .flags=FLAGS },
-    { "interp",    "set interpolation",         OFFSET(interp),        AV_OPT_TYPE_INT,    {.i64=1},       0, 1, .flags=FLAGS, "interp" },
-    {  "nearest",  "nearest neighbour",         0,                     AV_OPT_TYPE_CONST,  {.i64=0},       0, 0, .flags=FLAGS, "interp" },
-    {  "bilinear", "bilinear",                  0,                     AV_OPT_TYPE_CONST,  {.i64=1},       0, 0, .flags=FLAGS, "interp" },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(shear);
-
-static av_cold int init(AVFilterContext *ctx)
-{
-    ShearContext *s = ctx->priv;
-
-    if (!strcmp(s->fillcolor_str, "none"))
-        s->fillcolor_enable = 0;
-    else if (av_parse_color(s->fillcolor, s->fillcolor_str, -1, ctx) >= 0)
-        s->fillcolor_enable = 1;
-    else
-        return AVERROR(EINVAL);
-    return 0;
-}
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
-        AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
-        AV_PIX_FMT_YUV440P12,
-        AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
-        AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
-        AV_PIX_FMT_GBRAP,     AV_PIX_FMT_GBRAP10,    AV_PIX_FMT_GBRAP12,    AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-    if (!fmts_list)
-        return AVERROR(ENOMEM);
-    return ff_set_common_formats(ctx, fmts_list);
-}
-
-#define NN(type, name)                                                       \
-static int filter_slice_nn##name(AVFilterContext *ctx, void *arg, int jobnr, \
-                                 int nb_jobs)                                \
-{                                                                            \
-    ThreadData *td = arg;                                                    \
-    AVFrame *in = td->in;                                                    \
-    AVFrame *out = td->out;                                                  \
-    ShearContext *s = ctx->priv;                                             \
-    const float shx = s->shx;                                                \
-    const float shy = s->shy;                                                \
-                                                                             \
-    for (int p = 0; p < s->nb_planes; p++) {                                 \
-        const int hsub = (p == 1 || p == 2) ? s->hsub: 1;                    \
-        const int vsub = (p == 1 || p == 2) ? s->vsub: 1;                    \
-        const int width = s->planewidth[p];                                  \
-        const int height = s->planeheight[p];                                \
-        const int wx = vsub * shx * height * 0.5f / hsub;                    \
-        const int wy = hsub * shy * width  * 0.5f / vsub;                    \
-        const int slice_start = (height * jobnr) / nb_jobs;                  \
-        const int slice_end = (height * (jobnr+1)) / nb_jobs;                \
-        const int src_linesize = in->linesize[p] / sizeof(type);             \
-        const int dst_linesize = out->linesize[p] / sizeof(type);            \
-        const type *src = (const type *)in->data[p];                         \
-        type *dst = (type *)out->data[p] + slice_start * dst_linesize;       \
-                                                                             \
-        for (int y = slice_start; y < slice_end; y++) {                      \
-            for (int x = 0; x < width; x++) {                                \
-                int sx = x + vsub * shx * y / hsub - wx;                     \
-                int sy = y + hsub * shy * x / vsub - wy;                     \
-                                                                             \
-                if (sx >= 0 && sx < width - 1 &&                             \
-                    sy >= 0 && sy < height - 1) {                            \
-                    dst[x] = src[sy * src_linesize + sx];                    \
-                }                                                            \
-            }                                                                \
-                                                                             \
-            dst += dst_linesize;                                             \
-        }                                                                    \
-    }                                                                        \
-                                                                             \
-    return 0;                                                                \
-}
-
-NN(uint8_t, 8)
-NN(uint16_t, 16)
-
-#define BL(type, name)                                                       \
-static int filter_slice_bl##name(AVFilterContext *ctx, void *arg, int jobnr, \
-                                 int nb_jobs)                                \
-{                                                                            \
-    ThreadData *td = arg;                                                    \
-    AVFrame *in = td->in;                                                    \
-    AVFrame *out = td->out;                                                  \
-    ShearContext *s = ctx->priv;                                             \
-    const int depth = s->depth;                                              \
-    const float shx = s->shx;                                                \
-    const float shy = s->shy;                                                \
-                                                                             \
-    for (int p = 0; p < s->nb_planes; p++) {                                 \
-        const int hsub = (p == 1 || p == 2) ? s->hsub: 1;                    \
-        const int vsub = (p == 1 || p == 2) ? s->vsub: 1;                    \
-        const int width = s->planewidth[p];                                  \
-        const int height = s->planeheight[p];                                \
-        const float wx = vsub * shx * height * 0.5f / hsub;                  \
-        const float wy = hsub * shy * width  * 0.5f / vsub;                  \
-        const int slice_start = (height * jobnr) / nb_jobs;                  \
-        const int slice_end = (height * (jobnr+1)) / nb_jobs;                \
-        const int src_linesize = in->linesize[p] / sizeof(type);             \
-        const int dst_linesize = out->linesize[p] / sizeof(type);            \
-        const type *src = (const type *)in->data[p];                         \
-        type *dst = (type *)out->data[p] + slice_start * dst_linesize;       \
-                                                                             \
-        for (int y = slice_start; y < slice_end; y++) {                      \
-            for (int x = 0; x < width; x++) {                                \
-                const float sx = x + vsub * shx * y / hsub - wx;             \
-                const float sy = y + hsub * shy * x / vsub - wy;             \
-                                                                             \
-                if (sx >= 0 && sx < width - 1 &&                             \
-                    sy >= 0 && sy < height - 1) {                            \
-                    float sum = 0.f;                                         \
-                    int ax = floorf(sx);                                     \
-                    int ay = floorf(sy);                                     \
-                    float du = sx - ax;                                      \
-                    float dv = sy - ay;                                      \
-                    int bx = FFMIN(ax + 1, width - 1);                       \
-                    int by = FFMIN(ay + 1, height - 1);                      \
-                                                                             \
-                    sum += (1.f - du) * (1.f - dv) * src[ay * src_linesize + ax];\
-                    sum += (      du) * (1.f - dv) * src[ay * src_linesize + bx];\
-                    sum += (1.f - du) * (      dv) * src[by * src_linesize + ax];\
-                    sum += (      du) * (      dv) * src[by * src_linesize + bx];\
-                    dst[x] = av_clip_uintp2_c(lrintf(sum), depth);           \
-                }                                                            \
-            }                                                                \
-                                                                             \
-            dst += dst_linesize;                                             \
-        }                                                                    \
-    }                                                                        \
-                                                                             \
-    return 0;                                                                \
-}
-
-BL(uint8_t, 8)
-BL(uint16_t, 16)
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ShearContext *s = ctx->priv;
-    AVFilterLink *outlink = ctx->outputs[0];
-    ThreadData td;
-    AVFrame *out;
-
-    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    if (!out) {
-        av_frame_free(&in);
-        return AVERROR(ENOMEM);
-    }
-    av_frame_copy_props(out, in);
-
-    /* fill background */
-    if (s->fillcolor_enable)
-        ff_fill_rectangle(&s->draw, &s->color, out->data, out->linesize,
-                          0, 0, outlink->w, outlink->h);
-
-    td.in = in, td.out = out;
-    ctx->internal->execute(ctx, s->filter_slice[s->interp], &td, NULL, FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
-
-    av_frame_free(&in);
-    return ff_filter_frame(outlink, out);
-}
-
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    ShearContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
-
-    s->nb_planes = av_pix_fmt_count_planes(outlink->format);
-    s->depth = desc->comp[0].depth;
-    s->hsub = 1 << desc->log2_chroma_w;
-    s->vsub = 1 << desc->log2_chroma_h;
-    s->planewidth[1]  = s->planewidth[2] = AV_CEIL_RSHIFT(ctx->inputs[0]->w, desc->log2_chroma_w);
-    s->planewidth[0]  = s->planewidth[3] = ctx->inputs[0]->w;
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(ctx->inputs[0]->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = ctx->inputs[0]->h;
-
-    ff_draw_init(&s->draw, outlink->format, 0);
-    ff_draw_color(&s->draw, &s->color, s->fillcolor);
-
-    s->filter_slice[0] = s->depth <= 8 ? filter_slice_nn8 : filter_slice_nn16;
-    s->filter_slice[1] = s->depth <= 8 ? filter_slice_bl8 : filter_slice_bl16;
-
-    return 0;
-}
-
-static int process_command(AVFilterContext *ctx,
-                           const char *cmd,
-                           const char *arg,
-                           char *res,
-                           int res_len,
-                           int flags)
-{
-    ShearContext *s = ctx->priv;
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    ret = init(ctx);
-    if (ret < 0)
-        return ret;
-    ff_draw_color(&s->draw, &s->color, s->fillcolor);
-
-    return 0;
-}
-
-static const AVFilterPad inputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .filter_frame = filter_frame,
-    },
-    { NULL }
-};
-
-static const AVFilterPad outputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_output,
-    },
-    { NULL }
-};
-
-AVFilter ff_vf_shear = {
-    .name            = "shear",
-    .description     = NULL_IF_CONFIG_SMALL("Shear transform the input image."),
-    .priv_size       = sizeof(ShearContext),
-    .init            = init,
-    .query_formats   = query_formats,
-    .inputs          = inputs,
-    .outputs         = outputs,
-    .priv_class      = &shear_class,
-    .flags           = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
-};
diff --git a/libavfilter/vf_shufflepixels.c b/libavfilter/vf_shufflepixels.c
deleted file mode 100644
index 463bb66..0000000
--- a/libavfilter/vf_shufflepixels.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * Copyright (c) 2020 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/avassert.h"
-#include "libavutil/avstring.h"
-#include "libavutil/common.h"
-#include "libavutil/internal.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/lfg.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/random_seed.h"
-
-#include "avfilter.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct ShufflePixelsContext {
-    const AVClass *class;
-
-    int block_w, block_h;
-    int mode;
-    int direction;
-    int64_t seed;
-
-    int depth;
-    int nb_planes;
-    int linesize[4];
-    int planewidth[4];
-    int planeheight[4];
-
-    int nb_blocks;
-
-    uint8_t *used;
-    int32_t *map;
-
-    AVLFG c;
-
-    int (*shuffle_pixels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
-} ShufflePixelsContext;
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10,
-        AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
-        AV_PIX_FMT_GBRAP16, AV_PIX_FMT_GBRAP,
-        AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUVA444P10,
-        AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_NONE
-    };
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-    if (!fmts_list)
-        return AVERROR(ENOMEM);
-    return ff_set_common_formats(ctx, fmts_list);
-}
-
-static void make_horizontal_map(AVFilterContext *ctx)
-{
-    ShufflePixelsContext *s = ctx->priv;
-    const int nb_blocks = s->nb_blocks;
-    AVLFG *c = &s->c;
-    uint8_t *used = s->used;
-    int32_t *map = s->map;
-
-    for (int x = 0; x < s->planewidth[0];) {
-        int rand = av_lfg_get(c) % nb_blocks;
-
-        if (used[rand] == 0) {
-            int width;
-
-            if (s->direction) {
-                width = FFMIN(s->block_w, s->planewidth[0] - x);
-                map[rand * s->block_w] = x;
-            } else {
-                width = FFMIN(s->block_w, s->planewidth[0] - rand * s->block_w);
-                map[x] = rand * s->block_w;
-            }
-            used[rand] = 1;
-
-            if (s->direction) {
-                for (int i = 1; i < width; i++) {
-                    map[rand * s->block_w + i] = map[rand * s->block_w] + i;
-                }
-            } else {
-                for (int i = 1; i < width; i++) {
-                    map[x + i] = map[x] + i;
-                }
-            }
-
-            x += width;
-        }
-    }
-}
-
-static void make_vertical_map(AVFilterContext *ctx)
-{
-    ShufflePixelsContext *s = ctx->priv;
-    const int nb_blocks = s->nb_blocks;
-    AVLFG *c = &s->c;
-    uint8_t *used = s->used;
-    int32_t *map = s->map;
-
-    for (int y = 0; y < s->planeheight[0];) {
-        int rand = av_lfg_get(c) % nb_blocks;
-
-        if (used[rand] == 0) {
-            int height;
-
-            if (s->direction) {
-                height = FFMIN(s->block_h, s->planeheight[0] - y);
-                map[rand * s->block_h] = y;
-            } else {
-                height = FFMIN(s->block_h, s->planeheight[0] - rand * s->block_h);
-                map[y] = rand * s->block_h;
-            }
-            used[rand] = 1;
-
-            if (s->direction) {
-                for (int i = 1; i < height; i++) {
-                    map[rand * s->block_h + i] = map[rand * s->block_h] + i;
-                }
-            } else {
-                for (int i = 1; i < height; i++) {
-                    map[y + i] = map[y] + i;
-                }
-            }
-
-            y += height;
-        }
-    }
-}
-
-static void make_block_map(AVFilterContext *ctx)
-{
-    ShufflePixelsContext *s = ctx->priv;
-    const int nb_blocks = s->nb_blocks;
-    int nb_blocks_w = s->planewidth[0]  / s->block_w;
-    AVLFG *c = &s->c;
-    uint8_t *used = s->used;
-    int32_t *map = s->map;
-
-    for (int i = 0; i < nb_blocks;) {
-        int rand = av_lfg_get(c) % nb_blocks;
-
-        if (used[rand] == 0) {
-            int yin = i / nb_blocks_w;
-            int xin = i % nb_blocks_w;
-            int in = yin * s->block_h * s->planewidth[0] + xin * s->block_w;
-            int yout = rand / nb_blocks_w;
-            int xout = rand % nb_blocks_w;
-            int out = yout * s->block_h * s->planewidth[0] + xout * s->block_w;
-
-            if (s->direction) {
-                map[out] = in;
-            } else {
-                map[in] = out;
-            }
-            used[rand] = 1;
-
-            if (s->direction) {
-                for (int y = 0; y < s->block_h; y++) {
-                    for (int x = 0; x < s->block_w; x++) {
-                        map[out + y * s->planewidth[0] + x] = map[out] + x + y * s->planewidth[0];
-                    }
-                }
-            } else {
-                for (int y = 0; y < s->block_h; y++) {
-                    for (int x = 0; x < s->block_w; x++) {
-                        map[in + y * s->planewidth[0] + x] = map[in] + x + y * s->planewidth[0];
-                    }
-                }
-            }
-
-            i++;
-        }
-    }
-}
-
-typedef struct ThreadData {
-    AVFrame *in, *out;
-} ThreadData;
-
-
-#define SHUFFLE_HORIZONTAL(name, type)                                       \
-static int shuffle_horizontal## name(AVFilterContext *ctx, void *arg,        \
-                                     int jobnr, int nb_jobs)                 \
-{                                                                            \
-    ShufflePixelsContext *s = ctx->priv;                                     \
-    ThreadData *td = arg;                                                    \
-    AVFrame *in = td->in;                                                    \
-    AVFrame *out = td->out;                                                  \
-                                                                             \
-    for (int p = 0; p < s->nb_planes; p++) {                                 \
-        const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs;       \
-        const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs;     \
-        type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
-        const type *src = (const type *)(in->data[p] +                       \
-                                         slice_start * in->linesize[p]);     \
-        const int32_t *map = s->map;                                         \
-                                                                             \
-        for (int y = slice_start; y < slice_end; y++) {                      \
-            for (int x = 0; x < s->planewidth[p]; x++) {                     \
-                dst[x] = src[map[x]];                                        \
-            }                                                                \
-                                                                             \
-            dst += out->linesize[p] / sizeof(type);                          \
-            src += in->linesize[p] / sizeof(type);                           \
-        }                                                                    \
-    }                                                                        \
-                                                                             \
-    return 0;                                                                \
-}
-
-SHUFFLE_HORIZONTAL(8, uint8_t)
-SHUFFLE_HORIZONTAL(16, uint16_t)
-
-#define SHUFFLE_VERTICAL(name, type)                                         \
-static int shuffle_vertical## name(AVFilterContext *ctx, void *arg,          \
-                            int jobnr, int nb_jobs)                          \
-{                                                                            \
-    ShufflePixelsContext *s = ctx->priv;                                     \
-    ThreadData *td = arg;                                                    \
-    AVFrame *in = td->in;                                                    \
-    AVFrame *out = td->out;                                                  \
-                                                                             \
-    for (int p = 0; p < s->nb_planes; p++) {                                 \
-        const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs;       \
-        const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs;     \
-        type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
-        const int32_t *map = s->map;                                         \
-                                                                             \
-        for (int y = slice_start; y < slice_end; y++) {                      \
-            const type *src = (const type *)(in->data[p] +                   \
-                                             map[y] * in->linesize[p]);      \
-                                                                             \
-            memcpy(dst, src, s->linesize[p]);                                \
-            dst += out->linesize[p] / sizeof(type);                          \
-        }                                                                    \
-    }                                                                        \
-                                                                             \
-    return 0;                                                                \
-}
-
-SHUFFLE_VERTICAL(8, uint8_t)
-SHUFFLE_VERTICAL(16, uint16_t)
-
-#define SHUFFLE_BLOCK(name, type)                                            \
-static int shuffle_block## name(AVFilterContext *ctx, void *arg,             \
-                         int jobnr, int nb_jobs)                             \
-{                                                                            \
-    ShufflePixelsContext *s = ctx->priv;                                     \
-    ThreadData *td = arg;                                                    \
-    AVFrame *in = td->in;                                                    \
-    AVFrame *out = td->out;                                                  \
-                                                                             \
-    for (int p = 0; p < s->nb_planes; p++) {                                 \
-        const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs;       \
-        const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs;     \
-        type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
-        const type *src = (const type *)in->data[p];                         \
-        const int32_t *map = s->map + slice_start * s->planewidth[p];        \
-                                                                             \
-        for (int y = slice_start; y < slice_end; y++) {                      \
-            for (int x = 0; x < s->planewidth[p]; x++) {                     \
-                int ymap = map[x] / s->planewidth[p];                        \
-                int xmap = map[x] % s->planewidth[p];                        \
-                                                                             \
-                dst[x] = src[xmap + ymap * in->linesize[p] / sizeof(type)];  \
-            }                                                                \
-                                                                             \
-            dst += out->linesize[p] / sizeof(type);                          \
-            map += s->planewidth[p];                                         \
-        }                                                                    \
-    }                                                                        \
-                                                                             \
-    return 0;                                                                \
-}
-
-SHUFFLE_BLOCK(8, uint8_t)
-SHUFFLE_BLOCK(16, uint16_t)
-
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    ShufflePixelsContext *s = ctx->priv;
-    AVFilterLink *inlink = ctx->inputs[0];
-    const AVPixFmtDescriptor *desc;
-    int ret;
-
-    if (s->seed == -1)
-        s->seed = av_get_random_seed();
-    av_lfg_init(&s->c, s->seed);
-
-    desc = av_pix_fmt_desc_get(outlink->format);
-    if (!desc)
-        return AVERROR_BUG;
-    s->nb_planes = av_pix_fmt_count_planes(outlink->format);
-    s->depth = desc->comp[0].depth;
-
-    if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
-        return ret;
-
-    s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0] = s->planewidth[3] = inlink->w;
-
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-
-    s->map = av_calloc(inlink->w * inlink->h, sizeof(*s->map));
-    if (!s->map)
-        return AVERROR(ENOMEM);
-
-    switch (s->mode) {
-    case 0:
-        s->shuffle_pixels = s->depth <= 8 ? shuffle_horizontal8 : shuffle_horizontal16;
-        s->nb_blocks = (s->planewidth[0] + s->block_w - 1) / s->block_w;
-        break;
-    case 1:
-        s->shuffle_pixels = s->depth <= 8 ? shuffle_vertical8 : shuffle_vertical16;
-        s->nb_blocks = (s->planeheight[0] + s->block_h - 1) / s->block_h;
-        break;
-    case 2:
-        s->shuffle_pixels = s->depth <= 8 ? shuffle_block8 : shuffle_block16;
-        s->nb_blocks = (s->planeheight[0] / s->block_h) *
-                       (s->planewidth[0]  / s->block_w);
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    s->used = av_calloc(s->nb_blocks, sizeof(*s->used));
-    if (!s->used)
-        return AVERROR(ENOMEM);
-
-    switch (s->mode) {
-    case 0:
-        make_horizontal_map(ctx);
-        break;
-    case 1:
-        make_vertical_map(ctx);
-        break;
-    case 2:
-        make_block_map(ctx);
-        break;
-    default:
-        av_assert0(0);
-    }
-
-    return 0;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-    AVFilterContext *ctx = inlink->dst;
-    ShufflePixelsContext *s = ctx->priv;
-    AVFrame *out = ff_get_video_buffer(ctx->outputs[0], in->width, in->height);
-    ThreadData td;
-    int ret;
-
-    ret = av_frame_copy_props(out, in);
-    if (ret < 0) {
-        av_frame_free(&out);
-        goto fail;
-    }
-
-    td.out = out;
-    td.in = in;
-    ctx->internal->execute(ctx, s->shuffle_pixels, &td, NULL, FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
-
-    av_frame_free(&in);
-    return ff_filter_frame(ctx->outputs[0], out);
-fail:
-    av_frame_free(&in);
-    return ret;
-}
-
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    ShufflePixelsContext *s = ctx->priv;
-
-    av_freep(&s->map);
-    av_freep(&s->used);
-}
-
-#define OFFSET(x) offsetof(ShufflePixelsContext, x)
-#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
-static const AVOption shufflepixels_options[] = {
-    { "direction",  "set shuffle direction",  OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
-    { "d",          "set shuffle direction",  OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
-    {  "forward",    0,  0,  AV_OPT_TYPE_CONST,     {.i64=0}, 0,  0, FLAGS, "dir" },
-    {  "inverse",    0,  0,  AV_OPT_TYPE_CONST,     {.i64=1}, 0,  0, FLAGS, "dir" },
-    { "mode",       "set shuffle mode",  OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
-    { "m",          "set shuffle mode",  OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
-    {  "horizontal",  0,  0,  AV_OPT_TYPE_CONST,     {.i64=0}, 0,  0, FLAGS, "mode" },
-    {  "vertical",    0,  0,  AV_OPT_TYPE_CONST,     {.i64=1}, 0,  0, FLAGS, "mode" },
-    {  "block",       0,  0,  AV_OPT_TYPE_CONST,     {.i64=2}, 0,  0, FLAGS, "mode" },
-    { "width",      "set block width",  OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
-    { "w",          "set block width",  OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
-    { "height",     "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
-    { "h",          "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
-    { "seed",       "set random seed",  OFFSET(seed),   AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
-    { "s",          "set random seed",  OFFSET(seed),   AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
-    { NULL },
-};
-
-AVFILTER_DEFINE_CLASS(shufflepixels);
-
-static const AVFilterPad shufflepixels_inputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .filter_frame = filter_frame,
-    },
-    { NULL },
-};
-
-static const AVFilterPad shufflepixels_outputs[] = {
-    {
-        .name          = "default",
-        .type          = AVMEDIA_TYPE_VIDEO,
-        .config_props  = config_output,
-    },
-    { NULL },
-};
-
-AVFilter ff_vf_shufflepixels = {
-    .name          = "shufflepixels",
-    .description   = NULL_IF_CONFIG_SMALL("Shuffle video pixels."),
-    .priv_size     = sizeof(ShufflePixelsContext),
-    .priv_class    = &shufflepixels_class,
-    .query_formats = query_formats,
-    .uninit        = uninit,
-    .inputs        = shufflepixels_inputs,
-    .outputs       = shufflepixels_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
-};
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index 6ea7e74..4bcc642 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -33,11 +33,9 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
-#include "qp_table.h"
 #include "vf_spp.h"
 
 enum mode {
@@ -376,34 +374,47 @@
     AVFilterLink *outlink = ctx->outputs[0];
     AVFrame *out = in;
     int qp_stride = 0;
-    int8_t *qp_table = NULL;
+    const int8_t *qp_table = NULL;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     const int depth = desc->comp[0].depth;
-    int ret = 0;
 
     /* if we are not in a constant user quantizer mode and we don't want to use
      * the quantizers from the B-frames (B-frames often have a higher QP), we
      * need to save the qp table from the last non B-frame; this is what the
      * following code block does */
-    if (!s->qp && (s->use_bframe_qp || in->pict_type != AV_PICTURE_TYPE_B)) {
-        ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL, &s->qscale_type);
-        if (ret < 0) {
-            av_frame_free(&in);
-            return ret;
-        }
+    if (!s->qp) {
+        qp_table = av_frame_get_qp_table(in, &qp_stride, &s->qscale_type);
 
-        if (!s->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
-            av_freep(&s->non_b_qp_table);
-            s->non_b_qp_table  = qp_table;
-            s->non_b_qp_stride = qp_stride;
+        if (qp_table && !s->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
+            int w, h;
+
+            /* if the qp stride is not set, it means the QP are only defined on
+             * a line basis */
+            if (!qp_stride) {
+                w = AV_CEIL_RSHIFT(inlink->w, 4);
+                h = 1;
+            } else {
+                w = qp_stride;
+                h = AV_CEIL_RSHIFT(inlink->h, 4);
+            }
+
+            if (w * h > s->non_b_qp_alloc_size) {
+                int ret = av_reallocp_array(&s->non_b_qp_table, w, h);
+                if (ret < 0) {
+                    s->non_b_qp_alloc_size = 0;
+                    return ret;
+                }
+                s->non_b_qp_alloc_size = w * h;
+            }
+
+            av_assert0(w * h <= s->non_b_qp_alloc_size);
+            memcpy(s->non_b_qp_table, qp_table, w * h);
         }
     }
 
     if (s->log2_count && !ctx->is_disabled) {
-        if (!s->use_bframe_qp && s->non_b_qp_table) {
-            qp_table  = s->non_b_qp_table;
-            qp_stride = s->non_b_qp_stride;
-        }
+        if (!s->use_bframe_qp && s->non_b_qp_table)
+            qp_table = s->non_b_qp_table;
 
         if (qp_table || s->qp) {
             const int cw = AV_CEIL_RSHIFT(inlink->w, s->hsub);
@@ -418,8 +429,7 @@
                 out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
                 if (!out) {
                     av_frame_free(&in);
-                    ret = AVERROR(ENOMEM);
-                    goto finish;
+                    return AVERROR(ENOMEM);
                 }
                 av_frame_copy_props(out, in);
                 out->width  = in->width;
@@ -443,11 +453,7 @@
                                 inlink->w, inlink->h);
         av_frame_free(&in);
     }
-    ret = ff_filter_frame(outlink, out);
-finish:
-    if (qp_table != s->non_b_qp_table)
-        av_freep(&qp_table);
-    return ret;
+    return ff_filter_frame(outlink, out);
 }
 
 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
diff --git a/libavfilter/vf_spp.h b/libavfilter/vf_spp.h
index 76c0c34..879ed40 100644
--- a/libavfilter/vf_spp.h
+++ b/libavfilter/vf_spp.h
@@ -39,7 +39,7 @@
     uint16_t *temp;
     AVDCT *dct;
     int8_t *non_b_qp_table;
-    int non_b_qp_stride;
+    int non_b_qp_alloc_size;
     int use_bframe_qp;
     int hsub, vsub;
 
diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
index 45f941a..fe6c5d3 100644
--- a/libavfilter/vf_sr.c
+++ b/libavfilter/vf_sr.c
@@ -32,11 +32,15 @@
 #include "libavutil/pixdesc.h"
 #include "libavformat/avio.h"
 #include "libswscale/swscale.h"
-#include "dnn_filter_common.h"
+#include "dnn_interface.h"
 
 typedef struct SRContext {
     const AVClass *class;
-    DnnContext dnnctx;
+
+    char *model_filename;
+    DNNBackendType backend_type;
+    DNNModule *dnn_module;
+    DNNModel *model;
     int scale_factor;
     struct SwsContext *sws_uv_scale;
     int sws_uv_height;
@@ -46,15 +50,13 @@
 #define OFFSET(x) offsetof(SRContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption sr_options[] = {
-    { "dnn_backend", "DNN backend used for model execution", OFFSET(dnnctx.backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
+    { "dnn_backend", "DNN backend used for model execution", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
     { "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" },
 #if (CONFIG_LIBTENSORFLOW == 1)
     { "tensorflow", "tensorflow backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "backend" },
 #endif
     { "scale_factor", "scale factor for SRCNN model", OFFSET(scale_factor), AV_OPT_TYPE_INT, { .i64 = 2 }, 2, 4, FLAGS },
-    { "model", "path to model file specifying network architecture and its parameters", OFFSET(dnnctx.model_filename), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
-    { "input",       "input name of the model",     OFFSET(dnnctx.model_inputname),  AV_OPT_TYPE_STRING,    { .str = "x" },  0, 0, FLAGS },
-    { "output",      "output name of the model",    OFFSET(dnnctx.model_outputname), AV_OPT_TYPE_STRING,    { .str = "y" },  0, 0, FLAGS },
+    { "model", "path to model file specifying network architecture and its parameters", OFFSET(model_filename), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
     { NULL }
 };
 
@@ -63,7 +65,28 @@
 static av_cold int init(AVFilterContext *context)
 {
     SRContext *sr_context = context->priv;
-    return ff_dnn_init(&sr_context->dnnctx, DFT_PROCESS_FRAME, context);
+
+    sr_context->dnn_module = ff_get_dnn_module(sr_context->backend_type);
+    if (!sr_context->dnn_module){
+        av_log(context, AV_LOG_ERROR, "could not create DNN module for requested backend\n");
+        return AVERROR(ENOMEM);
+    }
+
+    if (!sr_context->model_filename){
+        av_log(context, AV_LOG_ERROR, "model file for network was not specified\n");
+        return AVERROR(EIO);
+    }
+    if (!sr_context->dnn_module->load_model) {
+        av_log(context, AV_LOG_ERROR, "load_model for network was not specified\n");
+        return AVERROR(EIO);
+    }
+    sr_context->model = (sr_context->dnn_module->load_model)(sr_context->model_filename, NULL, NULL);
+    if (!sr_context->model){
+        av_log(context, AV_LOG_ERROR, "could not load DNN model\n");
+        return AVERROR(EIO);
+    }
+
+    return 0;
 }
 
 static int query_formats(AVFilterContext *context)
@@ -91,7 +114,8 @@
     int out_width, out_height;
 
     // have a try run in case that the dnn model resize the frame
-    result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &out_width, &out_height);
+    result = ctx->model->get_output(ctx->model->model, "x", inlink->w, inlink->h,
+                                    "y", &out_width, &out_height);
     if (result != DNN_SUCCESS) {
         av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
         return AVERROR(EIO);
@@ -131,6 +155,7 @@
     AVFilterLink *outlink = context->outputs[0];
     AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     DNNReturnType dnn_result;
+    const char *model_output_name = "y";
 
     if (!out){
         av_log(context, AV_LOG_ERROR, "could not allocate memory for output frame\n");
@@ -143,9 +168,11 @@
         sws_scale(ctx->sws_pre_scale,
                     (const uint8_t **)in->data, in->linesize, 0, in->height,
                     out->data, out->linesize);
-        dnn_result = ff_dnn_execute_model(&ctx->dnnctx, out, out);
+        dnn_result = (ctx->dnn_module->execute_model)(ctx->model, "x", out,
+                                                      (const char **)&model_output_name, 1, out);
     } else {
-        dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, out);
+        dnn_result = (ctx->dnn_module->execute_model)(ctx->model, "x", in,
+                                                      (const char **)&model_output_name, 1, out);
     }
 
     if (dnn_result != DNN_SUCCESS){
@@ -170,7 +197,11 @@
 {
     SRContext *sr_context = context->priv;
 
-    ff_dnn_uninit(&sr_context->dnnctx);
+    if (sr_context->dnn_module){
+        (sr_context->dnn_module->free_model)(&sr_context->model);
+        av_freep(&sr_context->dnn_module);
+    }
+
     sws_freeContext(sr_context->sws_uv_scale);
     sws_freeContext(sr_context->sws_pre_scale);
 }
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index ebb314c..a32fada 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -51,7 +51,6 @@
     FILE *stats_file;
     char *stats_file_str;
     int nb_components;
-    int nb_threads;
     int max;
     uint64_t nb_frames;
     double ssim[4], ssim_total;
@@ -60,11 +59,13 @@
     uint8_t rgba_map[4];
     int planewidth[4];
     int planeheight[4];
-    int **temp;
+    int *temp;
     int is_rgb;
-    double **score;
-    int (*ssim_plane)(AVFilterContext *ctx, void *arg,
-                      int jobnr, int nb_jobs);
+    double (*ssim_plane)(SSIMDSPContext *dsp,
+                        uint8_t *main, int main_stride,
+                        uint8_t *ref, int ref_stride,
+                        int width, int height, void *temp,
+                        int max);
     SSIMDSPContext dsp;
 } SSIMContext;
 
@@ -82,7 +83,7 @@
 static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
 {
     char value[128];
-    snprintf(value, sizeof(value), "%f", d);
+    snprintf(value, sizeof(value), "%0.2f", d);
     if (comp) {
         char key2[128];
         snprintf(key2, sizeof(key2), "%s%c", key, comp);
@@ -220,104 +221,60 @@
 
 #define SUM_LEN(w) (((w) >> 2) + 3)
 
-typedef struct ThreadData {
-    const uint8_t *main_data[4];
-    const uint8_t *ref_data[4];
-    int main_linesize[4];
-    int ref_linesize[4];
-    int planewidth[4];
-    int planeheight[4];
-    double **score;
-    int **temp;
-    int nb_components;
-    int max;
-    SSIMDSPContext *dsp;
-} ThreadData;
-
-static int ssim_plane_16bit(AVFilterContext *ctx, void *arg,
-                            int jobnr, int nb_jobs)
+static double ssim_plane_16bit(SSIMDSPContext *dsp,
+                              uint8_t *main, int main_stride,
+                              uint8_t *ref, int ref_stride,
+                              int width, int height, void *temp,
+                              int max)
 {
-    ThreadData *td = arg;
-    double *score = td->score[jobnr];
-    void *temp = td->temp[jobnr];
-    const int max = td->max;
+    int z = 0, y;
+    double ssim = 0.0;
+    int64_t (*sum0)[4] = temp;
+    int64_t (*sum1)[4] = sum0 + SUM_LEN(width);
 
-    for (int c = 0; c < td->nb_components; c++) {
-        const uint8_t *main_data = td->main_data[c];
-        const uint8_t *ref_data = td->ref_data[c];
-        const int main_stride = td->main_linesize[c];
-        const int ref_stride = td->ref_linesize[c];
-        int width = td->planewidth[c];
-        int height = td->planeheight[c];
-        const int slice_start = ((height >> 2) * jobnr) / nb_jobs;
-        const int slice_end = ((height >> 2) * (jobnr+1)) / nb_jobs;
-        const int ystart = FFMAX(1, slice_start);
-        int z = ystart - 1;
-        double ssim = 0.0;
-        int64_t (*sum0)[4] = temp;
-        int64_t (*sum1)[4] = sum0 + SUM_LEN(width);
+    width >>= 2;
+    height >>= 2;
 
-        width >>= 2;
-        height >>= 2;
-
-        for (int y = ystart; y < slice_end; y++) {
-            for (; z <= y; z++) {
-                FFSWAP(void*, sum0, sum1);
-                ssim_4x4xn_16bit(&main_data[4 * z * main_stride], main_stride,
-                                 &ref_data[4 * z * ref_stride], ref_stride,
-                                 sum0, width);
-            }
-
-            ssim += ssim_endn_16bit((const int64_t (*)[4])sum0, (const int64_t (*)[4])sum1, width - 1, max);
+    for (y = 1; y < height; y++) {
+        for (; z <= y; z++) {
+            FFSWAP(void*, sum0, sum1);
+            ssim_4x4xn_16bit(&main[4 * z * main_stride], main_stride,
+                             &ref[4 * z * ref_stride], ref_stride,
+                             sum0, width);
         }
 
-        score[c] = ssim;
+        ssim += ssim_endn_16bit((const int64_t (*)[4])sum0, (const int64_t (*)[4])sum1, width - 1, max);
     }
 
-    return 0;
+    return ssim / ((height - 1) * (width - 1));
 }
 
-static int ssim_plane(AVFilterContext *ctx, void *arg,
-                      int jobnr, int nb_jobs)
+static double ssim_plane(SSIMDSPContext *dsp,
+                        uint8_t *main, int main_stride,
+                        uint8_t *ref, int ref_stride,
+                        int width, int height, void *temp,
+                        int max)
 {
-    ThreadData *td = arg;
-    double *score = td->score[jobnr];
-    void *temp = td->temp[jobnr];
-    SSIMDSPContext *dsp = td->dsp;
+    int z = 0, y;
+    double ssim = 0.0;
+    int (*sum0)[4] = temp;
+    int (*sum1)[4] = sum0 + SUM_LEN(width);
 
-    for (int c = 0; c < td->nb_components; c++) {
-        const uint8_t *main_data = td->main_data[c];
-        const uint8_t *ref_data = td->ref_data[c];
-        const int main_stride = td->main_linesize[c];
-        const int ref_stride = td->ref_linesize[c];
-        int width = td->planewidth[c];
-        int height = td->planeheight[c];
-        const int slice_start = ((height >> 2) * jobnr) / nb_jobs;
-        const int slice_end = ((height >> 2) * (jobnr+1)) / nb_jobs;
-        const int ystart = FFMAX(1, slice_start);
-        int z = ystart - 1;
-        double ssim = 0.0;
-        int (*sum0)[4] = temp;
-        int (*sum1)[4] = sum0 + SUM_LEN(width);
+    width >>= 2;
+    height >>= 2;
 
-        width >>= 2;
-        height >>= 2;
-
-        for (int y = ystart; y < slice_end; y++) {
-            for (; z <= y; z++) {
-                FFSWAP(void*, sum0, sum1);
-                dsp->ssim_4x4_line(&main_data[4 * z * main_stride], main_stride,
-                                   &ref_data[4 * z * ref_stride], ref_stride,
-                                   sum0, width);
-            }
-
-            ssim += dsp->ssim_end_line((const int (*)[4])sum0, (const int (*)[4])sum1, width - 1);
+    for (y = 1; y < height; y++) {
+        for (; z <= y; z++) {
+            FFSWAP(void*, sum0, sum1);
+            dsp->ssim_4x4_line(&main[4 * z * main_stride], main_stride,
+                               &ref[4 * z * ref_stride], ref_stride,
+                               sum0, width);
         }
 
-        score[c] = ssim;
+        ssim += dsp->ssim_end_line((const int (*)[4])sum0, (const int (*)[4])sum1, width - 1);
     }
 
-    return 0;
+    return ssim / ((height - 1) * (width - 1));
 }
 
 static double ssim_db(double ssim, double weight)
@@ -331,47 +288,26 @@
     SSIMContext *s = ctx->priv;
     AVFrame *master, *ref;
     AVDictionary **metadata;
-    double c[4] = {0}, ssimv = 0.0;
-    ThreadData td;
+    double c[4] = { 0 }, ssimv = 0.0;
     int ret, i;
 
     ret = ff_framesync_dualinput_get(fs, &master, &ref);
     if (ret < 0)
         return ret;
-    if (ctx->is_disabled || !ref)
+    if (!ref)
         return ff_filter_frame(ctx->outputs[0], master);
     metadata = &master->metadata;
 
     s->nb_frames++;
 
-    td.nb_components = s->nb_components;
-    td.dsp = &s->dsp;
-    td.score = s->score;
-    td.temp = s->temp;
-    td.max = s->max;
-
-    for (int n = 0; n < s->nb_components; n++) {
-        td.main_data[n] = master->data[n];
-        td.ref_data[n] = ref->data[n];
-        td.main_linesize[n] = master->linesize[n];
-        td.ref_linesize[n] = ref->linesize[n];
-        td.planewidth[n] = s->planewidth[n];
-        td.planeheight[n] = s->planeheight[n];
-    }
-
-    ctx->internal->execute(ctx, s->ssim_plane, &td, NULL, FFMIN((s->planeheight[1] + 3) >> 2, s->nb_threads));
-
     for (i = 0; i < s->nb_components; i++) {
-        for (int j = 0; j < s->nb_threads; j++)
-            c[i] += s->score[j][i];
-        c[i] = c[i] / (((s->planewidth[i] >> 2) - 1) * ((s->planeheight[i] >> 2) - 1));
-    }
-
-    for (i = 0; i < s->nb_components; i++) {
+        c[i] = s->ssim_plane(&s->dsp, master->data[i], master->linesize[i],
+                             ref->data[i], ref->linesize[i],
+                             s->planewidth[i], s->planeheight[i], s->temp,
+                             s->max);
         ssimv += s->coefs[i] * c[i];
         s->ssim[i] += c[i];
     }
-
     for (i = 0; i < s->nb_components; i++) {
         int cidx = s->is_rgb ? s->rgba_map[i] : i;
         set_meta(metadata, "lavfi.ssim.", s->comps[i], c[cidx]);
@@ -447,7 +383,6 @@
     SSIMContext *s = ctx->priv;
     int sum = 0, i;
 
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
     s->nb_components = desc->nb_components;
 
     if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
@@ -475,15 +410,9 @@
     for (i = 0; i < s->nb_components; i++)
         s->coefs[i] = (double) s->planeheight[i] * s->planewidth[i] / sum;
 
-    s->temp = av_calloc(s->nb_threads, sizeof(*s->temp));
+    s->temp = av_mallocz_array(2 * SUM_LEN(inlink->w), (desc->comp[0].depth > 8) ? sizeof(int64_t[4]) : sizeof(int[4]));
     if (!s->temp)
         return AVERROR(ENOMEM);
-
-    for (int t = 0; t < s->nb_threads; t++) {
-        s->temp[t] = av_mallocz_array(2 * SUM_LEN(inlink->w), (desc->comp[0].depth > 8) ? sizeof(int64_t[4]) : sizeof(int[4]));
-        if (!s->temp[t])
-            return AVERROR(ENOMEM);
-    }
     s->max = (1 << desc->comp[0].depth) - 1;
 
     s->ssim_plane = desc->comp[0].depth > 8 ? ssim_plane_16bit : ssim_plane;
@@ -492,16 +421,6 @@
     if (ARCH_X86)
         ff_ssim_init_x86(&s->dsp);
 
-    s->score = av_calloc(s->nb_threads, sizeof(*s->score));
-    if (!s->score)
-        return AVERROR(ENOMEM);
-
-    for (int t = 0; t < s->nb_threads && s->score; t++) {
-        s->score[t] = av_calloc(s->nb_components, sizeof(*s->score[0]));
-        if (!s->score[t])
-            return AVERROR(ENOMEM);
-    }
-
     return 0;
 }
 
@@ -563,12 +482,6 @@
     if (s->stats_file && s->stats_file != stdout)
         fclose(s->stats_file);
 
-    for (int t = 0; t < s->nb_threads && s->score; t++)
-        av_freep(&s->score[t]);
-    av_freep(&s->score);
-
-    for (int t = 0; t < s->nb_threads && s->temp; t++)
-        av_freep(&s->temp[t]);
     av_freep(&s->temp);
 }
 
@@ -605,5 +518,4 @@
     .priv_class    = &ssim_class,
     .inputs        = ssim_inputs,
     .outputs       = ssim_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index 3d2b19a..35b7177 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -60,21 +60,24 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-    AVFilterFormats *formats = NULL;
+    AVFilterFormats *pix_fmts = NULL;
     StackContext *s = ctx->priv;
-    int ret;
+    int fmt, ret;
 
     if (s->fillcolor_enable) {
         return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
     }
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_HWACCEL |
-                                    AV_PIX_FMT_FLAG_BITSTREAM |
-                                    AV_PIX_FMT_FLAG_PAL);
-    if (ret < 0)
-        return ret;
-    return ff_set_common_formats(ctx, formats);
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
+              desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
+              desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
+            (ret = ff_add_format(&pix_fmts, fmt)) < 0)
+            return ret;
+    }
+
+    return ff_set_common_formats(ctx, pix_fmts);
 }
 
 static av_cold int init(AVFilterContext *ctx)
diff --git a/libavfilter/vf_super2xsai.c b/libavfilter/vf_super2xsai.c
index d6c5f44..87eec04 100644
--- a/libavfilter/vf_super2xsai.c
+++ b/libavfilter/vf_super2xsai.c
@@ -46,10 +46,6 @@
     int is_be;
 } Super2xSaIContext;
 
-typedef struct ThreadData {
-    AVFrame *in, *out;
-} ThreadData;
-
 #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D))
 
 #define INTERPOLATE(A, B) (((A & hi_pixel_mask) >> 1) + ((B & hi_pixel_mask) >> 1) + (A & B & lo_pixel_mask))
@@ -57,40 +53,32 @@
 #define Q_INTERPOLATE(A, B, C, D) ((A & q_hi_pixel_mask) >> 2) + ((B & q_hi_pixel_mask) >> 2) + ((C & q_hi_pixel_mask) >> 2) + ((D & q_hi_pixel_mask) >> 2) \
     + ((((A & q_lo_pixel_mask) + (B & q_lo_pixel_mask) + (C & q_lo_pixel_mask) + (D & q_lo_pixel_mask)) >> 2) & q_lo_pixel_mask)
 
-static int super2xsai(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+static void super2xsai(AVFilterContext *ctx,
+                       uint8_t *src, int src_linesize,
+                       uint8_t *dst, int dst_linesize,
+                       int width, int height)
 {
     Super2xSaIContext *s = ctx->priv;
-    ThreadData *td = arg;
-    AVFrame *in = td->in;
-    AVFrame *out = td->out;
-    const uint8_t *src = in->data[0];
-    uint8_t *dst = out->data[0];
-    const int src_linesize = in->linesize[0];
-    const int dst_linesize = out->linesize[0];
-    const int width = in->width;
-    const int height = in->height;
     unsigned int x, y;
     uint32_t color[4][4];
-    const uint8_t *src_line[4];
+    unsigned char *src_line[4];
     const int bpp = s->bpp;
     const uint32_t hi_pixel_mask = s->hi_pixel_mask;
     const uint32_t lo_pixel_mask = s->lo_pixel_mask;
     const uint32_t q_hi_pixel_mask = s->q_hi_pixel_mask;
     const uint32_t q_lo_pixel_mask = s->q_lo_pixel_mask;
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr+1)) / nb_jobs;
 
     /* Point to the first 4 lines, first line is duplicated */
-    src_line[0] = src + src_linesize*FFMAX(slice_start - 1, 0);
-    src_line[1] = src + src_linesize*slice_start;
-    src_line[2] = src + src_linesize*FFMIN(slice_start + 1, height-1);
-    src_line[3] = src + src_linesize*FFMIN(slice_start + 2, height-1);
+    src_line[0] = src;
+    src_line[1] = src;
+    src_line[2] = src + src_linesize*FFMIN(1, height-1);
+    src_line[3] = src + src_linesize*FFMIN(2, height-1);
 
 #define READ_COLOR4(dst, src_line, off) dst = *((const uint32_t *)src_line + off)
 #define READ_COLOR3(dst, src_line, off) dst = AV_RL24 (src_line + 3*off)
 #define READ_COLOR2(dst, src_line, off) dst = s->is_be ? AV_RB16(src_line + 2 * off) : AV_RL16(src_line + 2 * off)
 
-    for (y = slice_start; y < slice_end; y++) {
+    for (y = 0; y < height; y++) {
         uint8_t *dst_line[2];
 
         dst_line[0] = dst + dst_linesize*2*y;
@@ -241,8 +229,6 @@
         if (y < height - 3)
             src_line[3] += src_linesize;
     } // y loop
-
-    return 0;
 }
 
 static int query_formats(AVFilterContext *ctx)
@@ -319,25 +305,24 @@
     return 0;
 }
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 {
-    AVFilterContext *ctx = inlink->dst;
-    AVFilterLink *outlink = ctx->outputs[0];
-    ThreadData td;
-    AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    if (!out) {
-        av_frame_free(&in);
+    AVFilterLink *outlink = inlink->dst->outputs[0];
+    AVFrame *outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+    if (!outpicref) {
+        av_frame_free(&inpicref);
         return AVERROR(ENOMEM);
     }
-    av_frame_copy_props(out, in);
-    out->width  = outlink->w;
-    out->height = outlink->h;
+    av_frame_copy_props(outpicref, inpicref);
+    outpicref->width  = outlink->w;
+    outpicref->height = outlink->h;
 
-    td.in = in, td.out = out;
-    ctx->internal->execute(ctx, super2xsai, &td, NULL, FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+    super2xsai(inlink->dst, inpicref->data[0], inpicref->linesize[0],
+               outpicref->data[0], outpicref->linesize[0],
+               inlink->w, inlink->h);
 
-    av_frame_free(&in);
-    return ff_filter_frame(outlink, out);
+    av_frame_free(&inpicref);
+    return ff_filter_frame(outlink, outpicref);
 }
 
 static const AVFilterPad super2xsai_inputs[] = {
@@ -366,5 +351,4 @@
     .query_formats = query_formats,
     .inputs        = super2xsai_inputs,
     .outputs       = super2xsai_outputs,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_swaprect.c b/libavfilter/vf_swaprect.c
index 66bed16..cf9c298 100644
--- a/libavfilter/vf_swaprect.c
+++ b/libavfilter/vf_swaprect.c
@@ -43,7 +43,7 @@
 } SwapRectContext;
 
 #define OFFSET(x) offsetof(SwapRectContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption swaprect_options[] = {
     { "w",  "set rect width",                     OFFSET(w),  AV_OPT_TYPE_STRING, {.str="w/2"}, 0, 0, .flags = FLAGS },
     { "h",  "set rect height",                    OFFSET(h),  AV_OPT_TYPE_STRING, {.str="h/2"}, 0, 0, .flags = FLAGS },
@@ -253,5 +253,4 @@
     .inputs        = inputs,
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 6563b49..741b19a 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -101,16 +101,19 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-    AVFilterFormats *formats = NULL;
-    int ret;
+    AVFilterFormats *pix_fmts = NULL;
+    int fmt, ret;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_BITSTREAM |
-                                    AV_PIX_FMT_FLAG_PAL |
-                                    AV_PIX_FMT_FLAG_HWACCEL);
-    if (ret < 0)
-        return ret;
-    return ff_set_common_formats(ctx, formats);
+    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
+              desc->flags & AV_PIX_FMT_FLAG_PAL     ||
+              desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
+            (ret = ff_add_format(&pix_fmts, fmt)) < 0)
+            return ret;
+    }
+
+    return ff_set_common_formats(ctx, pix_fmts);
 }
 
 static int config_input(AVFilterLink *inlink)
diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c
index 11623d3..ee29c88 100644
--- a/libavfilter/vf_threshold.c
+++ b/libavfilter/vf_threshold.c
@@ -52,12 +52,10 @@
         AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
         AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
         AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV440P12, AV_PIX_FMT_YUV444P12,
+        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
         AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
         AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9,
         AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
-        AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12,
         AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16,
         AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
         AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
diff --git a/libavfilter/vf_thumbnail.c b/libavfilter/vf_thumbnail.c
index e49b70c..ac04615 100644
--- a/libavfilter/vf_thumbnail.c
+++ b/libavfilter/vf_thumbnail.c
@@ -28,7 +28,6 @@
  */
 
 #include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "internal.h"
 
@@ -45,9 +44,6 @@
     int n_frames;               ///< number of frames for analysis
     struct thumb_frame *frames; ///< the n_frames frames
     AVRational tb;              ///< copy of the input timebase to ease access
-
-    int planewidth[4];
-    int planeheight[4];
 } ThumbContext;
 
 #define OFFSET(x) offsetof(ThumbContext, x)
@@ -144,55 +140,14 @@
     // keep a reference of each frame
     s->frames[s->n].buf = frame;
 
-    // update current frame histogram
-    switch (inlink->format) {
-    case AV_PIX_FMT_RGB24:
-    case AV_PIX_FMT_BGR24:
-        for (j = 0; j < inlink->h; j++) {
-            for (i = 0; i < inlink->w; i++) {
-                hist[0*256 + p[i*3    ]]++;
-                hist[1*256 + p[i*3 + 1]]++;
-                hist[2*256 + p[i*3 + 2]]++;
-            }
-            p += frame->linesize[0];
+    // update current frame RGB histogram
+    for (j = 0; j < inlink->h; j++) {
+        for (i = 0; i < inlink->w; i++) {
+            hist[0*256 + p[i*3    ]]++;
+            hist[1*256 + p[i*3 + 1]]++;
+            hist[2*256 + p[i*3 + 2]]++;
         }
-        break;
-    case AV_PIX_FMT_RGB0:
-    case AV_PIX_FMT_BGR0:
-    case AV_PIX_FMT_RGBA:
-    case AV_PIX_FMT_BGRA:
-        for (j = 0; j < inlink->h; j++) {
-            for (i = 0; i < inlink->w; i++) {
-                hist[0*256 + p[i*4    ]]++;
-                hist[1*256 + p[i*4 + 1]]++;
-                hist[2*256 + p[i*4 + 2]]++;
-            }
-            p += frame->linesize[0];
-        }
-        break;
-    case AV_PIX_FMT_0RGB:
-    case AV_PIX_FMT_0BGR:
-    case AV_PIX_FMT_ARGB:
-    case AV_PIX_FMT_ABGR:
-        for (j = 0; j < inlink->h; j++) {
-            for (i = 0; i < inlink->w; i++) {
-                hist[0*256 + p[i*4 + 1]]++;
-                hist[1*256 + p[i*4 + 2]]++;
-                hist[2*256 + p[i*4 + 3]]++;
-            }
-            p += frame->linesize[0];
-        }
-        break;
-    default:
-        for (int plane = 0; plane < 3; plane++) {
-            const uint8_t *p = frame->data[plane];
-            for (j = 0; j < s->planeheight[plane]; j++) {
-                for (i = 0; i < s->planewidth[plane]; i++)
-                    hist[256*plane + p[i]]++;
-                p += frame->linesize[plane];
-            }
-        }
-        break;
+        p += frame->linesize[0];
     }
 
     // no selection until the buffer of N frames is filled up
@@ -233,14 +188,8 @@
 {
     AVFilterContext *ctx = inlink->dst;
     ThumbContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 
     s->tb = inlink->time_base;
-    s->planewidth[1]  = s->planewidth[2]  = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-    s->planewidth[0]  = s->planewidth[3]  = inlink->w;
-    s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    s->planeheight[0] = s->planeheight[3] = inlink->h;
-
     return 0;
 }
 
@@ -248,18 +197,6 @@
 {
     static const enum AVPixelFormat pix_fmts[] = {
         AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
-        AV_PIX_FMT_RGBA,  AV_PIX_FMT_BGRA,
-        AV_PIX_FMT_RGB0,  AV_PIX_FMT_BGR0,
-        AV_PIX_FMT_ABGR,  AV_PIX_FMT_ARGB,
-        AV_PIX_FMT_0BGR,  AV_PIX_FMT_0RGB,
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-        AV_PIX_FMT_YUVJ411P,
-        AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
         AV_PIX_FMT_NONE
     };
     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index 7e421a9..6278f72 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -63,7 +63,7 @@
     { "color",   "set the color of the unused area", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
     { "overlap", "set how many frames to overlap for each render", OFFSET(overlap),
         AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
-    { "init_padding", "set how many frames to initially pad", OFFSET(init_padding),
+    { "init_padding", " set how many frames to initially pad", OFFSET(init_padding),
         AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
     { NULL }
 };
diff --git a/libavfilter/vf_tmidequalizer.c b/libavfilter/vf_tmidequalizer.c
deleted file mode 100644
index 6e3f3cc..0000000
--- a/libavfilter/vf_tmidequalizer.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright (c) 2020 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/imgutils.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/opt.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct TMidEqualizerContext {
-    const AVClass *class;
-
-    int planes;
-    int radius;
-    float sigma;
-
-    int plane_width[4], plane_height[4];
-    int nb_frames;
-    int depth;
-    int f_frames;
-    int l_frames;
-    int del_frame;
-    int cur_frame;
-    int nb_planes;
-    int histogram_size;
-    float  kernel[127];
-    float *histogram[4][256];
-    float *change[4];
-
-    AVFrame **frames;
-
-    void (*compute_histogram)(const uint8_t *ssrc, ptrdiff_t linesize,
-                              int w, int h, float *histogram, size_t hsize);
-    void (*apply_contrast_change)(const uint8_t *src, ptrdiff_t src_linesize,
-                                  uint8_t *dst, ptrdiff_t dst_linesize,
-                                  int w, int h, float *change, float *orig);
-} TMidEqualizerContext;
-
-#define OFFSET(x) offsetof(TMidEqualizerContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
-
-static const AVOption tmidequalizer_options[] = {
-    { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT,   {.i64=5},   1, 127, FLAGS },
-    { "sigma",  "set sigma",  OFFSET(sigma),  AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,   1, FLAGS },
-    { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT,   {.i64=0xF}, 0, 0xF, FLAGS },
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(tmidequalizer);
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P,
-        AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
-        AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV420P,
-        AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
-        AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
-        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
-        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
-        AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
-        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14,
-        AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9,
-        AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
-        AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12,
-        AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12,
-        AV_PIX_FMT_YUV420P16,  AV_PIX_FMT_YUV422P16,  AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16,
-        AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_NONE
-    };
-
-    return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
-}
-
-static void compute_contrast_function(const float *const histograms[256],
-                                      const float *const kernel,
-                                      int nb_frames, int radius, int hsize,
-                                      float *f, int idx)
-{
-    const float *const h1 = histograms[idx];
-    int p2[256] = { 0 };
-
-    for (int p1 = 0; p1 < hsize; p1++) {
-        float weight = 1.f;
-        float sum = p1 * weight;
-
-        for (int j = 0; j < radius; j++) {
-            const int nidx = ((idx - radius + j) % nb_frames);
-            const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
-            int k = j;
-
-            for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
-            if (p2[k] == hsize)
-                p2[k]--;
-
-            weight += kernel[j];
-            sum += kernel[j] * p2[k];
-        }
-
-        for (int j = radius + 1; j < nb_frames; j++) {
-            const int nidx = (idx - radius + j) % nb_frames;
-            const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
-            int k = j;
-
-            for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
-            if (p2[k] == hsize)
-                p2[k]--;
-
-            weight += kernel[j - radius - 1];
-            sum += kernel[j - radius - 1] * p2[k];
-        }
-
-        f[p1] = sum / weight;
-    }
-}
-
-static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
-                                   uint8_t *dst, ptrdiff_t dst_linesize,
-                                   int w, int h, float *change, float *orig)
-{
-    for (int y = 0; y < h; y++) {
-        for (int x = 0; x < w; x++)
-            dst[x] = lrintf(change[src[x]]);
-
-        dst += dst_linesize;
-        src += src_linesize;
-    }
-}
-
-static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t src_linesize,
-                                    uint8_t *ddst, ptrdiff_t dst_linesize,
-                                    int w, int h, float *change, float *orig)
-{
-    const uint16_t *src = (const uint16_t *)ssrc;
-    uint16_t *dst = (uint16_t *)ddst;
-
-    for (int y = 0; y < h; y++) {
-        for (int x = 0; x < w; x++)
-            dst[x] = lrintf(change[src[x]]);
-
-        dst += dst_linesize / 2;
-        src += src_linesize / 2;
-    }
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-    AVFilterContext *ctx = inlink->dst;
-    TMidEqualizerContext *s = ctx->priv;
-    AVFilterLink *outlink = ctx->outputs[0];
-    AVFrame *out;
-    int eof = 0;
-
-    if (!in) {
-        int idx = s->f_frames < s->nb_frames ? s->radius : s->del_frame ? s->del_frame - 1 : s->nb_frames - 1;
-
-        if (s->f_frames < s->nb_frames) {
-            s->l_frames = s->nb_frames - s->f_frames;
-        } else {
-            s->l_frames++;
-        }
-        in = av_frame_clone(s->frames[idx]);
-        if (!in)
-            return AVERROR(ENOMEM);
-        eof = 1;
-    }
-
-    if (s->f_frames < s->nb_frames) {
-        s->frames[s->f_frames] = in;
-
-        for (int p = 0; p < s->nb_planes; p++) {
-            s->compute_histogram(in->data[p], in->linesize[p],
-                                 s->plane_width[p], s->plane_height[p],
-                                 s->histogram[p][s->f_frames],
-                                 s->histogram_size);
-        }
-
-        s->f_frames++;
-
-        while (s->f_frames <= s->radius) {
-            s->frames[s->f_frames] = av_frame_clone(in);
-            if (!s->frames[s->f_frames])
-                return AVERROR(ENOMEM);
-            for (int p = 0; p < s->nb_planes; p++) {
-                memcpy(s->histogram[p][s->f_frames],
-                       s->histogram[p][s->f_frames - 1],
-                       s->histogram_size * sizeof(float));
-            }
-            s->f_frames++;
-        }
-
-        if (!eof && s->f_frames < s->nb_frames) {
-            return 0;
-        } else {
-            while (s->f_frames < s->nb_frames) {
-                s->frames[s->f_frames] = av_frame_clone(in);
-                if (!s->frames[s->f_frames])
-                    return AVERROR(ENOMEM);
-                for (int p = 0; p < s->nb_planes; p++) {
-                    memcpy(s->histogram[p][s->f_frames],
-                           s->histogram[p][s->f_frames - 1],
-                           s->histogram_size * sizeof(float));
-                }
-                s->f_frames++;
-            }
-        }
-        s->cur_frame = s->radius;
-        s->del_frame = 0;
-    } else {
-        av_frame_free(&s->frames[s->del_frame]);
-        s->frames[s->del_frame] = in;
-
-        for (int p = 0; p < s->nb_planes; p++) {
-            s->compute_histogram(in->data[p], in->linesize[p],
-                                 s->plane_width[p], s->plane_height[p],
-                                 s->histogram[p][s->del_frame],
-                                 s->histogram_size);
-        }
-
-        s->del_frame++;
-        if (s->del_frame >= s->nb_frames)
-            s->del_frame = 0;
-    }
-
-    if (ctx->is_disabled) {
-        const int idx = s->cur_frame;
-
-        out = av_frame_clone(s->frames[idx]);
-        if (!out)
-            return AVERROR(ENOMEM);
-    } else {
-        const int idx = s->cur_frame;
-
-        in = s->frames[idx];
-        out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-        if (!out)
-            return AVERROR(ENOMEM);
-        av_frame_copy_props(out, in);
-
-        for (int p = 0; p < s->nb_planes; p++) {
-            if (!((1 << p) & s->planes)) {
-                av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p],
-                                    s->plane_width[p] * (1 + (s->depth > 8)), s->plane_height[p]);
-                continue;
-            }
-
-            compute_contrast_function((const float *const *)s->histogram[p], s->kernel,
-                                      s->nb_frames, s->radius, s->histogram_size, s->change[p], idx);
-
-            s->apply_contrast_change(in->data[p], in->linesize[p],
-                                     out->data[p], out->linesize[p],
-                                     s->plane_width[p], s->plane_height[p],
-                                     s->change[p], s->histogram[p][idx]);
-        }
-    }
-
-    s->cur_frame++;
-    if (s->cur_frame >= s->nb_frames)
-        s->cur_frame = 0;
-
-    return ff_filter_frame(outlink, out);
-}
-
-static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize,
-                               int w, int h, float *histogram, size_t hsize)
-{
-    memset(histogram, 0, hsize * sizeof(*histogram));
-
-    for (int y = 0; y < h; y++) {
-        for (int x = 0; x < w; x++)
-            histogram[src[x]] += 1;
-        src += linesize;
-    }
-
-    for (int x = 0; x < hsize; x++)
-        histogram[x] /= hsize;
-
-    for (int x = 1; x < hsize; x++)
-        histogram[x] += histogram[x-1];
-}
-
-static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize,
-                                int w, int h, float *histogram, size_t hsize)
-{
-    const uint16_t *src = (const uint16_t *)ssrc;
-
-    memset(histogram, 0, hsize * sizeof(*histogram));
-
-    for (int y = 0; y < h; y++) {
-        for (int x = 0; x < w; x++)
-            histogram[src[x]] += 1;
-        src += linesize / 2;
-    }
-
-    for (int x = 0; x < hsize; x++)
-        histogram[x] /= hsize;
-
-    for (int x = 1; x < hsize; x++)
-        histogram[x] += histogram[x-1];
-}
-
-static int config_input(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx = inlink->dst;
-    TMidEqualizerContext *s = ctx->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    float sigma = s->radius * s->sigma;
-    int vsub, hsub;
-
-    s->depth = desc->comp[0].depth;
-    s->nb_frames = s->radius * 2 + 1;
-    s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-
-    hsub = desc->log2_chroma_w;
-    vsub = desc->log2_chroma_h;
-
-    s->plane_height[0] = s->plane_height[3] = inlink->h;
-    s->plane_width[0]  = s->plane_width[3]  = inlink->w;
-    s->plane_height[1] = s->plane_height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
-    s->plane_width[1]  = s->plane_width[2]  = AV_CEIL_RSHIFT(inlink->w, hsub);
-
-    s->histogram_size = 1 << s->depth;
-
-    for (int n = 0; n < s->radius; n++)
-        s->kernel[n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
-
-    for (int p = 0; p < s->nb_planes; p++) {
-        for (int n = 0; n < s->nb_frames; n++) {
-            s->histogram[p][n] = av_calloc(s->histogram_size, sizeof(float));
-            if (!s->histogram[p][n])
-                return AVERROR(ENOMEM);
-        }
-
-        s->change[p] = av_calloc(s->histogram_size, sizeof(float));
-        if (!s->change[p])
-            return AVERROR(ENOMEM);
-    }
-
-    if (!s->frames)
-        s->frames = av_calloc(s->nb_frames, sizeof(*s->frames));
-    if (!s->frames)
-        return AVERROR(ENOMEM);
-
-    s->compute_histogram = s->depth <= 8 ? compute_histogram8 : compute_histogram16;
-    s->apply_contrast_change = s->depth <= 8 ? apply_contrast_change8 : apply_contrast_change16;
-
-    return 0;
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    TMidEqualizerContext *s = ctx->priv;
-    int ret;
-
-    ret = ff_request_frame(ctx->inputs[0]);
-    if (ret == AVERROR_EOF && s->l_frames < s->radius) {
-        ret = filter_frame(ctx->inputs[0], NULL);
-    }
-
-    return ret;
-}
-
-static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
-{
-    TMidEqualizerContext *s = ctx->priv;
-
-    for (int n = 0; n < nb_frames; n++)
-        av_freep(&s->histogram[x][n]);
-    av_freep(&s->change[x]);
-}
-
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    TMidEqualizerContext *s = ctx->priv;
-
-    free_histograms(ctx, 0, s->nb_frames);
-    free_histograms(ctx, 1, s->nb_frames);
-    free_histograms(ctx, 2, s->nb_frames);
-    free_histograms(ctx, 3, s->nb_frames);
-
-    for (int i = 0; i < s->nb_frames && s->frames; i++)
-        av_frame_free(&s->frames[i]);
-    av_freep(&s->frames);
-}
-
-static const AVFilterPad tmidequalizer_inputs[] = {
-    {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_input,
-        .filter_frame = filter_frame,
-    },
-    { NULL }
-};
-
-static const AVFilterPad tmidequalizer_outputs[] = {
-    {
-        .name          = "default",
-        .type          = AVMEDIA_TYPE_VIDEO,
-        .request_frame = request_frame,
-    },
-    { NULL }
-};
-
-AVFilter ff_vf_tmidequalizer = {
-    .name          = "tmidequalizer",
-    .description   = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
-    .priv_size     = sizeof(TMidEqualizerContext),
-    .uninit        = uninit,
-    .query_formats = query_formats,
-    .inputs        = tmidequalizer_inputs,
-    .outputs       = tmidequalizer_outputs,
-    .priv_class    = &tmidequalizer_class,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-};
diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 2681ebd..b880228 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -71,12 +71,12 @@
     cl_mem                util_mem;
 } TonemapOpenCLContext;
 
-static const char *const linearize_funcs[AVCOL_TRC_NB] = {
+static const char *linearize_funcs[AVCOL_TRC_NB] = {
     [AVCOL_TRC_SMPTE2084] = "eotf_st2084",
     [AVCOL_TRC_ARIB_STD_B67] = "inverse_oetf_hlg",
 };
 
-static const char *const delinearize_funcs[AVCOL_TRC_NB] = {
+static const char *delinearize_funcs[AVCOL_TRC_NB] = {
     [AVCOL_TRC_BT709]     = "inverse_eotf_bt1886",
     [AVCOL_TRC_BT2020_10] = "inverse_eotf_bt1886",
 };
@@ -91,7 +91,7 @@
     [AVCOL_PRI_BT2020] = { 0.3127, 0.3290 },
 };
 
-static const char *const tonemap_func[TONEMAP_MAX] = {
+static const char *tonemap_func[TONEMAP_MAX] = {
     [TONEMAP_NONE]     = "direct",
     [TONEMAP_LINEAR]   = "linear",
     [TONEMAP_GAMMA]    = "gamma",
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 198dbba..e9b6c90 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -139,8 +139,8 @@
     }                                                                                                 \
     return 0;                                                                                         \
 }
-DEF_UNSHARP_SLICE_FUNC(unsharp_slice, 16)
-DEF_UNSHARP_SLICE_FUNC(unsharp_slice, 8)
+DEF_UNSHARP_SLICE_FUNC(unsharp_slice, 16);
+DEF_UNSHARP_SLICE_FUNC(unsharp_slice, 8);
 
 static int apply_unsharp_c(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
 {
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index 8b39f53..6a81435 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -29,11 +29,9 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
-#include "qp_table.h"
 #include "avfilter.h"
 
 #define MAX_LEVEL 8 /* quality levels */
@@ -53,8 +51,8 @@
     AVCodecContext *avctx_enc[BLOCK*BLOCK];
     AVFrame *frame;
     AVFrame *frame_dec;
-    int8_t *non_b_qp_table;
-    int non_b_qp_stride;
+    uint8_t *non_b_qp_table;
+    int non_b_qp_alloc_size;
     int use_bframe_qp;
 } USPPContext;
 
@@ -387,32 +385,45 @@
     AVFrame *out = in;
 
     int qp_stride = 0;
-    int8_t *qp_table = NULL;
-    int ret = 0;
+    uint8_t *qp_table = NULL;
 
     /* if we are not in a constant user quantizer mode and we don't want to use
      * the quantizers from the B-frames (B-frames often have a higher QP), we
      * need to save the qp table from the last non B-frame; this is what the
      * following code block does */
-    if (!uspp->qp && (uspp->use_bframe_qp || in->pict_type != AV_PICTURE_TYPE_B)) {
-        ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL, &uspp->qscale_type);
-        if (ret < 0) {
-            av_frame_free(&in);
-            return ret;
-        }
+    if (!uspp->qp) {
+        qp_table = av_frame_get_qp_table(in, &qp_stride, &uspp->qscale_type);
 
-        if (!uspp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
-            av_freep(&uspp->non_b_qp_table);
-            uspp->non_b_qp_table  = qp_table;
-            uspp->non_b_qp_stride = qp_stride;
+        if (qp_table && !uspp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
+            int w, h;
+
+            /* if the qp stride is not set, it means the QP are only defined on
+             * a line basis */
+            if (!qp_stride) {
+                w = AV_CEIL_RSHIFT(inlink->w, 4);
+                h = 1;
+            } else {
+                w = qp_stride;
+                h = AV_CEIL_RSHIFT(inlink->h, 4);
+            }
+
+            if (w * h > uspp->non_b_qp_alloc_size) {
+                int ret = av_reallocp_array(&uspp->non_b_qp_table, w, h);
+                if (ret < 0) {
+                    uspp->non_b_qp_alloc_size = 0;
+                    return ret;
+                }
+                uspp->non_b_qp_alloc_size = w * h;
+            }
+
+            av_assert0(w * h <= uspp->non_b_qp_alloc_size);
+            memcpy(uspp->non_b_qp_table, qp_table, w * h);
         }
     }
 
     if (uspp->log2_count && !ctx->is_disabled) {
-        if (!uspp->use_bframe_qp && uspp->non_b_qp_table) {
+        if (!uspp->use_bframe_qp && uspp->non_b_qp_table)
             qp_table = uspp->non_b_qp_table;
-            qp_stride = uspp->non_b_qp_stride;
-        }
 
         if (qp_table || uspp->qp) {
 
@@ -444,10 +455,7 @@
                                 inlink->w, inlink->h);
         av_frame_free(&in);
     }
-    ret = ff_filter_frame(outlink, out);
-    if (qp_table != uspp->non_b_qp_table)
-        av_freep(&qp_table);
-    return ret;
+    return ff_filter_frame(outlink, out);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c
index 1de3dc5..c7c39d3 100644
--- a/libavfilter/vf_vflip.c
+++ b/libavfilter/vf_vflip.c
@@ -33,7 +33,6 @@
 typedef struct FlipContext {
     const AVClass *class;
     int vsub;   ///< vertical chroma subsampling
-    int bayer;
 } FlipContext;
 
 static const AVOption vflip_options[] = {
@@ -48,7 +47,6 @@
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
 
     flip->vsub = desc->log2_chroma_h;
-    flip->bayer = !!(desc->flags & AV_PIX_FMT_FLAG_BAYER);
 
     return 0;
 }
@@ -76,43 +74,11 @@
     return frame;
 }
 
-static int flip_bayer(AVFilterLink *link, AVFrame *in)
-{
-    AVFilterContext *ctx  = link->dst;
-    AVFilterLink *outlink = ctx->outputs[0];
-    AVFrame *out;
-    uint8_t *inrow = in->data[0], *outrow;
-    int i, width = outlink->w << (av_pix_fmt_desc_get(link->format)->comp[0].step > 1);
-    if (outlink->h & 1) {
-        av_log(ctx, AV_LOG_ERROR, "Bayer vertical flip needs even height\n");
-        return AVERROR_INVALIDDATA;
-    }
-
-    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    if (!out) {
-        av_frame_free(&in);
-        return AVERROR(ENOMEM);
-    }
-    av_frame_copy_props(out, in);
-    outrow = out->data[0] + out->linesize[0] * (outlink->h - 2);
-    for (i = 0; i < outlink->h >> 1; i++) {
-        memcpy(outrow, inrow, width);
-        memcpy(outrow + out->linesize[0], inrow + in->linesize[0], width);
-        inrow  += 2 *  in->linesize[0];
-        outrow -= 2 * out->linesize[0];
-    }
-    av_frame_free(&in);
-    return ff_filter_frame(outlink, out);
-}
-
 static int filter_frame(AVFilterLink *link, AVFrame *frame)
 {
     FlipContext *flip = link->dst->priv;
     int i;
 
-    if (flip->bayer)
-        return flip_bayer(link, frame);
-
     for (i = 0; i < 4; i ++) {
         int vsub = i == 1 || i == 2 ? flip->vsub : 0;
         int height = AV_CEIL_RSHIFT(link->h, vsub);
diff --git a/libavfilter/vf_vibrance.c b/libavfilter/vf_vibrance.c
index edea521..8e1a55c 100644
--- a/libavfilter/vf_vibrance.c
+++ b/libavfilter/vf_vibrance.c
@@ -21,15 +21,10 @@
 #include "libavutil/opt.h"
 #include "libavutil/imgutils.h"
 #include "avfilter.h"
-#include "drawutils.h"
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
 
-#define R 0
-#define G 1
-#define B 2
-
 typedef struct VibranceContext {
     const AVClass *class;
 
@@ -38,9 +33,7 @@
     float lcoeffs[3];
     int alternate;
 
-    int step;
     int depth;
-    uint8_t rgba_map[4];
 
     int (*do_slice)(AVFilterContext *s, void *arg,
                     int jobnr, int nb_jobs);
@@ -167,118 +160,6 @@
     return 0;
 }
 
-static int vibrance_slice8p(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
-{
-    VibranceContext *s = avctx->priv;
-    AVFrame *frame = arg;
-    const int step = s->step;
-    const int width = frame->width;
-    const int height = frame->height;
-    const float scale = 1.f / 255.f;
-    const float gc = s->lcoeffs[0];
-    const float bc = s->lcoeffs[1];
-    const float rc = s->lcoeffs[2];
-    const uint8_t roffset = s->rgba_map[R];
-    const uint8_t goffset = s->rgba_map[G];
-    const uint8_t boffset = s->rgba_map[B];
-    const float intensity = s->intensity;
-    const float alternate = s->alternate ? 1.f : -1.f;
-    const float gintensity = intensity * s->balance[0];
-    const float bintensity = intensity * s->balance[1];
-    const float rintensity = intensity * s->balance[2];
-    const float sgintensity = alternate * FFSIGN(gintensity);
-    const float sbintensity = alternate * FFSIGN(bintensity);
-    const float srintensity = alternate * FFSIGN(rintensity);
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int linesize = frame->linesize[0];
-    uint8_t *ptr = frame->data[0] + slice_start * linesize;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = ptr[x * step + goffset] * scale;
-            float b = ptr[x * step + boffset] * scale;
-            float r = ptr[x * step + roffset] * scale;
-            float max_color = FFMAX3(r, g, b);
-            float min_color = FFMIN3(r, g, b);
-            float color_saturation = max_color - min_color;
-            float luma = g * gc + r * rc + b * bc;
-            const float cg = 1.f + gintensity * (1.f - sgintensity * color_saturation);
-            const float cb = 1.f + bintensity * (1.f - sbintensity * color_saturation);
-            const float cr = 1.f + rintensity * (1.f - srintensity * color_saturation);
-
-            g = lerpf(luma, g, cg);
-            b = lerpf(luma, b, cb);
-            r = lerpf(luma, r, cr);
-
-            ptr[x * step + goffset] = av_clip_uint8(g * 255.f);
-            ptr[x * step + boffset] = av_clip_uint8(b * 255.f);
-            ptr[x * step + roffset] = av_clip_uint8(r * 255.f);
-        }
-
-        ptr += linesize;
-    }
-
-    return 0;
-}
-
-static int vibrance_slice16p(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
-{
-    VibranceContext *s = avctx->priv;
-    AVFrame *frame = arg;
-    const int step = s->step;
-    const int depth = s->depth;
-    const float max = (1 << depth) - 1;
-    const float scale = 1.f / max;
-    const float gc = s->lcoeffs[0];
-    const float bc = s->lcoeffs[1];
-    const float rc = s->lcoeffs[2];
-    const uint8_t roffset = s->rgba_map[R];
-    const uint8_t goffset = s->rgba_map[G];
-    const uint8_t boffset = s->rgba_map[B];
-    const int width = frame->width;
-    const int height = frame->height;
-    const float intensity = s->intensity;
-    const float alternate = s->alternate ? 1.f : -1.f;
-    const float gintensity = intensity * s->balance[0];
-    const float bintensity = intensity * s->balance[1];
-    const float rintensity = intensity * s->balance[2];
-    const float sgintensity = alternate * FFSIGN(gintensity);
-    const float sbintensity = alternate * FFSIGN(bintensity);
-    const float srintensity = alternate * FFSIGN(rintensity);
-    const int slice_start = (height * jobnr) / nb_jobs;
-    const int slice_end = (height * (jobnr + 1)) / nb_jobs;
-    const int linesize = frame->linesize[0] / 2;
-    uint16_t *ptr = (uint16_t *)frame->data[0] + slice_start * linesize;
-
-    for (int y = slice_start; y < slice_end; y++) {
-        for (int x = 0; x < width; x++) {
-            float g = ptr[x * step + goffset] * scale;
-            float b = ptr[x * step + boffset] * scale;
-            float r = ptr[x * step + roffset] * scale;
-            float max_color = FFMAX3(r, g, b);
-            float min_color = FFMIN3(r, g, b);
-            float color_saturation = max_color - min_color;
-            float luma = g * gc + r * rc + b * bc;
-            const float cg = 1.f + gintensity * (1.f - sgintensity * color_saturation);
-            const float cb = 1.f + bintensity * (1.f - sbintensity * color_saturation);
-            const float cr = 1.f + rintensity * (1.f - srintensity * color_saturation);
-
-            g = lerpf(luma, g, cg);
-            b = lerpf(luma, b, cb);
-            r = lerpf(luma, r, cr);
-
-            ptr[x * step + goffset] = av_clip_uintp2_c(g * max, depth);
-            ptr[x * step + boffset] = av_clip_uintp2_c(b * max, depth);
-            ptr[x * step + roffset] = av_clip_uintp2_c(r * max, depth);
-        }
-
-        ptr += linesize;
-    }
-
-    return 0;
-}
-
 static int filter_frame(AVFilterLink *link, AVFrame *frame)
 {
     AVFilterContext *avctx = link->dst;
@@ -295,17 +176,10 @@
 static av_cold int query_formats(AVFilterContext *avctx)
 {
     static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
-        AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,
-        AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR,
-        AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR,
-        AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
         AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
         AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12,
         AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
         AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
-        AV_PIX_FMT_RGB48,  AV_PIX_FMT_BGR48,
-        AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
         AV_PIX_FMT_NONE
     };
 
@@ -323,21 +197,9 @@
     AVFilterContext *avctx = inlink->dst;
     VibranceContext *s = avctx->priv;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
-
-    s->step = desc->nb_components;
-    if (inlink->format == AV_PIX_FMT_RGB0 ||
-        inlink->format == AV_PIX_FMT_0RGB ||
-        inlink->format == AV_PIX_FMT_BGR0 ||
-        inlink->format == AV_PIX_FMT_0BGR)
-        s->step = 4;
 
     s->depth = desc->comp[0].depth;
     s->do_slice = s->depth <= 8 ? vibrance_slice8 : vibrance_slice16;
-    if (!planar)
-        s->do_slice = s->depth <= 8 ? vibrance_slice8p : vibrance_slice16p;
-
-    ff_fill_rgba_map(s->rgba_map, inlink->format);
 
     return 0;
 }
diff --git a/libavfilter/vf_vif.c b/libavfilter/vf_vif.c
deleted file mode 100644
index 0248210..0000000
--- a/libavfilter/vf_vif.c
+++ /dev/null
@@ -1,657 +0,0 @@
-/*
- * Copyright (c) 2017 Ronald S. Bultje <rsbultje@gmail.com>
- * Copyright (c) 2017 Ashish Pratap Singh <ashk43712@gmail.com>
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Calculate VIF between two input videos.
- */
-
-#include <float.h>
-
-#include "libavutil/avstring.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "avfilter.h"
-#include "framesync.h"
-#include "drawutils.h"
-#include "formats.h"
-#include "internal.h"
-#include "vif.h"
-#include "video.h"
-
-typedef struct VIFContext {
-    const AVClass *class;
-    FFFrameSync fs;
-    const AVPixFmtDescriptor *desc;
-    int width;
-    int height;
-    int nb_threads;
-    float factor;
-    float *data_buf[13];
-    float **temp;
-    float *ref_data;
-    float *main_data;
-    double vif_sum[4];
-    double vif_min[4];
-    double vif_max[4];
-    uint64_t nb_frames;
-} VIFContext;
-
-#define OFFSET(x) offsetof(VIFContext, x)
-
-static const AVOption vif_options[] = {
-    { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(vif);
-
-static const uint8_t vif_filter1d_width1[4] = { 17, 9, 5, 3 };
-
-static const float vif_filter1d_table[4][17] =
-{
-    {
-        0.00745626912, 0.0142655009, 0.0250313189, 0.0402820669, 0.0594526194,
-        0.0804751068, 0.0999041125, 0.113746084, 0.118773937, 0.113746084,
-        0.0999041125, 0.0804751068, 0.0594526194, 0.0402820669, 0.0250313189,
-        0.0142655009, 0.00745626912
-    },
-    {
-        0.0189780835, 0.0558981746, 0.120920904, 0.192116052, 0.224173605,
-        0.192116052, 0.120920904, 0.0558981746, 0.0189780835
-    },
-    {
-        0.054488685, 0.244201347, 0.402619958, 0.244201347, 0.054488685
-    },
-    {
-        0.166378498, 0.667243004, 0.166378498
-    }
-};
-
-typedef struct ThreadData {
-    const float *filter;
-    const float *src;
-    float *dst;
-    int w, h;
-    int src_stride;
-    int dst_stride;
-    int filter_width;
-    float **temp;
-} ThreadData;
-
-static void vif_dec2(const float *src, float *dst, int w, int h,
-                     int src_stride, int dst_stride)
-{
-    const int dst_px_stride = dst_stride / 2;
-
-    for (int i = 0; i < h / 2; i++) {
-        for (int j = 0; j < w / 2; j++)
-            dst[i * dst_px_stride + j] = src[(i * 2) * src_stride + (j * 2)];
-    }
-}
-
-static void vif_statistic(const float *mu1_sq, const float *mu2_sq,
-                          const float *mu1_mu2, const float *xx_filt,
-                          const float *yy_filt, const float *xy_filt,
-                          float *num, float *den, int w, int h)
-{
-    static const float sigma_nsq = 2;
-    float mu1_sq_val, mu2_sq_val, mu1_mu2_val, xx_filt_val, yy_filt_val, xy_filt_val;
-    float sigma1_sq, sigma2_sq, sigma12, g, sv_sq, eps = 1.0e-10f;
-    float gain_limit = 100.f;
-    float num_val, den_val;
-    float accum_num = 0.0f;
-    float accum_den = 0.0f;
-
-    for (int i = 0; i < h; i++) {
-        float accum_inner_num = 0.f;
-        float accum_inner_den = 0.f;
-
-        for (int j = 0; j < w; j++) {
-            mu1_sq_val  = mu1_sq[i * w + j];
-            mu2_sq_val  = mu2_sq[i * w + j];
-            mu1_mu2_val = mu1_mu2[i * w + j];
-            xx_filt_val = xx_filt[i * w + j];
-            yy_filt_val = yy_filt[i * w + j];
-            xy_filt_val = xy_filt[i * w + j];
-
-            sigma1_sq = xx_filt_val - mu1_sq_val;
-            sigma2_sq = yy_filt_val - mu2_sq_val;
-            sigma12   = xy_filt_val - mu1_mu2_val;
-
-            sigma1_sq = FFMAX(sigma1_sq, 0.0f);
-            sigma2_sq = FFMAX(sigma2_sq, 0.0f);
-            sigma12   = FFMAX(sigma12,   0.0f);
-
-            g = sigma12 / (sigma1_sq + eps);
-            sv_sq = sigma2_sq - g * sigma12;
-
-            if (sigma1_sq < eps) {
-                g = 0.0f;
-                sv_sq = sigma2_sq;
-                sigma1_sq = 0.0f;
-            }
-
-            if (sigma2_sq < eps) {
-                g = 0.0f;
-                sv_sq = 0.0f;
-            }
-
-            if (g < 0.0f) {
-                sv_sq = sigma2_sq;
-                g = 0.0f;
-            }
-            sv_sq = FFMAX(sv_sq, eps);
-
-            g = FFMIN(g, gain_limit);
-
-            num_val = log2f(1.0f + g * g * sigma1_sq / (sv_sq + sigma_nsq));
-            den_val = log2f(1.0f + sigma1_sq / sigma_nsq);
-
-            if (isnan(den_val))
-                num_val = den_val = 1.f;
-
-            accum_inner_num += num_val;
-            accum_inner_den += den_val;
-        }
-
-        accum_num += accum_inner_num;
-        accum_den += accum_inner_den;
-    }
-
-    num[0] = accum_num;
-    den[0] = accum_den;
-}
-
-static void vif_xx_yy_xy(const float *x, const float *y, float *xx, float *yy,
-                         float *xy, int w, int h)
-{
-    for (int i = 0; i < h; i++) {
-        for (int j = 0; j < w; j++) {
-            float xval = x[j];
-            float yval = y[j];
-            float xxval = xval * xval;
-            float yyval = yval * yval;
-            float xyval = xval * yval;
-
-            xx[j] = xxval;
-            yy[j] = yyval;
-            xy[j] = xyval;
-        }
-
-        xx += w;
-        yy += w;
-        xy += w;
-        x  += w;
-        y  += w;
-    }
-}
-
-static int vif_filter1d(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    ThreadData *td = arg;
-    const float *filter = td->filter;
-    const float *src = td->src;
-    float *dst = td->dst;
-    int w = td->w;
-    int h = td->h;
-    int src_stride = td->src_stride;
-    int dst_stride = td->dst_stride;
-    int filt_w = td->filter_width;
-    float *temp = td->temp[jobnr];
-    const int slice_start = (h * jobnr) / nb_jobs;
-    const int slice_end = (h * (jobnr+1)) / nb_jobs;
-
-    for (int i = slice_start; i < slice_end; i++) {
-        /** Vertical pass. */
-        for (int j = 0; j < w; j++) {
-            float sum = 0.f;
-
-            if (i >= filt_w / 2 && i < h - filt_w / 2 - 1) {
-                for (int filt_i = 0; filt_i < filt_w; filt_i++) {
-                    const float filt_coeff = filter[filt_i];
-                    float img_coeff;
-                    int ii = i - filt_w / 2 + filt_i;
-
-                    img_coeff = src[ii * src_stride + j];
-                    sum += filt_coeff * img_coeff;
-                }
-            } else {
-                for (int filt_i = 0; filt_i < filt_w; filt_i++) {
-                    const float filt_coeff = filter[filt_i];
-                    int ii = i - filt_w / 2 + filt_i;
-                    float img_coeff;
-
-                    ii = ii < 0 ? -ii : (ii >= h ? 2 * h - ii - 1 : ii);
-
-                    img_coeff = src[ii * src_stride + j];
-                    sum += filt_coeff * img_coeff;
-                }
-            }
-
-            temp[j] = sum;
-        }
-
-        /** Horizontal pass. */
-        for (int j = 0; j < w; j++) {
-            float sum = 0.f;
-
-            if (j >= filt_w / 2 && j < w - filt_w / 2 - 1) {
-                for (int filt_j = 0; filt_j < filt_w; filt_j++) {
-                    const float filt_coeff = filter[filt_j];
-                    int jj = j - filt_w / 2 + filt_j;
-                    float img_coeff;
-
-                    img_coeff = temp[jj];
-                    sum += filt_coeff * img_coeff;
-                }
-            } else {
-                for (int filt_j = 0; filt_j < filt_w; filt_j++) {
-                    const float filt_coeff = filter[filt_j];
-                    int jj = j - filt_w / 2 + filt_j;
-                    float img_coeff;
-
-                    jj = jj < 0 ? -jj : (jj >= w ? 2 * w - jj - 1 : jj);
-
-                    img_coeff = temp[jj];
-                    sum += filt_coeff * img_coeff;
-                }
-            }
-
-            dst[i * dst_stride + j] = sum;
-        }
-    }
-
-    return 0;
-}
-
-int ff_compute_vif2(AVFilterContext *ctx,
-                    const float *ref, const float *main, int w, int h,
-                    int ref_stride, int main_stride, float *score,
-                    float *data_buf[14], float **temp,
-                    int gnb_threads)
-{
-    ThreadData td;
-    float *ref_scale = data_buf[0];
-    float *main_scale = data_buf[1];
-    float *ref_sq = data_buf[2];
-    float *main_sq = data_buf[3];
-    float *ref_main = data_buf[4];
-    float *mu1 = data_buf[5];
-    float *mu2 = data_buf[6];
-    float *mu1_sq = data_buf[7];
-    float *mu2_sq = data_buf[8];
-    float *mu1_mu2 = data_buf[9];
-    float *ref_sq_filt = data_buf[10];
-    float *main_sq_filt = data_buf[11];
-    float *ref_main_filt = data_buf[12];
-
-    float *curr_ref_scale = (float *)ref;
-    float *curr_main_scale = (float *)main;
-    int curr_ref_stride = ref_stride;
-    int curr_main_stride = main_stride;
-
-    float num = 0.f;
-    float den = 0.f;
-
-    for (int scale = 0; scale < 4; scale++) {
-        const float *filter = vif_filter1d_table[scale];
-        int filter_width = vif_filter1d_width1[scale];
-        const int nb_threads = FFMIN(h, gnb_threads);
-        int buf_valid_w = w;
-        int buf_valid_h = h;
-
-        td.filter = filter;
-        td.filter_width = filter_width;
-
-        if (scale > 0) {
-            td.src = curr_ref_scale;
-            td.dst = mu1;
-            td.w = w;
-            td.h = h;
-            td.src_stride = curr_ref_stride;
-            td.dst_stride = w;
-            td.temp = temp;
-            ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-            td.src = curr_main_scale;
-            td.dst = mu2;
-            td.src_stride = curr_main_stride;
-            ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-            vif_dec2(mu1, ref_scale, buf_valid_w, buf_valid_h, w, w);
-            vif_dec2(mu2, main_scale, buf_valid_w, buf_valid_h, w, w);
-
-            w = buf_valid_w / 2;
-            h = buf_valid_h / 2;
-
-            buf_valid_w = w;
-            buf_valid_h = h;
-
-            curr_ref_scale = ref_scale;
-            curr_main_scale = main_scale;
-
-            curr_ref_stride = w;
-            curr_main_stride = w;
-        }
-
-        td.src = curr_ref_scale;
-        td.dst = mu1;
-        td.w = w;
-        td.h = h;
-        td.src_stride = curr_ref_stride;
-        td.dst_stride = w;
-        td.temp = temp;
-        ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-        td.src = curr_main_scale;
-        td.dst = mu2;
-        td.src_stride = curr_main_stride;
-        ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-        vif_xx_yy_xy(mu1, mu2, mu1_sq, mu2_sq, mu1_mu2, w, h);
-
-        vif_xx_yy_xy(curr_ref_scale, curr_main_scale, ref_sq, main_sq, ref_main, w, h);
-
-        td.src = ref_sq;
-        td.dst = ref_sq_filt;
-        td.src_stride = w;
-        ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-        td.src = main_sq;
-        td.dst = main_sq_filt;
-        td.src_stride = w;
-        ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-        td.src = ref_main;
-        td.dst = ref_main_filt;
-        ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
-
-        vif_statistic(mu1_sq, mu2_sq, mu1_mu2, ref_sq_filt, main_sq_filt,
-                      ref_main_filt, &num, &den, w, h);
-
-        score[scale] = den <= FLT_EPSILON ? 1.f : num / den;
-    }
-
-    return 0;
-}
-
-#define offset_fn(type, bits)                            \
-static void offset_##bits##bit(VIFContext *s,            \
-                               const AVFrame *ref,       \
-                               AVFrame *main, int stride)\
-{                                                        \
-    int w = s->width;                                    \
-    int h = s->height;                                   \
-                                                         \
-    int ref_stride = ref->linesize[0];                   \
-    int main_stride = main->linesize[0];                 \
-                                                         \
-    const type *ref_ptr = (const type *) ref->data[0];   \
-    const type *main_ptr = (const type *) main->data[0]; \
-                                            \
-    const float factor = s->factor;         \
-                                            \
-    float *ref_ptr_data = s->ref_data;      \
-    float *main_ptr_data = s->main_data;    \
-                                            \
-    for (int i = 0; i < h; i++) {           \
-        for (int j = 0; j < w; j++) {       \
-            ref_ptr_data[j] = ref_ptr[j] * factor - 128.f;   \
-            main_ptr_data[j] = main_ptr[j] * factor - 128.f; \
-        }                                   \
-        ref_ptr += ref_stride / sizeof(type);   \
-        ref_ptr_data += w;                      \
-        main_ptr += main_stride / sizeof(type); \
-        main_ptr_data += w;                     \
-    } \
-}
-
-offset_fn(uint8_t, 8)
-offset_fn(uint16_t, 16)
-
-static void set_meta(AVDictionary **metadata, const char *key, float d)
-{
-    char value[257];
-    snprintf(value, sizeof(value), "%f", d);
-    av_dict_set(metadata, key, value, 0);
-}
-
-static AVFrame *do_vif(AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
-{
-    VIFContext *s = ctx->priv;
-    AVDictionary **metadata = &main->metadata;
-    float score[4];
-
-    s->factor = 1.f / (1 << (s->desc->comp[0].depth - 8));
-    if (s->desc->comp[0].depth <= 8) {
-        offset_8bit(s, ref, main, s->width);
-    } else {
-        offset_16bit(s, ref, main, s->width);
-    }
-
-    ff_compute_vif2(ctx,
-                    s->ref_data, s->main_data, s->width,
-                    s->height, s->width, s->width,
-                    score, s->data_buf, s->temp,
-                    s->nb_threads);
-
-    set_meta(metadata, "lavfi.vif.scale.0", score[0]);
-    set_meta(metadata, "lavfi.vif.scale.1", score[1]);
-    set_meta(metadata, "lavfi.vif.scale.2", score[2]);
-    set_meta(metadata, "lavfi.vif.scale.3", score[3]);
-
-    for (int i = 0; i < 4; i++) {
-        s->vif_min[i]  = FFMIN(s->vif_min[i], score[i]);
-        s->vif_max[i]  = FFMAX(s->vif_max[i], score[i]);
-        s->vif_sum[i] += score[i];
-    }
-
-    s->nb_frames++;
-
-    return main;
-}
-
-static int query_formats(AVFilterContext *ctx)
-{
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10,
-        AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
-        AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
-#define PF(suf) AV_PIX_FMT_YUV420##suf,  AV_PIX_FMT_YUV422##suf,  AV_PIX_FMT_YUV444##suf
-        PF(P9), PF(P10), PF(P12), PF(P14), PF(P16),
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-    if (!fmts_list)
-        return AVERROR(ENOMEM);
-    return ff_set_common_formats(ctx, fmts_list);
-}
-
-static int config_input_ref(AVFilterLink *inlink)
-{
-    AVFilterContext *ctx  = inlink->dst;
-    VIFContext *s = ctx->priv;
-
-    if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
-        ctx->inputs[0]->h != ctx->inputs[1]->h) {
-        av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
-        return AVERROR(EINVAL);
-    }
-    if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
-        av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
-        return AVERROR(EINVAL);
-    }
-
-    s->desc = av_pix_fmt_desc_get(inlink->format);
-    s->width = ctx->inputs[0]->w;
-    s->height = ctx->inputs[0]->h;
-    s->nb_threads = ff_filter_get_nb_threads(ctx);
-
-    for (int i = 0; i < 4; i++) {
-        s->vif_min[i] =  DBL_MAX;
-        s->vif_max[i] = -DBL_MAX;
-    }
-
-    for (int i = 0; i < 13; i++) {
-        if (!(s->data_buf[i] = av_calloc(s->width, s->height * sizeof(float))))
-            return AVERROR(ENOMEM);
-    }
-
-    if (!(s->ref_data = av_calloc(s->width, s->height * sizeof(float))))
-        return AVERROR(ENOMEM);
-
-    if (!(s->main_data = av_calloc(s->width, s->height * sizeof(float))))
-        return AVERROR(ENOMEM);
-
-    if (!(s->temp = av_calloc(s->nb_threads, sizeof(s->temp[0]))))
-        return AVERROR(ENOMEM);
-
-    for (int i = 0; i < s->nb_threads; i++) {
-        if (!(s->temp[i] = av_calloc(s->width, sizeof(float))))
-            return AVERROR(ENOMEM);
-    }
-
-    return 0;
-}
-
-static int process_frame(FFFrameSync *fs)
-{
-    AVFilterContext *ctx = fs->parent;
-    VIFContext *s = fs->opaque;
-    AVFilterLink *outlink = ctx->outputs[0];
-    AVFrame *out_frame, *main_frame = NULL, *ref_frame = NULL;
-    int ret;
-
-    ret = ff_framesync_dualinput_get(fs, &main_frame, &ref_frame);
-    if (ret < 0)
-        return ret;
-
-    if (ctx->is_disabled || !ref_frame) {
-        out_frame = main_frame;
-    } else {
-        out_frame = do_vif(ctx, main_frame, ref_frame);
-    }
-
-    out_frame->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
-
-    return ff_filter_frame(outlink, out_frame);
-}
-
-
-static int config_output(AVFilterLink *outlink)
-{
-    AVFilterContext *ctx = outlink->src;
-    VIFContext *s = ctx->priv;
-    AVFilterLink *mainlink = ctx->inputs[0];
-    FFFrameSyncIn *in;
-    int ret;
-
-    outlink->w = mainlink->w;
-    outlink->h = mainlink->h;
-    outlink->time_base = mainlink->time_base;
-    outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
-    outlink->frame_rate = mainlink->frame_rate;
-    if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
-        return ret;
-
-    in = s->fs.in;
-    in[0].time_base = mainlink->time_base;
-    in[1].time_base = ctx->inputs[1]->time_base;
-    in[0].sync   = 2;
-    in[0].before = EXT_STOP;
-    in[0].after  = EXT_STOP;
-    in[1].sync   = 1;
-    in[1].before = EXT_STOP;
-    in[1].after  = EXT_STOP;
-    s->fs.opaque   = s;
-    s->fs.on_event = process_frame;
-
-    return ff_framesync_configure(&s->fs);
-}
-
-static int activate(AVFilterContext *ctx)
-{
-    VIFContext *s = ctx->priv;
-    return ff_framesync_activate(&s->fs);
-}
-
-static av_cold void uninit(AVFilterContext *ctx)
-{
-    VIFContext *s = ctx->priv;
-
-    if (s->nb_frames > 0) {
-        for (int i = 0; i < 4; i++)
-            av_log(ctx, AV_LOG_INFO, "VIF scale=%d average:%f min:%f: max:%f\n",
-                   i, s->vif_sum[i] / s->nb_frames, s->vif_min[i], s->vif_max[i]);
-    }
-
-    for (int i = 0; i < 13; i++)
-        av_freep(&s->data_buf[i]);
-
-    av_freep(&s->ref_data);
-    av_freep(&s->main_data);
-
-    for (int i = 0; i < s->nb_threads && s->temp; i++)
-        av_freep(&s->temp[i]);
-
-    av_freep(&s->temp);
-
-    ff_framesync_uninit(&s->fs);
-}
-
-static const AVFilterPad vif_inputs[] = {
-    {
-        .name         = "main",
-        .type         = AVMEDIA_TYPE_VIDEO,
-    },{
-        .name         = "reference",
-        .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_input_ref,
-    },
-    { NULL }
-};
-
-static const AVFilterPad vif_outputs[] = {
-    {
-        .name          = "default",
-        .type          = AVMEDIA_TYPE_VIDEO,
-        .config_props  = config_output,
-    },
-    { NULL }
-};
-
-AVFilter ff_vf_vif = {
-    .name          = "vif",
-    .description   = NULL_IF_CONFIG_SMALL("Calculate the VIF between two video streams."),
-    .uninit        = uninit,
-    .query_formats = query_formats,
-    .priv_size     = sizeof(VIFContext),
-    .priv_class    = &vif_class,
-    .activate      = activate,
-    .inputs        = vif_inputs,
-    .outputs       = vif_outputs,
-    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-};
diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index 1a64b2b..5d64dbd 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -34,8 +34,6 @@
 typedef struct W3FDIFContext {
     const AVClass *class;
     int filter;           ///< 0 is simple, 1 is more complex
-    int mode;             ///< 0 is frame, 1 is field
-    int parity;           ///< frame field parity
     int deint;            ///< which frames to deinterlace
     int linesize[4];      ///< bytes of pixel data per line for each plane
     int planeheight[4];   ///< height of each plane
@@ -51,20 +49,13 @@
 } W3FDIFContext;
 
 #define OFFSET(x) offsetof(W3FDIFContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
 
 static const AVOption w3fdif_options[] = {
     { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" },
     CONST("simple",  NULL, 0, "filter"),
     CONST("complex", NULL, 1, "filter"),
-    { "mode",   "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "mode"},
-    CONST("frame", "send one frame for each frame", 0, "mode"),
-    CONST("field", "send one frame for each field", 1, "mode"),
-    { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, "parity" },
-    CONST("tff",  "assume top field first",     0, "parity"),
-    CONST("bff",  "assume bottom field first",  1, "parity"),
-    CONST("auto", "auto detect parity",        -1, "parity"),
     { "deint",  "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
     CONST("all",        "deinterlace all frames",                       0, "deint"),
     CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
@@ -85,15 +76,11 @@
         AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
         AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
         AV_PIX_FMT_GRAY8,
-        AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
         AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
         AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
-        AV_PIX_FMT_YUV440P10,
         AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
-        AV_PIX_FMT_YUV440P12,
         AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
-        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
-        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
+        AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14,
         AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
         AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
         AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
@@ -359,16 +346,17 @@
 
 typedef struct ThreadData {
     AVFrame *out, *cur, *adj;
+    int plane;
 } ThreadData;
 
-static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg,
-                                   int jobnr, int nb_jobs, int plane)
+static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
     W3FDIFContext *s = ctx->priv;
     ThreadData *td = arg;
     AVFrame *out = td->out;
     AVFrame *cur = td->cur;
     AVFrame *adj = td->adj;
+    const int plane = td->plane;
     const int filter = s->filter;
     uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
     uint8_t *out_line, *out_pixel;
@@ -384,13 +372,10 @@
     const int start = (height * jobnr) / nb_jobs;
     const int end = (height * (jobnr+1)) / nb_jobs;
     const int max = s->max;
-    const int interlaced = cur->interlaced_frame;
-    const int tff = s->field == (s->parity == -1 ? interlaced ? cur->top_field_first : 1 :
-                                 s->parity ^ 1);
     int j, y_in, y_out;
 
     /* copy unchanged the lines of the field */
-    y_out = start + (tff ^ (start & 1));
+    y_out = start + ((s->field == cur->top_field_first) ^ (start & 1));
 
     in_line  = cur_data + (y_out * cur_line_stride);
     out_line = dst_data + (y_out * dst_line_stride);
@@ -403,7 +388,7 @@
     }
 
     /* interpolate other lines of the field */
-    y_out = start + ((!tff) ^ (start & 1));
+    y_out = start + ((s->field != cur->top_field_first) ^ (start & 1));
 
     out_line = dst_data + (y_out * dst_line_stride);
 
@@ -469,23 +454,13 @@
     return 0;
 }
 
-static int deinterlace_slice(AVFilterContext *ctx, void *arg,
-                             int jobnr, int nb_jobs)
-{
-    W3FDIFContext *s = ctx->priv;
-
-    for (int p = 0; p < s->nb_planes; p++)
-        deinterlace_plane_slice(ctx, arg, jobnr, nb_jobs, p);
-
-    return 0;
-}
-
 static int filter(AVFilterContext *ctx, int is_second)
 {
     W3FDIFContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
     AVFrame *out, *adj;
     ThreadData td;
+    int plane;
 
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out)
@@ -509,10 +484,12 @@
 
     adj = s->field ? s->next : s->prev;
     td.out = out; td.cur = s->cur; td.adj = adj;
-    ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[1], s->nb_threads));
+    for (plane = 0; plane < s->nb_planes; plane++) {
+        td.plane = plane;
+        ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
+    }
 
-    if (s->mode)
-        s->field = !s->field;
+    s->field = !s->field;
 
     return ff_filter_frame(outlink, out);
 }
@@ -549,7 +526,7 @@
         return 0;
 
     ret = filter(ctx, 0);
-    if (ret < 0 || s->mode == 0)
+    if (ret < 0)
         return ret;
 
     return filter(ctx, 1);
@@ -625,5 +602,4 @@
     .inputs        = w3fdif_inputs,
     .outputs       = w3fdif_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = ff_filter_process_command,
 };
diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 8191da2..11f8c00 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -303,6 +303,13 @@
     AV_PIX_FMT_NONE
 };
 
+static const enum AVPixelFormat flat_pix_fmts[] = {
+    AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
+    AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
+    AV_PIX_FMT_YUV444P12,
+    AV_PIX_FMT_NONE
+};
+
 static int query_formats(AVFilterContext *ctx)
 {
     WaveformContext *s = ctx->priv;
diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
index 6139844..8d4eb3d 100644
--- a/libavfilter/vf_weave.c
+++ b/libavfilter/vf_weave.c
@@ -54,11 +54,17 @@
     AVFilterFormats *formats = NULL;
     int ret;
 
-    ret = ff_formats_pixdesc_filter(&formats, 0,
-                                    AV_PIX_FMT_FLAG_PAL |
-                                    AV_PIX_FMT_FLAG_HWACCEL);
-    if (ret < 0)
-        return ret;
+    for (int fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+
+        if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) &&
+            !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+            if ((ret = ff_add_format(&formats, fmt)) < 0) {
+                return ret;
+            }
+        }
+    }
+
     return ff_set_common_formats(ctx, formats);
 }
 
@@ -90,51 +96,15 @@
     return 0;
 }
 
-typedef struct ThreadData {
-    AVFrame *in, *out;
-} ThreadData;
-
-static int weave_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
-    AVFilterLink *inlink = ctx->inputs[0];
-    WeaveContext *s = ctx->priv;
-    ThreadData *td = arg;
-    AVFrame *in = td->in;
-    AVFrame *out = td->out;
-
-    const int weave = (s->double_weave && !(inlink->frame_count_out & 1));
-    const int field1 = weave ? s->first_field : (!s->first_field);
-    const int field2 = weave ? (!s->first_field) : s->first_field;
-
-    for (int i = 0; i < s->nb_planes; i++) {
-        const int height = s->planeheight[i];
-        const int start = (height * jobnr) / nb_jobs;
-        const int end = (height * (jobnr+1)) / nb_jobs;
-
-        av_image_copy_plane(out->data[i] + out->linesize[i] * field1 +
-                            out->linesize[i] * start * 2,
-                            out->linesize[i] * 2,
-                            in->data[i] + start * in->linesize[i],
-                            in->linesize[i],
-                            s->linesize[i], end - start);
-        av_image_copy_plane(out->data[i] + out->linesize[i] * field2 +
-                            out->linesize[i] * start * 2,
-                            out->linesize[i] * 2,
-                            s->prev->data[i] + start * s->prev->linesize[i],
-                            s->prev->linesize[i],
-                            s->linesize[i], end - start);
-    }
-
-    return 0;
-}
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     AVFilterContext *ctx = inlink->dst;
     WeaveContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    ThreadData td;
     AVFrame *out;
+    int i;
+    int weave;
+    int field1, field2;
 
     if (!s->prev) {
         s->prev = in;
@@ -149,9 +119,19 @@
     }
     av_frame_copy_props(out, in);
 
-    td.out = out, td.in = in;
-    ctx->internal->execute(ctx, weave_slice, &td, NULL, FFMIN(s->planeheight[1],
-                                                              ff_filter_get_nb_threads(ctx)));
+    weave = (s->double_weave && !(inlink->frame_count_out & 1));
+    field1 = weave ? s->first_field : (!s->first_field);
+    field2 = weave ? (!s->first_field) : s->first_field;
+    for (i = 0; i < s->nb_planes; i++) {
+        av_image_copy_plane(out->data[i] + out->linesize[i] * field1,
+                            out->linesize[i] * 2,
+                            in->data[i], in->linesize[i],
+                            s->linesize[i], s->planeheight[i]);
+        av_image_copy_plane(out->data[i] + out->linesize[i] * field2,
+                            out->linesize[i] * 2,
+                            s->prev->data[i], s->prev->linesize[i],
+                            s->linesize[i], s->planeheight[i]);
+    }
 
     out->pts = s->double_weave ? s->prev->pts : in->pts / 2;
     out->interlaced_frame = 1;
@@ -199,7 +179,6 @@
     .uninit        = uninit,
     .inputs        = weave_inputs,
     .outputs       = weave_outputs,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS,
 };
 
 static av_cold int init(AVFilterContext *ctx)
@@ -225,5 +204,4 @@
     .uninit        = uninit,
     .inputs        = weave_inputs,
     .outputs       = weave_outputs,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index 8b6dd69..15857d6 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -244,20 +244,14 @@
             return ret;
     }
 
-    if (ctx->is_disabled) {
-        out = av_frame_clone(in[0]);
-    } else {
-        out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-    }
+    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out)
         return AVERROR(ENOMEM);
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
-    if (!ctx->is_disabled) {
-        td.in = in;
-        td.out = out;
-        ctx->internal->execute(ctx, s->median_frames, &td, NULL, FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
-    }
+    td.in = in;
+    td.out = out;
+    ctx->internal->execute(ctx, s->median_frames, &td, NULL, FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
 
     return ff_filter_frame(outlink, out);
 }
@@ -322,7 +316,7 @@
         in[i].time_base = inlink->time_base;
         in[i].sync   = 1;
         in[i].before = EXT_STOP;
-        in[i].after  = EXT_INFINITY;
+        in[i].after  = EXT_STOP;
     }
 
     ret = ff_framesync_configure(&s->fs);
@@ -350,32 +344,13 @@
     return ff_framesync_activate(&s->fs);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    XMedianContext *s = ctx->priv;
-    int ret;
-
-    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-    if (ret < 0)
-        return ret;
-
-    if (s->nb_inputs & 1)
-        s->index = s->radius * 2.f * s->percentile;
-    else
-        s->index = av_clip(s->radius * 2.f * s->percentile, 1, s->nb_inputs - 1);
-
-    return 0;
-}
-
 #define OFFSET(x) offsetof(XMedianContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
-#define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption xmedian_options[] = {
     { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3},  3, 255, .flags = FLAGS },
-    { "planes", "set planes to filter", OFFSET(planes),    AV_OPT_TYPE_INT, {.i64=15}, 0,  15, .flags =TFLAGS },
-    { "percentile", "set percentile",   OFFSET(percentile),AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, .flags =TFLAGS },
+    { "planes", "set planes to filter", OFFSET(planes),    AV_OPT_TYPE_INT, {.i64=15}, 0,  15, .flags = FLAGS },
+    { "percentile", "set percentile",   OFFSET(percentile),AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, .flags = FLAGS },
     { NULL },
 };
 
@@ -389,7 +364,7 @@
 };
 
 #if CONFIG_XMEDIAN_FILTER
-FRAMESYNC_DEFINE_CLASS(xmedian, XMedianContext, fs);
+AVFILTER_DEFINE_CLASS(xmedian);
 
 AVFilter ff_vf_xmedian = {
     .name          = "xmedian",
@@ -398,13 +373,10 @@
     .priv_class    = &xmedian_class,
     .query_formats = query_formats,
     .outputs       = outputs,
-    .preinit       = xmedian_framesync_preinit,
     .init          = init,
     .uninit        = uninit,
     .activate      = activate,
-    .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS |
-                     AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-    .process_command = process_command,
+    .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS,
 };
 
 #endif /* CONFIG_XMEDIAN_FILTER */
@@ -450,8 +422,8 @@
 
 static const AVOption tmedian_options[] = {
     { "radius",     "set median filter radius", OFFSET(radius),     AV_OPT_TYPE_INT,   {.i64=1},   1, 127, .flags = FLAGS },
-    { "planes",     "set planes to filter",     OFFSET(planes),     AV_OPT_TYPE_INT,   {.i64=15},  0,  15, .flags =TFLAGS },
-    { "percentile", "set percentile",           OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,   1, .flags =TFLAGS },
+    { "planes",     "set planes to filter",     OFFSET(planes),     AV_OPT_TYPE_INT,   {.i64=15},  0,  15, .flags = FLAGS },
+    { "percentile", "set percentile",           OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0,   1, .flags = FLAGS },
     { NULL },
 };
 
@@ -486,7 +458,6 @@
     .init          = init,
     .uninit        = uninit,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
 };
 
 #endif /* CONFIG_TMEDIAN_FILTER */
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index c18a161..8059061 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -101,8 +101,6 @@
     char *size_str;
     double nominal_peak_luminance;
     int approximate_gamma;
-    double param_a;
-    double param_b;
 
     char *w_expr;               ///< width  expression string
     char *h_expr;               ///< height expression string
@@ -303,7 +301,7 @@
     } else
         outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 
-    av_log(ctx, AV_LOG_TRACE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d\n",
+    av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d\n",
            inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
            inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den,
            outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
@@ -603,8 +601,6 @@
         s->params.resample_filter_uv = s->filter;
         s->params.nominal_peak_luminance = s->nominal_peak_luminance;
         s->params.allow_approximate_gamma = s->approximate_gamma;
-        s->params.filter_param_a = s->params.filter_param_a_uv = s->param_a;
-        s->params.filter_param_b = s->params.filter_param_b_uv = s->param_b;
 
         format_init(&s->src_format, in, desc, s->colorspace_in,
                     s->primaries_in, s->trc_in, s->range_in, s->chromal_in);
@@ -901,9 +897,6 @@
     { "cin",        "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, "chroma" },
     { "npl",       "set nominal peak luminance", OFFSET(nominal_peak_luminance), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, 0, DBL_MAX, FLAGS },
     { "agamma",       "allow approximate gamma", OFFSET(approximate_gamma),      AV_OPT_TYPE_BOOL,   {.i64 = 1},   0, 1,       FLAGS },
-    { "param_a", "parameter A, which is parameter \"b\" for bicubic, "
-                 "and the number of filter taps for lanczos", OFFSET(param_a), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS },
-    { "param_b", "parameter B, which is parameter \"c\" for bicubic", OFFSET(param_b), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS },
     { NULL }
 };
 
diff --git a/libavfilter/vif.h b/libavfilter/vif.h
deleted file mode 100644
index 5b0d86d..0000000
--- a/libavfilter/vif.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2017 Ronald S. Bultje <rsbultje@gmail.com>
- * Copyright (c) 2017 Ashish Pratap Singh <ashk43712@gmail.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVFILTER_VIF_H
-#define AVFILTER_VIF_H
-
-#include "avfilter.h"
-
-int ff_compute_vif2(AVFilterContext *ctx,
-                    const float *ref, const float *main, int w, int h,
-                    int ref_stride, int main_stride, float *score,
-                    float *data_buf[13], float **temp, int nb_threads);
-
-#endif /* AVFILTER_VIF_H */
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index b05ad5b..8955573 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -187,7 +187,7 @@
     for (int y = start; y < end; y++) {
         for (int x = 0; x < width; x++) {
             float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y);
-            dst[x] = lerp_colors(s->color_rgba, s->nb_colors, factor);
+            dst[x] = lerp_colors(s->color_rgba, s->nb_colors, factor);;
         }
 
         dst += linesize;
@@ -210,7 +210,7 @@
     for (int y = start; y < end; y++) {
         for (int x = 0; x < width; x++) {
             float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y);
-            dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, factor);
+            dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, factor);;
         }
 
         dst += linesize;
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 7899c84..cf9fa4b 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -77,8 +77,6 @@
 
     /* only used by rgbtest */
     uint8_t rgba_map[4];
-    int complement;
-    int depth;
 
     /* only used by haldclut */
     int level;
@@ -101,9 +99,6 @@
 
 #define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE
 
-#define NOSIZE_OPTIONS_OFFSET 2
-/* Filters using COMMON_OPTIONS_NOSIZE also use the following options
- * via &options[NOSIZE_OPTIONS_OFFSET]. So don't break it. */
 static const AVOption options[] = {
     COMMON_OPTIONS
     { NULL }
@@ -964,13 +959,7 @@
 
 #if CONFIG_RGBTESTSRC_FILTER
 
-static const AVOption rgbtestsrc_options[] = {
-    COMMON_OPTIONS
-    { "complement", "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
-    { "co",         "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
-    { NULL }
-};
-
+#define rgbtestsrc_options options
 AVFILTER_DEFINE_CLASS(rgbtestsrc);
 
 #define R 0
@@ -978,15 +967,12 @@
 #define B 2
 #define A 3
 
-static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
+static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
                               int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
                               uint8_t rgba_map[4])
 {
-    uint8_t *dst = dstp[0];
-    int dst_linesize = dst_linesizep[0];
     uint32_t v;
     uint8_t *p;
-    uint16_t *p16;
 
     switch (fmt) {
     case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;
@@ -1009,52 +995,9 @@
         p = dst + 4*x + y*dst_linesize;
         AV_WL32(p, v);
         break;
-    case AV_PIX_FMT_GBRP:
-        p = dstp[0] + x + y * dst_linesizep[0];
-        p[0] = g;
-        p = dstp[1] + x + y * dst_linesizep[1];
-        p[0] = b;
-        p = dstp[2] + x + y * dst_linesizep[2];
-        p[0] = r;
-        break;
-    case AV_PIX_FMT_GBRP9:
-    case AV_PIX_FMT_GBRP10:
-    case AV_PIX_FMT_GBRP12:
-    case AV_PIX_FMT_GBRP14:
-    case AV_PIX_FMT_GBRP16:
-        p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]);
-        p16[0] = g;
-        p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]);
-        p16[0] = b;
-        p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]);
-        p16[0] = r;
-        break;
     }
 }
 
-static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame)
-{
-    TestSourceContext *test = ctx->priv;
-    int x, y, w = frame->width, h = frame->height;
-
-    for (y = 0; y < h; y++) {
-         for (x = 0; x < w; x++) {
-             int c = (1 << FFMAX(test->depth, 8))*x/w;
-             int r = 0, g = 0, b = 0;
-
-             if      (6*y < h  ) r = c;
-             else if (6*y < 2*h) g = c, b = c;
-             else if (6*y < 3*h) g = c;
-             else if (6*y < 4*h) r = c, b = c;
-             else if (6*y < 5*h) b = c;
-             else                r = c, g = c;
-
-             rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
-                               ctx->outputs[0]->format, test->rgba_map);
-         }
-     }
-}
-
 static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
 {
     TestSourceContext *test = ctx->priv;
@@ -1062,14 +1005,14 @@
 
     for (y = 0; y < h; y++) {
          for (x = 0; x < w; x++) {
-             int c = (1 << FFMAX(test->depth, 8))*x/w;
+             int c = 256*x/w;
              int r = 0, g = 0, b = 0;
 
              if      (3*y < h  ) r = c;
              else if (3*y < 2*h) g = c;
              else                b = c;
 
-             rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
+             rgbtest_put_pixel(frame->data[0], frame->linesize[0], x, y, r, g, b,
                                ctx->outputs[0]->format, test->rgba_map);
          }
      }
@@ -1080,7 +1023,7 @@
     TestSourceContext *test = ctx->priv;
 
     test->draw_once = 1;
-    test->fill_picture_fn = test->complement ? rgbtest_fill_picture_complement : rgbtest_fill_picture;
+    test->fill_picture_fn = rgbtest_fill_picture;
     return init(ctx);
 }
 
@@ -1092,8 +1035,6 @@
         AV_PIX_FMT_RGB444, AV_PIX_FMT_BGR444,
         AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565,
         AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555,
-        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
-        AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
         AV_PIX_FMT_NONE
     };
 
@@ -1106,9 +1047,7 @@
 static int rgbtest_config_props(AVFilterLink *outlink)
 {
     TestSourceContext *test = outlink->src->priv;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
 
-    test->depth = desc->comp[0].depth;
     ff_fill_rgba_map(test->rgba_map, outlink->format);
     return config_props(outlink);
 }
@@ -1714,7 +1653,11 @@
 
 #if CONFIG_ALLYUV_FILTER
 
-#define allyuv_options &options[NOSIZE_OPTIONS_OFFSET]
+static const AVOption allyuv_options[] = {
+    COMMON_OPTIONS_NOSIZE
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(allyuv);
 
 static void allyuv_fill_picture(AVFilterContext *ctx, AVFrame *frame)
@@ -1791,7 +1734,11 @@
 
 #if CONFIG_ALLRGB_FILTER
 
-#define allrgb_options &options[NOSIZE_OPTIONS_OFFSET]
+static const AVOption allrgb_options[] = {
+    COMMON_OPTIONS_NOSIZE
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(allrgb);
 
 static void allrgb_fill_picture(AVFilterContext *ctx, AVFrame *frame)
diff --git a/libavfilter/x86/vf_atadenoise_init.c b/libavfilter/x86/vf_atadenoise_init.c
index 3f87f3c..1f69b1a 100644
--- a/libavfilter/x86/vf_atadenoise_init.c
+++ b/libavfilter/x86/vf_atadenoise_init.c
@@ -28,24 +28,22 @@
 void ff_atadenoise_filter_row8_sse4(const uint8_t *src, uint8_t *dst,
                                     const uint8_t **srcf,
                                     int w, int mid, int size,
-                                    int thra, int thrb, const float *weights);
+                                    int thra, int thrb);
 
 void ff_atadenoise_filter_row8_serial_sse4(const uint8_t *src, uint8_t *dst,
                                            const uint8_t **srcf,
                                            int w, int mid, int size,
-                                           int thra, int thrb, const float *weights);
+                                           int thra, int thrb);
 
-av_cold void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm, const float *sigma)
+av_cold void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm)
 {
     int cpu_flags = av_get_cpu_flags();
 
-    for (int p = 0; p < 4; p++) {
-        if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL && sigma[p] == INT16_MAX) {
-            dsp->filter_row[p] = ff_atadenoise_filter_row8_sse4;
-        }
+    if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL) {
+        dsp->filter_row = ff_atadenoise_filter_row8_sse4;
+    }
 
-        if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == SERIAL && sigma[p] == INT16_MAX) {
-            dsp->filter_row[p] = ff_atadenoise_filter_row8_serial_sse4;
-        }
+    if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == SERIAL) {
+        dsp->filter_row = ff_atadenoise_filter_row8_serial_sse4;
     }
 }
diff --git a/libavfilter/x86/vf_convolution_init.c b/libavfilter/x86/vf_convolution_init.c
index b78a47d..45df576 100644
--- a/libavfilter/x86/vf_convolution_init.c
+++ b/libavfilter/x86/vf_convolution_init.c
@@ -27,7 +27,7 @@
 void ff_filter_3x3_sse4(uint8_t *dst, int width,
                         float rdiv, float bias, const int *const matrix,
                         const uint8_t *c[], int peak, int radius,
-                        int dstride, int stride, int size);
+                        int dstride, int stride);
 
 av_cold void ff_convolution_init_x86(ConvolutionContext *s)
 {
diff --git a/libavfilter/x86/vf_gblur.asm b/libavfilter/x86/vf_gblur.asm
index 4d84e6d..a25b165 100644
--- a/libavfilter/x86/vf_gblur.asm
+++ b/libavfilter/x86/vf_gblur.asm
@@ -183,49 +183,3 @@
 INIT_XMM avx2
 HORIZ_SLICE
 %endif
-
-%macro POSTSCALE_SLICE 0
-cglobal postscale_slice, 2, 2, 4, ptr, length, postscale, min, max
-    shl lengthd, 2
-    add ptrq, lengthq
-    neg lengthq
-%if ARCH_X86_32
-    VBROADCASTSS m0, postscalem
-    VBROADCASTSS m1, minm
-    VBROADCASTSS m2, maxm
-%elif WIN64
-    SWAP 0, 2
-    SWAP 1, 3
-    VBROADCASTSS m0, xm0
-    VBROADCASTSS m1, xm1
-    VBROADCASTSS m2, maxm
-%else ; UNIX64
-    VBROADCASTSS m0, xm0
-    VBROADCASTSS m1, xm1
-    VBROADCASTSS m2, xm2
-%endif
-
-    .loop:
-%if cpuflag(avx2)
-    mulps         m3, m0, [ptrq + lengthq]
-%else
-    movu          m3, [ptrq + lengthq]
-    mulps         m3, m0
-%endif
-    maxps         m3, m1
-    minps         m3, m2
-    movu   [ptrq+lengthq], m3
-
-    add lengthq, mmsize
-    jl .loop
-
-    RET
-%endmacro
-
-INIT_XMM sse
-POSTSCALE_SLICE
-
-%if HAVE_AVX2_EXTERNAL
-INIT_YMM avx2
-POSTSCALE_SLICE
-%endif
diff --git a/libavfilter/x86/vf_gblur_init.c b/libavfilter/x86/vf_gblur_init.c
index d80fb46..e63e59f 100644
--- a/libavfilter/x86/vf_gblur_init.c
+++ b/libavfilter/x86/vf_gblur_init.c
@@ -27,25 +27,14 @@
 void ff_horiz_slice_sse4(float *ptr, int width, int height, int steps, float nu, float bscale);
 void ff_horiz_slice_avx2(float *ptr, int width, int height, int steps, float nu, float bscale);
 
-void ff_postscale_slice_sse(float *ptr, int length, float postscale, float min, float max);
-void ff_postscale_slice_avx2(float *ptr, int length, float postscale, float min, float max);
-
 av_cold void ff_gblur_init_x86(GBlurContext *s)
 {
+#if ARCH_X86_64
     int cpu_flags = av_get_cpu_flags();
 
-    if (EXTERNAL_SSE(cpu_flags)) {
-        s->postscale_slice = ff_postscale_slice_sse;
-    }
-    if (EXTERNAL_AVX2_FAST(cpu_flags)) {
-        s->postscale_slice = ff_postscale_slice_avx2;
-    }
-#if ARCH_X86_64
-    if (EXTERNAL_SSE4(cpu_flags)) {
+    if (EXTERNAL_SSE4(cpu_flags))
         s->horiz_slice = ff_horiz_slice_sse4;
-    }
-    if (EXTERNAL_AVX2(cpu_flags)) {
+    if (EXTERNAL_AVX2(cpu_flags))
         s->horiz_slice = ff_horiz_slice_avx2;
-    }
 #endif
 }
diff --git a/libavformat/3dostr.c b/libavformat/3dostr.c
index 534f205..2a35d66 100644
--- a/libavformat/3dostr.c
+++ b/libavformat/3dostr.c
@@ -103,7 +103,7 @@
             st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
             st->codecpar->sample_rate = avio_rb32(s->pb);
             st->codecpar->channels    = avio_rb32(s->pb);
-            if (st->codecpar->channels <= 0 || st->codecpar->sample_rate <= 0)
+            if (st->codecpar->channels <= 0)
                 return AVERROR_INVALIDDATA;
             codec                  = avio_rl32(s->pb);
             avio_skip(s->pb, 4);
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index 30f1b05..6a227a0 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -299,7 +299,7 @@
     unsigned int track_number;
     int packet_read = 0;
     unsigned char header[8];
-    int64_t audio_frame_count;
+    int audio_frame_count;
 
     while (!packet_read) {
         if ((ret = avio_read(s->pb, header, 8)) < 0)
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 0504f47..97d8680 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -8,6 +8,7 @@
 OBJS = allformats.o         \
        avio.o               \
        aviobuf.o            \
+       cutils.o             \
        dump.o               \
        format.o             \
        id3v1.o              \
@@ -16,6 +17,7 @@
        mux.o                \
        options.o            \
        os_support.o         \
+       qtpalette.o          \
        protocols.o          \
        riff.o               \
        sdp.o                \
@@ -25,7 +27,7 @@
 OBJS-$(HAVE_LIBC_MSVCRT)                 += file_open.o
 
 # subsystems
-OBJS-$(CONFIG_ISO_MEDIA)                 += isom.o isom_tags.o
+OBJS-$(CONFIG_ISO_MEDIA)                 += isom.o
 OBJS-$(CONFIG_NETWORK)                   += network.o
 OBJS-$(CONFIG_RIFFDEC)                   += riffdec.o
 OBJS-$(CONFIG_RIFFENC)                   += riffenc.o
@@ -81,9 +83,9 @@
 OBJS-$(CONFIG_ADX_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_AEA_DEMUXER)               += aea.o pcm.o
 OBJS-$(CONFIG_AFC_DEMUXER)               += afc.o
-OBJS-$(CONFIG_AIFF_DEMUXER)              += aiffdec.o aiff.o pcm.o \
+OBJS-$(CONFIG_AIFF_DEMUXER)              += aiffdec.o pcm.o isom.o \
                                             mov_chan.o replaygain.o
-OBJS-$(CONFIG_AIFF_MUXER)                += aiffenc.o aiff.o id3v2enc.o
+OBJS-$(CONFIG_AIFF_MUXER)                += aiffenc.o id3v2enc.o
 OBJS-$(CONFIG_AIX_DEMUXER)               += aixdec.o
 OBJS-$(CONFIG_ALP_DEMUXER)               += alp.o
 OBJS-$(CONFIG_ALP_MUXER)                 += alp.o
@@ -118,18 +120,17 @@
 OBJS-$(CONFIG_AST_MUXER)                 += ast.o astenc.o
 OBJS-$(CONFIG_AU_DEMUXER)                += au.o pcm.o
 OBJS-$(CONFIG_AU_MUXER)                  += au.o rawenc.o
-OBJS-$(CONFIG_AVI_DEMUXER)               += avidec.o isom_tags.o
+OBJS-$(CONFIG_AVI_DEMUXER)               += avidec.o
 OBJS-$(CONFIG_AVI_MUXER)                 += avienc.o mpegtsenc.o avlanguage.o rawutils.o
 OBJS-$(CONFIG_AVM2_MUXER)                += swfenc.o swf.o
 OBJS-$(CONFIG_AVR_DEMUXER)               += avr.o pcm.o
-OBJS-$(CONFIG_AVS_DEMUXER)               += avs.o voc_packet.o voc.o
+OBJS-$(CONFIG_AVS_DEMUXER)               += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)              += avs2dec.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)                += rawenc.o
 OBJS-$(CONFIG_AVS3_DEMUXER)              += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)       += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)               += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)              += bink.o
-OBJS-$(CONFIG_BINKA_DEMUXER)             += binka.o
 OBJS-$(CONFIG_BINTEXT_DEMUXER)           += bintext.o sauce.o
 OBJS-$(CONFIG_BIT_DEMUXER)               += bit.o
 OBJS-$(CONFIG_BIT_MUXER)                 += bit.o
@@ -137,7 +138,7 @@
 OBJS-$(CONFIG_BOA_DEMUXER)               += boadec.o
 OBJS-$(CONFIG_BFSTM_DEMUXER)             += brstm.o
 OBJS-$(CONFIG_BRSTM_DEMUXER)             += brstm.o
-OBJS-$(CONFIG_C93_DEMUXER)               += c93.o voc_packet.o voc.o
+OBJS-$(CONFIG_C93_DEMUXER)               += c93.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_CAF_DEMUXER)               += cafdec.o caf.o mov_chan.o mov_esds.o
 OBJS-$(CONFIG_CAF_MUXER)                 += cafenc.o caf.o riff.o
 OBJS-$(CONFIG_CAVSVIDEO_DEMUXER)         += cavsvideodec.o rawdec.o
@@ -237,7 +238,7 @@
 OBJS-$(CONFIG_HEVC_DEMUXER)              += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)                += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)               += hls.o
-OBJS-$(CONFIG_HLS_MUXER)                 += hlsenc.o hlsplaylist.o avc.o
+OBJS-$(CONFIG_HLS_MUXER)                 += hlsenc.o hlsplaylist.o
 OBJS-$(CONFIG_HNM_DEMUXER)               += hnm.o
 OBJS-$(CONFIG_ICO_DEMUXER)               += icodec.o
 OBJS-$(CONFIG_ICO_MUXER)                 += icoenc.o
@@ -277,7 +278,6 @@
 OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_TIFF_PIPE_DEMUXER)    += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)    += img2dec.o img2.o
-OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_INGENIENT_DEMUXER)         += ingenientdec.o rawdec.o
@@ -307,11 +307,11 @@
 OBJS-$(CONFIG_M4V_DEMUXER)               += m4vdec.o rawdec.o
 OBJS-$(CONFIG_M4V_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o matroska.o  \
-                                            flac_picture.o isom_tags.o rmsipr.o \
+                                            rmsipr.o flac_picture.o \
                                             oggparsevorbis.o vorbiscomment.o \
-                                            qtpalette.o replaygain.o
+                                            replaygain.o
 OBJS-$(CONFIG_MATROSKA_MUXER)            += matroskaenc.o matroska.o \
-                                            av1.o avc.o hevc.o isom_tags.o \
+                                            av1.o avc.o hevc.o \
                                             flacenc_header.o avlanguage.o \
                                             vorbiscomment.o wv.o
 OBJS-$(CONFIG_MCA_DEMUXER)               += mca.o
@@ -331,8 +331,7 @@
 OBJS-$(CONFIG_MMF_MUXER)                 += mmf.o rawenc.o
 OBJS-$(CONFIG_MODS_DEMUXER)              += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)            += moflex.o
-OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o mov_chan.o mov_esds.o \
-                                            qtpalette.o replaygain.o
+OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o mov_chan.o mov_esds.o replaygain.o
 OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o av1.o avc.o hevc.o vpcc.o \
                                             movenchint.o mov_chan.o rtp.o \
                                             movenccenc.o rawutils.o
@@ -372,7 +371,7 @@
 OBJS-$(CONFIG_NSP_DEMUXER)               += nspdec.o pcm.o
 OBJS-$(CONFIG_NSV_DEMUXER)               += nsvdec.o
 OBJS-$(CONFIG_NULL_MUXER)                += nullenc.o
-OBJS-$(CONFIG_NUT_DEMUXER)               += nutdec.o nut.o isom_tags.o
+OBJS-$(CONFIG_NUT_DEMUXER)               += nutdec.o nut.o isom.o
 OBJS-$(CONFIG_NUT_MUXER)                 += nutenc.o nut.o
 OBJS-$(CONFIG_NUV_DEMUXER)               += nuv.o
 OBJS-$(CONFIG_AV1_DEMUXER)               += av1dec.o
@@ -502,10 +501,8 @@
 OBJS-$(CONFIG_SEGAFILM_MUXER)            += segafilmenc.o
 OBJS-$(CONFIG_SEGMENT_MUXER)             += segment.o
 OBJS-$(CONFIG_SER_DEMUXER)               += serdec.o
-OBJS-$(CONFIG_SGA_DEMUXER)               += sga.o
 OBJS-$(CONFIG_SHORTEN_DEMUXER)           += shortendec.o rawdec.o
 OBJS-$(CONFIG_SIFF_DEMUXER)              += siff.o
-OBJS-$(CONFIG_SIMBIOSIS_IMX_DEMUXER)     += imx.o
 OBJS-$(CONFIG_SINGLEJPEG_MUXER)          += rawenc.o
 OBJS-$(CONFIG_SLN_DEMUXER)               += pcmdec.o pcm.o
 OBJS-$(CONFIG_SMACKER_DEMUXER)           += smacker.o
@@ -546,7 +543,6 @@
 OBJS-$(CONFIG_TRUEHD_MUXER)              += rawenc.o
 OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o apetag.o img2.o
 OBJS-$(CONFIG_TTA_MUXER)                 += ttaenc.o apetag.o img2.o
-OBJS-$(CONFIG_TTML_MUXER)                += ttmlenc.o
 OBJS-$(CONFIG_TTY_DEMUXER)               += tty.o sauce.o
 OBJS-$(CONFIG_TY_DEMUXER)                += ty.o
 OBJS-$(CONFIG_TXD_DEMUXER)               += txd.o
@@ -573,7 +569,7 @@
 OBJS-$(CONFIG_WAV_MUXER)                 += wavenc.o
 OBJS-$(CONFIG_WC3_DEMUXER)               += wc3movie.o
 OBJS-$(CONFIG_WEBM_MUXER)                += matroskaenc.o matroska.o \
-                                            av1.o avc.o hevc.o isom_tags.o \
+                                            av1.o avc.o hevc.o \
                                             flacenc_header.o avlanguage.o \
                                             wv.o vorbiscomment.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index e88cdb8..63f8176 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -72,8 +72,8 @@
 static int aa_read_header(AVFormatContext *s)
 {
     int i, j, idx, largest_idx = -1;
-    uint32_t toc_size, npairs, header_seed = 0, start;
-    char codec_name[64] = {0};
+    uint32_t nkey, nval, toc_size, npairs, header_seed = 0, start;
+    char key[128], val[128], codec_name[64] = {0};
     uint8_t output[24], dst[8], src[8];
     int64_t largest_size = -1, current_size = -1, chapter_pos;
     struct toc_entry {
@@ -104,9 +104,8 @@
     if (npairs > MAX_DICTIONARY_ENTRIES)
         return AVERROR_INVALIDDATA;
     for (i = 0; i < npairs; i++) {
-        char key[128], val[128];
-        uint32_t nkey, nval;
-
+        memset(val, 0, sizeof(val));
+        memset(key, 0, sizeof(key));
         avio_skip(pb, 1); // unidentified integer
         nkey = avio_rb32(pb); // key string length
         nval = avio_rb32(pb); // value string length
@@ -114,7 +113,7 @@
         avio_get_str(pb, nval, val, sizeof(val));
         if (!strcmp(key, "codec")) {
             av_log(s, AV_LOG_DEBUG, "Codec is <%s>\n", val);
-            av_strlcpy(codec_name, val, sizeof(codec_name));
+            strncpy(codec_name, val, sizeof(codec_name) - 1);
         } else if (!strcmp(key, "HeaderSeed")) {
             av_log(s, AV_LOG_DEBUG, "HeaderSeed is <%s>\n", val);
             header_seed = atoi(val);
@@ -224,8 +223,7 @@
     while ((chapter_pos = avio_tell(pb)) >= 0 && chapter_pos < c->content_end) {
         int chapter_idx = s->nb_chapters;
         uint32_t chapter_size = avio_rb32(pb);
-        if (chapter_size == 0 || avio_feof(pb))
-            break;
+        if (chapter_size == 0) break;
         chapter_pos -= start + CHAPTER_HEADER_SIZE * chapter_idx;
         avio_skip(pb, 4 + chapter_size);
         if (!avpriv_new_chapter(s, chapter_idx, st->time_base,
diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c
index 7d10e80..3db6e9b 100644
--- a/libavformat/aaxdec.c
+++ b/libavformat/aaxdec.c
@@ -232,7 +232,7 @@
         int64_t col_offset;
         int flag, type;
 
-        if (!a->xcolumns[c].name || strcmp(a->xcolumns[c].name, "data"))
+        if (strcmp(a->xcolumns[c].name, "data"))
             continue;
 
         type = a->xcolumns[c].type;
diff --git a/libavformat/ads.c b/libavformat/ads.c
index 544d652..f25141b 100644
--- a/libavformat/ads.c
+++ b/libavformat/ads.c
@@ -34,9 +34,8 @@
 
 static int ads_read_header(AVFormatContext *s)
 {
-    int align, codec;
+    int align, codec, size;
     AVStream *st;
-    int64_t size;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
@@ -63,7 +62,7 @@
     st->codecpar->block_align = st->codecpar->channels * align;
     avio_skip(s->pb, 12);
     size = avio_rl32(s->pb);
-    if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX && size >= 0x40)
+    if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX)
         st->duration = (size - 0x40) / 16 / st->codecpar->channels * 28;
     avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 3595cb3..44ff5a7 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -170,8 +170,7 @@
         return 0;
     if (!par->extradata_size) {
         uint8_t *side_data;
-        buffer_size_t side_data_size;
-        int ret;
+        int side_data_size, ret;
 
         side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
                                             &side_data_size);
diff --git a/libavformat/aiff.c b/libavformat/aiff.c
deleted file mode 100644
index 0f25b43..0000000
--- a/libavformat/aiff.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * AIFF/AIFF-C muxer/demuxer common data
- * Copyright (c) 2006  Patrick Guimond
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stddef.h>
-#include "libavcodec/codec_id.h"
-#include "internal.h"
-
-const AVCodecTag ff_codec_aiff_tags[] = {
-    { AV_CODEC_ID_PCM_S16BE,    MKTAG('N','O','N','E') },
-    { AV_CODEC_ID_PCM_S8,       MKTAG('N','O','N','E') },
-    { AV_CODEC_ID_PCM_U8,       MKTAG('r','a','w',' ') },
-    { AV_CODEC_ID_PCM_S24BE,    MKTAG('N','O','N','E') },
-    { AV_CODEC_ID_PCM_S32BE,    MKTAG('N','O','N','E') },
-    { AV_CODEC_ID_PCM_F32BE,    MKTAG('f','l','3','2') },
-    { AV_CODEC_ID_PCM_F64BE,    MKTAG('f','l','6','4') },
-    { AV_CODEC_ID_PCM_ALAW,     MKTAG('a','l','a','w') },
-    { AV_CODEC_ID_PCM_MULAW,    MKTAG('u','l','a','w') },
-    { AV_CODEC_ID_PCM_S24BE,    MKTAG('i','n','2','4') },
-    { AV_CODEC_ID_PCM_S32BE,    MKTAG('i','n','3','2') },
-    { AV_CODEC_ID_MACE3,        MKTAG('M','A','C','3') },
-    { AV_CODEC_ID_MACE6,        MKTAG('M','A','C','6') },
-    { AV_CODEC_ID_GSM,          MKTAG('G','S','M',' ') },
-    { AV_CODEC_ID_ADPCM_G722,   MKTAG('G','7','2','2') },
-    { AV_CODEC_ID_ADPCM_G726LE, MKTAG('G','7','2','6') },
-    { AV_CODEC_ID_PCM_S16BE,    MKTAG('t','w','o','s') },
-    { AV_CODEC_ID_PCM_S16LE,    MKTAG('s','o','w','t') },
-    { AV_CODEC_ID_ADPCM_IMA_QT, MKTAG('i','m','a','4') },
-    { AV_CODEC_ID_QDMC,         MKTAG('Q','D','M','C') },
-    { AV_CODEC_ID_QDM2,         MKTAG('Q','D','M','2') },
-    { AV_CODEC_ID_QCELP,        MKTAG('Q','c','l','p') },
-    { AV_CODEC_ID_SDX2_DPCM,    MKTAG('S','D','X','2') },
-    { AV_CODEC_ID_ADPCM_IMA_WS, MKTAG('A','D','P','4') },
-    { AV_CODEC_ID_NONE,         0 },
-};
-
-const AVCodecTag *const ff_aiff_codec_tags_list[] = { ff_codec_aiff_tags, NULL };
diff --git a/libavformat/aiff.h b/libavformat/aiff.h
index 7c7c55c..0ed10a2 100644
--- a/libavformat/aiff.h
+++ b/libavformat/aiff.h
@@ -27,9 +27,35 @@
 #ifndef AVFORMAT_AIFF_H
 #define AVFORMAT_AIFF_H
 
+#include "avformat.h"
 #include "internal.h"
 
-extern const AVCodecTag ff_codec_aiff_tags[];
-extern const AVCodecTag *const ff_aiff_codec_tags_list[];
+static const AVCodecTag ff_codec_aiff_tags[] = {
+    { AV_CODEC_ID_PCM_S16BE,    MKTAG('N','O','N','E') },
+    { AV_CODEC_ID_PCM_S8,       MKTAG('N','O','N','E') },
+    { AV_CODEC_ID_PCM_U8,       MKTAG('r','a','w',' ') },
+    { AV_CODEC_ID_PCM_S24BE,    MKTAG('N','O','N','E') },
+    { AV_CODEC_ID_PCM_S32BE,    MKTAG('N','O','N','E') },
+    { AV_CODEC_ID_PCM_F32BE,    MKTAG('f','l','3','2') },
+    { AV_CODEC_ID_PCM_F64BE,    MKTAG('f','l','6','4') },
+    { AV_CODEC_ID_PCM_ALAW,     MKTAG('a','l','a','w') },
+    { AV_CODEC_ID_PCM_MULAW,    MKTAG('u','l','a','w') },
+    { AV_CODEC_ID_PCM_S24BE,    MKTAG('i','n','2','4') },
+    { AV_CODEC_ID_PCM_S32BE,    MKTAG('i','n','3','2') },
+    { AV_CODEC_ID_MACE3,        MKTAG('M','A','C','3') },
+    { AV_CODEC_ID_MACE6,        MKTAG('M','A','C','6') },
+    { AV_CODEC_ID_GSM,          MKTAG('G','S','M',' ') },
+    { AV_CODEC_ID_ADPCM_G722,   MKTAG('G','7','2','2') },
+    { AV_CODEC_ID_ADPCM_G726LE, MKTAG('G','7','2','6') },
+    { AV_CODEC_ID_PCM_S16BE,    MKTAG('t','w','o','s') },
+    { AV_CODEC_ID_PCM_S16LE,    MKTAG('s','o','w','t') },
+    { AV_CODEC_ID_ADPCM_IMA_QT, MKTAG('i','m','a','4') },
+    { AV_CODEC_ID_QDMC,         MKTAG('Q','D','M','C') },
+    { AV_CODEC_ID_QDM2,         MKTAG('Q','D','M','2') },
+    { AV_CODEC_ID_QCELP,        MKTAG('Q','c','l','p') },
+    { AV_CODEC_ID_SDX2_DPCM,    MKTAG('S','D','X','2') },
+    { AV_CODEC_ID_ADPCM_IMA_WS, MKTAG('A','D','P','4') },
+    { AV_CODEC_ID_NONE,         0 },
+};
 
 #endif /* AVFORMAT_AIFF_H */
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index dcaf156..1573347 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -20,11 +20,13 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mathematics.h"
 #include "libavutil/dict.h"
 #include "avformat.h"
 #include "internal.h"
 #include "pcm.h"
 #include "aiff.h"
+#include "isom.h"
 #include "id3v2.h"
 #include "mov_chan.h"
 #include "replaygain.h"
@@ -118,8 +120,6 @@
     else
         sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
     par->sample_rate = sample_rate;
-    if (size < 18)
-        return AVERROR_INVALIDDATA;
     size -= 18;
 
     /* get codec id for AIFF-C */
@@ -286,8 +286,6 @@
             get_meta(s, "comment"  , size);
             break;
         case MKTAG('S', 'S', 'N', 'D'):     /* Sampled sound chunk */
-            if (size < 8)
-                return AVERROR_INVALIDDATA;
             aiff->data_end = avio_tell(pb) + size;
             offset = avio_rb32(pb);      /* Offset of sound data */
             avio_rb32(pb);               /* BlockSize... don't care */
@@ -432,5 +430,5 @@
     .read_header    = aiff_read_header,
     .read_packet    = aiff_read_packet,
     .read_seek      = ff_pcm_read_seek,
-    .codec_tag      = ff_aiff_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ ff_codec_aiff_tags, 0 },
 };
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 53a2f97..c4ffe9f 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -305,6 +305,6 @@
     .write_packet      = aiff_write_packet,
     .write_trailer     = aiff_write_trailer,
     .deinit            = aiff_deinit,
-    .codec_tag         = ff_aiff_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ ff_codec_aiff_tags, 0 },
     .priv_class        = &aiff_muxer_class,
 };
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index a38fd1f..0e0caaa 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -94,7 +94,6 @@
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
 extern AVInputFormat  ff_bink_demuxer;
-extern AVInputFormat  ff_binka_demuxer;
 extern AVInputFormat  ff_bit_demuxer;
 extern AVOutputFormat ff_bit_muxer;
 extern AVInputFormat  ff_bmv_demuxer;
@@ -401,10 +400,8 @@
 extern AVOutputFormat ff_segment_muxer;
 extern AVOutputFormat ff_stream_segment_muxer;
 extern AVInputFormat  ff_ser_demuxer;
-extern AVInputFormat  ff_sga_demuxer;
 extern AVInputFormat  ff_shorten_demuxer;
 extern AVInputFormat  ff_siff_demuxer;
-extern AVInputFormat  ff_simbiosis_imx_demuxer;
 extern AVOutputFormat ff_singlejpeg_muxer;
 extern AVInputFormat  ff_sln_demuxer;
 extern AVInputFormat  ff_smacker_demuxer;
@@ -445,7 +442,6 @@
 extern AVOutputFormat ff_truehd_muxer;
 extern AVInputFormat  ff_tta_demuxer;
 extern AVOutputFormat ff_tta_muxer;
-extern AVOutputFormat ff_ttml_muxer;
 extern AVInputFormat  ff_txd_demuxer;
 extern AVInputFormat  ff_tty_demuxer;
 extern AVInputFormat  ff_ty_demuxer;
@@ -521,7 +517,6 @@
 extern AVInputFormat  ff_image_sunrast_pipe_demuxer;
 extern AVInputFormat  ff_image_tiff_pipe_demuxer;
 extern AVInputFormat  ff_image_webp_pipe_demuxer;
-extern AVInputFormat  ff_image_xbm_pipe_demuxer;
 extern AVInputFormat  ff_image_xpm_pipe_demuxer;
 extern AVInputFormat  ff_image_xwd_pipe_demuxer;
 
@@ -546,7 +541,7 @@
 
     if (i < size) {
         f = muxer_list[i];
-    } else if (outdev_list) {
+    } else if (indev_list) {
         f = outdev_list[i - size];
     }
 
@@ -563,7 +558,7 @@
 
     if (i < size) {
         f = demuxer_list[i];
-    } else if (indev_list) {
+    } else if (outdev_list) {
         f = indev_list[i - size];
     }
 
diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index 7e86f45..7ad6a92 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -119,7 +119,7 @@
     AVIOContext *io_context = format_context->pb;
     AVStream *codec_stream = format_context->streams[0];
     uint8_t *side_data = NULL;
-    buffer_size_t side_data_size;
+    int side_data_size;
 
     av_assert0(apng->prev_packet);
 
diff --git a/libavformat/asf.c b/libavformat/asf.c
index f1f171e..719cae9 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -40,6 +40,12 @@
     0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
 };
 
+const ff_asf_guid ff_asf_audio_conceal_none = {
+    // 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
+    // New value lifted from avifile
+    0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
+};
+
 const ff_asf_guid ff_asf_audio_conceal_spread = {
     0x50, 0xCD, 0xC3, 0xBF, 0x8F, 0x61, 0xCF, 0x11, 0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20
 };
diff --git a/libavformat/asf.h b/libavformat/asf.h
index bce820e..a30d3bb 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -74,6 +74,7 @@
 extern const ff_asf_guid ff_asf_stream_header;
 extern const ff_asf_guid ff_asf_ext_stream_header;
 extern const ff_asf_guid ff_asf_audio_stream;
+extern const ff_asf_guid ff_asf_audio_conceal_none;
 extern const ff_asf_guid ff_asf_audio_conceal_spread;
 extern const ff_asf_guid ff_asf_video_stream;
 extern const ff_asf_guid ff_asf_jfif_media;
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 1484b54..8e48e45 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -143,12 +143,6 @@
     0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
 };
 
-static const ff_asf_guid asf_audio_conceal_none = {
-    // 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
-    // New value lifted from avifile
-    0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
-};
-
 #define PRINT_IF_GUID(g, cmp) \
     if (!ff_guidcmp(g, &cmp)) \
         av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp)
@@ -160,7 +154,7 @@
     else PRINT_IF_GUID(g, ff_asf_file_header);
     else PRINT_IF_GUID(g, ff_asf_stream_header);
     else PRINT_IF_GUID(g, ff_asf_audio_stream);
-    else PRINT_IF_GUID(g, asf_audio_conceal_none);
+    else PRINT_IF_GUID(g, ff_asf_audio_conceal_none);
     else PRINT_IF_GUID(g, ff_asf_video_stream);
     else PRINT_IF_GUID(g, ff_asf_video_conceal_none);
     else PRINT_IF_GUID(g, ff_asf_command_stream);
@@ -522,8 +516,6 @@
         tag1                             = avio_rl32(pb);
         avio_skip(pb, 20);
         if (sizeX > 40) {
-            if (size < sizeX - 40)
-                return AVERROR_INVALIDDATA;
             st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
             st->codecpar->extradata      = av_mallocz(st->codecpar->extradata_size +
                                                    AV_INPUT_BUFFER_PADDING_SIZE);
diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index c1d9036..655ba9f 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -245,9 +245,6 @@
         avio_skip(pb, 4); // flags
         len = avio_rl32(pb);
 
-        if (avio_feof(pb))
-            return AVERROR_INVALIDDATA;
-
         if ((ret = avio_get_str16le(pb, len, name,
                                     sizeof(name))) < len)
             avio_skip(pb, len - ret);
@@ -854,8 +851,6 @@
     st_num     = avio_rl16(pb);
     st_num    &= ASF_STREAM_NUM;
     lang_idx   = avio_rl16(pb); // Stream Language ID Index
-    if (lang_idx >= ASF_MAX_STREAMS)
-        return AVERROR_INVALIDDATA;
     for (i = 0; i < asf->nb_streams; i++) {
         if (st_num == asf->asf_st[i]->stream_index) {
             st                       = s->streams[asf->asf_st[i]->index];
@@ -1666,9 +1661,6 @@
     ff_asf_guid guid;
     int ret;
 
-    if (offset > INT64_MAX - size)
-        return AVERROR_INVALIDDATA;
-
     while (avio_tell(pb) <= offset + size) {
         if (avio_tell(pb) == asf->offset)
             break;
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 23a09ef..8b24264 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -258,10 +258,6 @@
     { AV_CODEC_ID_NONE,      0 },
 };
 
-static const AVCodecTag *const asf_codec_tags[] = {
-        codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, NULL
-};
-
 #define PREROLL_TIME 3100
 
 static void put_str16(AVIOContext *s, const char *tag)
@@ -1174,7 +1170,9 @@
     .write_packet   = asf_write_packet,
     .write_trailer  = asf_write_trailer,
     .flags          = AVFMT_GLOBALHEADER,
-    .codec_tag      = asf_codec_tags,
+    .codec_tag      = (const AVCodecTag * const []) {
+        codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0
+    },
     .priv_class        = &asf_muxer_class,
 };
 #endif /* CONFIG_ASF_MUXER */
@@ -1199,7 +1197,9 @@
     .write_packet   = asf_write_packet,
     .write_trailer  = asf_write_trailer,
     .flags          = AVFMT_GLOBALHEADER,
-    .codec_tag      = asf_codec_tags,
+    .codec_tag      = (const AVCodecTag * const []) {
+        codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0
+    },
     .priv_class        = &asf_stream_muxer_class,
 };
 #endif /* CONFIG_ASF_STREAM_MUXER */
diff --git a/libavformat/ast.c b/libavformat/ast.c
index 856d36f..9de74aa 100644
--- a/libavformat/ast.c
+++ b/libavformat/ast.c
@@ -19,8 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stddef.h>
-#include "libavcodec/codec_id.h"
+#include "avformat.h"
 #include "internal.h"
 
 const AVCodecTag ff_codec_ast_tags[] = {
@@ -28,5 +27,3 @@
     { AV_CODEC_ID_PCM_S16BE_PLANAR,   1 },
     { AV_CODEC_ID_NONE,               0 },
 };
-
-const AVCodecTag *const ff_ast_codec_tags_list[] = { ff_codec_ast_tags, NULL };
diff --git a/libavformat/ast.h b/libavformat/ast.h
index b629f7e..4a399ea 100644
--- a/libavformat/ast.h
+++ b/libavformat/ast.h
@@ -26,6 +26,5 @@
 #include "internal.h"
 
 extern const AVCodecTag ff_codec_ast_tags[];
-extern const AVCodecTag *const ff_ast_codec_tags_list[];
 
 #endif /* AVFORMAT_AST_H */
diff --git a/libavformat/astdec.c b/libavformat/astdec.c
index 610c938..9d2174f 100644
--- a/libavformat/astdec.c
+++ b/libavformat/astdec.c
@@ -118,5 +118,5 @@
     .read_packet    = ast_read_packet,
     .extensions     = "ast",
     .flags          = AVFMT_GENERIC_INDEX,
-    .codec_tag      = ff_ast_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ff_codec_ast_tags, 0},
 };
diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index 69541bc..e0b94b8 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -207,5 +207,5 @@
     .write_packet      = ast_write_packet,
     .write_trailer     = ast_write_trailer,
     .priv_class        = &ast_muxer_class,
-    .codec_tag         = ff_ast_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ff_codec_ast_tags, 0},
 };
diff --git a/libavformat/async.c b/libavformat/async.c
index 5a81507..a0bdfa2 100644
--- a/libavformat/async.c
+++ b/libavformat/async.c
@@ -262,28 +262,24 @@
 
     ret = pthread_mutex_init(&c->mutex, NULL);
     if (ret != 0) {
-        ret = AVERROR(ret);
         av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", av_err2str(ret));
         goto mutex_fail;
     }
 
     ret = pthread_cond_init(&c->cond_wakeup_main, NULL);
     if (ret != 0) {
-        ret = AVERROR(ret);
         av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", av_err2str(ret));
         goto cond_wakeup_main_fail;
     }
 
     ret = pthread_cond_init(&c->cond_wakeup_background, NULL);
     if (ret != 0) {
-        ret = AVERROR(ret);
         av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", av_err2str(ret));
         goto cond_wakeup_background_fail;
     }
 
     ret = pthread_create(&c->async_buffer_thread, NULL, async_buffer_task, h);
     if (ret) {
-        ret = AVERROR(ret);
         av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", av_err2str(ret));
         goto thread_fail;
     }
@@ -612,8 +608,7 @@
     /*
      * test normal read
      */
-    ret = ffurl_open_whitelist(&h, "async:async-test:", AVIO_FLAG_READ,
-                               NULL, NULL, NULL, NULL, NULL);
+    ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, NULL);
     printf("open: %d\n", ret);
 
     size = ffurl_size(h);
@@ -689,8 +684,7 @@
      */
     ffurl_close(h);
     av_dict_set_int(&opts, "async-test-read-error", -10000, 0);
-    ret = ffurl_open_whitelist(&h, "async:async-test:", AVIO_FLAG_READ,
-                               NULL, &opts, NULL, NULL, NULL);
+    ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, &opts);
     printf("open: %d\n", ret);
 
     ret = ffurl_read(h, buf, 1);
diff --git a/libavformat/au.c b/libavformat/au.c
index c2c1b7a..4f2b811 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -53,8 +53,6 @@
     { AV_CODEC_ID_NONE,       0 },
 };
 
-static const AVCodecTag *const au_codec_tags[] = { codec_au_tags, NULL };
-
 #if CONFIG_AU_DEMUXER
 
 static int au_probe(const AVProbeData *p)
@@ -233,7 +231,7 @@
     .read_header = au_read_header,
     .read_packet = ff_pcm_read_packet,
     .read_seek   = ff_pcm_read_seek,
-    .codec_tag   = au_codec_tags,
+    .codec_tag   = (const AVCodecTag* const []) { codec_au_tags, 0 },
 };
 
 #endif /* CONFIG_AU_DEMUXER */
@@ -339,7 +337,7 @@
     .write_header  = au_write_header,
     .write_packet  = ff_raw_write_packet,
     .write_trailer = au_write_trailer,
-    .codec_tag     = au_codec_tags,
+    .codec_tag     = (const AVCodecTag* const []) { codec_au_tags, 0 },
     .flags         = AVFMT_NOTIMESTAMPS,
 };
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e3bd01e..4865c56 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -590,7 +590,6 @@
      * @see avdevice_list_devices() for more details.
      */
     int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
-#if LIBAVFORMAT_VERSION_MAJOR < 59
     /**
      * Initialize device capabilities submodule.
      * @see avdevice_capabilities_create() for more details.
@@ -601,7 +600,6 @@
      * @see avdevice_capabilities_free() for more details.
      */
     int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
-#endif
     enum AVCodecID data_codec; /**< default data codec */
     /**
      * Initialize format. May allocate data here, and set any AVFormatContext or
@@ -771,7 +769,6 @@
      */
     int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
 
-#if LIBAVFORMAT_VERSION_MAJOR < 59
     /**
      * Initialize device capabilities submodule.
      * @see avdevice_capabilities_create() for more details.
@@ -783,7 +780,6 @@
      * @see avdevice_capabilities_free() for more details.
      */
     int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
-#endif
 } AVInputFormat;
 /**
  * @}
@@ -1100,12 +1096,12 @@
      */
     int stream_identifier;
 
-#if LIBAVFORMAT_VERSION_MAJOR < 59
-    // kept for ABI compatibility only, do not access in any way
-    int unused8;
-    int unused9;
-    int unused10;
-#endif
+    /**
+     * Details of the MPEG-TS program which created this stream.
+     */
+    int program_num;
+    int pmt_version;
+    int pmt_stream_idx;
 
     /**
      * An opaque field for libavformat internal usage.
@@ -1379,9 +1375,7 @@
 #define AVFMT_FLAG_MP4A_LATM    0x8000 ///< Deprecated, does nothing.
 #endif
 #define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
-#if FF_API_LAVF_PRIV_OPT
-#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (deprecated, will do nothing once av_demuxer_open() is removed)
-#endif
+#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
 #if FF_API_LAVF_KEEPSIDE_FLAG
 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Deprecated, does nothing.
 #endif
@@ -2083,11 +2077,7 @@
  * @return pointer to fresh allocated data or NULL otherwise
  */
 uint8_t *av_stream_new_side_data(AVStream *stream,
-#if FF_API_BUFFER_SIZE_T
                                  enum AVPacketSideDataType type, int size);
-#else
-                                 enum AVPacketSideDataType type, size_t size);
-#endif
 /**
  * Get side information from stream.
  *
@@ -2098,11 +2088,7 @@
  * @return pointer to data if present or NULL otherwise
  */
 uint8_t *av_stream_get_side_data(const AVStream *stream,
-#if FF_API_BUFFER_SIZE_T
                                  enum AVPacketSideDataType type, int *size);
-#else
-                                 enum AVPacketSideDataType type, size_t *size);
-#endif
 
 AVProgram *av_new_program(AVFormatContext *s, int id);
 
@@ -2220,13 +2206,8 @@
  */
 int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options);
 
-#if FF_API_DEMUXER_OPEN
-/**
- * @deprecated Use an AVDictionary to pass options to a demuxer.
- */
 attribute_deprecated
 int av_demuxer_open(AVFormatContext *ic);
-#endif
 
 /**
  * Read packets of a media file to get stream information. This
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 5ea6160..7e527e1 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -135,7 +135,7 @@
     if (ast->sample_size)
         return len;
     else if (ast->dshow_block_align)
-        return (len + (int64_t)ast->dshow_block_align - 1) / ast->dshow_block_align;
+        return (len + ast->dshow_block_align - 1) / ast->dshow_block_align;
     else
         return 1;
 }
@@ -838,12 +838,6 @@
                         st->codecpar->codec_tag == MKTAG('H', '2', '6', '5'))
                         st->need_parsing = AVSTREAM_PARSE_FULL;
 
-                    if (st->codecpar->codec_id  == AV_CODEC_ID_AVRN &&
-                        st->codecpar->codec_tag == MKTAG('A', 'V', 'R', 'n') &&
-                        (st->codecpar->extradata_size < 31 ||
-                          memcmp(&st->codecpar->extradata[28], "1:1", 3)))
-                        st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
-
                     if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
                         st->codecpar->extradata_size < 1U << 30) {
                         st->codecpar->extradata_size += 9;
@@ -1452,7 +1446,6 @@
     if (avi->stream_index >= 0) {
         AVStream *st   = s->streams[avi->stream_index];
         AVIStream *ast = st->priv_data;
-        int dv_demux = CONFIG_DV_DEMUXER && avi->dv_demux;
         int size, err;
 
         if (get_subtitle_pkt(s, st, pkt))
@@ -1475,7 +1468,7 @@
             return err;
         size = err;
 
-        if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2 && !dv_demux) {
+        if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2) {
             uint8_t *pal;
             pal = av_packet_new_side_data(pkt,
                                           AV_PKT_DATA_PALETTE,
@@ -1489,7 +1482,7 @@
             }
         }
 
-        if (CONFIG_DV_DEMUXER && dv_demux) {
+        if (CONFIG_DV_DEMUXER && avi->dv_demux) {
             AVBufferRef *avbuf = pkt->buf;
             size = avpriv_dv_produce_packet(avi->dv_demux, pkt,
                                             pkt->data, pkt->size, pkt->pos);
@@ -1698,19 +1691,18 @@
             AVIStream *ast = st->priv_data;
 
             if (idx[i] && min_dts != INT64_MAX / 2) {
-                int64_t dts, delta_dts;
+                int64_t dts;
                 dts = av_rescale_q(st->internal->index_entries[idx[i] - 1].timestamp /
                                    FFMAX(ast->sample_size, 1),
                                    st->time_base, AV_TIME_BASE_Q);
-                delta_dts = av_sat_sub64(dts, min_dts);
                 max_dts = FFMAX(max_dts, dts);
                 max_buffer = FFMAX(max_buffer,
-                                   av_rescale(delta_dts,
+                                   av_rescale(dts - min_dts,
                                               st->codecpar->bit_rate,
                                               AV_TIME_BASE));
             }
         }
-        if (av_sat_sub64(max_dts, min_dts) > 2 * AV_TIME_BASE ||
+        if (max_dts - min_dts > 2 * AV_TIME_BASE ||
             max_buffer > 1024 * 1024 * 8 * 8) {
             av_free(idx);
             return 1;
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9cbf3d3..1b2cb52 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -1018,6 +1018,8 @@
     .write_header   = avi_write_header,
     .write_packet   = avi_write_packet,
     .write_trailer  = avi_write_trailer,
-    .codec_tag      = ff_riff_codec_tags_list,
+    .codec_tag      = (const AVCodecTag * const []) {
+        ff_codec_bmp_tags, ff_codec_wav_tags, 0
+    },
     .priv_class     = &avi_muxer_class,
 };
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 8011482..3886ed7 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -114,10 +114,11 @@
             goto fail;
         }
         if (up->priv_data_class) {
-            char *start;
+            int proto_len= strlen(up->name);
+            char *start = strchr(uc->filename, ',');
             *(const AVClass **)uc->priv_data = up->priv_data_class;
             av_opt_set_defaults(uc->priv_data);
-            if (av_strstart(uc->filename, up->name, (const char**)&start) && *start == ',') {
+            if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){
                 int ret= 0;
                 char *p= start;
                 char sep= *++p;
@@ -353,6 +354,13 @@
     return ret;
 }
 
+int ffurl_open(URLContext **puc, const char *filename, int flags,
+               const AVIOInterruptCB *int_cb, AVDictionary **options)
+{
+    return ffurl_open_whitelist(puc, filename, flags,
+                                int_cb, options, NULL, NULL, NULL);
+}
+
 static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
                                          int size, int size_min,
                                          int (*transfer_func)(URLContext *h,
diff --git a/libavformat/avlanguage.c b/libavformat/avlanguage.c
index c36893c..f5d2ddf 100644
--- a/libavformat/avlanguage.c
+++ b/libavformat/avlanguage.c
@@ -763,3 +763,10 @@
 
     return NULL;
 }
+
+#if LIBAVFORMAT_VERSION_MAJOR < 58
+const char *av_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
+{
+    return ff_convert_lang_to(lang, target_codespace);
+}
+#endif
diff --git a/libavformat/avlanguage.h b/libavformat/avlanguage.h
index 1901e78..1d72dcb 100644
--- a/libavformat/avlanguage.h
+++ b/libavformat/avlanguage.h
@@ -21,6 +21,9 @@
 #ifndef AVFORMAT_AVLANGUAGE_H
 #define AVFORMAT_AVLANGUAGE_H
 
+#include "libavutil/attributes.h"
+#include "libavformat/version.h"
+
 /**
  * Known language codespaces
  */
@@ -35,5 +38,9 @@
  * @return NULL if the provided lang is null or invalid.
  */
 const char *ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace);
+#if LIBAVFORMAT_VERSION_MAJOR < 58
+attribute_deprecated
+const char *av_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace);
+#endif
 
 #endif /* AVFORMAT_AVLANGUAGE_H */
diff --git a/libavformat/bfi.c b/libavformat/bfi.c
index 2dab986..29e2cf8 100644
--- a/libavformat/bfi.c
+++ b/libavformat/bfi.c
@@ -69,9 +69,6 @@
     /* Set the total number of frames. */
     avio_skip(pb, 8);
     chunk_header           = avio_rl32(pb);
-    if (chunk_header < 3)
-        return AVERROR_INVALIDDATA;
-
     bfi->nframes           = avio_rl32(pb);
     avio_rl32(pb);
     avio_rl32(pb);
diff --git a/libavformat/binka.c b/libavformat/binka.c
deleted file mode 100644
index 13ca9ca..0000000
--- a/libavformat/binka.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/intreadwrite.h"
-#include "avformat.h"
-#include "internal.h"
-
-static int binka_probe(const AVProbeData *p)
-{
-    if (AV_RB32(p->buf) == MKBETAG('1', 'F', 'C', 'B') &&
-        (p->buf[4] == 1 || p->buf[4] == 2))
-        return AVPROBE_SCORE_MAX;
-    return 0;
-}
-
-static int binka_read_header(AVFormatContext *s)
-{
-    AVIOContext *pb = s->pb;
-    AVStream *st;
-    int entries, offset;
-
-    st = avformat_new_stream(s, NULL);
-    if (!st)
-        return AVERROR(ENOMEM);
-
-    avio_skip(pb, 5);
-
-    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codecpar->codec_id = AV_CODEC_ID_BINKAUDIO_DCT;
-    st->codecpar->channels = avio_r8(pb);
-    st->codecpar->sample_rate = avio_rl16(pb);
-    st->duration = avio_rl32(pb);
-
-    avio_skip(pb, 8);
-    entries = avio_rl16(pb);
-
-    offset = entries * 2 + 2;
-    avio_skip(pb, offset);
-
-    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
-
-    return 0;
-}
-
-static int binka_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    AVIOContext *pb = s->pb;
-    AVStream *st = s->streams[0];
-    int64_t pos;
-    int pkt_size;
-    int ret;
-
-    if (avio_feof(pb))
-        return AVERROR_EOF;
-
-    pos = avio_tell(pb);
-    avio_skip(pb, 2);
-    pkt_size = avio_rl16(pb) + 4;
-    if (pkt_size <= 4)
-        return AVERROR(EIO);
-    ret = av_new_packet(pkt, pkt_size);
-    if (ret < 0)
-        return ret;
-
-    avio_read(pb, pkt->data + 4, pkt_size - 4);
-    AV_WL32(pkt->data, pkt_size);
-
-    pkt->pos = pos;
-    pkt->stream_index = 0;
-    pkt->duration = av_get_audio_frame_duration2(st->codecpar, 0);
-
-    return 0;
-}
-
-AVInputFormat ff_binka_demuxer = {
-    .name           = "binka",
-    .long_name      = NULL_IF_CONFIG_SMALL("Bink Audio"),
-    .read_probe     = binka_probe,
-    .read_header    = binka_read_header,
-    .read_packet    = binka_read_packet,
-    .flags          = AVFMT_GENERIC_INDEX,
-    .extensions     = "binka",
-};
diff --git a/libavformat/caf.c b/libavformat/caf.c
index a700e40..fe242ff 100644
--- a/libavformat/caf.c
+++ b/libavformat/caf.c
@@ -78,4 +78,3 @@
     { AV_CODEC_ID_NONE,            0 },
 };
 
-const AVCodecTag *const ff_caf_codec_tags_list[] = { ff_codec_caf_tags, NULL };
diff --git a/libavformat/caf.h b/libavformat/caf.h
index ed0392b..9c25f2c 100644
--- a/libavformat/caf.h
+++ b/libavformat/caf.h
@@ -30,6 +30,5 @@
 #include "internal.h"
 
 extern const AVCodecTag ff_codec_caf_tags[];
-extern const AVCodecTag *const ff_caf_codec_tags_list[];
 
 #endif /* AVFORMAT_CAF_H */
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index d56187f..c188aad 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -70,7 +70,7 @@
 
     /* parse format description */
     st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codecpar->sample_rate = av_clipd(av_int2double(avio_rb64(pb)), 0, INT_MAX);
+    st->codecpar->sample_rate = av_int2double(avio_rb64(pb));
     st->codecpar->codec_tag   = avio_rl32(pb);
     flags = avio_rb32(pb);
     caf->bytes_per_packet  = avio_rb32(pb);
@@ -460,5 +460,5 @@
     .read_header    = read_header,
     .read_packet    = read_packet,
     .read_seek      = read_seek,
-    .codec_tag      = ff_caf_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ ff_codec_caf_tags, 0 },
 };
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 7e44797..98d4d92 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -274,5 +274,5 @@
     .write_header   = caf_write_header,
     .write_packet   = caf_write_packet,
     .write_trailer  = caf_write_trailer,
-    .codec_tag      = ff_caf_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ff_codec_caf_tags, 0},
 };
diff --git a/libavformat/cdxl.c b/libavformat/cdxl.c
index 33b6d5c..5718fc3 100644
--- a/libavformat/cdxl.c
+++ b/libavformat/cdxl.c
@@ -30,70 +30,53 @@
 
 typedef struct CDXLDemuxContext {
     AVClass     *class;
-    int         read_chunk;
-    AVRational  frate;
-    int         srate;
-    AVRational  frame_rate;
     int         sample_rate;
+    char        *framerate;
+    AVRational  fps;
+    int         read_chunk;
     uint8_t     header[CDXL_HEADER_SIZE];
     int         video_stream_index;
     int         audio_stream_index;
     int64_t     filesize;
-    int64_t     pos;
 } CDXLDemuxContext;
 
 static int cdxl_read_probe(const AVProbeData *p)
 {
     int score = AVPROBE_SCORE_EXTENSION + 10;
-    const uint8_t *buf = p->buf;
 
     if (p->buf_size < CDXL_HEADER_SIZE)
         return 0;
 
-    /* check type */
-    if (buf[0] > 1)
+    /* reserved bytes should always be set to 0 */
+    if (AV_RN64(&p->buf[24]) || AV_RN16(&p->buf[10]))
         return 0;
 
-    /* reserved bytes should always be set to 0 */
-    if (AV_RL24(&buf[29]))
+    /* check type */
+    if (p->buf[0] != 1)
         return 0;
 
     /* check palette size */
-    if (!AV_RN16(&buf[20]))
-        return 0;
-    if (buf[0] == 1 && AV_RB16(&buf[20]) > 512)
-        return 0;
-    if (buf[0] == 0 && AV_RB16(&buf[20]) > 768)
-        return 0;
-
-    if (!AV_RN16(&buf[22]) && AV_RN16(&buf[24]))
-        return 0;
-
-    if (buf[0] == 0 && (!buf[26] || !AV_RB16(&buf[24])))
+    if (AV_RB16(&p->buf[20]) > 512)
         return 0;
 
     /* check number of planes */
-    if (buf[19] != 6 && buf[19] != 8 && buf[19] != 24)
-        return 0;
-
-    if (buf[18])
+    if (p->buf[18] || !p->buf[19])
         return 0;
 
     /* check widh and height */
-    if (AV_RB16(&buf[14]) > 640 || AV_RB16(&buf[16]) > 480 ||
-        AV_RB16(&buf[14]) == 0 || AV_RB16(&buf[16]) == 0)
+    if (!AV_RN16(&p->buf[14]) || !AV_RN16(&p->buf[16]))
         return 0;
 
     /* chunk size */
-    if (AV_RB32(&buf[2]) <= AV_RB16(&buf[20]) + AV_RB16(&buf[22]) * (1 + !!(buf[1] & 0x10)) + CDXL_HEADER_SIZE)
+    if (AV_RB32(&p->buf[2]) < AV_RB16(&p->buf[22]) + AV_RB16(&p->buf[20]) + CDXL_HEADER_SIZE)
         return 0;
 
     /* previous chunk size */
-    if (AV_RN32(&buf[6]))
+    if (AV_RN32(&p->buf[6]))
         score /= 2;
 
     /* current frame number, usually starts from 1 */
-    if (AV_RB32(&buf[10]) != 1)
+    if (AV_RB16(&p->buf[12]) != 1)
         score /= 2;
 
     return score;
@@ -102,6 +85,13 @@
 static int cdxl_read_header(AVFormatContext *s)
 {
     CDXLDemuxContext *cdxl = s->priv_data;
+    int ret;
+
+    if (cdxl->framerate && (ret = av_parse_video_rate(&cdxl->fps, cdxl->framerate)) < 0) {
+        av_log(s, AV_LOG_ERROR,
+               "Could not parse framerate: %s.\n", cdxl->framerate);
+        return ret;
+    }
 
     cdxl->read_chunk         =  0;
     cdxl->video_stream_index = -1;
@@ -120,34 +110,27 @@
     AVIOContext *pb = s->pb;
     uint32_t current_size, video_size, image_size;
     uint16_t audio_size, palette_size, width, height;
-    int      channels, type, format, ret;
+    int64_t  pos;
+    int      format, frames, ret;
 
     if (avio_feof(pb))
         return AVERROR_EOF;
 
-    if (!cdxl->read_chunk) {
-        cdxl->pos = avio_tell(pb);
-        if (avio_read(pb, cdxl->header, CDXL_HEADER_SIZE) != CDXL_HEADER_SIZE)
-            return AVERROR_EOF;
-    }
-    if (cdxl->header[0] > 1) {
-        av_log(s, AV_LOG_ERROR, "unsupported cdxl file\n");
+    pos = avio_tell(pb);
+    if (!cdxl->read_chunk &&
+        avio_read(pb, cdxl->header, CDXL_HEADER_SIZE) != CDXL_HEADER_SIZE)
+        return AVERROR_EOF;
+    if (cdxl->header[0] != 1) {
+        av_log(s, AV_LOG_ERROR, "non-standard cdxl file\n");
         return AVERROR_INVALIDDATA;
     }
 
-    type         = cdxl->header[0];
-    channels     = 1 + !!(cdxl->header[1] & 0x10);
     format       = cdxl->header[1] & 0xE0;
     current_size = AV_RB32(&cdxl->header[2]);
     width        = AV_RB16(&cdxl->header[14]);
     height       = AV_RB16(&cdxl->header[16]);
     palette_size = AV_RB16(&cdxl->header[20]);
-    audio_size   = AV_RB16(&cdxl->header[22]) * channels;
-    cdxl->srate  = AV_RB16(&cdxl->header[24]);
-    if (!cdxl->srate && audio_size)
-        cdxl->srate = cdxl->sample_rate;
-    cdxl->frate.num = cdxl->header[26];
-    cdxl->frate.den = 1;
+    audio_size   = AV_RB16(&cdxl->header[22]);
     if (cdxl->header[19] == 0 ||
         FFALIGN(width, 16) * (uint64_t)height * cdxl->header[19] > INT_MAX)
         return AVERROR_INVALIDDATA;
@@ -157,18 +140,11 @@
         image_size = FFALIGN(width, 16) * height * cdxl->header[19] / 8;
     video_size   = palette_size + image_size;
 
-    if ((type == 1 && palette_size > 512) ||
-        (type == 0 && palette_size > 768))
+    if (palette_size > 512)
         return AVERROR_INVALIDDATA;
     if (current_size < (uint64_t)audio_size + video_size + CDXL_HEADER_SIZE)
         return AVERROR_INVALIDDATA;
 
-    if (!cdxl->frate.num && audio_size && cdxl->srate > 0) {
-        cdxl->frate = (AVRational){ cdxl->srate, audio_size };
-    } else if (!cdxl->frate.num) {
-        cdxl->frate = cdxl->frame_rate;
-    }
-
     if (cdxl->read_chunk && audio_size) {
         if (cdxl->audio_stream_index == -1) {
             AVStream *st = avformat_new_stream(s, NULL);
@@ -177,23 +153,26 @@
 
             st->codecpar->codec_type    = AVMEDIA_TYPE_AUDIO;
             st->codecpar->codec_tag     = 0;
-            st->codecpar->codec_id      = AV_CODEC_ID_PCM_S8_PLANAR;
-            st->codecpar->channels      = channels;
-            st->codecpar->channel_layout = channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
-            st->codecpar->sample_rate= cdxl->srate;
+            st->codecpar->codec_id      = AV_CODEC_ID_PCM_S8;
+            if (cdxl->header[1] & 0x10) {
+                st->codecpar->channels       = 2;
+                st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+            } else {
+                st->codecpar->channels       = 1;
+                st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+            }
+            st->codecpar->sample_rate   = cdxl->sample_rate;
             st->start_time           = 0;
             cdxl->audio_stream_index = st->index;
-            avpriv_set_pts_info(st, 64, 1, cdxl->srate);
-            if (current_size && cdxl->filesize > 0 && audio_size > 0)
-                st->duration = (cdxl->filesize / current_size) * audio_size / channels;
+            avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
         }
 
         ret = av_get_packet(pb, pkt, audio_size);
         if (ret < 0)
             return ret;
         pkt->stream_index = cdxl->audio_stream_index;
-        pkt->pos          = cdxl->pos;
-        pkt->duration     = audio_size / channels;
+        pkt->pos          = pos;
+        pkt->duration     = audio_size;
         cdxl->read_chunk  = 0;
     } else {
         if (cdxl->video_stream_index == -1) {
@@ -207,11 +186,20 @@
             st->codecpar->width         = width;
             st->codecpar->height        = height;
 
-            if (current_size && cdxl->filesize > 0)
-                st->nb_frames = cdxl->filesize / current_size;
+            if (audio_size + video_size && cdxl->filesize > 0) {
+                frames = cdxl->filesize / (audio_size + video_size);
+
+                if(cdxl->framerate)
+                    st->duration = frames;
+                else
+                    st->duration = frames * (int64_t)audio_size;
+            }
             st->start_time           = 0;
             cdxl->video_stream_index = st->index;
-            avpriv_set_pts_info(st, 64, cdxl->frate.den, cdxl->frate.num);
+            if (cdxl->framerate)
+                avpriv_set_pts_info(st, 64, cdxl->fps.den, cdxl->fps.num);
+            else
+                avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
         }
 
         if ((ret = av_new_packet(pkt, video_size + CDXL_HEADER_SIZE)) < 0)
@@ -224,8 +212,8 @@
         av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);
         pkt->stream_index  = cdxl->video_stream_index;
         pkt->flags        |= AV_PKT_FLAG_KEY;
-        pkt->pos           = cdxl->pos;
-        pkt->duration      = 1;
+        pkt->pos           = pos;
+        pkt->duration      = cdxl->framerate ? 1 : audio_size ? audio_size : 220;
         cdxl->read_chunk   = audio_size;
     }
 
@@ -234,20 +222,10 @@
     return ret;
 }
 
-static int read_seek(AVFormatContext *s, int stream_index,
-                     int64_t timestamp, int flags)
-{
-    CDXLDemuxContext *cdxl = s->priv_data;
-
-    cdxl->read_chunk = 0;
-
-    return -1;
-}
-
 #define OFFSET(x) offsetof(CDXLDemuxContext, x)
 static const AVOption cdxl_options[] = {
-    { "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64=11025 }, 8000, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
-    { "frame_rate", "", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str="15" }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT,    { .i64 = 11025 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "framerate",   "", OFFSET(framerate),   AV_OPT_TYPE_STRING, { .str = NULL },  0, 0,       AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
 };
 
@@ -262,11 +240,10 @@
     .name           = "cdxl",
     .long_name      = NULL_IF_CONFIG_SMALL("Commodore CDXL video"),
     .priv_data_size = sizeof(CDXLDemuxContext),
-    .priv_class     = &cdxl_demuxer_class,
     .read_probe     = cdxl_read_probe,
     .read_header    = cdxl_read_header,
     .read_packet    = cdxl_read_packet,
-    .read_seek      = read_seek,
     .extensions     = "cdxl,xl",
     .flags          = AVFMT_GENERIC_INDEX,
+    .priv_class     = &cdxl_demuxer_class,
 };
diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index 423f5b7..0cd7cde 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -1,6 +1,6 @@
 /*
  * Chromaprint fingerprinting muxer
- * Copyright (c) 2015 rcombs
+ * Copyright (c) 2015 Rodger Combs
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/concat.c b/libavformat/concat.c
index 278afd9..418405d 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -73,11 +73,14 @@
 
     for (i = 0, len = 1; uri[i]; i++) {
         if (uri[i] == *AV_CAT_SEPARATOR) {
-            len++;
+            /* integer overflow */
+            if (++len == UINT_MAX / sizeof(*nodes)) {
+                return AVERROR(ENAMETOOLONG);
+            }
         }
     }
 
-    if (!(nodes = av_realloc_array(NULL, len, sizeof(*nodes))))
+    if (!(nodes = av_realloc(NULL, sizeof(*nodes) * len)))
         return AVERROR(ENOMEM);
     else
         data->nodes = nodes;
diff --git a/libavformat/cutils.c b/libavformat/cutils.c
new file mode 100644
index 0000000..d86ba05
--- /dev/null
+++ b/libavformat/cutils.c
@@ -0,0 +1,39 @@
+/*
+ * various simple utilities for libavformat
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/time_internal.h"
+#include "avformat.h"
+#include "internal.h"
+
+#define ISLEAP(y) (((y) % 4 == 0) && (((y) % 100) != 0 || ((y) % 400) == 0))
+#define LEAPS_COUNT(y) ((y)/4 - (y)/100 + (y)/400)
+
+/* This is our own gmtime_r. It differs from its POSIX counterpart in a
+   couple of places, though. */
+struct tm *ff_brktimegm(time_t secs, struct tm *tm)
+{
+    tm = gmtime_r(&secs, tm);
+
+    tm->tm_year += 1900; /* unlike gmtime_r we store complete year here */
+    tm->tm_mon  += 1;    /* unlike gmtime_r tm_mon is from 1 to 12 */
+
+    return tm;
+}
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 6f3f28d..693fc73 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -82,7 +82,7 @@
     AVFormatContext *ctx;
     int stream_index;
 
-    char *id;
+    char id[20];
     char *lang;
     int bandwidth;
     AVRational framerate;
@@ -155,14 +155,13 @@
     /* Flags for init section*/
     int is_init_section_common_video;
     int is_init_section_common_audio;
-    int is_init_section_common_subtitle;
 
 } DASHContext;
 
 static int ishttp(char *url)
 {
     const char *proto_name = avio_find_protocol_name(url);
-    return proto_name && av_strstart(proto_name, "http", NULL);
+    return av_strstart(proto_name, "http", NULL);
 }
 
 static int aligned(int val)
@@ -361,7 +360,6 @@
 
     av_freep(&pls->url_template);
     av_freep(&pls->lang);
-    av_freep(&pls->id);
     av_freep(&pls);
 }
 
@@ -843,7 +841,7 @@
     char *val = NULL;
     xmlNodePtr baseurl_nodes[4];
     xmlNodePtr representation_node = node;
-    char *rep_bandwidth_val;
+    char *rep_id_val, *rep_bandwidth_val;
     enum AVMediaType type = AVMEDIA_TYPE_UNKNOWN;
 
     // try get information from representation
@@ -877,14 +875,8 @@
     representation_segmenttemplate_node = find_child_node_by_name(representation_node, "SegmentTemplate");
     representation_baseurl_node = find_child_node_by_name(representation_node, "BaseURL");
     representation_segmentlist_node = find_child_node_by_name(representation_node, "SegmentList");
+    rep_id_val        = xmlGetProp(representation_node, "id");
     rep_bandwidth_val = xmlGetProp(representation_node, "bandwidth");
-    val               = xmlGetProp(representation_node, "id");
-    if (val) {
-        rep->id = av_strdup(val);
-        xmlFree(val);
-        if (!rep->id)
-            goto enomem;
-    }
 
     baseurl_nodes[0] = mpd_baseurl_node;
     baseurl_nodes[1] = period_baseurl_node;
@@ -893,7 +885,7 @@
 
     ret = resolve_content_path(s, url, &c->max_url_size, baseurl_nodes, 4);
     c->max_url_size = aligned(c->max_url_size
-                              + (rep->id ? strlen(rep->id) : 0)
+                              + (rep_id_val ? strlen(rep_id_val) : 0)
                               + (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
     if (ret == AVERROR(ENOMEM) || ret == 0)
         goto free;
@@ -913,9 +905,7 @@
                 goto enomem;
             }
             c->max_url_size = aligned(c->max_url_size  + strlen(val));
-            rep->init_section->url = get_content_url(baseurl_nodes, 4,
-                                                     c->max_url_size, rep->id,
-                                                     rep_bandwidth_val, val);
+            rep->init_section->url = get_content_url(baseurl_nodes, 4,  c->max_url_size, rep_id_val, rep_bandwidth_val, val);
             xmlFree(val);
             if (!rep->init_section->url)
                 goto enomem;
@@ -924,9 +914,7 @@
         val = get_val_from_nodes_tab(fragment_templates_tab, 4, "media");
         if (val) {
             c->max_url_size = aligned(c->max_url_size  + strlen(val));
-            rep->url_template = get_content_url(baseurl_nodes, 4,
-                                                c->max_url_size, rep->id,
-                                                rep_bandwidth_val, val);
+            rep->url_template = get_content_url(baseurl_nodes, 4, c->max_url_size, rep_id_val, rep_bandwidth_val, val);
             xmlFree(val);
         }
         val = get_val_from_nodes_tab(fragment_templates_tab, 4, "presentationTimeOffset");
@@ -991,8 +979,7 @@
             av_free(seg);
             goto free;
         }
-        seg->url = get_content_url(baseurl_nodes, 4, c->max_url_size,
-                                   rep->id, rep_bandwidth_val, NULL);
+        seg->url = get_content_url(baseurl_nodes, 4, c->max_url_size, rep_id_val, rep_bandwidth_val, NULL);
         if (!seg->url)
             goto enomem;
         seg->size = -1;
@@ -1026,7 +1013,8 @@
         fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
         while (fragmenturl_node) {
             ret = parse_manifest_segmenturlnode(s, rep, fragmenturl_node,
-                                                baseurl_nodes, rep->id,
+                                                baseurl_nodes,
+                                                rep_id_val,
                                                 rep_bandwidth_val);
             if (ret < 0)
                 goto free;
@@ -1046,14 +1034,14 @@
             }
         }
     } else {
-        av_log(s, AV_LOG_ERROR, "Unknown format of Representation node id '%s' \n",
-               rep->id ? rep->id : "");
+        av_log(s, AV_LOG_ERROR, "Unknown format of Representation node id[%s] \n", rep_id_val);
         goto free;
     }
 
     if (rep->fragment_duration > 0 && !rep->fragment_timescale)
         rep->fragment_timescale = 1;
     rep->bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
+    strncpy(rep->id, rep_id_val ? rep_id_val : "", sizeof(rep->id));
     rep->framerate = av_make_q(0, 0);
     if (type == AVMEDIA_TYPE_VIDEO) {
         char *rep_framerate_val = xmlGetProp(representation_node, "frameRate");
@@ -1080,6 +1068,8 @@
         goto free;
 
 end:
+    if (rep_id_val)
+        xmlFree(rep_id_val);
     if (rep_bandwidth_val)
         xmlFree(rep_bandwidth_val);
 
@@ -1635,15 +1625,8 @@
         }
     }
     if (seg) {
-        char *tmpfilename;
-        if (!pls->url_template) {
-            av_log(pls->parent, AV_LOG_ERROR, "Cannot get fragment, missing template URL\n");
-            av_free(seg);
-            return NULL;
-        }
-        tmpfilename = av_mallocz(c->max_url_size);
+        char *tmpfilename= av_mallocz(c->max_url_size);
         if (!tmpfilename) {
-            av_free(seg);
             return NULL;
         }
         ff_dash_fill_tmpl_params(tmpfilename, c->max_url_size, pls->url_template, 0, pls->cur_seq_no, 0, get_segment_start_time_based_on_timeline(pls, pls->cur_seq_no));
@@ -1654,7 +1637,6 @@
             if (!seg->url) {
                 av_log(pls->parent, AV_LOG_ERROR, "Cannot resolve template url '%s'\n", pls->url_template);
                 av_free(tmpfilename);
-                av_free(seg);
                 return NULL;
             }
         }
@@ -2010,12 +1992,7 @@
     url_offset = first_init_section->url_offset;
     size = pls[0]->init_section->size;
     for (i=0;i<n_pls;i++) {
-        if (!pls[i]->init_section)
-            continue;
-
-        if (av_strcasecmp(pls[i]->init_section->url, url) ||
-            pls[i]->init_section->url_offset != url_offset ||
-            pls[i]->init_section->size != size) {
+        if (av_strcasecmp(pls[i]->init_section->url,url) || pls[i]->init_section->url_offset != url_offset || pls[i]->init_section->size != size) {
             return 0;
         }
     }
@@ -2039,14 +2016,6 @@
 
 static int dash_close(AVFormatContext *s);
 
-static void move_metadata(AVStream *st, const char *key, char **value)
-{
-    if (*value) {
-        av_dict_set(&st->metadata, key, *value, AV_DICT_DONT_STRDUP_VAL);
-        *value = NULL;
-    }
-}
-
 static int dash_read_header(AVFormatContext *s)
 {
     DASHContext *c = s->priv_data;
@@ -2110,11 +2079,11 @@
     }
 
     if (c->n_subtitles)
-        c->is_init_section_common_subtitle = is_common_init_section_exist(c->subtitles, c->n_subtitles);
+        c->is_init_section_common_audio = is_common_init_section_exist(c->subtitles, c->n_subtitles);
 
     for (i = 0; i < c->n_subtitles; i++) {
         rep = c->subtitles[i];
-        if (i > 0 && c->is_init_section_common_subtitle) {
+        if (i > 0 && c->is_init_section_common_audio) {
             ret = copy_init_section(rep, c->subtitles[0]);
             if (ret < 0)
                 goto fail;
@@ -2145,7 +2114,8 @@
         rep->assoc_stream = s->streams[rep->stream_index];
         if (rep->bandwidth > 0)
             av_dict_set_int(&rep->assoc_stream->metadata, "variant_bitrate", rep->bandwidth, 0);
-        move_metadata(rep->assoc_stream, "id", &rep->id);
+        if (rep->id[0])
+            av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
     }
     for (i = 0; i < c->n_audios; i++) {
         rep = c->audios[i];
@@ -2153,15 +2123,23 @@
         rep->assoc_stream = s->streams[rep->stream_index];
         if (rep->bandwidth > 0)
             av_dict_set_int(&rep->assoc_stream->metadata, "variant_bitrate", rep->bandwidth, 0);
-        move_metadata(rep->assoc_stream, "id", &rep->id);
-        move_metadata(rep->assoc_stream, "language", &rep->lang);
+        if (rep->id[0])
+            av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
+        if (rep->lang) {
+            av_dict_set(&rep->assoc_stream->metadata, "language", rep->lang, 0);
+            av_freep(&rep->lang);
+        }
     }
     for (i = 0; i < c->n_subtitles; i++) {
         rep = c->subtitles[i];
         av_program_add_stream_index(s, 0, rep->stream_index);
         rep->assoc_stream = s->streams[rep->stream_index];
-        move_metadata(rep->assoc_stream, "id", &rep->id);
-        move_metadata(rep->assoc_stream, "language", &rep->lang);
+        if (rep->id[0])
+            av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
+        if (rep->lang) {
+            av_dict_set(&rep->assoc_stream->metadata, "language", rep->lang, 0);
+            av_freep(&rep->lang);
+        }
     }
 
     return 0;
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 81a5c2b..2d757b3 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1815,8 +1815,7 @@
 {
     AVCodecParameters *par = os->ctx->streams[0]->codecpar;
     uint8_t *extradata;
-    buffer_size_t extradata_size;
-    int ret;
+    int ret, extradata_size;
 
     if (par->extradata_size)
         return 0;
@@ -2031,7 +2030,7 @@
 {
     OutputStream *os = &c->streams[pkt->stream_index];
     AVProducerReferenceTime *prft;
-    buffer_size_t side_data_size;
+    int side_data_size;
 
     prft = (AVProducerReferenceTime *)av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
     if (!prft || side_data_size != sizeof(AVProducerReferenceTime) || (prft->flags && prft->flags != 24)) {
diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c
index 9ddccc7..9041a86 100644
--- a/libavformat/dcstr.c
+++ b/libavformat/dcstr.c
@@ -43,8 +43,6 @@
     st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
     st->codecpar->channels    = avio_rl32(s->pb);
     st->codecpar->sample_rate = avio_rl32(s->pb);
-    if (st->codecpar->sample_rate <= 0)
-        return AVERROR_INVALIDDATA;
     codec                  = avio_rl32(s->pb);
     align                  = avio_rl32(s->pb);
     avio_skip(s->pb, 4);
diff --git a/libavformat/dhav.c b/libavformat/dhav.c
index 526331a..53deaff 100644
--- a/libavformat/dhav.c
+++ b/libavformat/dhav.c
@@ -173,9 +173,18 @@
     if (avio_feof(s->pb))
         return AVERROR_EOF;
 
-    while (avio_r8(s->pb) != 'D' || avio_r8(s->pb) != 'H' || avio_r8(s->pb) != 'A' || avio_r8(s->pb) != 'V') {
-        if (avio_feof(s->pb))
-            return AVERROR_EOF;
+    if (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
+        dhav->last_good_pos += 0x8000;
+        avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
+
+        while (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
+            if (avio_feof(s->pb))
+                return AVERROR_EOF;
+            dhav->last_good_pos += 0x8000;
+            ret = avio_skip(s->pb, 0x8000 - 4);
+            if (ret < 0)
+                return ret;
+        }
     }
 
     start = avio_tell(s->pb) - 4;
@@ -281,8 +290,6 @@
                 int seek_back;
 
                 seek_back = avio_rl32(s->pb) + 8;
-                if (seek_back < 9)
-                    break;
                 dhav->last_good_pos = avio_tell(s->pb);
                 avio_seek(s->pb, -seek_back, SEEK_CUR);
             }
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 62ef5e9..fe62801 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -543,7 +543,7 @@
     avcodec_string(buf, sizeof(buf), avctx, is_output);
     avcodec_free_context(&avctx);
 
-    av_log(NULL, AV_LOG_INFO, "  Stream #%d:%d", index, i);
+    av_log(NULL, AV_LOG_INFO, "    Stream #%d:%d", index, i);
 
     /* the pid is an important information, so we display it */
     /* XXX: add a generic system */
@@ -686,8 +686,6 @@
         av_log(NULL, AV_LOG_INFO, "\n");
     }
 
-    if (ic->nb_chapters)
-        av_log(NULL, AV_LOG_INFO, "  Chapters:\n");
     for (i = 0; i < ic->nb_chapters; i++) {
         const AVChapter *ch = ic->chapters[i];
         av_log(NULL, AV_LOG_INFO, "    Chapter #%d:%d: ", index, i);
@@ -696,7 +694,7 @@
         av_log(NULL, AV_LOG_INFO,
                "end %f\n", ch->end * av_q2d(ch->time_base));
 
-        dump_metadata(NULL, ch->metadata, "      ");
+        dump_metadata(NULL, ch->metadata, "    ");
     }
 
     if (ic->nb_programs) {
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 320f847..6c0d40f 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -29,7 +29,6 @@
  */
 #include <time.h>
 
-#include "libavutil/time_internal.h"
 #include "avformat.h"
 #include "internal.h"
 #include "libavcodec/dv_profile.h"
@@ -73,14 +72,6 @@
     { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
 };
 
-static void brktimegm(time_t secs, struct tm *tm)
-{
-    tm = gmtime_r(&secs, tm);
-
-    tm->tm_year += 1900; /* unlike gmtime_r we store complete year here */
-    tm->tm_mon  += 1;    /* unlike gmtime_r tm_mon is from 1 to 12 */
-}
-
 static int dv_audio_frame_size(const AVDVProfile* sys, int frame, int sample_rate)
 {
     if ((sys->time_base.den == 25 || sys->time_base.den == 50) && sys->time_base.num == 1) {
@@ -152,7 +143,7 @@
     case dv_video_recdate:  /* VAUX recording date */
         ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
                                             c->sys->time_base.den, AV_ROUND_DOWN);
-        brktimegm(ct, &tc);
+        ff_brktimegm(ct, &tc);
         buf[1] = 0xff; /* ds, tm, tens of time zone, units of time zone */
                        /* 0xff is very likely to be "unknown" */
         buf[2] = (3 << 6) | /* reserved -- always 1 */
@@ -168,7 +159,7 @@
     case dv_video_rectime:  /* VAUX recording time */
         ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
                                                        c->sys->time_base.den, AV_ROUND_DOWN);
-        brktimegm(ct, &tc);
+        ff_brktimegm(ct, &tc);
         buf[1] = (3 << 6) | /* reserved -- always 1 */
                  0x3f; /* tens of frame, units of frame: 0x3f - "unknown" ? */
         buf[2] = (1 << 7) | /* reserved -- always 1 */
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index 7c0d6a2..4c292f2 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -607,14 +607,10 @@
                 break;
             } else if (ea->audio_codec == AV_CODEC_ID_PCM_S16LE_PLANAR ||
                        ea->audio_codec == AV_CODEC_ID_MP3) {
-                if (chunk_size < 12)
-                    return AVERROR_INVALIDDATA;
                 num_samples = avio_rl32(pb);
                 avio_skip(pb, 8);
                 chunk_size -= 12;
             } else if (ea->audio_codec == AV_CODEC_ID_ADPCM_PSX) {
-                if (chunk_size < 8)
-                    return AVERROR_INVALIDDATA;
                 avio_skip(pb, 8);
                 chunk_size -= 8;
             }
@@ -697,8 +693,6 @@
         case fVGT_TAG:
         case MADm_TAG:
         case MADe_TAG:
-            if (chunk_size > INT_MAX - 8)
-                return AVERROR_INVALIDDATA;
             avio_seek(pb, -8, SEEK_CUR);    // include chunk preamble
             chunk_size += 8;
             goto get_video_packet;
@@ -728,7 +722,6 @@
                 ret = av_get_packet(pb, pkt, chunk_size);
             if (ret < 0) {
                 packet_read = 1;
-                partial_packet = 0;
                 break;
             }
             partial_packet = chunk_type == MVIh_TAG;
diff --git a/libavformat/fitsdec.c b/libavformat/fitsdec.c
index df757e8..e52ddc7 100644
--- a/libavformat/fitsdec.c
+++ b/libavformat/fitsdec.c
@@ -24,7 +24,6 @@
  * FITS demuxer.
  */
 
-#include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
 #include "internal.h"
 #include "libavutil/opt.h"
@@ -126,14 +125,14 @@
     size += header->pcount;
 
     t = (abs(header->bitpix) >> 3) * ((int64_t) header->gcount);
-    if(size && t > INT64_MAX / size)
+    if(size && t > UINT64_MAX / size)
         return AVERROR_INVALIDDATA;
     size *= t;
 
     if (!size) {
         image = 0;
     } else {
-        if(FITS_BLOCK_SIZE - 1 > INT64_MAX - size)
+        if(FITS_BLOCK_SIZE - 1 > UINT64_MAX - size)
             return AVERROR_INVALIDDATA;
         size = ((size + FITS_BLOCK_SIZE - 1) / FITS_BLOCK_SIZE) * FITS_BLOCK_SIZE;
     }
@@ -174,11 +173,6 @@
         goto fail;
     }
 
-    av_assert0(avbuf.len <= INT64_MAX && size <= INT64_MAX);
-    if (avbuf.len + size > INT_MAX - 80)  {
-        ret = AVERROR_INVALIDDATA;
-        goto fail;
-    }
     // Header is sent with the first line removed...
     ret = av_new_packet(pkt, avbuf.len - 80 + size);
     if (ret < 0)
diff --git a/libavformat/fitsenc.c b/libavformat/fitsenc.c
index 212c769..cc3999a 100644
--- a/libavformat/fitsenc.c
+++ b/libavformat/fitsenc.c
@@ -45,8 +45,7 @@
  * @param lines_written to keep track of lines written so far
  * @return 0
  */
-static int write_keyword_value(AVFormatContext *s, const char *fmt,
-                               const char *keyword, void *value, int *lines_written)
+static int write_keyword_value(AVFormatContext *s, const char *keyword, int value, int *lines_written)
 {
     int len, ret;
     uint8_t header[80];
@@ -58,12 +57,7 @@
     header[8] = '=';
     header[9] = ' ';
 
-    if (!strcmp(fmt, "%d")) {
-        ret = snprintf(header + 10, 70, fmt, *(int *)value);
-    } else {
-        ret = snprintf(header + 10, 70, fmt, *(float *)value);
-    }
-
+    ret = snprintf(header + 10, 70, "%d", value);
     memset(&header[ret + 10], ' ', sizeof(header) - (ret + 10));
 
     avio_write(s->pb, header, sizeof(header));
@@ -78,22 +72,16 @@
     FITSContext *fitsctx = s->priv_data;
     uint8_t buffer[80];
     int bitpix, naxis, naxis3 = 1, bzero = 0, rgb = 0, lines_written = 0, lines_left;
-    int pcount = 0, gcount = 1;
-    float datamax, datamin;
 
     switch (encctx->format) {
         case AV_PIX_FMT_GRAY8:
             bitpix = 8;
             naxis = 2;
-            datamin = 0;
-            datamax = 255;
             break;
         case AV_PIX_FMT_GRAY16BE:
             bitpix = 16;
             naxis = 2;
             bzero = 32768;
-            datamin = 0;
-            datamax = 65535;
             break;
         case AV_PIX_FMT_GBRP:
         case AV_PIX_FMT_GBRAP:
@@ -105,8 +93,6 @@
             } else {
                 naxis3 = 4;
             }
-            datamin = 0;
-            datamax = 255;
             break;
         case AV_PIX_FMT_GBRP16BE:
         case AV_PIX_FMT_GBRAP16BE:
@@ -119,8 +105,6 @@
                 naxis3 = 4;
             }
             bzero = 32768;
-            datamin = 0;
-            datamax = 65535;
             break;
         default:
             return AVERROR(EINVAL);
@@ -138,31 +122,28 @@
     }
     lines_written++;
 
-    write_keyword_value(s, "%d", "BITPIX", &bitpix, &lines_written);         // no of bits per pixel
-    write_keyword_value(s, "%d", "NAXIS", &naxis, &lines_written);           // no of dimensions of image
-    write_keyword_value(s, "%d", "NAXIS1", &encctx->width, &lines_written);   // first dimension i.e. width
-    write_keyword_value(s, "%d", "NAXIS2", &encctx->height, &lines_written);  // second dimension i.e. height
+    write_keyword_value(s, "BITPIX", bitpix, &lines_written);         // no of bits per pixel
+    write_keyword_value(s, "NAXIS", naxis, &lines_written);           // no of dimensions of image
+    write_keyword_value(s, "NAXIS1", encctx->width, &lines_written);   // first dimension i.e. width
+    write_keyword_value(s, "NAXIS2", encctx->height, &lines_written);  // second dimension i.e. height
 
     if (rgb)
-        write_keyword_value(s, "%d", "NAXIS3", &naxis3, &lines_written);     // third dimension to store RGBA planes
+        write_keyword_value(s, "NAXIS3", naxis3, &lines_written);     // third dimension to store RGBA planes
 
     if (!fitsctx->first_image) {
-        write_keyword_value(s, "%d", "PCOUNT", &pcount, &lines_written);
-        write_keyword_value(s, "%d", "GCOUNT", &gcount, &lines_written);
+        write_keyword_value(s, "PCOUNT", 0, &lines_written);
+        write_keyword_value(s, "GCOUNT", 1, &lines_written);
     } else {
         fitsctx->first_image = 0;
     }
 
-    write_keyword_value(s, "%g", "DATAMIN", &datamin, &lines_written);
-    write_keyword_value(s, "%g", "DATAMAX", &datamax, &lines_written);
-
     /*
      * Since FITS does not support unsigned 16 bit integers,
      * BZERO = 32768 is used to store unsigned 16 bit integers as
      * signed integers so that it can be read properly.
      */
     if (bitpix == 16)
-        write_keyword_value(s, "%d", "BZERO", &bzero, &lines_written);
+        write_keyword_value(s, "BZERO", bzero, &lines_written);
 
     if (rgb) {
         memcpy(buffer, "CTYPE3  = 'RGB     '", 20);
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 088f347..1c98348 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -280,7 +280,7 @@
 {
     FlacMuxerContext *c = s->priv_data;
     uint8_t *streaminfo;
-    buffer_size_t streaminfo_size;
+    int streaminfo_size;
 
     /* check for updated streaminfo */
     streaminfo = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index e4b40a1..ad6e7a3 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -41,8 +41,6 @@
 
 #define RESYNC_BUFFER_SIZE (1<<20)
 
-#define MAX_DEPTH 16      ///< arbitrary limit to prevent unbounded recursion
-
 typedef struct FLVContext {
     const AVClass *class; ///< Class for private options.
     int trust_metadata;   ///< configure streams according onMetaData
@@ -384,18 +382,13 @@
 
 static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
 {
-    int ret;
     int length = avio_rb16(ioc);
     if (length >= buffsize) {
         avio_skip(ioc, length);
         return -1;
     }
 
-    ret = avio_read(ioc, buffer, length);
-    if (ret < 0)
-        return ret;
-    if (ret < length)
-        return AVERROR_INVALIDDATA;
+    avio_read(ioc, buffer, length);
 
     buffer[length] = '\0';
 
@@ -453,13 +446,9 @@
         }
 
         for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) {
-            double d;
             if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER)
                 goto invalid;
-            d = av_int2double(avio_rb64(ioc));
-            if (isnan(d) || d < INT64_MIN || d > INT64_MAX)
-                goto invalid;
-            current_array[0][i] = d;
+            current_array[0][i] = av_int2double(avio_rb64(ioc));
         }
         if (times && filepositions) {
             // All done, exiting at a position allowing amf_parse_object
@@ -504,9 +493,6 @@
     double num_val;
     amf_date date;
 
-    if (depth > MAX_DEPTH)
-        return AVERROR_PATCHWELCOME;
-
     num_val  = 0;
     ioc      = s->pb;
     if (avio_feof(ioc))
@@ -851,16 +837,10 @@
     }
 }
 
-static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
+static int amf_skip_tag(AVIOContext *pb, AMFDataType type)
 {
     int nb = -1, ret, parse_name = 1;
 
-    if (depth > MAX_DEPTH)
-        return AVERROR_PATCHWELCOME;
-
-    if (avio_feof(pb))
-        return AVERROR_EOF;
-
     switch (type) {
     case AMF_DATA_TYPE_NUMBER:
         avio_skip(pb, 8);
@@ -885,7 +865,7 @@
                 }
                 avio_skip(pb, size);
             }
-            if ((ret = amf_skip_tag(pb, avio_r8(pb), depth + 1)) < 0)
+            if ((ret = amf_skip_tag(pb, avio_r8(pb))) < 0)
                 return ret;
         }
         break;
@@ -929,7 +909,7 @@
             else
                 break;
         } else {
-            if ((ret = amf_skip_tag(pb, type, 0)) < 0)
+            if ((ret = amf_skip_tag(pb, type)) < 0)
                 goto skip;
         }
     }
@@ -1178,7 +1158,7 @@
             avio_seek(s->pb, fsize - 3 - size, SEEK_SET);
             if (size == avio_rb24(s->pb) + 11) {
                 uint32_t ts = avio_rb24(s->pb);
-                ts         |= (unsigned)avio_r8(s->pb) << 24;
+                ts         |= avio_r8(s->pb) << 24;
                 if (ts)
                     s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
                 else if (fsize >= 8 && fsize - 8 >= size) {
@@ -1251,7 +1231,7 @@
         if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
             // sign extension
             int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
-            pts = av_sat_add64(dts, cts);
+            pts = dts + cts;
             if (cts < 0) { // dts might be wrong
                 if (!flv->wrong_dts)
                     av_log(s, AV_LOG_WARNING,
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 35bf7ac..1cfcdc6 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -902,7 +902,7 @@
 
     if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264
             || par->codec_id == AV_CODEC_ID_MPEG4) {
-        buffer_size_t side_size;
+        int side_size;
         uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
         if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
             ret = ff_alloc_extradata(par, side_size);
diff --git a/libavformat/frmdec.c b/libavformat/frmdec.c
index 1bc3a83..9a962f3 100644
--- a/libavformat/frmdec.c
+++ b/libavformat/frmdec.c
@@ -29,12 +29,13 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 
-static const enum AVPixelFormat frm_pix_fmt_tags[] = {
-    AV_PIX_FMT_RGB555,
-    AV_PIX_FMT_RGB0,
-    AV_PIX_FMT_RGB24,
-    AV_PIX_FMT_BGR0,
-    AV_PIX_FMT_BGRA,
+static const PixelFormatTag frm_pix_fmt_tags[] = {
+    { AV_PIX_FMT_RGB555, 1 },
+    { AV_PIX_FMT_RGB0,   2 },
+    { AV_PIX_FMT_RGB24,  3 },
+    { AV_PIX_FMT_BGR0,   4 },
+    { AV_PIX_FMT_BGRA,   5 },
+    { AV_PIX_FMT_NONE,   0 },
 };
 
 typedef struct {
@@ -54,8 +55,6 @@
 {
     AVIOContext *pb = avctx->pb;
     AVStream *st = avformat_new_stream(avctx, 0);
-    unsigned idx;
-
     if (!st)
         return AVERROR(ENOMEM);
 
@@ -63,10 +62,9 @@
     st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
     avio_skip(pb, 3);
 
-    idx = avio_r8(pb) - 1;
-    if (idx >= FF_ARRAY_ELEMS(frm_pix_fmt_tags))
+    st->codecpar->format    = avpriv_find_pix_fmt(frm_pix_fmt_tags, avio_r8(pb));
+    if (!st->codecpar->format)
         return AVERROR_INVALIDDATA;
-    st->codecpar->format = frm_pix_fmt_tags[idx];
 
     st->codecpar->codec_tag  = 0;
     st->codecpar->width      = avio_rl16(pb);
diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
index 1e9faf3..5523dfd 100644
--- a/libavformat/hashenc.c
+++ b/libavformat/hashenc.c
@@ -42,8 +42,8 @@
 #define FORMAT_VERSION_OPT \
     { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }
 
-#if CONFIG_HASH_MUXER || CONFIG_STREAMHASH_MUXER
-static const AVOption hash_streamhash_options[] = {
+#if CONFIG_HASH_MUXER
+static const AVOption hash_options[] = {
     HASH_OPT("sha256"),
     { NULL },
 };
@@ -57,6 +57,13 @@
 };
 #endif
 
+#if CONFIG_STREAMHASH_MUXER
+static const AVOption streamhash_options[] = {
+    HASH_OPT("sha256"),
+    { NULL },
+};
+#endif
+
 #if CONFIG_MD5_MUXER
 static const AVOption md5_options[] = {
     HASH_OPT("md5"),
@@ -167,7 +174,7 @@
 static const AVClass hashenc_class = {
     .class_name = "hash muxer",
     .item_name  = av_default_item_name,
-    .option     = hash_streamhash_options,
+    .option     = hash_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
@@ -215,7 +222,7 @@
 static const AVClass streamhashenc_class = {
     .class_name = "stream hash muxer",
     .item_name  = av_default_item_name,
-    .option     = hash_streamhash_options,
+    .option     = streamhash_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
diff --git a/libavformat/hls.c b/libavformat/hls.c
index af2468a..0a522a4 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -23,7 +23,7 @@
 /**
  * @file
  * Apple HTTP Live Streaming demuxer
- * https://www.rfc-editor.org/rfc/rfc8216.txt
+ * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
 #include "libavformat/http.h"
@@ -112,13 +112,13 @@
     int finished;
     enum PlaylistType type;
     int64_t target_duration;
-    int64_t start_seq_no;
+    int start_seq_no;
     int n_segments;
     struct segment **segments;
     int needed;
     int broken;
-    int64_t cur_seq_no;
-    int64_t last_seq_no;
+    int cur_seq_no;
+    int last_seq_no;
     int m3u8_hold_counters;
     int64_t cur_seg_offset;
     int64_t last_load_time;
@@ -199,7 +199,7 @@
     int n_renditions;
     struct rendition **renditions;
 
-    int64_t cur_seq_no;
+    int cur_seq_no;
     int m3u8_hold_counters;
     int live_start_index;
     int first_packet;
@@ -722,7 +722,7 @@
     int is_http = av_strstart(url, "http", NULL);
     struct segment **prev_segments = NULL;
     int prev_n_segments = 0;
-    int64_t prev_start_seq_no = -1;
+    int prev_start_seq_no = -1;
 
     if (is_http && !in && c->http_persistent && c->playlist_pb) {
         in = c->playlist_pb;
@@ -808,17 +808,10 @@
                 goto fail;
             pls->target_duration = strtoll(ptr, NULL, 10) * AV_TIME_BASE;
         } else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
-            uint64_t seq_no;
             ret = ensure_playlist(c, &pls, url);
             if (ret < 0)
                 goto fail;
-            seq_no = strtoull(ptr, NULL, 10);
-            if (seq_no > INT64_MAX) {
-                av_log(c->ctx, AV_LOG_DEBUG, "MEDIA-SEQUENCE higher than "
-                        "INT64_MAX, mask out the highest bit\n");
-                seq_no &= INT64_MAX;
-            }
-            pls->start_seq_no = seq_no;
+            pls->start_seq_no = atoi(ptr);
         } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
             ret = ensure_playlist(c, &pls, url);
             if (ret < 0)
@@ -839,9 +832,9 @@
             if (has_iv) {
                 memcpy(cur_init_section->iv, iv, sizeof(iv));
             } else {
-                int64_t seq = pls->start_seq_no + pls->n_segments;
+                int seq = pls->start_seq_no + pls->n_segments;
                 memset(cur_init_section->iv, 0, sizeof(cur_init_section->iv));
-                AV_WB64(cur_init_section->iv + 8, seq);
+                AV_WB32(cur_init_section->iv + 12, seq);
             }
 
             if (key_type != KEY_NONE) {
@@ -896,9 +889,9 @@
                 if (has_iv) {
                     memcpy(seg->iv, iv, sizeof(iv));
                 } else {
-                    int64_t seq = pls->start_seq_no + pls->n_segments;
+                    int seq = pls->start_seq_no + pls->n_segments;
                     memset(seg->iv, 0, sizeof(seg->iv));
-                    AV_WB64(seg->iv + 8, seq);
+                    AV_WB32(seg->iv + 12, seq);
                 }
 
                 if (key_type != KEY_NONE) {
@@ -961,17 +954,16 @@
     if (prev_segments) {
         if (pls->start_seq_no > prev_start_seq_no && c->first_timestamp != AV_NOPTS_VALUE) {
             int64_t prev_timestamp = c->first_timestamp;
-            int i;
-            int64_t diff = pls->start_seq_no - prev_start_seq_no;
+            int i, diff = pls->start_seq_no - prev_start_seq_no;
             for (i = 0; i < prev_n_segments && i < diff; i++) {
                 c->first_timestamp += prev_segments[i]->duration;
             }
-            av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%"PRId64" -> %"PRId64")"
+            av_log(c->ctx, AV_LOG_DEBUG, "Media sequence change (%d -> %d)"
                    " reflected in first_timestamp: %"PRId64" -> %"PRId64"\n",
                    prev_start_seq_no, pls->start_seq_no,
                    prev_timestamp, c->first_timestamp);
         } else if (pls->start_seq_no < prev_start_seq_no) {
-            av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed unexpectedly: %"PRId64" -> %"PRId64"\n",
+            av_log(c->ctx, AV_LOG_WARNING, "Media sequence changed unexpectedly: %d -> %d\n",
                    prev_start_seq_no, pls->start_seq_no);
         }
         free_segment_dynarray(prev_segments, prev_n_segments);
@@ -999,7 +991,7 @@
 
 static struct segment *next_segment(struct playlist *pls)
 {
-    int64_t n = pls->cur_seq_no - pls->start_seq_no + 1;
+    int n = pls->cur_seq_no - pls->start_seq_no + 1;
     if (n >= pls->n_segments)
         return NULL;
     return pls->segments[n];
@@ -1465,7 +1457,7 @@
         }
         if (v->cur_seq_no < v->start_seq_no) {
             av_log(v->parent, AV_LOG_WARNING,
-                   "skipping %"PRId64" segments ahead, expired from playlists\n",
+                   "skipping %d segments ahead, expired from playlists\n",
                    v->start_seq_no - v->cur_seq_no);
             v->cur_seq_no = v->start_seq_no;
         }
@@ -1511,7 +1503,7 @@
         if (ret < 0) {
             if (ff_check_interrupt(c->interrupt_callback))
                 return AVERROR_EXIT;
-            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %"PRId64" of playlist %d\n",
+            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %d of playlist %d\n",
                    v->cur_seq_no,
                    v->index);
             v->cur_seq_no += 1;
@@ -1536,7 +1528,7 @@
         if (ret < 0) {
             if (ff_check_interrupt(c->interrupt_callback))
                 return AVERROR_EXIT;
-            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %"PRId64" of playlist %d\n",
+            av_log(v->parent, AV_LOG_WARNING, "Failed to open next segment %d of playlist %d\n",
                    v->cur_seq_no + 1,
                    v->index);
         } else {
@@ -1633,7 +1625,7 @@
 /* if timestamp was in valid range: returns 1 and sets seq_no
  * if not: returns 0 and sets seq_no to closest segment */
 static int find_timestamp_in_playlist(HLSContext *c, struct playlist *pls,
-                                      int64_t timestamp, int64_t *seq_no)
+                                      int64_t timestamp, int *seq_no)
 {
     int i;
     int64_t pos = c->first_timestamp == AV_NOPTS_VALUE ?
@@ -1658,9 +1650,9 @@
     return 0;
 }
 
-static int64_t select_cur_seq_no(HLSContext *c, struct playlist *pls)
+static int select_cur_seq_no(HLSContext *c, struct playlist *pls)
 {
-    int64_t seq_no;
+    int seq_no;
 
     if (!pls->finished && !c->first_packet &&
         av_gettime_relative() - pls->last_load_time >= default_reload_interval(pls))
@@ -1852,7 +1844,7 @@
 {
     HLSContext *c = s->priv_data;
     int ret = 0, i;
-    int64_t highest_cur_seq_no = 0;
+    int highest_cur_seq_no = 0;
 
     c->ctx                = s;
     c->interrupt_callback = &s->interrupt_callback;
@@ -2085,7 +2077,7 @@
                 pls->seek_flags = AVSEEK_FLAG_ANY;
                 pls->seek_stream_index = -1;
             }
-            av_log(s, AV_LOG_INFO, "Now receiving playlist %d, segment %"PRId64"\n", i, pls->cur_seq_no);
+            av_log(s, AV_LOG_INFO, "Now receiving playlist %d, segment %d\n", i, pls->cur_seq_no);
         } else if (first && !cur_needed && pls->needed) {
             ff_format_io_close(pls->parent, &pls->input);
             pls->input_read_done = 0;
@@ -2282,10 +2274,10 @@
 {
     HLSContext *c = s->priv_data;
     struct playlist *seek_pls = NULL;
-    int i, j;
+    int i, seq_no;
+    int j;
     int stream_subdemuxer_index;
     int64_t first_timestamp, seek_timestamp, duration;
-    int64_t seq_no;
 
     if ((flags & AVSEEK_FLAG_BYTE) || (c->ctx->ctx_flags & AVFMTCTX_UNSEEKABLE))
         return AVERROR(ENOSYS);
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 7d97ce1..cafe0e8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -196,8 +196,8 @@
     int64_t start_sequence;
     uint32_t start_sequence_source_type;  // enum StartSequenceSourceType
 
-    int64_t time;          // Set by a private option.
-    int64_t init_time;     // Set by a private option.
+    float time;            // Set by a private option.
+    float init_time;       // Set by a private option.
     int max_nb_segments;   // Set by a private option.
     int hls_delete_threshold; // Set by a private option.
 #if FF_API_HLS_WRAP
@@ -1564,10 +1564,6 @@
         sequence = 0;
     }
 
-    if (hls->flags & HLS_I_FRAMES_ONLY) {
-        hls->version = 4;
-    }
-
     if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
         hls->version = 6;
     }
@@ -2458,9 +2454,9 @@
 
     if (vs->sequence - vs->nb_entries > hls->start_sequence && hls->init_time > 0) {
         /* reset end_pts, hls->recording_time at end of the init hls list */
-        int64_t init_list_dur = hls->init_time * vs->nb_entries;
-        int64_t after_init_list_dur = (vs->sequence - hls->start_sequence - vs->nb_entries) * hls->time;
-        hls->recording_time = hls->time;
+        int64_t init_list_dur = hls->init_time * vs->nb_entries * AV_TIME_BASE;
+        int64_t after_init_list_dur = (vs->sequence - hls->start_sequence - vs->nb_entries) * (hls->time * AV_TIME_BASE);
+        hls->recording_time = hls->time * AV_TIME_BASE;
         end_pts = init_list_dur + after_init_list_dur ;
     }
 
@@ -2945,7 +2941,7 @@
         av_log(hls, AV_LOG_DEBUG, "start_number evaluated to %"PRId64"\n", hls->start_sequence);
     }
 
-    hls->recording_time = hls->init_time ? hls->init_time : hls->time;
+    hls->recording_time = (hls->init_time ? hls->init_time : hls->time) * AV_TIME_BASE;
 
     if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & HLS_INDEPENDENT_SEGMENTS) {
         // Independent segments cannot be guaranteed when splitting by time
@@ -3036,8 +3032,8 @@
 
                     r = strftime_expand(vs->fmp4_init_filename, &expanded);
                     if (r < 0) {
-                        av_log(s, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
-                        return r;
+                      av_log(s, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
+                      return r;
                     }
                     av_free(vs->fmp4_init_filename);
                     vs->fmp4_init_filename = expanded;
@@ -3098,7 +3094,7 @@
                 av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time,"
                        " hls_init_time value will have no effect\n");
                 hls->init_time = 0;
-                hls->recording_time = hls->time;
+                hls->recording_time = hls->time * AV_TIME_BASE;
             }
         }
 
@@ -3114,8 +3110,8 @@
 #define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
     {"start_number",  "set first number in the sequence",        OFFSET(start_sequence),AV_OPT_TYPE_INT64,  {.i64 = 0},     0, INT64_MAX, E},
-    {"hls_time",      "set segment length",                      OFFSET(time),          AV_OPT_TYPE_DURATION, {.i64 = 2000000}, 0, INT64_MAX, E},
-    {"hls_init_time", "set segment length at init list",         OFFSET(init_time),     AV_OPT_TYPE_DURATION, {.i64 = 0},       0, INT64_MAX, E},
+    {"hls_time",      "set segment length in seconds",           OFFSET(time),    AV_OPT_TYPE_FLOAT,  {.dbl = 2},     0, FLT_MAX, E},
+    {"hls_init_time", "set segment length in seconds at init list",           OFFSET(init_time),    AV_OPT_TYPE_FLOAT,  {.dbl = 0},     0, FLT_MAX, E},
     {"hls_list_size", "set maximum number of playlist entries",  OFFSET(max_nb_segments),    AV_OPT_TYPE_INT,    {.i64 = 5},     0, INT_MAX, E},
     {"hls_delete_threshold", "set number of unreferenced segments to keep before deleting",  OFFSET(hls_delete_threshold),    AV_OPT_TYPE_INT,    {.i64 = 1},     1, INT_MAX, E},
     {"hls_ts_options","set hls mpegts list of options for the container format used for hls", OFFSET(format_options), AV_OPT_TYPE_DICT, {.str = NULL},  0, 0,    E},
diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c
index 9e78f93..de45f77 100644
--- a/libavformat/hlsproto.c
+++ b/libavformat/hlsproto.c
@@ -22,7 +22,7 @@
 /**
  * @file
  * Apple HTTP Live Streaming Protocol Handler
- * https://www.rfc-editor.org/rfc/rfc8216.txt
+ * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
 #include "libavutil/avstring.h"
diff --git a/libavformat/http.c b/libavformat/http.c
index d44bc64..2d24c00 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -78,6 +78,9 @@
     char *http_version;
     char *user_agent;
     char *referer;
+#if FF_API_HTTP_USER_AGENT
+    char *user_agent_deprecated;
+#endif
     char *content_type;
     /* Set if the server correctly handles Connection: close and will close
      * the connection after feeding us the content. */
@@ -116,10 +119,8 @@
     char *method;
     int reconnect;
     int reconnect_at_eof;
-    int reconnect_on_network_error;
     int reconnect_streamed;
     int reconnect_delay_max;
-    char *reconnect_on_http_error;
     int listen;
     char *resource;
     int reply_code;
@@ -142,7 +143,7 @@
     { "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D },
     { "referer", "override referer header", OFFSET(referer), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
 #if FF_API_HTTP_USER_AGENT
-    { "user-agent", "use the \"user_agent\" option instead", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D|AV_OPT_FLAG_DEPRECATED },
+    { "user-agent", "use the \"user_agent\" option instead", OFFSET(user_agent_deprecated), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D|AV_OPT_FLAG_DEPRECATED },
 #endif
     { "multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D | E },
     { "post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D | E },
@@ -163,8 +164,6 @@
     { "method", "Override the HTTP method or set the expected HTTP method from a client", OFFSET(method), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E },
     { "reconnect", "auto reconnect after disconnect before EOF", OFFSET(reconnect), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
     { "reconnect_at_eof", "auto reconnect at EOF", OFFSET(reconnect_at_eof), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
-    { "reconnect_on_network_error", "auto reconnect in case of tcp/tls error during connect", OFFSET(reconnect_on_network_error), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
-    { "reconnect_on_http_error", "list of http status codes to reconnect on", OFFSET(reconnect_on_http_error), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
     { "reconnect_streamed", "auto reconnect streamed / non seekable streams", OFFSET(reconnect_streamed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
     { "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D },
     { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E },
@@ -259,73 +258,21 @@
     return location_changed;
 }
 
-static int http_should_reconnect(HTTPContext *s, int err)
-{
-    const char *status_group;
-    char http_code[4];
-
-    switch (err) {
-    case AVERROR_HTTP_BAD_REQUEST:
-    case AVERROR_HTTP_UNAUTHORIZED:
-    case AVERROR_HTTP_FORBIDDEN:
-    case AVERROR_HTTP_NOT_FOUND:
-    case AVERROR_HTTP_OTHER_4XX:
-        status_group = "4xx";
-        break;
-
-    case AVERROR_HTTP_SERVER_ERROR:
-        status_group = "5xx";
-        break;
-
-    default:
-        return s->reconnect_on_network_error;
-    }
-
-    if (!s->reconnect_on_http_error)
-        return 0;
-
-    if (av_match_list(status_group, s->reconnect_on_http_error, ',') > 0)
-        return 1;
-
-    snprintf(http_code, sizeof(http_code), "%d", s->http_code);
-
-    return av_match_list(http_code, s->reconnect_on_http_error, ',') > 0;
-}
-
 /* return non zero if error */
 static int http_open_cnx(URLContext *h, AVDictionary **options)
 {
     HTTPAuthType cur_auth_type, cur_proxy_auth_type;
     HTTPContext *s = h->priv_data;
     int location_changed, attempts = 0, redirects = 0;
-    int reconnect_delay = 0;
-    uint64_t off;
-
 redo:
     av_dict_copy(options, s->chained_options, 0);
 
     cur_auth_type       = s->auth_state.auth_type;
     cur_proxy_auth_type = s->auth_state.auth_type;
 
-    off = s->off;
     location_changed = http_open_cnx_internal(h, options);
-    if (location_changed < 0) {
-        if (!http_should_reconnect(s, location_changed) ||
-            reconnect_delay > s->reconnect_delay_max)
-            goto fail;
-
-        av_log(h, AV_LOG_WARNING, "Will reconnect at %"PRIu64" in %d second(s).\n", off, reconnect_delay);
-        location_changed = ff_network_sleep_interruptible(1000U * 1000 * reconnect_delay, &h->interrupt_callback);
-        if (location_changed != AVERROR(ETIMEDOUT))
-            goto fail;
-        reconnect_delay = 1 + 2 * reconnect_delay;
-
-        /* restore the offset (http_connect resets it) */
-        s->off = off;
-
-        ffurl_closep(&s->hd);
-        goto redo;
-    }
+    if (location_changed < 0)
+        goto fail;
 
     attempts++;
     if (s->http_code == 401) {
@@ -345,7 +292,7 @@
             goto fail;
     }
     if ((s->http_code == 301 || s->http_code == 302 ||
-         s->http_code == 303 || s->http_code == 307 || s->http_code == 308) &&
+         s->http_code == 303 || s->http_code == 307) &&
         location_changed == 1) {
         /* url moved, get next */
         ffurl_closep(&s->hd);
@@ -1318,6 +1265,12 @@
         }
     }
 
+#if FF_API_HTTP_USER_AGENT
+    if (strcmp(s->user_agent_deprecated, DEFAULT_USER_AGENT)) {
+        s->user_agent = av_strdup(s->user_agent_deprecated);
+    }
+#endif
+
     av_bprintf(&request, "%s ", method);
     bprint_escaped_path(&request, path);
     av_bprintf(&request, " HTTP/1.1\r\n");
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index df11b54..336a396 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -605,10 +605,7 @@
 
     /* mimetype */
     if (isv34) {
-        int ret = avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
-        if (ret < 0 || ret >= taglen)
-            goto fail;
-        taglen -= ret;
+        taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
     } else {
         if (avio_read(pb, mimetype, 3) < 0)
             goto fail;
@@ -998,8 +995,6 @@
 
                     if (tlen <= 0)
                         goto seek;
-                    if (dlen / 32768 > tlen)
-                        goto seek;
 
                     av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen);
                     if (!uncompressed_buffer) {
diff --git a/libavformat/iff.c b/libavformat/iff.c
index b07b6c8..f017684 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -368,7 +368,7 @@
         data_size = iff->is_64bit ? avio_rb64(pb) : avio_rb32(pb);
         data_pos = avio_tell(pb);
 
-        if (data_size < 1 || data_size >= INT64_MAX)
+        if (data_size < 1)
             return AVERROR_INVALIDDATA;
 
         switch (chunk_id) {
@@ -763,7 +763,7 @@
         st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
         st->codecpar->bit_rate = (int64_t)st->codecpar->channels * st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample;
         st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample;
-        if ((st->codecpar->codec_tag == ID_DSD || st->codecpar->codec_tag == ID_MAUD) && st->codecpar->block_align <= 0)
+        if (st->codecpar->codec_tag == ID_DSD && st->codecpar->block_align <= 0)
             return AVERROR_INVALIDDATA;
         break;
 
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 6c78dad..ccb933a 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -817,7 +817,7 @@
         return AVPROBE_SCORE_EXTENSION + 1;
     if (state == SOS)
         return AVPROBE_SCORE_EXTENSION / 2;
-    return AVPROBE_SCORE_EXTENSION / 8 + 1;
+    return AVPROBE_SCORE_EXTENSION / 8;
 }
 
 static int jpegls_probe(const AVProbeData *p)
@@ -993,7 +993,7 @@
 
 static int pbm_probe(const AVProbeData *p)
 {
-    return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) || pnm_magic_check(p, 22) || pnm_magic_check(p, 54) ? pnm_probe(p) : 0;
+    return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) ? pnm_probe(p) : 0;
 }
 
 static inline int pgmx_probe(const AVProbeData *p)
@@ -1031,16 +1031,6 @@
     return pnm_magic_check(p, 7) ? pnm_probe(p) : 0;
 }
 
-static int xbm_probe(const AVProbeData *p)
-{
-    if (!memcmp(p->buf, "/* XBM X10 format */", 20))
-        return AVPROBE_SCORE_MAX;
-
-    if (!memcmp(p->buf, "#define", 7))
-        return AVPROBE_SCORE_MAX - 1;
-    return 0;
-}
-
 static int xpm_probe(const AVProbeData *p)
 {
     const uint8_t *b = p->buf;
@@ -1149,6 +1139,5 @@
 IMAGEAUTO_DEMUXER(svg,     AV_CODEC_ID_SVG)
 IMAGEAUTO_DEMUXER(tiff,    AV_CODEC_ID_TIFF)
 IMAGEAUTO_DEMUXER(webp,    AV_CODEC_ID_WEBP)
-IMAGEAUTO_DEMUXER(xbm,     AV_CODEC_ID_XBM)
 IMAGEAUTO_DEMUXER(xpm,     AV_CODEC_ID_XPM)
 IMAGEAUTO_DEMUXER(xwd,     AV_CODEC_ID_XWD)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 0f7a21f..b303d38 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -260,7 +260,7 @@
 AVOutputFormat ff_image2_muxer = {
     .name           = "image2",
     .long_name      = NULL_IF_CONFIG_SMALL("image2 sequence"),
-    .extensions     = "bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png,"
+    .extensions     = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,"
                       "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24,"
                       "sunras,xbm,xface,pix,y",
     .priv_data_size = sizeof(VideoMuxData),
diff --git a/libavformat/imx.c b/libavformat/imx.c
deleted file mode 100644
index d203ed7..0000000
--- a/libavformat/imx.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Simbiosis game demuxer
- *
- * Copyright (C) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "avformat.h"
-#include "internal.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/avassert.h"
-#include "libavutil/internal.h"
-
-#define IMX_TAG MKTAG('I', 'M', 'A', 'X')
-
-typedef struct SimbiosisIMXDemuxContext {
-    uint8_t pal[AVPALETTE_SIZE];
-    int pal_changed;
-    int64_t first_video_packet_pos;
-} SimbiosisIMXDemuxContext;
-
-static int simbiosis_imx_probe(const AVProbeData *p)
-{
-    if (AV_RL32(p->buf) != IMX_TAG)
-        return 0;
-    if (AV_RN32(p->buf+4) == 0)
-        return 0;
-    if (AV_RN16(p->buf+8) == 0)
-        return 0;
-    if (AV_RL16(p->buf+10) != 0x102)
-        return 0;
-
-    return AVPROBE_SCORE_EXTENSION + 10;
-}
-
-static int simbiosis_imx_read_header(AVFormatContext *s)
-{
-    AVIOContext *pb = s->pb;
-    AVStream *vst, *ast;
-    int rate;
-
-    vst = avformat_new_stream(s, NULL);
-    ast = avformat_new_stream(s, NULL);
-    if (!vst || !ast)
-        return AVERROR(ENOMEM);
-
-    avio_skip(pb, 4);
-
-    vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
-    vst->codecpar->codec_tag  = 0;
-    vst->codecpar->format     = AV_PIX_FMT_PAL8;
-    vst->codecpar->codec_id   = AV_CODEC_ID_SIMBIOSIS_IMX;
-    vst->start_time = 0;
-    vst->duration =
-    vst->nb_frames = avio_rl32(pb);
-    rate = avio_rl16(pb);
-    avio_skip(pb, 12);
-
-    avpriv_set_pts_info(vst, 64, 1, rate);
-
-    ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
-    ast->codecpar->codec_tag  = 0;
-    ast->codecpar->codec_id   = AV_CODEC_ID_PCM_U8;
-    ast->codecpar->channels   = 1;
-    ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
-    ast->codecpar->sample_rate = 22050;
-    ast->start_time = 0;
-
-    avpriv_set_pts_info(ast, 64, 1, 22050);
-
-    return 0;
-}
-
-static int simbiosis_imx_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    AVIOContext *pb = s->pb;
-    SimbiosisIMXDemuxContext *imx = s->priv_data;
-    uint32_t chunk_size, chunk_type;
-    int64_t pos = avio_tell(pb);
-    int ret, idx = -1;
-
-retry:
-    if (avio_feof(pb))
-        return AVERROR_EOF;
-
-    chunk_size = avio_rl32(pb);
-    chunk_type = avio_rl32(pb);
-
-    switch (chunk_type) {
-    case 0xAAFF:
-        return AVERROR_EOF;
-    case 0xAA99:
-        idx = 1;
-        break;
-    case 0xAA97:
-        idx = 0;
-        if (!imx->first_video_packet_pos)
-            imx->first_video_packet_pos = pos;
-        break;
-    case 0xAA98:
-        for (int i = 0; i < chunk_size / 3; i++) {
-            unsigned r = avio_r8(pb) << 18;
-            unsigned g = avio_r8(pb) << 10;
-            unsigned b = avio_r8(pb) <<  2;
-
-            AV_WL32(imx->pal + i * 4, (0xFFU << 24) | r | g | b);
-        }
-        imx->pal_changed = 1;
-        idx = -1;
-        break;
-    default:
-        return AVERROR_INVALIDDATA;
-    }
-
-    if (idx == -1)
-        goto retry;
-
-    ret = av_get_packet(pb, pkt, chunk_size);
-    if (ret < 0)
-        return ret;
-
-    if (imx->pal_changed && idx == 0) {
-        uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
-                                               AVPALETTE_SIZE);
-        if (!pal)
-            return AVERROR(ENOMEM);
-        memcpy(pal, imx->pal, AVPALETTE_SIZE);
-        imx->pal_changed = 0;
-        if (pos <= imx->first_video_packet_pos)
-            pkt->flags |= AV_PKT_FLAG_KEY;
-    } else if (idx == 1) {
-        pkt->flags |= AV_PKT_FLAG_KEY;
-    }
-
-    pkt->pos = pos;
-    pkt->stream_index = idx;
-    pkt->duration = idx ? chunk_size : 1;
-
-    return ret;
-}
-
-AVInputFormat ff_simbiosis_imx_demuxer = {
-    .name           = "simbiosis_imx",
-    .long_name      = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX"),
-    .priv_data_size = sizeof(SimbiosisIMXDemuxContext),
-    .read_probe     = simbiosis_imx_probe,
-    .read_header    = simbiosis_imx_read_header,
-    .read_packet    = simbiosis_imx_read_packet,
-    .extensions     = "imx",
-    .flags          = AVFMT_GENERIC_INDEX,
-};
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 0ffdc87..49e82bf 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -142,11 +142,6 @@
      * Prefer the codec framerate for avg_frame_rate computation.
      */
     int prefer_codec_framerate;
-
-    /**
-     * Set if chapter ids are strictly monotonic.
-     */
-    int chapter_ids_monotonic;
 };
 
 struct AVStreamInternal {
@@ -365,6 +360,8 @@
 } while(0)
 #endif
 
+struct tm *ff_brktimegm(time_t secs, struct tm *tm);
+
 /**
  * Automatically create sub-directories
  *
@@ -865,12 +862,15 @@
 
 /**
  * Find the next packet in the interleaving queue for the given stream.
+ * The pkt parameter is filled in with the queued packet, including
+ * references to the data (which the caller is not allowed to keep or
+ * modify).
  *
- * @return a pointer to a packet if one was found, NULL otherwise.
+ * @return 0 if a packet was found, a negative value if no packet was found
  */
-const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream);
+int ff_interleaved_peek(AVFormatContext *s, int stream,
+                        AVPacket *pkt, int add_offset);
 
-int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset);
 
 int ff_lock_avformat(void);
 int ff_unlock_avformat(void);
diff --git a/libavformat/ircamdec.c b/libavformat/ircamdec.c
index db09f60..17bfb4e 100644
--- a/libavformat/ircamdec.c
+++ b/libavformat/ircamdec.c
@@ -66,12 +66,12 @@
     }
 
     if (le == 1) {
-        sample_rate = lrintf(av_int2float(avio_rl32(s->pb)));
+        sample_rate = av_int2float(avio_rl32(s->pb));
         channels    = avio_rl32(s->pb);
         tag         = avio_rl32(s->pb);
         tags        = ff_codec_ircam_le_tags;
     } else if (le == 0) {
-        sample_rate = lrintf(av_int2float(avio_rb32(s->pb)));
+        sample_rate = av_int2float(avio_rb32(s->pb));
         channels    = avio_rb32(s->pb);
         tag         = avio_rb32(s->pb);
         tags        = ff_codec_ircam_be_tags;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index df98779..d1ef6e3 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -72,6 +72,315 @@
     { AV_CODEC_ID_NONE        ,    0 },
 };
 
+const AVCodecTag ff_codec_movvideo_tags[] = {
+/*  { AV_CODEC_ID_, MKTAG('I', 'V', '5', '0') }, *//* Indeo 5.0 */
+
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('r', 'a', 'w', ' ') }, /* uncompressed RGB */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', '2') }, /* uncompressed YUV422 */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, /* uncompressed 8-bit 4:2:2 */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') }, /* same as 2VUY but byte-swapped */
+
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('L', '5', '5', '5') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('L', '5', '6', '5') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('B', '5', '6', '5') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('2', '4', 'B', 'G') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 'A') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 'A') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '1', '6', 'g') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '4', '8', 'r') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '6', '4', 'a') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', 'x', 'b', 'g') }, /* BOXX */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', 'x', 'r', 'g') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', 'x', 'y', 'v') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('N', 'O', '1', '6') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '2', '0') }, /* Radius DV YUV PAL */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '1', '1') }, /* Radius DV YUV NTSC */
+
+    { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'k') }, /* uncompressed 10-bit RGB */
+    { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'g') }, /* uncompressed 10-bit RGB */
+    { AV_CODEC_ID_R210,   MKTAG('r', '2', '1', '0') }, /* uncompressed 10-bit RGB */
+    { AV_CODEC_ID_AVUI,   MKTAG('A', 'V', 'U', 'I') }, /* AVID Uncompressed deinterleaved UYVY422 */
+    { AV_CODEC_ID_AVRP,   MKTAG('A', 'V', 'r', 'p') }, /* Avid 1:1 10-bit RGB Packer */
+    { AV_CODEC_ID_AVRP,   MKTAG('S', 'U', 'D', 'S') }, /* Avid DS Uncompressed */
+    { AV_CODEC_ID_V210,   MKTAG('v', '2', '1', '0') }, /* uncompressed 10-bit 4:2:2 */
+    { AV_CODEC_ID_V210,   MKTAG('b', 'x', 'y', '2') }, /* BOXX 10-bit 4:2:2 */
+    { AV_CODEC_ID_V308,   MKTAG('v', '3', '0', '8') }, /* uncompressed  8-bit 4:4:4 */
+    { AV_CODEC_ID_V408,   MKTAG('v', '4', '0', '8') }, /* uncompressed  8-bit 4:4:4:4 */
+    { AV_CODEC_ID_V410,   MKTAG('v', '4', '1', '0') }, /* uncompressed 10-bit 4:4:4 */
+    { AV_CODEC_ID_Y41P,   MKTAG('Y', '4', '1', 'P') }, /* uncompressed 12-bit 4:1:1 */
+    { AV_CODEC_ID_YUV4,   MKTAG('y', 'u', 'v', '4') }, /* libquicktime packed yuv420p */
+    { AV_CODEC_ID_TARGA_Y216, MKTAG('Y', '2', '1', '6') },
+
+    { AV_CODEC_ID_MJPEG,  MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */
+    { AV_CODEC_ID_MJPEG,  MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */
+    { AV_CODEC_ID_AVRN ,  MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */
+/*  { AV_CODEC_ID_MJPEG,  MKTAG('A', 'V', 'R', 'n') }, *//* MJPEG with alpha-channel (AVID ABVB/Truevision NuVista) */
+    { AV_CODEC_ID_MJPEG,  MKTAG('d', 'm', 'b', '1') }, /* Motion JPEG OpenDML */
+    { AV_CODEC_ID_MJPEGB, MKTAG('m', 'j', 'p', 'b') }, /* Motion-JPEG (format B) */
+
+    { AV_CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, /* Sorenson Video v1 */
+    { AV_CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, /* Sorenson Video v1 */
+    { AV_CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', 'i') }, /* Sorenson Video v1 (from QT specs)*/
+    { AV_CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, /* Sorenson Video v3 */
+
+    { AV_CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, /* OpenDiVX *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
+    { AV_CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
+    { AV_CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') }, /* experimental: 3IVX files before ivx D4 4.5.1 */
+
+    { AV_CODEC_ID_H263, MKTAG('h', '2', '6', '3') }, /* H.263 */
+    { AV_CODEC_ID_H263, MKTAG('s', '2', '6', '3') }, /* H.263 ?? works */
+
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL produced by FCP */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL produced by FCP */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC produced by FCP */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, /* AVID DV */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', '1') }, /* AVID DV100 */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'q') }, /* DVCPRO HD 720p50 */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'p') }, /* DVCPRO HD 720p60 */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '2') },
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '4') },
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '5') }, /* DVCPRO HD 50i produced by FCP */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '6') }, /* DVCPRO HD 60i produced by FCP */
+    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '3') }, /* DVCPRO HD 30p produced by FCP */
+
+    { AV_CODEC_ID_VP3,     MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */
+    { AV_CODEC_ID_RPZA,    MKTAG('r', 'p', 'z', 'a') }, /* Apple Video (RPZA) */
+    { AV_CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, /* Cinepak */
+    { AV_CODEC_ID_8BPS,    MKTAG('8', 'B', 'P', 'S') }, /* Planar RGB (8BPS) */
+    { AV_CODEC_ID_SMC,     MKTAG('s', 'm', 'c', ' ') }, /* Apple Graphics (SMC) */
+    { AV_CODEC_ID_QTRLE,   MKTAG('r', 'l', 'e', ' ') }, /* Apple Animation (RLE) */
+    { AV_CODEC_ID_SGIRLE,  MKTAG('r', 'l', 'e', '1') }, /* SGI RLE 8-bit */
+    { AV_CODEC_ID_MSRLE,   MKTAG('W', 'R', 'L', 'E') },
+    { AV_CODEC_ID_QDRAW,   MKTAG('q', 'd', 'r', 'w') }, /* QuickDraw */
+    { AV_CODEC_ID_CDTOONS, MKTAG('Q', 'k', 'B', 'k') }, /* CDToons */
+
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('W', 'R', 'A', 'W') },
+
+    { AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, /* HEVC/H.265 which indicates parameter sets may be in ES */
+    { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which indicates parameter sets shall not be in ES */
+    { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby Vision derived from hev1 */
+                                                     /* dvh1 is handled within mov.c */
+
+    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') },
+    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') },
+    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '4') },
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', 'p') }, /* AVC-Intra  50M 720p24/30/60 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', 'q') }, /* AVC-Intra  50M 720p25/50 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '2') }, /* AVC-Intra  50M 1080p25/50 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '3') }, /* AVC-Intra  50M 1080p24/30/60 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '5') }, /* AVC-Intra  50M 1080i50 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '6') }, /* AVC-Intra  50M 1080i60 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', 'p') }, /* AVC-Intra 100M 720p24/30/60 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', 'q') }, /* AVC-Intra 100M 720p25/50 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '2') }, /* AVC-Intra 100M 1080p25/50 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '3') }, /* AVC-Intra 100M 1080p24/30/60 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '5') }, /* AVC-Intra 100M 1080i50 */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '6') }, /* AVC-Intra 100M 1080i60 */
+    { AV_CODEC_ID_H264, MKTAG('A', 'V', 'i', 'n') }, /* AVC-Intra with implicit SPS/PPS */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', 'v', 'x') }, /* XAVC 10-bit 4:2:2 */
+    { AV_CODEC_ID_H264, MKTAG('r', 'v', '6', '4') }, /* X-Com Radvision */
+    { AV_CODEC_ID_H264, MKTAG('x', 'a', 'l', 'g') }, /* XAVC-L HD422 produced by FCP */
+    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'l', 'g') }, /* Panasonic P2 AVC-LongG */
+    { AV_CODEC_ID_H264, MKTAG('d', 'v', 'a', '1') }, /* AVC-based Dolby Vision derived from avc1 */
+    { AV_CODEC_ID_H264, MKTAG('d', 'v', 'a', 'v') }, /* AVC-based Dolby Vision derived from avc3 */
+
+    { AV_CODEC_ID_VP8,  MKTAG('v', 'p', '0', '8') }, /* VP8 */
+    { AV_CODEC_ID_VP9,  MKTAG('v', 'p', '0', '9') }, /* VP9 */
+    { AV_CODEC_ID_AV1,  MKTAG('a', 'v', '0', '1') }, /* AV1 */
+
+    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', '1', 'v', ' ') },
+    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', '1', 'v', '1') }, /* Apple MPEG-1 Camcorder */
+    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
+    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', '1', 'v') }, /* CoreMedia CMVideoCodecType */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', '2', 'v', '1') }, /* Apple MPEG-2 Camcorder */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '1') }, /* MPEG-2 HDV 720p30 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '2') }, /* MPEG-2 HDV 1080i60 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '3') }, /* MPEG-2 HDV 1080i50 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '4') }, /* MPEG-2 HDV 720p24 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '5') }, /* MPEG-2 HDV 720p25 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '6') }, /* MPEG-2 HDV 1080p24 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '7') }, /* MPEG-2 HDV 1080p25 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '8') }, /* MPEG-2 HDV 1080p30 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '9') }, /* MPEG-2 HDV 720p60 JVC */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', 'a') }, /* MPEG-2 HDV 720p50 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'n') }, /* MPEG-2 IMX NTSC 525/60 50mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'p') }, /* MPEG-2 IMX PAL 625/50 50mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'n') }, /* MPEG-2 IMX NTSC 525/60 40mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'p') }, /* MPEG-2 IMX PAL 625/50 40mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'n') }, /* MPEG-2 IMX NTSC 525/60 30mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'p') }, /* MPEG-2 IMX PAL 625/50 30mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '1') }, /* XDCAM HD422 720p30 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '4') }, /* XDCAM HD422 720p24 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '5') }, /* XDCAM HD422 720p25 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '9') }, /* XDCAM HD422 720p60 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'a') }, /* XDCAM HD422 720p50 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'b') }, /* XDCAM HD422 1080i60 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'c') }, /* XDCAM HD422 1080i50 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'd') }, /* XDCAM HD422 1080p24 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'e') }, /* XDCAM HD422 1080p25 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'f') }, /* XDCAM HD422 1080p30 CBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '1') }, /* XDCAM EX 720p30 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '2') }, /* XDCAM HD 1080i60 */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '3') }, /* XDCAM HD 1080i50 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '4') }, /* XDCAM EX 720p24 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '5') }, /* XDCAM EX 720p25 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '6') }, /* XDCAM HD 1080p24 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '7') }, /* XDCAM HD 1080p25 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '8') }, /* XDCAM HD 1080p30 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '9') }, /* XDCAM EX 720p60 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'a') }, /* XDCAM EX 720p50 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'b') }, /* XDCAM EX 1080i60 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'c') }, /* XDCAM EX 1080i50 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'd') }, /* XDCAM EX 1080p24 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'e') }, /* XDCAM EX 1080p25 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'f') }, /* XDCAM EX 1080p30 VBR */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', 'd') }, /* XDCAM HD 540p */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', '2') }, /* XDCAM HD422 540p */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('A', 'V', 'm', 'p') }, /* AVID IMX PAL */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', '2', 'v') }, /* FCP5 */
+
+    { AV_CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */
+
+    { AV_CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, /* Truevision Targa */
+    { AV_CODEC_ID_TIFF,  MKTAG('t', 'i', 'f', 'f') }, /* TIFF embedded in MOV */
+    { AV_CODEC_ID_GIF,   MKTAG('g', 'i', 'f', ' ') }, /* embedded gif files as frames (usually one "click to play movie" frame) */
+    { AV_CODEC_ID_PNG,   MKTAG('p', 'n', 'g', ' ') },
+    { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },
+
+    { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
+    { AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
+
+    { AV_CODEC_ID_DIRAC,     MKTAG('d', 'r', 'a', 'c') },
+    { AV_CODEC_ID_DNXHD,     MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
+    { AV_CODEC_ID_DNXHD,     MKTAG('A', 'V', 'd', 'h') }, /* AVID DNxHR */
+    { AV_CODEC_ID_H263,      MKTAG('H', '2', '6', '3') },
+    { AV_CODEC_ID_MSMPEG4V3, MKTAG('3', 'I', 'V', 'D') }, /* 3ivx DivX Doctor */
+    { AV_CODEC_ID_RAWVIDEO,  MKTAG('A', 'V', '1', 'x') }, /* AVID 1:1x */
+    { AV_CODEC_ID_RAWVIDEO,  MKTAG('A', 'V', 'u', 'p') },
+    { AV_CODEC_ID_SGI,       MKTAG('s', 'g', 'i', ' ') }, /* SGI  */
+    { AV_CODEC_ID_DPX,       MKTAG('d', 'p', 'x', ' ') }, /* DPX */
+    { AV_CODEC_ID_EXR,       MKTAG('e', 'x', 'r', ' ') }, /* OpenEXR */
+
+    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'h') }, /* Apple ProRes 422 High Quality */
+    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'n') }, /* Apple ProRes 422 Standard Definition */
+    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 's') }, /* Apple ProRes 422 LT */
+    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'o') }, /* Apple ProRes 422 Proxy */
+    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', '4', 'h') }, /* Apple ProRes 4444 */
+    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', '4', 'x') }, /* Apple ProRes 4444 XQ */
+    { AV_CODEC_ID_FLIC,   MKTAG('f', 'l', 'i', 'c') },
+
+    { AV_CODEC_ID_AIC, MKTAG('i', 'c', 'o', 'd') },
+
+    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', '1') },
+    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', '5') },
+    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'Y') },
+    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'A') },
+    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'M') },
+
+    { AV_CODEC_ID_DXV, MKTAG('D', 'X', 'D', '3') },
+    { AV_CODEC_ID_DXV, MKTAG('D', 'X', 'D', 'I') },
+
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'R', '0') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'R', 'A') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'R', 'G') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '0') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '2') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '4') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'R', 'G') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'R', 'A') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'G', '0') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', '0') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', '2') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', '4') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', 'A') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'A') },
+    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'G') },
+
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '0') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '1') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '2') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '3') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '4') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '5') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '6') },
+    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '7') },
+
+    { AV_CODEC_ID_PIXLET, MKTAG('p', 'x', 'l', 't') },
+
+    { AV_CODEC_ID_NOTCHLC, MKTAG('n', 'c', 'l', 'c') },
+
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'G', 'R') }, /* ASC Bayer BGGR */
+
+    { AV_CODEC_ID_NONE, 0 },
+};
+
+const AVCodecTag ff_codec_movaudio_tags[] = {
+    { AV_CODEC_ID_AAC,             MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_AC3,             MKTAG('a', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */
+    { AV_CODEC_ID_AC3,             MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */
+    { AV_CODEC_ID_ADPCM_IMA_QT,    MKTAG('i', 'm', 'a', '4') },
+    { AV_CODEC_ID_ALAC,            MKTAG('a', 'l', 'a', 'c') },
+    { AV_CODEC_ID_AMR_NB,          MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */
+    { AV_CODEC_ID_AMR_WB,          MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */
+    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'c') }, /* DTS formats prior to DTS-HD */
+    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'h') }, /* DTS-HD audio formats */
+    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'l') }, /* DTS-HD Lossless formats */
+    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'e') }, /* DTS Express */
+    { AV_CODEC_ID_DTS,             MKTAG('D', 'T', 'S', ' ') }, /* non-standard */
+    { AV_CODEC_ID_EAC3,            MKTAG('e', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F (only valid in ISOBMFF) */
+    { AV_CODEC_ID_DVAUDIO,         MKTAG('v', 'd', 'v', 'a') },
+    { AV_CODEC_ID_DVAUDIO,         MKTAG('d', 'v', 'c', 'a') },
+    { AV_CODEC_ID_GSM,             MKTAG('a', 'g', 's', 'm') },
+    { AV_CODEC_ID_ILBC,            MKTAG('i', 'l', 'b', 'c') },
+    { AV_CODEC_ID_MACE3,           MKTAG('M', 'A', 'C', '3') },
+    { AV_CODEC_ID_MACE6,           MKTAG('M', 'A', 'C', '6') },
+    { AV_CODEC_ID_MP1,             MKTAG('.', 'm', 'p', '1') },
+    { AV_CODEC_ID_MP2,             MKTAG('.', 'm', 'p', '2') },
+    { AV_CODEC_ID_MP3,             MKTAG('.', 'm', 'p', '3') },
+    { AV_CODEC_ID_MP3,             MKTAG('m', 'p', '3', ' ') }, /* vlc */
+    { AV_CODEC_ID_MP3,             0x6D730055                },
+    { AV_CODEC_ID_NELLYMOSER,      MKTAG('n', 'm', 'o', 's') }, /* Flash Media Server */
+    { AV_CODEC_ID_NELLYMOSER,      MKTAG('N', 'E', 'L', 'L') }, /* Perian */
+    { AV_CODEC_ID_PCM_ALAW,        MKTAG('a', 'l', 'a', 'w') },
+    { AV_CODEC_ID_PCM_F32BE,       MKTAG('f', 'l', '3', '2') },
+    { AV_CODEC_ID_PCM_F32LE,       MKTAG('f', 'l', '3', '2') },
+    { AV_CODEC_ID_PCM_F64BE,       MKTAG('f', 'l', '6', '4') },
+    { AV_CODEC_ID_PCM_F64LE,       MKTAG('f', 'l', '6', '4') },
+    { AV_CODEC_ID_PCM_MULAW,       MKTAG('u', 'l', 'a', 'w') },
+    { AV_CODEC_ID_PCM_S16BE,       MKTAG('t', 'w', 'o', 's') },
+    { AV_CODEC_ID_PCM_S16LE,       MKTAG('s', 'o', 'w', 't') },
+    { AV_CODEC_ID_PCM_S16BE,       MKTAG('l', 'p', 'c', 'm') },
+    { AV_CODEC_ID_PCM_S16LE,       MKTAG('l', 'p', 'c', 'm') },
+    { AV_CODEC_ID_PCM_S24BE,       MKTAG('i', 'n', '2', '4') },
+    { AV_CODEC_ID_PCM_S24LE,       MKTAG('i', 'n', '2', '4') },
+    { AV_CODEC_ID_PCM_S32BE,       MKTAG('i', 'n', '3', '2') },
+    { AV_CODEC_ID_PCM_S32LE,       MKTAG('i', 'n', '3', '2') },
+    { AV_CODEC_ID_PCM_S8,          MKTAG('s', 'o', 'w', 't') },
+    { AV_CODEC_ID_PCM_U8,          MKTAG('r', 'a', 'w', ' ') },
+    { AV_CODEC_ID_PCM_U8,          MKTAG('N', 'O', 'N', 'E') },
+    { AV_CODEC_ID_QCELP,           MKTAG('Q', 'c', 'l', 'p') },
+    { AV_CODEC_ID_QCELP,           MKTAG('Q', 'c', 'l', 'q') },
+    { AV_CODEC_ID_QCELP,           MKTAG('s', 'q', 'c', 'p') }, /* ISO Media fourcc */
+    { AV_CODEC_ID_QDM2,            MKTAG('Q', 'D', 'M', '2') },
+    { AV_CODEC_ID_QDMC,            MKTAG('Q', 'D', 'M', 'C') },
+    { AV_CODEC_ID_SPEEX,           MKTAG('s', 'p', 'e', 'x') }, /* Flash Media Server */
+    { AV_CODEC_ID_SPEEX,           MKTAG('S', 'P', 'X', 'N') }, /* ZygoAudio (quality 10 mode) */
+    { AV_CODEC_ID_EVRC,            MKTAG('s', 'e', 'v', 'c') }, /* 3GPP2 */
+    { AV_CODEC_ID_SMV,             MKTAG('s', 's', 'm', 'v') }, /* 3GPP2 */
+    { AV_CODEC_ID_FLAC,            MKTAG('f', 'L', 'a', 'C') }, /* nonstandard */
+    { AV_CODEC_ID_TRUEHD,          MKTAG('m', 'l', 'p', 'a') }, /* mp4ra.org */
+    { AV_CODEC_ID_OPUS,            MKTAG('O', 'p', 'u', 's') }, /* mp4ra.org */
+    { AV_CODEC_ID_MPEGH_3D_AUDIO,  MKTAG('m', 'h', 'm', '1') }, /* MPEG-H 3D Audio bitstream */
+    { AV_CODEC_ID_NONE, 0 },
+};
+
 const AVCodecTag ff_codec_movsubtitle_tags[] = {
     { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'e', 'x', 't') },
     { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') },
@@ -418,6 +727,45 @@
     { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY,  (137<<16) | 5}, // kCAFChannelLayoutTag_DVD_11
     { 0, 0},
 };
+#if 0
+int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size)
+{
+    AVCodecContext *codec= st->codec;
+    uint32_t layout_tag;
+    AVIOContext *pb = s->pb;
+    const MovChannelLayout *layouts = mov_channel_layout;
+
+    if (size < 12)
+        return AVERROR_INVALIDDATA;
+
+    layout_tag = avio_rb32(pb);
+    size -= 4;
+    if (layout_tag == 0) { // kCAFChannelLayoutTag_UseChannelDescriptions
+        // Channel descriptions not implemented
+        av_log_ask_for_sample(s, "Unimplemented container channel layout.\n");
+        avio_skip(pb, size);
+        return 0;
+    }
+    if (layout_tag == 0x10000) { // kCAFChannelLayoutTag_UseChannelBitmap
+        codec->channel_layout = avio_rb32(pb);
+        size -= 4;
+        avio_skip(pb, size);
+        return 0;
+    }
+    while (layouts->channel_layout) {
+        if (layout_tag == layouts->layout_tag) {
+            codec->channel_layout = layouts->channel_layout;
+            break;
+        }
+        layouts++;
+    }
+    if (!codec->channel_layout)
+        av_log(s, AV_LOG_WARNING, "Unknown container channel layout.\n");
+    avio_skip(pb, size);
+
+    return 0;
+}
+#endif
 
 void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout)
 {
@@ -439,3 +787,13 @@
     }
     avio_wb32(pb, 0);              // mNumberChannelDescriptions
 }
+
+const struct AVCodecTag *avformat_get_mov_video_tags(void)
+{
+    return ff_codec_movvideo_tags;
+}
+
+const struct AVCodecTag *avformat_get_mov_audio_tags(void)
+{
+    return ff_codec_movaudio_tags;
+}
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
deleted file mode 100644
index 1666b9d..0000000
--- a/libavformat/isom_tags.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * ISO Media codec tags
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002 Francois Revol <revol@free.fr>
- * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavcodec/codec_id.h"
-#include "avformat.h"
-#include "internal.h"
-#include "isom.h"
-
-const AVCodecTag ff_codec_movvideo_tags[] = {
-/*  { AV_CODEC_ID_, MKTAG('I', 'V', '5', '0') }, *//* Indeo 5.0 */
-
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('r', 'a', 'w', ' ') }, /* uncompressed RGB */
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', '2') }, /* uncompressed YUV422 */
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, /* uncompressed 8-bit 4:2:2 */
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') }, /* same as 2VUY but byte-swapped */
-
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('L', '5', '5', '5') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('L', '5', '6', '5') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('B', '5', '6', '5') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('2', '4', 'B', 'G') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 'A') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 'A') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '1', '6', 'g') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '4', '8', 'r') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '6', '4', 'a') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', 'x', 'b', 'g') }, /* BOXX */
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', 'x', 'r', 'g') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('b', 'x', 'y', 'v') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('N', 'O', '1', '6') },
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '2', '0') }, /* Radius DV YUV PAL */
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '1', '1') }, /* Radius DV YUV NTSC */
-
-    { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'k') }, /* uncompressed 10-bit RGB */
-    { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'g') }, /* uncompressed 10-bit RGB */
-    { AV_CODEC_ID_R210,   MKTAG('r', '2', '1', '0') }, /* uncompressed 10-bit RGB */
-    { AV_CODEC_ID_AVUI,   MKTAG('A', 'V', 'U', 'I') }, /* AVID Uncompressed deinterleaved UYVY422 */
-    { AV_CODEC_ID_AVRP,   MKTAG('A', 'V', 'r', 'p') }, /* Avid 1:1 10-bit RGB Packer */
-    { AV_CODEC_ID_AVRP,   MKTAG('S', 'U', 'D', 'S') }, /* Avid DS Uncompressed */
-    { AV_CODEC_ID_V210,   MKTAG('v', '2', '1', '0') }, /* uncompressed 10-bit 4:2:2 */
-    { AV_CODEC_ID_V210,   MKTAG('b', 'x', 'y', '2') }, /* BOXX 10-bit 4:2:2 */
-    { AV_CODEC_ID_V308,   MKTAG('v', '3', '0', '8') }, /* uncompressed  8-bit 4:4:4 */
-    { AV_CODEC_ID_V408,   MKTAG('v', '4', '0', '8') }, /* uncompressed  8-bit 4:4:4:4 */
-    { AV_CODEC_ID_V410,   MKTAG('v', '4', '1', '0') }, /* uncompressed 10-bit 4:4:4 */
-    { AV_CODEC_ID_Y41P,   MKTAG('Y', '4', '1', 'P') }, /* uncompressed 12-bit 4:1:1 */
-    { AV_CODEC_ID_YUV4,   MKTAG('y', 'u', 'v', '4') }, /* libquicktime packed yuv420p */
-    { AV_CODEC_ID_TARGA_Y216, MKTAG('Y', '2', '1', '6') },
-
-    { AV_CODEC_ID_MJPEG,  MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */
-    { AV_CODEC_ID_MJPEG,  MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */
-    { AV_CODEC_ID_MJPEG,  MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */
-    { AV_CODEC_ID_MJPEG,  MKTAG('A', 'V', 'R', 'n') }, /* MJPEG with alpha-channel (AVID ABVB/Truevision NuVista) */
-    { AV_CODEC_ID_MJPEG,  MKTAG('d', 'm', 'b', '1') }, /* Motion JPEG OpenDML */
-    { AV_CODEC_ID_MJPEGB, MKTAG('m', 'j', 'p', 'b') }, /* Motion-JPEG (format B) */
-
-    { AV_CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, /* Sorenson Video v1 */
-    { AV_CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, /* Sorenson Video v1 */
-    { AV_CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', 'i') }, /* Sorenson Video v1 (from QT specs)*/
-    { AV_CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, /* Sorenson Video v3 */
-
-    { AV_CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
-    { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, /* OpenDiVX *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
-    { AV_CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
-    { AV_CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') }, /* experimental: 3IVX files before ivx D4 4.5.1 */
-
-    { AV_CODEC_ID_H263, MKTAG('h', '2', '6', '3') }, /* H.263 */
-    { AV_CODEC_ID_H263, MKTAG('s', '2', '6', '3') }, /* H.263 ?? works */
-
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL produced by FCP */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL produced by FCP */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC produced by FCP */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, /* AVID DV */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', '1') }, /* AVID DV100 */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'q') }, /* DVCPRO HD 720p50 */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'p') }, /* DVCPRO HD 720p60 */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '2') },
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '4') },
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '5') }, /* DVCPRO HD 50i produced by FCP */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '6') }, /* DVCPRO HD 60i produced by FCP */
-    { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '3') }, /* DVCPRO HD 30p produced by FCP */
-
-    { AV_CODEC_ID_VP3,     MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */
-    { AV_CODEC_ID_RPZA,    MKTAG('r', 'p', 'z', 'a') }, /* Apple Video (RPZA) */
-    { AV_CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, /* Cinepak */
-    { AV_CODEC_ID_8BPS,    MKTAG('8', 'B', 'P', 'S') }, /* Planar RGB (8BPS) */
-    { AV_CODEC_ID_SMC,     MKTAG('s', 'm', 'c', ' ') }, /* Apple Graphics (SMC) */
-    { AV_CODEC_ID_QTRLE,   MKTAG('r', 'l', 'e', ' ') }, /* Apple Animation (RLE) */
-    { AV_CODEC_ID_SGIRLE,  MKTAG('r', 'l', 'e', '1') }, /* SGI RLE 8-bit */
-    { AV_CODEC_ID_MSRLE,   MKTAG('W', 'R', 'L', 'E') },
-    { AV_CODEC_ID_QDRAW,   MKTAG('q', 'd', 'r', 'w') }, /* QuickDraw */
-    { AV_CODEC_ID_CDTOONS, MKTAG('Q', 'k', 'B', 'k') }, /* CDToons */
-
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('W', 'R', 'A', 'W') },
-
-    { AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, /* HEVC/H.265 which indicates parameter sets may be in ES */
-    { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which indicates parameter sets shall not be in ES */
-    { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby Vision derived from hev1 */
-                                                     /* dvh1 is handled within mov.c */
-
-    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') },
-    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') },
-    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '4') },
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', 'p') }, /* AVC-Intra  50M 720p24/30/60 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', 'q') }, /* AVC-Intra  50M 720p25/50 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '2') }, /* AVC-Intra  50M 1080p25/50 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '3') }, /* AVC-Intra  50M 1080p24/30/60 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '5') }, /* AVC-Intra  50M 1080i50 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', '6') }, /* AVC-Intra  50M 1080i60 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', 'p') }, /* AVC-Intra 100M 720p24/30/60 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', 'q') }, /* AVC-Intra 100M 720p25/50 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '2') }, /* AVC-Intra 100M 1080p25/50 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '3') }, /* AVC-Intra 100M 1080p24/30/60 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '5') }, /* AVC-Intra 100M 1080i50 */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '6') }, /* AVC-Intra 100M 1080i60 */
-    { AV_CODEC_ID_H264, MKTAG('A', 'V', 'i', 'n') }, /* AVC-Intra with implicit SPS/PPS */
-    { AV_CODEC_ID_H264, MKTAG('a', 'i', 'v', 'x') }, /* XAVC 10-bit 4:2:2 */
-    { AV_CODEC_ID_H264, MKTAG('r', 'v', '6', '4') }, /* X-Com Radvision */
-    { AV_CODEC_ID_H264, MKTAG('x', 'a', 'l', 'g') }, /* XAVC-L HD422 produced by FCP */
-    { AV_CODEC_ID_H264, MKTAG('a', 'v', 'l', 'g') }, /* Panasonic P2 AVC-LongG */
-    { AV_CODEC_ID_H264, MKTAG('d', 'v', 'a', '1') }, /* AVC-based Dolby Vision derived from avc1 */
-    { AV_CODEC_ID_H264, MKTAG('d', 'v', 'a', 'v') }, /* AVC-based Dolby Vision derived from avc3 */
-
-    { AV_CODEC_ID_VP8,  MKTAG('v', 'p', '0', '8') }, /* VP8 */
-    { AV_CODEC_ID_VP9,  MKTAG('v', 'p', '0', '9') }, /* VP9 */
-    { AV_CODEC_ID_AV1,  MKTAG('a', 'v', '0', '1') }, /* AV1 */
-
-    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', '1', 'v', ' ') },
-    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', '1', 'v', '1') }, /* Apple MPEG-1 Camcorder */
-    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
-    { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', '1', 'v') }, /* CoreMedia CMVideoCodecType */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', '2', 'v', '1') }, /* Apple MPEG-2 Camcorder */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '1') }, /* MPEG-2 HDV 720p30 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '2') }, /* MPEG-2 HDV 1080i60 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '3') }, /* MPEG-2 HDV 1080i50 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '4') }, /* MPEG-2 HDV 720p24 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '5') }, /* MPEG-2 HDV 720p25 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '6') }, /* MPEG-2 HDV 1080p24 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '7') }, /* MPEG-2 HDV 1080p25 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '8') }, /* MPEG-2 HDV 1080p30 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '9') }, /* MPEG-2 HDV 720p60 JVC */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', 'a') }, /* MPEG-2 HDV 720p50 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'n') }, /* MPEG-2 IMX NTSC 525/60 50mb/s produced by FCP */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'p') }, /* MPEG-2 IMX PAL 625/50 50mb/s produced by FCP */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'n') }, /* MPEG-2 IMX NTSC 525/60 40mb/s produced by FCP */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'p') }, /* MPEG-2 IMX PAL 625/50 40mb/s produced by FCP */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'n') }, /* MPEG-2 IMX NTSC 525/60 30mb/s produced by FCP */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'p') }, /* MPEG-2 IMX PAL 625/50 30mb/s produced by FCP */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '1') }, /* XDCAM HD422 720p30 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '4') }, /* XDCAM HD422 720p24 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '5') }, /* XDCAM HD422 720p25 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '9') }, /* XDCAM HD422 720p60 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'a') }, /* XDCAM HD422 720p50 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'b') }, /* XDCAM HD422 1080i60 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'c') }, /* XDCAM HD422 1080i50 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'd') }, /* XDCAM HD422 1080p24 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'e') }, /* XDCAM HD422 1080p25 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'f') }, /* XDCAM HD422 1080p30 CBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '1') }, /* XDCAM EX 720p30 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '2') }, /* XDCAM HD 1080i60 */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '3') }, /* XDCAM HD 1080i50 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '4') }, /* XDCAM EX 720p24 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '5') }, /* XDCAM EX 720p25 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '6') }, /* XDCAM HD 1080p24 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '7') }, /* XDCAM HD 1080p25 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '8') }, /* XDCAM HD 1080p30 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', '9') }, /* XDCAM EX 720p60 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'a') }, /* XDCAM EX 720p50 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'b') }, /* XDCAM EX 1080i60 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'c') }, /* XDCAM EX 1080i50 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'd') }, /* XDCAM EX 1080p24 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'e') }, /* XDCAM EX 1080p25 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'f') }, /* XDCAM EX 1080p30 VBR */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', 'd') }, /* XDCAM HD 540p */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', '2') }, /* XDCAM HD422 540p */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('A', 'V', 'm', 'p') }, /* AVID IMX PAL */
-    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', '2', 'v') }, /* FCP5 */
-
-    { AV_CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */
-
-    { AV_CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, /* Truevision Targa */
-    { AV_CODEC_ID_TIFF,  MKTAG('t', 'i', 'f', 'f') }, /* TIFF embedded in MOV */
-    { AV_CODEC_ID_GIF,   MKTAG('g', 'i', 'f', ' ') }, /* embedded gif files as frames (usually one "click to play movie" frame) */
-    { AV_CODEC_ID_PNG,   MKTAG('p', 'n', 'g', ' ') },
-    { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },
-
-    { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
-    { AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
-
-    { AV_CODEC_ID_DIRAC,     MKTAG('d', 'r', 'a', 'c') },
-    { AV_CODEC_ID_DNXHD,     MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
-    { AV_CODEC_ID_DNXHD,     MKTAG('A', 'V', 'd', 'h') }, /* AVID DNxHR */
-    { AV_CODEC_ID_H263,      MKTAG('H', '2', '6', '3') },
-    { AV_CODEC_ID_MSMPEG4V3, MKTAG('3', 'I', 'V', 'D') }, /* 3ivx DivX Doctor */
-    { AV_CODEC_ID_RAWVIDEO,  MKTAG('A', 'V', '1', 'x') }, /* AVID 1:1x */
-    { AV_CODEC_ID_RAWVIDEO,  MKTAG('A', 'V', 'u', 'p') },
-    { AV_CODEC_ID_SGI,       MKTAG('s', 'g', 'i', ' ') }, /* SGI  */
-    { AV_CODEC_ID_DPX,       MKTAG('d', 'p', 'x', ' ') }, /* DPX */
-    { AV_CODEC_ID_EXR,       MKTAG('e', 'x', 'r', ' ') }, /* OpenEXR */
-
-    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'h') }, /* Apple ProRes 422 High Quality */
-    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'n') }, /* Apple ProRes 422 Standard Definition */
-    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 's') }, /* Apple ProRes 422 LT */
-    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'o') }, /* Apple ProRes 422 Proxy */
-    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', '4', 'h') }, /* Apple ProRes 4444 */
-    { AV_CODEC_ID_PRORES, MKTAG('a', 'p', '4', 'x') }, /* Apple ProRes 4444 XQ */
-    { AV_CODEC_ID_FLIC,   MKTAG('f', 'l', 'i', 'c') },
-
-    { AV_CODEC_ID_AIC, MKTAG('i', 'c', 'o', 'd') },
-
-    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', '1') },
-    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', '5') },
-    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'Y') },
-    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'A') },
-    { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'M') },
-
-    { AV_CODEC_ID_DXV, MKTAG('D', 'X', 'D', '3') },
-    { AV_CODEC_ID_DXV, MKTAG('D', 'X', 'D', 'I') },
-
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'R', '0') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'R', 'A') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'R', 'G') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '0') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '2') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '4') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'R', 'G') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'R', 'A') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'G', '0') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', '0') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', '2') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', '4') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', 'A') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'A') },
-    { AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'G') },
-
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '0') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '1') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '2') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '3') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '4') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '5') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '6') },
-    { AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '7') },
-
-    { AV_CODEC_ID_PIXLET, MKTAG('p', 'x', 'l', 't') },
-
-    { AV_CODEC_ID_NOTCHLC, MKTAG('n', 'c', 'l', 'c') },
-
-    { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'G', 'R') }, /* ASC Bayer BGGR */
-
-    { AV_CODEC_ID_NONE, 0 },
-};
-
-const AVCodecTag ff_codec_movaudio_tags[] = {
-    { AV_CODEC_ID_AAC,             MKTAG('m', 'p', '4', 'a') },
-    { AV_CODEC_ID_AC3,             MKTAG('a', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */
-    { AV_CODEC_ID_AC3,             MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */
-    { AV_CODEC_ID_ADPCM_IMA_QT,    MKTAG('i', 'm', 'a', '4') },
-    { AV_CODEC_ID_ALAC,            MKTAG('a', 'l', 'a', 'c') },
-    { AV_CODEC_ID_AMR_NB,          MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */
-    { AV_CODEC_ID_AMR_WB,          MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */
-    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'c') }, /* DTS formats prior to DTS-HD */
-    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'h') }, /* DTS-HD audio formats */
-    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'l') }, /* DTS-HD Lossless formats */
-    { AV_CODEC_ID_DTS,             MKTAG('d', 't', 's', 'e') }, /* DTS Express */
-    { AV_CODEC_ID_DTS,             MKTAG('D', 'T', 'S', ' ') }, /* non-standard */
-    { AV_CODEC_ID_EAC3,            MKTAG('e', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F (only valid in ISOBMFF) */
-    { AV_CODEC_ID_DVAUDIO,         MKTAG('v', 'd', 'v', 'a') },
-    { AV_CODEC_ID_DVAUDIO,         MKTAG('d', 'v', 'c', 'a') },
-    { AV_CODEC_ID_GSM,             MKTAG('a', 'g', 's', 'm') },
-    { AV_CODEC_ID_ILBC,            MKTAG('i', 'l', 'b', 'c') },
-    { AV_CODEC_ID_MACE3,           MKTAG('M', 'A', 'C', '3') },
-    { AV_CODEC_ID_MACE6,           MKTAG('M', 'A', 'C', '6') },
-    { AV_CODEC_ID_MP1,             MKTAG('.', 'm', 'p', '1') },
-    { AV_CODEC_ID_MP2,             MKTAG('.', 'm', 'p', '2') },
-    { AV_CODEC_ID_MP3,             MKTAG('.', 'm', 'p', '3') },
-    { AV_CODEC_ID_MP3,             MKTAG('m', 'p', '3', ' ') }, /* vlc */
-    { AV_CODEC_ID_MP3,             0x6D730055                },
-    { AV_CODEC_ID_NELLYMOSER,      MKTAG('n', 'm', 'o', 's') }, /* Flash Media Server */
-    { AV_CODEC_ID_NELLYMOSER,      MKTAG('N', 'E', 'L', 'L') }, /* Perian */
-    { AV_CODEC_ID_PCM_ALAW,        MKTAG('a', 'l', 'a', 'w') },
-    { AV_CODEC_ID_PCM_F32BE,       MKTAG('f', 'l', '3', '2') },
-    { AV_CODEC_ID_PCM_F32LE,       MKTAG('f', 'l', '3', '2') },
-    { AV_CODEC_ID_PCM_F64BE,       MKTAG('f', 'l', '6', '4') },
-    { AV_CODEC_ID_PCM_F64LE,       MKTAG('f', 'l', '6', '4') },
-    { AV_CODEC_ID_PCM_MULAW,       MKTAG('u', 'l', 'a', 'w') },
-    { AV_CODEC_ID_PCM_S16BE,       MKTAG('t', 'w', 'o', 's') },
-    { AV_CODEC_ID_PCM_S16LE,       MKTAG('s', 'o', 'w', 't') },
-    { AV_CODEC_ID_PCM_S16BE,       MKTAG('l', 'p', 'c', 'm') },
-    { AV_CODEC_ID_PCM_S16LE,       MKTAG('l', 'p', 'c', 'm') },
-    { AV_CODEC_ID_PCM_S24BE,       MKTAG('i', 'n', '2', '4') },
-    { AV_CODEC_ID_PCM_S24LE,       MKTAG('i', 'n', '2', '4') },
-    { AV_CODEC_ID_PCM_S32BE,       MKTAG('i', 'n', '3', '2') },
-    { AV_CODEC_ID_PCM_S32LE,       MKTAG('i', 'n', '3', '2') },
-    { AV_CODEC_ID_PCM_S8,          MKTAG('s', 'o', 'w', 't') },
-    { AV_CODEC_ID_PCM_U8,          MKTAG('r', 'a', 'w', ' ') },
-    { AV_CODEC_ID_PCM_U8,          MKTAG('N', 'O', 'N', 'E') },
-    { AV_CODEC_ID_QCELP,           MKTAG('Q', 'c', 'l', 'p') },
-    { AV_CODEC_ID_QCELP,           MKTAG('Q', 'c', 'l', 'q') },
-    { AV_CODEC_ID_QCELP,           MKTAG('s', 'q', 'c', 'p') }, /* ISO Media fourcc */
-    { AV_CODEC_ID_QDM2,            MKTAG('Q', 'D', 'M', '2') },
-    { AV_CODEC_ID_QDMC,            MKTAG('Q', 'D', 'M', 'C') },
-    { AV_CODEC_ID_SPEEX,           MKTAG('s', 'p', 'e', 'x') }, /* Flash Media Server */
-    { AV_CODEC_ID_SPEEX,           MKTAG('S', 'P', 'X', 'N') }, /* ZygoAudio (quality 10 mode) */
-    { AV_CODEC_ID_EVRC,            MKTAG('s', 'e', 'v', 'c') }, /* 3GPP2 */
-    { AV_CODEC_ID_SMV,             MKTAG('s', 's', 'm', 'v') }, /* 3GPP2 */
-    { AV_CODEC_ID_FLAC,            MKTAG('f', 'L', 'a', 'C') }, /* nonstandard */
-    { AV_CODEC_ID_TRUEHD,          MKTAG('m', 'l', 'p', 'a') }, /* mp4ra.org */
-    { AV_CODEC_ID_OPUS,            MKTAG('O', 'p', 'u', 's') }, /* mp4ra.org */
-    { AV_CODEC_ID_MPEGH_3D_AUDIO,  MKTAG('m', 'h', 'm', '1') }, /* MPEG-H 3D Audio bitstream */
-    { AV_CODEC_ID_NONE, 0 },
-};
-
-const struct AVCodecTag *avformat_get_mov_video_tags(void)
-{
-    return ff_codec_movvideo_tags;
-}
-
-const struct AVCodecTag *avformat_get_mov_audio_tags(void)
-{
-    return ff_codec_movaudio_tags;
-}
diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index 889c004..0951f56 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -23,7 +23,7 @@
 
 typedef struct IVFEncContext {
     unsigned frame_cnt;
-    uint64_t last_pts, sum_delta_pts, last_pkt_duration;
+    uint64_t last_pts, sum_delta_pts;
 } IVFEncContext;
 
 static int ivf_init(AVFormatContext *s)
@@ -86,7 +86,6 @@
     avio_write(pb, pkt->data, pkt->size);
     if (ctx->frame_cnt)
         ctx->sum_delta_pts += pkt->pts - ctx->last_pts;
-    ctx->last_pkt_duration = pkt->duration;
     ctx->frame_cnt++;
     ctx->last_pts = pkt->pts;
 
@@ -98,15 +97,12 @@
     AVIOContext *pb = s->pb;
     IVFEncContext *ctx = s->priv_data;
 
-    if ((pb->seekable & AVIO_SEEKABLE_NORMAL) &&
-        (ctx->frame_cnt > 1 || (ctx->frame_cnt == 1 && ctx->last_pkt_duration))) {
+    if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && ctx->frame_cnt > 1) {
         int64_t end = avio_tell(pb);
 
         avio_seek(pb, 24, SEEK_SET);
         // overwrite the "length" field (duration)
-        avio_wl32(pb, ctx->last_pkt_duration ?
-                  ctx->sum_delta_pts + ctx->last_pkt_duration :
-                  ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
+        avio_wl32(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
         avio_wl32(pb, 0); // zero out unused bytes
         avio_seek(pb, end, SEEK_SET);
     }
diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
index 91e96e9..701c393 100644
--- a/libavformat/latmenc.c
+++ b/libavformat/latmenc.c
@@ -176,8 +176,7 @@
             return ff_raw_write_packet(s, pkt);
         else {
             uint8_t *side_data;
-            buffer_size_t side_data_size;
-            int ret;
+            int side_data_size, ret;
 
             side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
                                                 &side_data_size);
diff --git a/libavformat/libamqp.c b/libavformat/libamqp.c
index c3b9c48..81df724 100644
--- a/libavformat/libamqp.c
+++ b/libavformat/libamqp.c
@@ -62,10 +62,10 @@
 static int amqp_proto_open(URLContext *h, const char *uri, int flags)
 {
     int ret, server_msg;
-    char hostname[STR_LEN], credentials[STR_LEN], path[STR_LEN];
+    char hostname[STR_LEN], credentials[STR_LEN];
     int port;
-    const char *user, *password = NULL, *vhost;
-    const char *user_decoded, *password_decoded, *vhost_decoded;
+    const char *user, *password = NULL;
+    const char *user_decoded, *password_decoded;
     char *p;
     amqp_rpc_reply_t broker_reply;
     struct timeval tval = { 0 };
@@ -76,7 +76,7 @@
     h->max_packet_size = s->pkt_size;
 
     av_url_split(NULL, 0, credentials, sizeof(credentials),
-                 hostname, sizeof(hostname), &port, path, sizeof(path), uri);
+                 hostname, sizeof(hostname), &port, NULL, 0, uri);
 
     if (port < 0)
         port = 5672;
@@ -109,27 +109,8 @@
         return AVERROR(ENOMEM);
     }
 
-    /* skip query for now */
-    p = strchr(path, '?');
-    if (p)
-        *p = '\0';
-
-    vhost = path;
-    if (*vhost == '\0')
-        vhost = "/";
-    else
-        vhost++; /* skip leading '/' */
-
-    vhost_decoded = ff_urldecode(vhost, 0);
-    if (!vhost_decoded) {
-        av_freep(&user_decoded);
-        av_freep(&password_decoded);
-        return AVERROR(ENOMEM);
-    }
-
     s->conn = amqp_new_connection();
     if (!s->conn) {
-        av_freep(&vhost_decoded);
         av_freep(&user_decoded);
         av_freep(&password_decoded);
         av_log(h, AV_LOG_ERROR, "Error creating connection\n");
@@ -155,7 +136,7 @@
         goto destroy_connection;
     }
 
-    broker_reply = amqp_login(s->conn, vhost_decoded, 0, s->pkt_size, 0,
+    broker_reply = amqp_login(s->conn, "/", 0, s->pkt_size, 0,
                               AMQP_SASL_METHOD_PLAIN, user_decoded, password_decoded);
 
     if (broker_reply.reply_type != AMQP_RESPONSE_NORMAL) {
@@ -214,7 +195,6 @@
         }
     }
 
-    av_freep(&vhost_decoded);
     av_freep(&user_decoded);
     av_freep(&password_decoded);
     return 0;
@@ -226,7 +206,6 @@
 destroy_connection:
     amqp_destroy_connection(s->conn);
 
-    av_freep(&vhost_decoded);
     av_freep(&user_decoded);
     av_freep(&password_decoded);
     return AVERROR_EXTERNAL;
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 233e909..f73e7db 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -53,6 +53,7 @@
 typedef struct SRTContext {
     const AVClass *class;
     int fd;
+    int listen_fd;
     int eid;
     int64_t rw_timeout;
     int64_t listen_timeout;
@@ -163,25 +164,15 @@
     return srt_setsockopt(socket, 0, SRTO_RCVSYN, &blocking, sizeof(blocking));
 }
 
-static int libsrt_epoll_create(URLContext *h, int fd, int write)
-{
-    int modes = SRT_EPOLL_ERR | (write ? SRT_EPOLL_OUT : SRT_EPOLL_IN);
-    int eid = srt_epoll_create();
-    if (eid < 0)
-        return libsrt_neterrno(h);
-    if (srt_epoll_add_usock(eid, fd, &modes) < 0) {
-        srt_epoll_release(eid);
-        return libsrt_neterrno(h);
-    }
-    return eid;
-}
-
-static int libsrt_network_wait_fd(URLContext *h, int eid, int write)
+static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write)
 {
     int ret, len = 1, errlen = 1;
+    int modes = SRT_EPOLL_ERR | (write ? SRT_EPOLL_OUT : SRT_EPOLL_IN);
     SRTSOCKET ready[1];
     SRTSOCKET error[1];
 
+    if (srt_epoll_add_usock(eid, fd, &modes) < 0)
+        return libsrt_neterrno(h);
     if (write) {
         ret = srt_epoll_wait(eid, error, &errlen, ready, &len, POLLING_TIME, 0, 0, 0, 0);
     } else {
@@ -195,12 +186,14 @@
     } else {
         ret = errlen ? AVERROR(EIO) : 0;
     }
+    if (srt_epoll_remove_usock(eid, fd) < 0)
+        return libsrt_neterrno(h);
     return ret;
 }
 
 /* TODO de-duplicate code from ff_network_wait_fd_timeout() */
 
-static int libsrt_network_wait_fd_timeout(URLContext *h, int eid, int write, int64_t timeout, AVIOInterruptCB *int_cb)
+static int libsrt_network_wait_fd_timeout(URLContext *h, int eid, int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)
 {
     int ret;
     int64_t wait_start = 0;
@@ -208,7 +201,7 @@
     while (1) {
         if (ff_check_interrupt(int_cb))
             return AVERROR_EXIT;
-        ret = libsrt_network_wait_fd(h, eid, write);
+        ret = libsrt_network_wait_fd(h, eid, fd, write);
         if (ret != AVERROR(EAGAIN))
             return ret;
         if (timeout > 0) {
@@ -227,13 +220,15 @@
     if (srt_setsockopt(fd, SOL_SOCKET, SRTO_REUSEADDR, &reuse, sizeof(reuse))) {
         av_log(h, AV_LOG_WARNING, "setsockopt(SRTO_REUSEADDR) failed\n");
     }
-    if (srt_bind(fd, addr, addrlen))
+    ret = srt_bind(fd, addr, addrlen);
+    if (ret)
         return libsrt_neterrno(h);
 
-    if (srt_listen(fd, 1))
+    ret = srt_listen(fd, 1);
+    if (ret)
         return libsrt_neterrno(h);
 
-    ret = libsrt_network_wait_fd_timeout(h, eid, 1, timeout, &h->interrupt_callback);
+    ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback);
     if (ret < 0)
         return ret;
 
@@ -250,10 +245,11 @@
 {
     int ret;
 
-    if (srt_connect(fd, addr, addrlen) < 0)
+    ret = srt_connect(fd, addr, addrlen);
+    if (ret < 0)
         return libsrt_neterrno(h);
 
-    ret = libsrt_network_wait_fd_timeout(h, eid, 1, timeout, &h->interrupt_callback);
+    ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback);
     if (ret < 0) {
         if (will_try_next) {
             av_log(h, AV_LOG_WARNING,
@@ -367,7 +363,7 @@
 static int libsrt_setup(URLContext *h, const char *uri, int flags)
 {
     struct addrinfo hints = { 0 }, *ai, *cur_ai;
-    int port, fd;
+    int port, fd = -1, listen_fd = -1;
     SRTContext *s = h->priv_data;
     const char *p;
     char buf[256];
@@ -375,7 +371,7 @@
     char hostname[1024],proto[1024],path[1024];
     char portstr[10];
     int64_t open_timeout = 0;
-    int eid, write_eid;
+    int eid;
 
     av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
         &port, path, sizeof(path), uri);
@@ -412,6 +408,11 @@
 
     cur_ai = ai;
 
+    eid = srt_epoll_create();
+    if (eid < 0)
+        return libsrt_neterrno(h);
+    s->eid = eid;
+
  restart:
 
     fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0);
@@ -435,30 +436,21 @@
     if (libsrt_socket_nonblock(fd, 1) < 0)
         av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n");
 
-    ret = write_eid = libsrt_epoll_create(h, fd, 1);
-    if (ret < 0)
-        goto fail1;
     if (s->mode == SRT_MODE_LISTENER) {
         // multi-client
-        ret = libsrt_listen(write_eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout);
-        srt_epoll_release(write_eid);
-        if (ret < 0)
+        if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout)) < 0)
             goto fail1;
-        srt_close(fd);
+        listen_fd = fd;
         fd = ret;
     } else {
         if (s->mode == SRT_MODE_RENDEZVOUS) {
-            if (srt_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen)) {
-                ret = libsrt_neterrno(h);
-                srt_epoll_release(write_eid);
+            ret = srt_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
+            if (ret)
                 goto fail1;
-            }
         }
 
-        ret = libsrt_listen_connect(write_eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
-                                    open_timeout, h, !!cur_ai->ai_next);
-        srt_epoll_release(write_eid);
-        if (ret < 0) {
+        if ((ret = libsrt_listen_connect(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
+                                          open_timeout, h, !!cur_ai->ai_next)) < 0) {
             if (ret == AVERROR_EXIT)
                 goto fail1;
             else
@@ -479,13 +471,9 @@
             h->max_packet_size = packet_size;
     }
 
-    ret = eid = libsrt_epoll_create(h, fd, flags & AVIO_FLAG_WRITE);
-    if (eid < 0)
-        goto fail1;
-
     h->is_streamed = 1;
     s->fd = fd;
-    s->eid = eid;
+    s->listen_fd = listen_fd;
 
     freeaddrinfo(ai);
     return 0;
@@ -496,13 +484,18 @@
         cur_ai = cur_ai->ai_next;
         if (fd >= 0)
             srt_close(fd);
+        if (listen_fd >= 0)
+            srt_close(listen_fd);
         ret = 0;
         goto restart;
     }
  fail1:
     if (fd >= 0)
         srt_close(fd);
+    if (listen_fd >= 0)
+        srt_close(listen_fd);
     freeaddrinfo(ai);
+    srt_epoll_release(s->eid);
     return ret;
 }
 
@@ -659,7 +652,7 @@
     int ret;
 
     if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
-        ret = libsrt_network_wait_fd_timeout(h, s->eid, 0, h->rw_timeout, &h->interrupt_callback);
+        ret = libsrt_network_wait_fd_timeout(h, s->eid, s->fd, 0, h->rw_timeout, &h->interrupt_callback);
         if (ret)
             return ret;
     }
@@ -678,7 +671,7 @@
     int ret;
 
     if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
-        ret = libsrt_network_wait_fd_timeout(h, s->eid, 1, h->rw_timeout, &h->interrupt_callback);
+        ret = libsrt_network_wait_fd_timeout(h, s->eid, s->fd, 1, h->rw_timeout, &h->interrupt_callback);
         if (ret)
             return ret;
     }
@@ -695,9 +688,13 @@
 {
     SRTContext *s = h->priv_data;
 
-    srt_epoll_release(s->eid);
     srt_close(s->fd);
 
+    if (s->listen_fd >= 0)
+        srt_close(s->listen_fd);
+
+    srt_epoll_release(s->eid);
+
     srt_cleanup();
 
     return 0;
diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
index 509d19f..fa84cee 100644
--- a/libavformat/lxfdec.c
+++ b/libavformat/lxfdec.c
@@ -195,7 +195,7 @@
             return AVERROR_PATCHWELCOME;
         }
 
-        samples = track_size * 8LL / st->codecpar->bits_per_coded_sample;
+        samples = track_size * 8 / st->codecpar->bits_per_coded_sample;
 
         //use audio packet size to determine video standard
         //for NTSC we have one 8008-sample audio frame per five video frames
@@ -210,8 +210,6 @@
             avpriv_set_pts_info(s->streams[0], 64, 1, 25);
         }
 
-        if (av_popcount(channels) * (uint64_t)track_size > INT_MAX)
-            return AVERROR_INVALIDDATA;
         //TODO: warning if track mask != (1 << channels) - 1?
         ret = av_popcount(channels) * track_size;
 
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 30cbe18..6f198f0 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -98,11 +98,6 @@
 #define MATROSKA_ID_TRACKFLAGENABLED 0xB9
 #define MATROSKA_ID_TRACKFLAGDEFAULT 0x88
 #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA
-#define MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED  0x55AB
-#define MATROSKA_ID_TRACKFLAGVISUALIMPAIRED   0x55AC
-#define MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS 0x55AD
-#define MATROSKA_ID_TRACKFLAGORIGINAL         0x55AE
-#define MATROSKA_ID_TRACKFLAGCOMMENTARY       0x55AF
 #define MATROSKA_ID_TRACKFLAGLACING 0x9C
 #define MATROSKA_ID_TRACKMINCACHE 0x6DE7
 #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 95e9304..d266511 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -99,20 +99,9 @@
     EBML_TYPE_COUNT
 } EbmlType;
 
-typedef struct CountedElement {
-    union {
-        uint64_t  u;
-        int64_t   i;
-        double    f;
-        char     *s;
-    } el;
-    unsigned count;
-} CountedElement;
-
 typedef const struct EbmlSyntax {
     uint32_t id;
-    uint8_t type;
-    uint8_t is_counted;
+    EbmlType type;
     size_t list_elem_size;
     size_t data_offset;
     union {
@@ -172,7 +161,7 @@
     double white_x;
     double white_y;
     double max_luminance;
-    CountedElement min_luminance;
+    double min_luminance;
 } MatroskaMasteringMeta;
 
 typedef struct MatroskaTrackVideoColor {
@@ -254,11 +243,6 @@
     uint64_t default_duration;
     uint64_t flag_default;
     uint64_t flag_forced;
-    uint64_t flag_comment;
-    uint64_t flag_hearingimpaired;
-    uint64_t flag_visualimpaired;
-    uint64_t flag_textdescriptions;
-    CountedElement flag_original;
     uint64_t seek_preroll;
     MatroskaTrackVideo video;
     MatroskaTrackAudio audio;
@@ -339,7 +323,7 @@
 
 typedef struct MatroskaBlock {
     uint64_t duration;
-    CountedElement reference;
+    int64_t  reference;
     uint64_t non_simple;
     EbmlBin  bin;
     uint64_t additional_id;
@@ -418,120 +402,120 @@
 // incomplete type (6.7.2 in C90, 6.9.2 in C99).
 // Removing the sizes breaks MSVC.
 static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19],
-                  matroska_track[32], matroska_track_encoding[6], matroska_track_encodings[2],
+                  matroska_track[27], matroska_track_encoding[6], matroska_track_encodings[2],
                   matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2],
                   matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2],
                   matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2],
                   matroska_blockadditions[2], matroska_blockgroup[8], matroska_cluster_parsing[8];
 
 static EbmlSyntax ebml_header[] = {
-    { EBML_ID_EBMLREADVERSION,    EBML_UINT, 0, 0, offsetof(Ebml, version),         { .u = EBML_VERSION } },
-    { EBML_ID_EBMLMAXSIZELENGTH,  EBML_UINT, 0, 0, offsetof(Ebml, max_size),        { .u = 8 } },
-    { EBML_ID_EBMLMAXIDLENGTH,    EBML_UINT, 0, 0, offsetof(Ebml, id_length),       { .u = 4 } },
-    { EBML_ID_DOCTYPE,            EBML_STR,  0, 0, offsetof(Ebml, doctype),         { .s = "(none)" } },
-    { EBML_ID_DOCTYPEREADVERSION, EBML_UINT, 0, 0, offsetof(Ebml, doctype_version), { .u = 1 } },
+    { EBML_ID_EBMLREADVERSION,    EBML_UINT, 0, offsetof(Ebml, version),         { .u = EBML_VERSION } },
+    { EBML_ID_EBMLMAXSIZELENGTH,  EBML_UINT, 0, offsetof(Ebml, max_size),        { .u = 8 } },
+    { EBML_ID_EBMLMAXIDLENGTH,    EBML_UINT, 0, offsetof(Ebml, id_length),       { .u = 4 } },
+    { EBML_ID_DOCTYPE,            EBML_STR,  0, offsetof(Ebml, doctype),         { .s = "(none)" } },
+    { EBML_ID_DOCTYPEREADVERSION, EBML_UINT, 0, offsetof(Ebml, doctype_version), { .u = 1 } },
     { EBML_ID_EBMLVERSION,        EBML_NONE },
     { EBML_ID_DOCTYPEVERSION,     EBML_NONE },
     CHILD_OF(ebml_syntax)
 };
 
 static EbmlSyntax ebml_syntax[] = {
-    { EBML_ID_HEADER,      EBML_NEST, 0, 0, 0, { .n = ebml_header } },
+    { EBML_ID_HEADER,      EBML_NEST, 0, 0, { .n = ebml_header } },
     { MATROSKA_ID_SEGMENT, EBML_STOP },
     { 0 }
 };
 
 static EbmlSyntax matroska_info[] = {
-    { MATROSKA_ID_TIMECODESCALE, EBML_UINT,  0, 0, offsetof(MatroskaDemuxContext, time_scale), { .u = 1000000 } },
-    { MATROSKA_ID_DURATION,      EBML_FLOAT, 0, 0, offsetof(MatroskaDemuxContext, duration) },
-    { MATROSKA_ID_TITLE,         EBML_UTF8,  0, 0, offsetof(MatroskaDemuxContext, title) },
+    { MATROSKA_ID_TIMECODESCALE, EBML_UINT,  0, offsetof(MatroskaDemuxContext, time_scale), { .u = 1000000 } },
+    { MATROSKA_ID_DURATION,      EBML_FLOAT, 0, offsetof(MatroskaDemuxContext, duration) },
+    { MATROSKA_ID_TITLE,         EBML_UTF8,  0, offsetof(MatroskaDemuxContext, title) },
     { MATROSKA_ID_WRITINGAPP,    EBML_NONE },
-    { MATROSKA_ID_MUXINGAPP,     EBML_UTF8, 0, 0, offsetof(MatroskaDemuxContext, muxingapp) },
-    { MATROSKA_ID_DATEUTC,       EBML_BIN,  0, 0, offsetof(MatroskaDemuxContext, date_utc) },
+    { MATROSKA_ID_MUXINGAPP,     EBML_UTF8, 0, offsetof(MatroskaDemuxContext, muxingapp) },
+    { MATROSKA_ID_DATEUTC,       EBML_BIN,  0, offsetof(MatroskaDemuxContext, date_utc) },
     { MATROSKA_ID_SEGMENTUID,    EBML_NONE },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_mastering_meta[] = {
-    { MATROSKA_ID_VIDEOCOLOR_RX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, r_x) },
-    { MATROSKA_ID_VIDEOCOLOR_RY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, r_y) },
-    { MATROSKA_ID_VIDEOCOLOR_GX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, g_x) },
-    { MATROSKA_ID_VIDEOCOLOR_GY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, g_y) },
-    { MATROSKA_ID_VIDEOCOLOR_BX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, b_x) },
-    { MATROSKA_ID_VIDEOCOLOR_BY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, b_y) },
-    { MATROSKA_ID_VIDEOCOLOR_WHITEX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, white_x) },
-    { MATROSKA_ID_VIDEOCOLOR_WHITEY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, white_y) },
-    { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN, EBML_FLOAT, 1, 0, offsetof(MatroskaMasteringMeta, min_luminance) },
-    { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, max_luminance) },
+    { MATROSKA_ID_VIDEOCOLOR_RX, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, r_x), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_RY, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, r_y), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_GX, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, g_x), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_GY, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, g_y), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_BX, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, b_x), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_BY, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, b_y), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_WHITEX, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, white_x), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_WHITEY, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, white_y), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, min_luminance), { .f=-1 } },
+    { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX, EBML_FLOAT, 0, offsetof(MatroskaMasteringMeta, max_luminance), { .f=-1 } },
     CHILD_OF(matroska_track_video_color)
 };
 
 static EbmlSyntax matroska_track_video_color[] = {
-    { MATROSKA_ID_VIDEOCOLORMATRIXCOEFF,      EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, matrix_coefficients), { .u = AVCOL_SPC_UNSPECIFIED } },
-    { MATROSKA_ID_VIDEOCOLORBITSPERCHANNEL,   EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, bits_per_channel), { .u = 0 } },
-    { MATROSKA_ID_VIDEOCOLORCHROMASUBHORZ,    EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, chroma_sub_horz) },
-    { MATROSKA_ID_VIDEOCOLORCHROMASUBVERT,    EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, chroma_sub_vert) },
-    { MATROSKA_ID_VIDEOCOLORCBSUBHORZ,        EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, cb_sub_horz) },
-    { MATROSKA_ID_VIDEOCOLORCBSUBVERT,        EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, cb_sub_vert) },
-    { MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, chroma_siting_horz), { .u = MATROSKA_COLOUR_CHROMASITINGHORZ_UNDETERMINED } },
-    { MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, chroma_siting_vert), { .u = MATROSKA_COLOUR_CHROMASITINGVERT_UNDETERMINED } },
-    { MATROSKA_ID_VIDEOCOLORRANGE,            EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, range), { .u = AVCOL_RANGE_UNSPECIFIED } },
-    { MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, transfer_characteristics), { .u = AVCOL_TRC_UNSPECIFIED } },
-    { MATROSKA_ID_VIDEOCOLORPRIMARIES,        EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, primaries), { .u = AVCOL_PRI_UNSPECIFIED } },
-    { MATROSKA_ID_VIDEOCOLORMAXCLL,           EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, max_cll) },
-    { MATROSKA_ID_VIDEOCOLORMAXFALL,          EBML_UINT, 0, 0, offsetof(MatroskaTrackVideoColor, max_fall) },
-    { MATROSKA_ID_VIDEOCOLORMASTERINGMETA,    EBML_NEST, 0, 0, offsetof(MatroskaTrackVideoColor, mastering_meta), { .n = matroska_mastering_meta } },
+    { MATROSKA_ID_VIDEOCOLORMATRIXCOEFF,      EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, matrix_coefficients), { .u = AVCOL_SPC_UNSPECIFIED } },
+    { MATROSKA_ID_VIDEOCOLORBITSPERCHANNEL,   EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, bits_per_channel), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORCHROMASUBHORZ,    EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, chroma_sub_horz), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORCHROMASUBVERT,    EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, chroma_sub_vert), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORCBSUBHORZ,        EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, cb_sub_horz), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORCBSUBVERT,        EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, cb_sub_vert), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ, EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, chroma_siting_horz), { .u = MATROSKA_COLOUR_CHROMASITINGHORZ_UNDETERMINED } },
+    { MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT, EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, chroma_siting_vert), { .u = MATROSKA_COLOUR_CHROMASITINGVERT_UNDETERMINED } },
+    { MATROSKA_ID_VIDEOCOLORRANGE,            EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, range), { .u = AVCOL_RANGE_UNSPECIFIED } },
+    { MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS, EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, transfer_characteristics), { .u = AVCOL_TRC_UNSPECIFIED } },
+    { MATROSKA_ID_VIDEOCOLORPRIMARIES,        EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, primaries), { .u = AVCOL_PRI_UNSPECIFIED } },
+    { MATROSKA_ID_VIDEOCOLORMAXCLL,           EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, max_cll), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORMAXFALL,          EBML_UINT, 0, offsetof(MatroskaTrackVideoColor, max_fall), { .u=0 } },
+    { MATROSKA_ID_VIDEOCOLORMASTERINGMETA,    EBML_NEST, 0, offsetof(MatroskaTrackVideoColor, mastering_meta), { .n = matroska_mastering_meta } },
     CHILD_OF(matroska_track_video)
 };
 
 static EbmlSyntax matroska_track_video_projection[] = {
-    { MATROSKA_ID_VIDEOPROJECTIONTYPE,        EBML_UINT,  0, 0, offsetof(MatroskaTrackVideoProjection, type), { .u = MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR } },
-    { MATROSKA_ID_VIDEOPROJECTIONPRIVATE,     EBML_BIN,   0, 0, offsetof(MatroskaTrackVideoProjection, private) },
-    { MATROSKA_ID_VIDEOPROJECTIONPOSEYAW,     EBML_FLOAT, 0, 0, offsetof(MatroskaTrackVideoProjection, yaw),   { .f = 0.0 } },
-    { MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH,   EBML_FLOAT, 0, 0, offsetof(MatroskaTrackVideoProjection, pitch), { .f = 0.0 } },
-    { MATROSKA_ID_VIDEOPROJECTIONPOSEROLL,    EBML_FLOAT, 0, 0, offsetof(MatroskaTrackVideoProjection, roll),  { .f = 0.0 } },
+    { MATROSKA_ID_VIDEOPROJECTIONTYPE,        EBML_UINT,  0, offsetof(MatroskaTrackVideoProjection, type), { .u = MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR } },
+    { MATROSKA_ID_VIDEOPROJECTIONPRIVATE,     EBML_BIN,   0, offsetof(MatroskaTrackVideoProjection, private) },
+    { MATROSKA_ID_VIDEOPROJECTIONPOSEYAW,     EBML_FLOAT, 0, offsetof(MatroskaTrackVideoProjection, yaw), { .f=0.0 } },
+    { MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH,   EBML_FLOAT, 0, offsetof(MatroskaTrackVideoProjection, pitch), { .f=0.0 } },
+    { MATROSKA_ID_VIDEOPROJECTIONPOSEROLL,    EBML_FLOAT, 0, offsetof(MatroskaTrackVideoProjection, roll), { .f=0.0 } },
     CHILD_OF(matroska_track_video)
 };
 
 static EbmlSyntax matroska_track_video[] = {
-    { MATROSKA_ID_VIDEOFRAMERATE,      EBML_FLOAT, 0, 0, offsetof(MatroskaTrackVideo, frame_rate) },
-    { MATROSKA_ID_VIDEODISPLAYWIDTH,   EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, display_width), { .u=-1 } },
-    { MATROSKA_ID_VIDEODISPLAYHEIGHT,  EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, display_height), { .u=-1 } },
-    { MATROSKA_ID_VIDEOPIXELWIDTH,     EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, pixel_width) },
-    { MATROSKA_ID_VIDEOPIXELHEIGHT,    EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, pixel_height) },
-    { MATROSKA_ID_VIDEOCOLORSPACE,     EBML_BIN,   0, 0, offsetof(MatroskaTrackVideo, color_space) },
-    { MATROSKA_ID_VIDEOALPHAMODE,      EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, alpha_mode), { .u = 0 } },
-    { MATROSKA_ID_VIDEOCOLOR,          EBML_NEST,  0, sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = matroska_track_video_color } },
-    { MATROSKA_ID_VIDEOPROJECTION,     EBML_NEST,  0, 0, offsetof(MatroskaTrackVideo, projection), { .n = matroska_track_video_projection } },
+    { MATROSKA_ID_VIDEOFRAMERATE,      EBML_FLOAT, 0, offsetof(MatroskaTrackVideo, frame_rate) },
+    { MATROSKA_ID_VIDEODISPLAYWIDTH,   EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_width), { .u=-1 } },
+    { MATROSKA_ID_VIDEODISPLAYHEIGHT,  EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_height), { .u=-1 } },
+    { MATROSKA_ID_VIDEOPIXELWIDTH,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, pixel_width) },
+    { MATROSKA_ID_VIDEOPIXELHEIGHT,    EBML_UINT,  0, offsetof(MatroskaTrackVideo, pixel_height) },
+    { MATROSKA_ID_VIDEOCOLORSPACE,     EBML_BIN,   0, offsetof(MatroskaTrackVideo, color_space) },
+    { MATROSKA_ID_VIDEOALPHAMODE,      EBML_UINT,  0, offsetof(MatroskaTrackVideo, alpha_mode) },
+    { MATROSKA_ID_VIDEOCOLOR,          EBML_NEST,  sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = matroska_track_video_color } },
+    { MATROSKA_ID_VIDEOPROJECTION,     EBML_NEST,  0, offsetof(MatroskaTrackVideo, projection), { .n = matroska_track_video_projection } },
     { MATROSKA_ID_VIDEOPIXELCROPB,     EBML_NONE },
     { MATROSKA_ID_VIDEOPIXELCROPT,     EBML_NONE },
     { MATROSKA_ID_VIDEOPIXELCROPL,     EBML_NONE },
     { MATROSKA_ID_VIDEOPIXELCROPR,     EBML_NONE },
-    { MATROSKA_ID_VIDEODISPLAYUNIT,    EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, display_unit), { .u= MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } },
-    { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, interlaced),  { .u = MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } },
-    { MATROSKA_ID_VIDEOFIELDORDER,     EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, field_order), { .u = MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } },
-    { MATROSKA_ID_VIDEOSTEREOMODE,     EBML_UINT,  0, 0, offsetof(MatroskaTrackVideo, stereo_mode), { .u = MATROSKA_VIDEO_STEREOMODE_TYPE_NB } },
+    { MATROSKA_ID_VIDEODISPLAYUNIT,    EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_unit), { .u= MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } },
+    { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT,  0, offsetof(MatroskaTrackVideo, interlaced),  { .u = MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } },
+    { MATROSKA_ID_VIDEOFIELDORDER,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, field_order), { .u = MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } },
+    { MATROSKA_ID_VIDEOSTEREOMODE,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, stereo_mode), { .u = MATROSKA_VIDEO_STEREOMODE_TYPE_NB } },
     { MATROSKA_ID_VIDEOASPECTRATIO,    EBML_NONE },
     CHILD_OF(matroska_track)
 };
 
 static EbmlSyntax matroska_track_audio[] = {
-    { MATROSKA_ID_AUDIOSAMPLINGFREQ,    EBML_FLOAT, 0, 0, offsetof(MatroskaTrackAudio, samplerate), { .f = 8000.0 } },
-    { MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, EBML_FLOAT, 0, 0, offsetof(MatroskaTrackAudio, out_samplerate) },
-    { MATROSKA_ID_AUDIOBITDEPTH,        EBML_UINT,  0, 0, offsetof(MatroskaTrackAudio, bitdepth) },
-    { MATROSKA_ID_AUDIOCHANNELS,        EBML_UINT,  0, 0, offsetof(MatroskaTrackAudio, channels),   { .u = 1 } },
+    { MATROSKA_ID_AUDIOSAMPLINGFREQ,    EBML_FLOAT, 0, offsetof(MatroskaTrackAudio, samplerate), { .f = 8000.0 } },
+    { MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, EBML_FLOAT, 0, offsetof(MatroskaTrackAudio, out_samplerate) },
+    { MATROSKA_ID_AUDIOBITDEPTH,        EBML_UINT,  0, offsetof(MatroskaTrackAudio, bitdepth) },
+    { MATROSKA_ID_AUDIOCHANNELS,        EBML_UINT,  0, offsetof(MatroskaTrackAudio, channels),   { .u = 1 } },
     CHILD_OF(matroska_track)
 };
 
 static EbmlSyntax matroska_track_encoding_compression[] = {
-    { MATROSKA_ID_ENCODINGCOMPALGO,     EBML_UINT, 0, 0, offsetof(MatroskaTrackCompression, algo), { .u = MATROSKA_TRACK_ENCODING_COMP_ZLIB } },
-    { MATROSKA_ID_ENCODINGCOMPSETTINGS, EBML_BIN,  0, 0, offsetof(MatroskaTrackCompression, settings) },
+    { MATROSKA_ID_ENCODINGCOMPALGO,     EBML_UINT, 0, offsetof(MatroskaTrackCompression, algo), { .u = 0 } },
+    { MATROSKA_ID_ENCODINGCOMPSETTINGS, EBML_BIN,  0, offsetof(MatroskaTrackCompression, settings) },
     CHILD_OF(matroska_track_encoding)
 };
 
 static EbmlSyntax matroska_track_encoding_encryption[] = {
-    { MATROSKA_ID_ENCODINGENCALGO,        EBML_UINT, 0, 0, offsetof(MatroskaTrackEncryption,algo), {.u = 0} },
-    { MATROSKA_ID_ENCODINGENCKEYID,       EBML_BIN, 0, 0, offsetof(MatroskaTrackEncryption,key_id) },
+    { MATROSKA_ID_ENCODINGENCALGO,        EBML_UINT, 0, offsetof(MatroskaTrackEncryption,algo), {.u = 0} },
+    { MATROSKA_ID_ENCODINGENCKEYID,       EBML_BIN, 0, offsetof(MatroskaTrackEncryption,key_id) },
     { MATROSKA_ID_ENCODINGENCAESSETTINGS, EBML_NONE },
     { MATROSKA_ID_ENCODINGSIGALGO,        EBML_NONE },
     { MATROSKA_ID_ENCODINGSIGHASHALGO,    EBML_NONE },
@@ -540,59 +524,54 @@
     CHILD_OF(matroska_track_encoding)
 };
 static EbmlSyntax matroska_track_encoding[] = {
-    { MATROSKA_ID_ENCODINGSCOPE,       EBML_UINT, 0, 0, offsetof(MatroskaTrackEncoding, scope),       { .u = 1 } },
-    { MATROSKA_ID_ENCODINGTYPE,        EBML_UINT, 0, 0, offsetof(MatroskaTrackEncoding, type),        { .u = 0 } },
-    { MATROSKA_ID_ENCODINGCOMPRESSION, EBML_NEST, 0, 0, offsetof(MatroskaTrackEncoding, compression), { .n = matroska_track_encoding_compression } },
-    { MATROSKA_ID_ENCODINGENCRYPTION,  EBML_NEST, 0, 0, offsetof(MatroskaTrackEncoding, encryption),  { .n = matroska_track_encoding_encryption } },
+    { MATROSKA_ID_ENCODINGSCOPE,       EBML_UINT, 0, offsetof(MatroskaTrackEncoding, scope),       { .u = 1 } },
+    { MATROSKA_ID_ENCODINGTYPE,        EBML_UINT, 0, offsetof(MatroskaTrackEncoding, type),        { .u = 0 } },
+    { MATROSKA_ID_ENCODINGCOMPRESSION, EBML_NEST, 0, offsetof(MatroskaTrackEncoding, compression), { .n = matroska_track_encoding_compression } },
+    { MATROSKA_ID_ENCODINGENCRYPTION,  EBML_NEST, 0, offsetof(MatroskaTrackEncoding, encryption),  { .n = matroska_track_encoding_encryption } },
     { MATROSKA_ID_ENCODINGORDER,       EBML_NONE },
     CHILD_OF(matroska_track_encodings)
 };
 
 static EbmlSyntax matroska_track_encodings[] = {
-    { MATROSKA_ID_TRACKCONTENTENCODING, EBML_NEST, 0, sizeof(MatroskaTrackEncoding), offsetof(MatroskaTrack, encodings), { .n = matroska_track_encoding } },
+    { MATROSKA_ID_TRACKCONTENTENCODING, EBML_NEST, sizeof(MatroskaTrackEncoding), offsetof(MatroskaTrack, encodings), { .n = matroska_track_encoding } },
     CHILD_OF(matroska_track)
 };
 
 static EbmlSyntax matroska_track_plane[] = {
-    { MATROSKA_ID_TRACKPLANEUID,  EBML_UINT, 0, 0, offsetof(MatroskaTrackPlane,uid) },
-    { MATROSKA_ID_TRACKPLANETYPE, EBML_UINT, 0, 0, offsetof(MatroskaTrackPlane,type) },
+    { MATROSKA_ID_TRACKPLANEUID,  EBML_UINT, 0, offsetof(MatroskaTrackPlane,uid) },
+    { MATROSKA_ID_TRACKPLANETYPE, EBML_UINT, 0, offsetof(MatroskaTrackPlane,type) },
     CHILD_OF(matroska_track_combine_planes)
 };
 
 static EbmlSyntax matroska_track_combine_planes[] = {
-    { MATROSKA_ID_TRACKPLANE, EBML_NEST, 0, sizeof(MatroskaTrackPlane), offsetof(MatroskaTrackOperation,combine_planes), {.n = matroska_track_plane} },
+    { MATROSKA_ID_TRACKPLANE, EBML_NEST, sizeof(MatroskaTrackPlane), offsetof(MatroskaTrackOperation,combine_planes), {.n = matroska_track_plane} },
     CHILD_OF(matroska_track_operation)
 };
 
 static EbmlSyntax matroska_track_operation[] = {
-    { MATROSKA_ID_TRACKCOMBINEPLANES, EBML_NEST, 0, 0, 0, {.n = matroska_track_combine_planes} },
+    { MATROSKA_ID_TRACKCOMBINEPLANES, EBML_NEST, 0, 0, {.n = matroska_track_combine_planes} },
     CHILD_OF(matroska_track)
 };
 
 static EbmlSyntax matroska_track[] = {
-    { MATROSKA_ID_TRACKNUMBER,           EBML_UINT,  0, 0, offsetof(MatroskaTrack, num) },
-    { MATROSKA_ID_TRACKNAME,             EBML_UTF8,  0, 0, offsetof(MatroskaTrack, name) },
-    { MATROSKA_ID_TRACKUID,              EBML_UINT,  0, 0, offsetof(MatroskaTrack, uid) },
-    { MATROSKA_ID_TRACKTYPE,             EBML_UINT,  0, 0, offsetof(MatroskaTrack, type) },
-    { MATROSKA_ID_CODECID,               EBML_STR,   0, 0, offsetof(MatroskaTrack, codec_id) },
-    { MATROSKA_ID_CODECPRIVATE,          EBML_BIN,   0, 0, offsetof(MatroskaTrack, codec_priv) },
-    { MATROSKA_ID_CODECDELAY,            EBML_UINT,  0, 0, offsetof(MatroskaTrack, codec_delay),  { .u = 0 } },
-    { MATROSKA_ID_TRACKLANGUAGE,         EBML_STR,   0, 0, offsetof(MatroskaTrack, language),     { .s = "eng" } },
-    { MATROSKA_ID_TRACKDEFAULTDURATION,  EBML_UINT,  0, 0, offsetof(MatroskaTrack, default_duration) },
-    { MATROSKA_ID_TRACKTIMECODESCALE,    EBML_FLOAT, 0, 0, offsetof(MatroskaTrack, time_scale),   { .f = 1.0 } },
-    { MATROSKA_ID_TRACKFLAGCOMMENTARY,   EBML_UINT,  0, 0, offsetof(MatroskaTrack, flag_comment), { .u = 0 } },
-    { MATROSKA_ID_TRACKFLAGDEFAULT,      EBML_UINT,  0, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } },
-    { MATROSKA_ID_TRACKFLAGFORCED,       EBML_UINT,  0, 0, offsetof(MatroskaTrack, flag_forced),  { .u = 0 } },
-    { MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_hearingimpaired), { .u = 0 } },
-    { MATROSKA_ID_TRACKFLAGVISUALIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_visualimpaired), { .u = 0 } },
-    { MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_textdescriptions), { .u = 0 } },
-    { MATROSKA_ID_TRACKFLAGORIGINAL,     EBML_UINT,  1, 0, offsetof(MatroskaTrack, flag_original), {.u = 0 } },
-    { MATROSKA_ID_TRACKVIDEO,            EBML_NEST,  0, 0, offsetof(MatroskaTrack, video),        { .n = matroska_track_video } },
-    { MATROSKA_ID_TRACKAUDIO,            EBML_NEST,  0, 0, offsetof(MatroskaTrack, audio),        { .n = matroska_track_audio } },
-    { MATROSKA_ID_TRACKOPERATION,        EBML_NEST,  0, 0, offsetof(MatroskaTrack, operation),    { .n = matroska_track_operation } },
-    { MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST,  0, 0, 0,                                     { .n = matroska_track_encodings } },
-    { MATROSKA_ID_TRACKMAXBLKADDID,      EBML_UINT,  0, 0, offsetof(MatroskaTrack, max_block_additional_id), { .u = 0 } },
-    { MATROSKA_ID_SEEKPREROLL,           EBML_UINT,  0, 0, offsetof(MatroskaTrack, seek_preroll), { .u = 0 } },
+    { MATROSKA_ID_TRACKNUMBER,           EBML_UINT,  0, offsetof(MatroskaTrack, num) },
+    { MATROSKA_ID_TRACKNAME,             EBML_UTF8,  0, offsetof(MatroskaTrack, name) },
+    { MATROSKA_ID_TRACKUID,              EBML_UINT,  0, offsetof(MatroskaTrack, uid) },
+    { MATROSKA_ID_TRACKTYPE,             EBML_UINT,  0, offsetof(MatroskaTrack, type) },
+    { MATROSKA_ID_CODECID,               EBML_STR,   0, offsetof(MatroskaTrack, codec_id) },
+    { MATROSKA_ID_CODECPRIVATE,          EBML_BIN,   0, offsetof(MatroskaTrack, codec_priv) },
+    { MATROSKA_ID_CODECDELAY,            EBML_UINT,  0, offsetof(MatroskaTrack, codec_delay) },
+    { MATROSKA_ID_TRACKLANGUAGE,         EBML_STR,   0, offsetof(MatroskaTrack, language),     { .s = "eng" } },
+    { MATROSKA_ID_TRACKDEFAULTDURATION,  EBML_UINT,  0, offsetof(MatroskaTrack, default_duration) },
+    { MATROSKA_ID_TRACKTIMECODESCALE,    EBML_FLOAT, 0, offsetof(MatroskaTrack, time_scale),   { .f = 1.0 } },
+    { MATROSKA_ID_TRACKFLAGDEFAULT,      EBML_UINT,  0, offsetof(MatroskaTrack, flag_default), { .u = 1 } },
+    { MATROSKA_ID_TRACKFLAGFORCED,       EBML_UINT,  0, offsetof(MatroskaTrack, flag_forced),  { .u = 0 } },
+    { MATROSKA_ID_TRACKVIDEO,            EBML_NEST,  0, offsetof(MatroskaTrack, video),        { .n = matroska_track_video } },
+    { MATROSKA_ID_TRACKAUDIO,            EBML_NEST,  0, offsetof(MatroskaTrack, audio),        { .n = matroska_track_audio } },
+    { MATROSKA_ID_TRACKOPERATION,        EBML_NEST,  0, offsetof(MatroskaTrack, operation),    { .n = matroska_track_operation } },
+    { MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST,  0, 0,                                     { .n = matroska_track_encodings } },
+    { MATROSKA_ID_TRACKMAXBLKADDID,      EBML_UINT,  0, offsetof(MatroskaTrack, max_block_additional_id) },
+    { MATROSKA_ID_SEEKPREROLL,           EBML_UINT,  0, offsetof(MatroskaTrack, seek_preroll) },
     { MATROSKA_ID_TRACKFLAGENABLED,      EBML_NONE },
     { MATROSKA_ID_TRACKFLAGLACING,       EBML_NONE },
     { MATROSKA_ID_CODECNAME,             EBML_NONE },
@@ -605,36 +584,36 @@
 };
 
 static EbmlSyntax matroska_tracks[] = {
-    { MATROSKA_ID_TRACKENTRY, EBML_NEST, 0, sizeof(MatroskaTrack), offsetof(MatroskaDemuxContext, tracks), { .n = matroska_track } },
+    { MATROSKA_ID_TRACKENTRY, EBML_NEST, sizeof(MatroskaTrack), offsetof(MatroskaDemuxContext, tracks), { .n = matroska_track } },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_attachment[] = {
-    { MATROSKA_ID_FILEUID,      EBML_UINT, 0, 0, offsetof(MatroskaAttachment, uid) },
-    { MATROSKA_ID_FILENAME,     EBML_UTF8, 0, 0, offsetof(MatroskaAttachment, filename) },
-    { MATROSKA_ID_FILEMIMETYPE, EBML_STR,  0, 0, offsetof(MatroskaAttachment, mime) },
-    { MATROSKA_ID_FILEDATA,     EBML_BIN,  0, 0, offsetof(MatroskaAttachment, bin) },
-    { MATROSKA_ID_FILEDESC,     EBML_UTF8, 0, 0, offsetof(MatroskaAttachment, description) },
+    { MATROSKA_ID_FILEUID,      EBML_UINT, 0, offsetof(MatroskaAttachment, uid) },
+    { MATROSKA_ID_FILENAME,     EBML_UTF8, 0, offsetof(MatroskaAttachment, filename) },
+    { MATROSKA_ID_FILEMIMETYPE, EBML_STR,  0, offsetof(MatroskaAttachment, mime) },
+    { MATROSKA_ID_FILEDATA,     EBML_BIN,  0, offsetof(MatroskaAttachment, bin) },
+    { MATROSKA_ID_FILEDESC,     EBML_UTF8, 0, offsetof(MatroskaAttachment, description) },
     CHILD_OF(matroska_attachments)
 };
 
 static EbmlSyntax matroska_attachments[] = {
-    { MATROSKA_ID_ATTACHEDFILE, EBML_NEST, 0, sizeof(MatroskaAttachment), offsetof(MatroskaDemuxContext, attachments), { .n = matroska_attachment } },
+    { MATROSKA_ID_ATTACHEDFILE, EBML_NEST, sizeof(MatroskaAttachment), offsetof(MatroskaDemuxContext, attachments), { .n = matroska_attachment } },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_chapter_display[] = {
-    { MATROSKA_ID_CHAPSTRING,  EBML_UTF8, 0, 0, offsetof(MatroskaChapter, title) },
+    { MATROSKA_ID_CHAPSTRING,  EBML_UTF8, 0, offsetof(MatroskaChapter, title) },
     { MATROSKA_ID_CHAPLANG,    EBML_NONE },
     { MATROSKA_ID_CHAPCOUNTRY, EBML_NONE },
     CHILD_OF(matroska_chapter_entry)
 };
 
 static EbmlSyntax matroska_chapter_entry[] = {
-    { MATROSKA_ID_CHAPTERTIMESTART,   EBML_UINT, 0, 0, offsetof(MatroskaChapter, start), { .u = AV_NOPTS_VALUE } },
-    { MATROSKA_ID_CHAPTERTIMEEND,     EBML_UINT, 0, 0, offsetof(MatroskaChapter, end),   { .u = AV_NOPTS_VALUE } },
-    { MATROSKA_ID_CHAPTERUID,         EBML_UINT, 0, 0, offsetof(MatroskaChapter, uid) },
-    { MATROSKA_ID_CHAPTERDISPLAY,     EBML_NEST, 0, 0,                        0,         { .n = matroska_chapter_display } },
+    { MATROSKA_ID_CHAPTERTIMESTART,   EBML_UINT, 0, offsetof(MatroskaChapter, start), { .u = AV_NOPTS_VALUE } },
+    { MATROSKA_ID_CHAPTERTIMEEND,     EBML_UINT, 0, offsetof(MatroskaChapter, end),   { .u = AV_NOPTS_VALUE } },
+    { MATROSKA_ID_CHAPTERUID,         EBML_UINT, 0, offsetof(MatroskaChapter, uid) },
+    { MATROSKA_ID_CHAPTERDISPLAY,     EBML_NEST, 0,                        0,         { .n = matroska_chapter_display } },
     { MATROSKA_ID_CHAPTERFLAGHIDDEN,  EBML_NONE },
     { MATROSKA_ID_CHAPTERFLAGENABLED, EBML_NONE },
     { MATROSKA_ID_CHAPTERPHYSEQUIV,   EBML_NONE },
@@ -643,7 +622,7 @@
 };
 
 static EbmlSyntax matroska_chapter[] = {
-    { MATROSKA_ID_CHAPTERATOM,        EBML_NEST, 0, sizeof(MatroskaChapter), offsetof(MatroskaDemuxContext, chapters), { .n = matroska_chapter_entry } },
+    { MATROSKA_ID_CHAPTERATOM,        EBML_NEST, sizeof(MatroskaChapter), offsetof(MatroskaDemuxContext, chapters), { .n = matroska_chapter_entry } },
     { MATROSKA_ID_EDITIONUID,         EBML_NONE },
     { MATROSKA_ID_EDITIONFLAGHIDDEN,  EBML_NONE },
     { MATROSKA_ID_EDITIONFLAGDEFAULT, EBML_NONE },
@@ -652,13 +631,13 @@
 };
 
 static EbmlSyntax matroska_chapters[] = {
-    { MATROSKA_ID_EDITIONENTRY, EBML_NEST, 0, 0, 0, { .n = matroska_chapter } },
+    { MATROSKA_ID_EDITIONENTRY, EBML_NEST, 0, 0, { .n = matroska_chapter } },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_index_pos[] = {
-    { MATROSKA_ID_CUETRACK,           EBML_UINT, 0, 0, offsetof(MatroskaIndexPos, track) },
-    { MATROSKA_ID_CUECLUSTERPOSITION, EBML_UINT, 0, 0, offsetof(MatroskaIndexPos, pos) },
+    { MATROSKA_ID_CUETRACK,           EBML_UINT, 0, offsetof(MatroskaIndexPos, track) },
+    { MATROSKA_ID_CUECLUSTERPOSITION, EBML_UINT, 0, offsetof(MatroskaIndexPos, pos) },
     { MATROSKA_ID_CUERELATIVEPOSITION,EBML_NONE },
     { MATROSKA_ID_CUEDURATION,        EBML_NONE },
     { MATROSKA_ID_CUEBLOCKNUMBER,     EBML_NONE },
@@ -666,102 +645,102 @@
 };
 
 static EbmlSyntax matroska_index_entry[] = {
-    { MATROSKA_ID_CUETIME,          EBML_UINT, 0, 0,                        offsetof(MatroskaIndex, time) },
-    { MATROSKA_ID_CUETRACKPOSITION, EBML_NEST, 0, sizeof(MatroskaIndexPos), offsetof(MatroskaIndex, pos), { .n = matroska_index_pos } },
+    { MATROSKA_ID_CUETIME,          EBML_UINT, 0,                        offsetof(MatroskaIndex, time) },
+    { MATROSKA_ID_CUETRACKPOSITION, EBML_NEST, sizeof(MatroskaIndexPos), offsetof(MatroskaIndex, pos), { .n = matroska_index_pos } },
     CHILD_OF(matroska_index)
 };
 
 static EbmlSyntax matroska_index[] = {
-    { MATROSKA_ID_POINTENTRY, EBML_NEST, 0, sizeof(MatroskaIndex), offsetof(MatroskaDemuxContext, index), { .n = matroska_index_entry } },
+    { MATROSKA_ID_POINTENTRY, EBML_NEST, sizeof(MatroskaIndex), offsetof(MatroskaDemuxContext, index), { .n = matroska_index_entry } },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_simpletag[] = {
-    { MATROSKA_ID_TAGNAME,        EBML_UTF8, 0, 0,                   offsetof(MatroskaTag, name) },
-    { MATROSKA_ID_TAGSTRING,      EBML_UTF8, 0, 0,                   offsetof(MatroskaTag, string) },
-    { MATROSKA_ID_TAGLANG,        EBML_STR,  0, 0,                   offsetof(MatroskaTag, lang), { .s = "und" } },
-    { MATROSKA_ID_TAGDEFAULT,     EBML_UINT, 0, 0,                   offsetof(MatroskaTag, def) },
-    { MATROSKA_ID_TAGDEFAULT_BUG, EBML_UINT, 0, 0,                   offsetof(MatroskaTag, def) },
-    { MATROSKA_ID_SIMPLETAG,      EBML_NEST, 0, sizeof(MatroskaTag), offsetof(MatroskaTag, sub),  { .n = matroska_simpletag } },
+    { MATROSKA_ID_TAGNAME,        EBML_UTF8, 0,                   offsetof(MatroskaTag, name) },
+    { MATROSKA_ID_TAGSTRING,      EBML_UTF8, 0,                   offsetof(MatroskaTag, string) },
+    { MATROSKA_ID_TAGLANG,        EBML_STR,  0,                   offsetof(MatroskaTag, lang), { .s = "und" } },
+    { MATROSKA_ID_TAGDEFAULT,     EBML_UINT, 0,                   offsetof(MatroskaTag, def) },
+    { MATROSKA_ID_TAGDEFAULT_BUG, EBML_UINT, 0,                   offsetof(MatroskaTag, def) },
+    { MATROSKA_ID_SIMPLETAG,      EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTag, sub),  { .n = matroska_simpletag } },
     CHILD_OF(matroska_tag)
 };
 
 static EbmlSyntax matroska_tagtargets[] = {
-    { MATROSKA_ID_TAGTARGETS_TYPE,       EBML_STR,  0, 0, offsetof(MatroskaTagTarget, type) },
-    { MATROSKA_ID_TAGTARGETS_TYPEVALUE,  EBML_UINT, 0, 0, offsetof(MatroskaTagTarget, typevalue),  { .u = 50 } },
-    { MATROSKA_ID_TAGTARGETS_TRACKUID,   EBML_UINT, 0, 0, offsetof(MatroskaTagTarget, trackuid),   { .u = 0 } },
-    { MATROSKA_ID_TAGTARGETS_CHAPTERUID, EBML_UINT, 0, 0, offsetof(MatroskaTagTarget, chapteruid), { .u = 0 } },
-    { MATROSKA_ID_TAGTARGETS_ATTACHUID,  EBML_UINT, 0, 0, offsetof(MatroskaTagTarget, attachuid),  { .u = 0 } },
+    { MATROSKA_ID_TAGTARGETS_TYPE,       EBML_STR,  0, offsetof(MatroskaTagTarget, type) },
+    { MATROSKA_ID_TAGTARGETS_TYPEVALUE,  EBML_UINT, 0, offsetof(MatroskaTagTarget, typevalue), { .u = 50 } },
+    { MATROSKA_ID_TAGTARGETS_TRACKUID,   EBML_UINT, 0, offsetof(MatroskaTagTarget, trackuid) },
+    { MATROSKA_ID_TAGTARGETS_CHAPTERUID, EBML_UINT, 0, offsetof(MatroskaTagTarget, chapteruid) },
+    { MATROSKA_ID_TAGTARGETS_ATTACHUID,  EBML_UINT, 0, offsetof(MatroskaTagTarget, attachuid) },
     CHILD_OF(matroska_tag)
 };
 
 static EbmlSyntax matroska_tag[] = {
-    { MATROSKA_ID_SIMPLETAG,  EBML_NEST, 0, sizeof(MatroskaTag), offsetof(MatroskaTags, tag),    { .n = matroska_simpletag } },
-    { MATROSKA_ID_TAGTARGETS, EBML_NEST, 0, 0,                   offsetof(MatroskaTags, target), { .n = matroska_tagtargets } },
+    { MATROSKA_ID_SIMPLETAG,  EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTags, tag),    { .n = matroska_simpletag } },
+    { MATROSKA_ID_TAGTARGETS, EBML_NEST, 0,                   offsetof(MatroskaTags, target), { .n = matroska_tagtargets } },
     CHILD_OF(matroska_tags)
 };
 
 static EbmlSyntax matroska_tags[] = {
-    { MATROSKA_ID_TAG, EBML_NEST, 0, sizeof(MatroskaTags), offsetof(MatroskaDemuxContext, tags), { .n = matroska_tag } },
+    { MATROSKA_ID_TAG, EBML_NEST, sizeof(MatroskaTags), offsetof(MatroskaDemuxContext, tags), { .n = matroska_tag } },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_seekhead_entry[] = {
-    { MATROSKA_ID_SEEKID,       EBML_UINT, 0, 0, offsetof(MatroskaSeekhead, id) },
-    { MATROSKA_ID_SEEKPOSITION, EBML_UINT, 0, 0, offsetof(MatroskaSeekhead, pos), { .u = -1 } },
+    { MATROSKA_ID_SEEKID,       EBML_UINT, 0, offsetof(MatroskaSeekhead, id) },
+    { MATROSKA_ID_SEEKPOSITION, EBML_UINT, 0, offsetof(MatroskaSeekhead, pos), { .u = -1 } },
     CHILD_OF(matroska_seekhead)
 };
 
 static EbmlSyntax matroska_seekhead[] = {
-    { MATROSKA_ID_SEEKENTRY, EBML_NEST, 0, sizeof(MatroskaSeekhead), offsetof(MatroskaDemuxContext, seekhead), { .n = matroska_seekhead_entry } },
+    { MATROSKA_ID_SEEKENTRY, EBML_NEST, sizeof(MatroskaSeekhead), offsetof(MatroskaDemuxContext, seekhead), { .n = matroska_seekhead_entry } },
     CHILD_OF(matroska_segment)
 };
 
 static EbmlSyntax matroska_segment[] = {
     { MATROSKA_ID_CLUSTER,     EBML_STOP },
-    { MATROSKA_ID_INFO,        EBML_LEVEL1, 0, 0, 0, { .n = matroska_info } },
-    { MATROSKA_ID_TRACKS,      EBML_LEVEL1, 0, 0, 0, { .n = matroska_tracks } },
-    { MATROSKA_ID_ATTACHMENTS, EBML_LEVEL1, 0, 0, 0, { .n = matroska_attachments } },
-    { MATROSKA_ID_CHAPTERS,    EBML_LEVEL1, 0, 0, 0, { .n = matroska_chapters } },
-    { MATROSKA_ID_CUES,        EBML_LEVEL1, 0, 0, 0, { .n = matroska_index } },
-    { MATROSKA_ID_TAGS,        EBML_LEVEL1, 0, 0, 0, { .n = matroska_tags } },
-    { MATROSKA_ID_SEEKHEAD,    EBML_LEVEL1, 0, 0, 0, { .n = matroska_seekhead } },
+    { MATROSKA_ID_INFO,        EBML_LEVEL1, 0, 0, { .n = matroska_info } },
+    { MATROSKA_ID_TRACKS,      EBML_LEVEL1, 0, 0, { .n = matroska_tracks } },
+    { MATROSKA_ID_ATTACHMENTS, EBML_LEVEL1, 0, 0, { .n = matroska_attachments } },
+    { MATROSKA_ID_CHAPTERS,    EBML_LEVEL1, 0, 0, { .n = matroska_chapters } },
+    { MATROSKA_ID_CUES,        EBML_LEVEL1, 0, 0, { .n = matroska_index } },
+    { MATROSKA_ID_TAGS,        EBML_LEVEL1, 0, 0, { .n = matroska_tags } },
+    { MATROSKA_ID_SEEKHEAD,    EBML_LEVEL1, 0, 0, { .n = matroska_seekhead } },
     { 0 }   /* We don't want to go back to level 0, so don't add the parent. */
 };
 
 static EbmlSyntax matroska_segments[] = {
-    { MATROSKA_ID_SEGMENT, EBML_NEST, 0, 0, 0, { .n = matroska_segment } },
+    { MATROSKA_ID_SEGMENT, EBML_NEST, 0, 0, { .n = matroska_segment } },
     { 0 }
 };
 
 static EbmlSyntax matroska_blockmore[] = {
-    { MATROSKA_ID_BLOCKADDID,      EBML_UINT, 0, 0, offsetof(MatroskaBlock,additional_id), { .u = 1 } },
-    { MATROSKA_ID_BLOCKADDITIONAL, EBML_BIN,  0, 0, offsetof(MatroskaBlock,additional) },
+    { MATROSKA_ID_BLOCKADDID,      EBML_UINT, 0, offsetof(MatroskaBlock,additional_id), { .u = 1 } },
+    { MATROSKA_ID_BLOCKADDITIONAL, EBML_BIN,  0, offsetof(MatroskaBlock,additional) },
     CHILD_OF(matroska_blockadditions)
 };
 
 static EbmlSyntax matroska_blockadditions[] = {
-    { MATROSKA_ID_BLOCKMORE, EBML_NEST, 0, 0, 0, {.n = matroska_blockmore} },
+    { MATROSKA_ID_BLOCKMORE, EBML_NEST, 0, 0, {.n = matroska_blockmore} },
     CHILD_OF(matroska_blockgroup)
 };
 
 static EbmlSyntax matroska_blockgroup[] = {
-    { MATROSKA_ID_BLOCK,          EBML_BIN,  0, 0, offsetof(MatroskaBlock, bin) },
-    { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, 0, { .n = matroska_blockadditions} },
-    { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, 0, offsetof(MatroskaBlock, duration) },
-    { MATROSKA_ID_DISCARDPADDING, EBML_SINT, 0, 0, offsetof(MatroskaBlock, discard_padding) },
-    { MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 1, 0, offsetof(MatroskaBlock, reference) },
+    { MATROSKA_ID_BLOCK,          EBML_BIN,  0, offsetof(MatroskaBlock, bin) },
+    { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, { .n = matroska_blockadditions} },
+    { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, offsetof(MatroskaBlock, duration) },
+    { MATROSKA_ID_DISCARDPADDING, EBML_SINT, 0, offsetof(MatroskaBlock, discard_padding) },
+    { MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 0, offsetof(MatroskaBlock, reference), { .i = INT64_MIN } },
     { MATROSKA_ID_CODECSTATE,     EBML_NONE },
-    {                          1, EBML_UINT, 0, 0, offsetof(MatroskaBlock, non_simple), { .u = 1 } },
+    {                          1, EBML_UINT, 0, offsetof(MatroskaBlock, non_simple), { .u = 1 } },
     CHILD_OF(matroska_cluster_parsing)
 };
 
 // The following array contains SimpleBlock and BlockGroup twice
 // in order to reuse the other values for matroska_cluster_enter.
 static EbmlSyntax matroska_cluster_parsing[] = {
-    { MATROSKA_ID_SIMPLEBLOCK,     EBML_BIN,  0, 0, offsetof(MatroskaBlock, bin) },
-    { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, 0, 0, 0, { .n = matroska_blockgroup } },
-    { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, 0, offsetof(MatroskaCluster, timecode) },
+    { MATROSKA_ID_SIMPLEBLOCK,     EBML_BIN,  0, offsetof(MatroskaBlock, bin) },
+    { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, 0, 0, { .n = matroska_blockgroup } },
+    { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) },
     { MATROSKA_ID_SIMPLEBLOCK,     EBML_STOP },
     { MATROSKA_ID_BLOCKGROUP,      EBML_STOP },
     { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
@@ -770,7 +749,7 @@
 };
 
 static EbmlSyntax matroska_cluster_enter[] = {
-    { MATROSKA_ID_CLUSTER,     EBML_NEST, 0, 0, 0, { .n = &matroska_cluster_parsing[2] } },
+    { MATROSKA_ID_CLUSTER,     EBML_NEST, 0, 0, { .n = &matroska_cluster_parsing[2] } },
     { 0 }
 };
 #undef CHILD_OF
@@ -943,17 +922,12 @@
 
 /*
  * Read the next element as an unsigned int.
- * Returns NEEDS_CHECKING unless size == 0.
+ * Returns NEEDS_CHECKING.
  */
-static int ebml_read_uint(AVIOContext *pb, int size,
-                          uint64_t default_value, uint64_t *num)
+static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
 {
     int n = 0;
 
-    if (size == 0) {
-        *num = default_value;
-        return 0;
-    }
     /* big-endian ordering; build up number */
     *num = 0;
     while (n++ < size)
@@ -964,16 +938,14 @@
 
 /*
  * Read the next element as a signed int.
- * Returns NEEDS_CHECKING unless size == 0.
+ * Returns NEEDS_CHECKING.
  */
-static int ebml_read_sint(AVIOContext *pb, int size,
-                          int64_t default_value, int64_t *num)
+static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num)
 {
     int n = 1;
 
     if (size == 0) {
-        *num = default_value;
-        return 0;
+        *num = 0;
     } else {
         *num = sign_extend(avio_r8(pb), 8);
 
@@ -987,19 +959,17 @@
 
 /*
  * Read the next element as a float.
- * Returns 0 if size == 0, NEEDS_CHECKING or < 0 on obvious failure.
+ * Returns NEEDS_CHECKING or < 0 on obvious failure.
  */
-static int ebml_read_float(AVIOContext *pb, int size,
-                           double default_value, double *num)
+static int ebml_read_float(AVIOContext *pb, int size, double *num)
 {
-    if (size == 0) {
-        *num = default_value;
-        return 0;
-    } else if (size == 4) {
+    if (size == 0)
+        *num = 0;
+    else if (size == 4)
         *num = av_int2float(avio_rb32(pb));
-    } else if (size == 8) {
+    else if (size == 8)
         *num = av_int2double(avio_rb64(pb));
-    } else
+    else
         return AVERROR_INVALIDDATA;
 
     return NEEDS_CHECKING;
@@ -1009,27 +979,20 @@
  * Read the next element as an ASCII string.
  * 0 is success, < 0 or NEEDS_CHECKING is failure.
  */
-static int ebml_read_ascii(AVIOContext *pb, int size,
-                           const char *default_value, char **str)
+static int ebml_read_ascii(AVIOContext *pb, int size, char **str)
 {
     char *res;
     int ret;
 
-    if (size == 0 && default_value) {
-        res = av_strdup(default_value);
-        if (!res)
-            return AVERROR(ENOMEM);
-    } else {
-        /* EBML strings are usually not 0-terminated, so we allocate one
-         * byte more, read the string and NUL-terminate it ourselves. */
-        if (!(res = av_malloc(size + 1)))
-            return AVERROR(ENOMEM);
-        if ((ret = avio_read(pb, (uint8_t *) res, size)) != size) {
-            av_free(res);
-            return ret < 0 ? ret : NEEDS_CHECKING;
-        }
-        (res)[size] = '\0';
+    /* EBML strings are usually not 0-terminated, so we allocate one
+     * byte more, read the string and NULL-terminate it ourselves. */
+    if (!(res = av_malloc(size + 1)))
+        return AVERROR(ENOMEM);
+    if ((ret = avio_read(pb, (uint8_t *) res, size)) != size) {
+        av_free(res);
+        return ret < 0 ? ret : NEEDS_CHECKING;
     }
+    (res)[size] = '\0';
     av_free(*str);
     *str = res;
 
@@ -1128,29 +1091,28 @@
     int res;
 
     if (data) {
-        for (int i = 0; syntax[i].id; i++) {
-            void *dst = (char *)data + syntax[i].data_offset;
+        for (int i = 0; syntax[i].id; i++)
             switch (syntax[i].type) {
             case EBML_UINT:
-                *(uint64_t *)dst = syntax[i].def.u;
+                *(uint64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.u;
                 break;
             case EBML_SINT:
-                *(int64_t *) dst = syntax[i].def.i;
+                *(int64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.i;
                 break;
             case EBML_FLOAT:
-                *(double *)  dst = syntax[i].def.f;
+                *(double *) ((char *) data + syntax[i].data_offset) = syntax[i].def.f;
                 break;
             case EBML_STR:
             case EBML_UTF8:
                 // the default may be NULL
                 if (syntax[i].def.s) {
-                    *(char**)dst = av_strdup(syntax[i].def.s);
-                    if (!*(char**)dst)
+                    uint8_t **dst = (uint8_t **) ((uint8_t *) data + syntax[i].data_offset);
+                    *dst = av_strdup(syntax[i].def.s);
+                    if (!*dst)
                         return AVERROR(ENOMEM);
                 }
                 break;
             }
-        }
 
         if (!matroska->levels[matroska->num_levels - 1].length) {
             matroska->num_levels--;
@@ -1427,17 +1389,17 @@
 
     switch (syntax->type) {
     case EBML_UINT:
-        res = ebml_read_uint(pb, length, syntax->def.u, data);
+        res = ebml_read_uint(pb, length, data);
         break;
     case EBML_SINT:
-        res = ebml_read_sint(pb, length, syntax->def.i, data);
+        res = ebml_read_sint(pb, length, data);
         break;
     case EBML_FLOAT:
-        res = ebml_read_float(pb, length, syntax->def.f, data);
+        res = ebml_read_float(pb, length, data);
         break;
     case EBML_STR:
     case EBML_UTF8:
-        res = ebml_read_ascii(pb, length, syntax->def.s, data);
+        res = ebml_read_ascii(pb, length, data);
         break;
     case EBML_BIN:
         res = ebml_read_binary(pb, length, pos_alt, data);
@@ -1510,12 +1472,6 @@
     }
 
 level_check:
-    if (syntax->is_counted && data) {
-        CountedElement *elem = data;
-        if (elem->count != UINT_MAX)
-            elem->count++;
-    }
-
     if (level_check == LEVEL_ENDED && matroska->num_levels) {
         level = &matroska->levels[matroska->num_levels - 1];
         pos   = avio_tell(pb);
@@ -2141,10 +2097,7 @@
         mastering_meta->g_x > 0 && mastering_meta->g_y > 0 &&
         mastering_meta->b_x > 0 && mastering_meta->b_y > 0 &&
         mastering_meta->white_x > 0 && mastering_meta->white_y > 0;
-    has_mastering_luminance = mastering_meta->max_luminance >
-                                  mastering_meta->min_luminance.el.f  &&
-                              mastering_meta->min_luminance.el.f >= 0 &&
-                              mastering_meta->min_luminance.count;
+    has_mastering_luminance = mastering_meta->max_luminance > 0;
 
     if (color->matrix_coefficients != AVCOL_SPC_RESERVED)
         st->codecpar->color_space = color->matrix_coefficients;
@@ -2203,7 +2156,7 @@
         }
         if (has_mastering_luminance) {
             metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX);
-            metadata->min_luminance = av_d2q(mastering_meta->min_luminance.el.f, INT_MAX);
+            metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX);
             metadata->has_luminance = 1;
         }
     }
@@ -2476,7 +2429,8 @@
                                  encodings[0].compression.settings.size);
 
         for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) {
-            if (av_strstart(track->codec_id, ff_mkv_codec_tags[j].str, NULL)) {
+            if (!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
+                         strlen(ff_mkv_codec_tags[j].str))) {
                 codec_id = ff_mkv_codec_tags[j].id;
                 break;
             }
@@ -2759,15 +2713,6 @@
             st->disposition |= AV_DISPOSITION_DEFAULT;
         if (track->flag_forced)
             st->disposition |= AV_DISPOSITION_FORCED;
-        if (track->flag_comment)
-            st->disposition |= AV_DISPOSITION_COMMENT;
-        if (track->flag_hearingimpaired)
-            st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
-        if (track->flag_visualimpaired)
-            st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
-        if (track->flag_original.count > 0)
-            st->disposition |= track->flag_original.el.u ? AV_DISPOSITION_ORIGINAL
-                                                         : AV_DISPOSITION_DUB;
 
         if (!st->codecpar->extradata) {
             if (extradata) {
@@ -2894,9 +2839,6 @@
             }
         } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
             st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
-
-            if (track->flag_textdescriptions)
-                st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
         }
     }
 
@@ -2998,7 +2940,8 @@
             st->codecpar->codec_id   = AV_CODEC_ID_NONE;
 
             for (i = 0; mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
-                if (av_strstart(attachments[j].mime, mkv_image_mime_tags[i].str, NULL)) {
+                if (!strncmp(mkv_image_mime_tags[i].str, attachments[j].mime,
+                             strlen(mkv_image_mime_tags[i].str))) {
                     st->codecpar->codec_id = mkv_image_mime_tags[i].id;
                     break;
                 }
@@ -3027,7 +2970,8 @@
                        attachments[j].bin.size);
 
                 for (i = 0; mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
-                    if (av_strstart(attachments[j].mime, mkv_mime_tags[i].str, NULL)) {
+                    if (!strncmp(mkv_mime_tags[i].str, attachments[j].mime,
+                                strlen(mkv_mime_tags[i].str))) {
                         st->codecpar->codec_id = mkv_mime_tags[i].id;
                         break;
                     }
@@ -3787,7 +3731,7 @@
         res = ebml_parse(matroska, matroska_cluster_parsing, cluster);
 
         if (res >= 0 && block->bin.size > 0) {
-            int is_keyframe = block->non_simple ? block->reference.count == 0 : -1;
+            int is_keyframe = block->non_simple ? block->reference == INT64_MIN : -1;
             uint8_t* additional = block->additional.size > 0 ?
                                     block->additional.data : NULL;
 
@@ -4333,7 +4277,7 @@
 AVInputFormat ff_matroska_demuxer = {
     .name           = "matroska,webm",
     .long_name      = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
-    .extensions     = "mkv,mk3d,mka,mks,webm",
+    .extensions     = "mkv,mk3d,mka,mks",
     .priv_data_size = sizeof(MatroskaDemuxContext),
     .read_probe     = matroska_probe,
     .read_header    = matroska_read_header,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1749b7f..233c472 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1147,7 +1147,7 @@
         put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
     tag = av_dict_get(st->metadata, "language", NULL, 0);
     put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE,
-                    tag && tag->value[0] ? tag->value : "und");
+                    tag && tag->value ? tag->value : "und");
 
     // The default value for TRACKFLAGDEFAULT is 1, so add element
     // if we need to clear it.
@@ -1191,18 +1191,6 @@
 
         put_ebml_string(pb, MATROSKA_ID_CODECID, codec_id);
     } else {
-        if (st->disposition & AV_DISPOSITION_COMMENT)
-            put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGCOMMENTARY, 1);
-        if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
-            put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED, 1);
-        if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
-            put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGVISUALIMPAIRED,  1);
-        if (st->disposition & (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB) &&
-            (st->disposition & (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB))
-                            != (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB))
-            put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGORIGINAL,
-                          !!(st->disposition & AV_DISPOSITION_ORIGINAL));
-
         // look for a codec ID string specific to mkv to use,
         // if none are found, use AVI codes
         if (par->codec_id != AV_CODEC_ID_RAWVIDEO || par->codec_tag) {
@@ -1364,8 +1352,6 @@
             av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", par->codec_id);
             return AVERROR(ENOSYS);
         }
-        if (mkv->mode != MODE_WEBM && st->disposition & AV_DISPOSITION_DESCRIPTIONS)
-            put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS, 1);
 
         if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT)
             native_id = MATROSKA_TRACK_TYPE_SUBTITLE;
@@ -2023,8 +2009,7 @@
     AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
     mkv_track *track = &mkv->tracks[pkt->stream_index];
     uint8_t *data = NULL, *side_data = NULL;
-    buffer_size_t side_data_size;
-    int err = 0, offset = 0, size = pkt->size;
+    int err = 0, offset = 0, size = pkt->size, side_data_size;
     int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
     uint64_t additional_id;
     int64_t discard_padding = 0;
@@ -2134,8 +2119,7 @@
     MatroskaMuxContext *mkv = s->priv_data;
     mkv_track *track = &mkv->tracks[pkt->stream_index];
     ebml_master blockgroup;
-    buffer_size_t id_size, settings_size;
-    int size;
+    int id_size, settings_size, size;
     const char *id, *settings;
     int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
     const int flags = 0;
@@ -2200,8 +2184,7 @@
     mkv_track *track        = &mkv->tracks[pkt->stream_index];
     AVCodecParameters *par  = s->streams[pkt->stream_index]->codecpar;
     uint8_t *side_data;
-    buffer_size_t side_data_size;
-    int ret;
+    int side_data_size, ret;
 
     side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
                                         &side_data_size);
diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c
index 2a0b790..874ff45 100644
--- a/libavformat/mccdec.c
+++ b/libavformat/mccdec.c
@@ -142,7 +142,7 @@
         if (av_sscanf(line, "%d:%d:%d:%d", &hh, &mm, &ss, &fs) != 4)
             continue;
 
-        ts = av_sat_add64(av_rescale(hh * 3600LL + mm * 60LL + ss, rate.num, rate.den), fs);
+        ts = av_rescale(hh * 3600LL + mm * 60LL + ss, rate.num, rate.den) + fs;
 
         lline = (char *)&line;
         lline += 12;
diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c
index ecebff1..1f871b2 100644
--- a/libavformat/microdvddec.c
+++ b/libavformat/microdvddec.c
@@ -65,12 +65,12 @@
     return AV_NOPTS_VALUE;
 }
 
-static int64_t get_duration(const char *buf)
+static int get_duration(const char *buf)
 {
     int frame_start, frame_end;
 
     if (sscanf(buf, "{%d}{%d}", &frame_start, &frame_end) == 2)
-        return frame_end - (int64_t)frame_start;
+        return frame_end - frame_start;
     return -1;
 }
 
diff --git a/libavformat/mods.c b/libavformat/mods.c
index a26db87..4f093cd 100644
--- a/libavformat/mods.c
+++ b/libavformat/mods.c
@@ -1,7 +1,5 @@
 /*
  * MODS demuxer
- * Copyright (c) 2015-2016 Florian Nouwt
- * Copyright (c) 2017 Adib Surani
  * Copyright (c) 2020 Paul B Mahol
  *
  * This file is part of FFmpeg.
diff --git a/libavformat/moflex.c b/libavformat/moflex.c
index 41335ad..8142925 100644
--- a/libavformat/moflex.c
+++ b/libavformat/moflex.c
@@ -1,7 +1,5 @@
 /*
  * MOFLEX demuxer
- * Copyright (c) 2015-2016 Florian Nouwt
- * Copyright (c) 2017 Adib Surani
  * Copyright (c) 2020 Paul B Mahol
  *
  * This file is part of FFmpeg.
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 375568c..1654c62 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -288,8 +288,6 @@
         return 0;
 
     n_hmmt = avio_rb32(pb);
-    if (n_hmmt > len / 4)
-        return AVERROR_INVALIDDATA;
     for (i = 0; i < n_hmmt && !pb->eof_reached; i++) {
         int moment_time = avio_rb32(pb);
         avpriv_new_chapter(c->fc, i, av_make_q(1, 1000), moment_time, AV_NOPTS_VALUE, NULL);
@@ -404,7 +402,7 @@
     if (c->itunes_metadata && atom.size > 8) {
         int data_size = avio_rb32(pb);
         int tag = avio_rl32(pb);
-        if (tag == MKTAG('d','a','t','a') && data_size <= atom.size && data_size >= 16) {
+        if (tag == MKTAG('d','a','t','a') && data_size <= atom.size) {
             data_type = avio_rb32(pb); // type
             avio_rb32(pb); // unknown
             str_size = data_size - 16;
@@ -2361,6 +2359,19 @@
             st->codec->time_base = av_inv_q(st->avg_frame_rate);
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
+            /* adjust for per frame dur in counter mode */
+            if (tmcd_ctx->tmcd_flags & 0x0008) {
+                int timescale = AV_RB32(st->codecpar->extradata + 8);
+                int framedur = AV_RB32(st->codecpar->extradata + 12);
+                st->avg_frame_rate.num *= timescale;
+                st->avg_frame_rate.den *= framedur;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+                st->codec->time_base.den *= timescale;
+                st->codec->time_base.num *= framedur;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+            }
             if (size > 30) {
                 uint32_t len = AV_RB32(st->codecpar->extradata + 18); /* name atom length */
                 uint32_t format = AV_RB32(st->codecpar->extradata + 22);
@@ -2605,7 +2616,7 @@
     entries = avio_rb32(pb);
 
     /* Each entry contains a size (4 bytes) and format (4 bytes). */
-    if (entries <= 0 || entries > atom.size / 8 || entries > 1024) {
+    if (entries <= 0 || entries > atom.size / 8) {
         av_log(c->fc, AV_LOG_ERROR, "invalid STSD entries %d\n", entries);
         return AVERROR_INVALIDDATA;
     }
@@ -5569,10 +5580,6 @@
         av_log(c->fc, AV_LOG_ERROR, "Empty stereoscopic video box\n");
         return AVERROR_INVALIDDATA;
     }
-
-    if (sc->stereo3d)
-        return AVERROR_INVALIDDATA;
-
     avio_skip(pb, 4); /* version + flags */
 
     mode = avio_r8(pb);
@@ -6396,8 +6403,7 @@
     AVStream *st;
     uint8_t *side_data, *extra_data, *old_side_data;
     size_t side_data_size;
-    buffer_size_t old_side_data_size;
-    int ret = 0;
+    int ret = 0, old_side_data_size;
     unsigned int version, kid_count, extra_data_size, alloc_size = 0;
 
     if (c->fc->nb_streams < 1)
@@ -7023,8 +7029,6 @@
                 uint32_t type;
                 avio_skip(pb, 4);
                 type = avio_rl32(pb);
-                if (avio_feof(pb))
-                    break;
                 avio_seek(pb, -8, SEEK_CUR);
                 if (type == MKTAG('m','v','h','d') ||
                     type == MKTAG('c','m','o','v')) {
@@ -7088,7 +7092,7 @@
                 c->atom_depth --;
                 return err;
             }
-            if (c->found_moov && c->found_mdat && a.size <= INT64_MAX - start_pos &&
+            if (c->found_moov && c->found_mdat &&
                 ((!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX || c->frag_index.complete) ||
                  start_pos + a.size == avio_size(pb))) {
                 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX || c->frag_index.complete)
@@ -7127,22 +7131,9 @@
     /* check file header */
     offset = 0;
     for (;;) {
-        int64_t size;
-        int minsize = 8;
         /* ignore invalid offset */
         if ((offset + 8) > (unsigned int)p->buf_size)
             break;
-        size = AV_RB32(p->buf + offset);
-        if (size == 1 && offset + 16 > (unsigned int)p->buf_size) {
-            size = AV_RB64(p->buf+offset + 8);
-            minsize = 16;
-        } else if (size == 0) {
-            size = p->buf_size - offset;
-        }
-        if (size < minsize) {
-            offset += 4;
-            continue;
-        }
         tag = AV_RL32(p->buf + offset + 4);
         switch(tag) {
         /* check for obvious tags */
@@ -7152,7 +7143,12 @@
         case MKTAG('p','n','o','t'): /* detect movs with preview pics like ew.mov and april.mov */
         case MKTAG('u','d','t','a'): /* Packet Video PVAuthor adds this and a lot of more junk */
         case MKTAG('f','t','y','p'):
-            if (tag == MKTAG('f','t','y','p') &&
+            if (AV_RB32(p->buf+offset) < 8 &&
+                (AV_RB32(p->buf+offset) != 1 ||
+                 offset + 12 > (unsigned int)p->buf_size ||
+                 AV_RB64(p->buf+offset + 8) == 0)) {
+                score = FFMAX(score, AVPROBE_SCORE_EXTENSION);
+            } else if (tag == MKTAG('f','t','y','p') &&
                        (   AV_RL32(p->buf + offset + 8) == MKTAG('j','p','2',' ')
                         || AV_RL32(p->buf + offset + 8) == MKTAG('j','p','x',' ')
                     )) {
@@ -7160,6 +7156,7 @@
             } else {
                 score = AVPROBE_SCORE_MAX;
             }
+            offset = FFMAX(4, AV_RB32(p->buf+offset)) + offset;
             break;
         /* those are more common words, so rate then a bit less */
         case MKTAG('e','d','i','w'): /* xdcam files have reverted first tags */
@@ -7168,6 +7165,7 @@
         case MKTAG('j','u','n','k'):
         case MKTAG('p','i','c','t'):
             score  = FFMAX(score, AVPROBE_SCORE_MAX - 5);
+            offset = FFMAX(4, AV_RB32(p->buf+offset)) + offset;
             break;
         case MKTAG(0x82,0x82,0x7f,0x7d):
         case MKTAG('s','k','i','p'):
@@ -7175,9 +7173,11 @@
         case MKTAG('p','r','f','l'):
             /* if we only find those cause probedata is too small at least rate them */
             score  = FFMAX(score, AVPROBE_SCORE_EXTENSION);
+            offset = FFMAX(4, AV_RB32(p->buf+offset)) + offset;
             break;
+        default:
+            offset = FFMAX(4, AV_RB32(p->buf+offset)) + offset;
         }
-        offset += size;
     }
     if (score > AVPROBE_SCORE_MAX - 50 && moov_offset != -1) {
         /* moov atom in the header - we should make sure that this is not a
@@ -8143,22 +8143,6 @@
     return sample;
 }
 
-static int64_t mov_get_skip_samples(AVStream *st, int sample)
-{
-    MOVStreamContext *sc = st->priv_data;
-    int64_t first_ts = st->internal->index_entries[0].timestamp;
-    int64_t ts = st->internal->index_entries[sample].timestamp;
-    int64_t off;
-
-    if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
-        return 0;
-
-    /* compute skip samples according to stream start_pad, seek ts and first ts */
-    off = av_rescale_q(ts - first_ts, st->time_base,
-                       (AVRational){1, st->codecpar->sample_rate});
-    return FFMAX(sc->start_pad - off, 0);
-}
-
 static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
 {
     MOVContext *mc = s->priv_data;
@@ -8177,19 +8161,18 @@
     if (mc->seek_individually) {
         /* adjust seek timestamp to found sample timestamp */
         int64_t seek_timestamp = st->internal->index_entries[sample].timestamp;
-        st->internal->skip_samples = mov_get_skip_samples(st, sample);
 
         for (i = 0; i < s->nb_streams; i++) {
             int64_t timestamp;
+            MOVStreamContext *sc = s->streams[i]->priv_data;
             st = s->streams[i];
+            st->internal->skip_samples = (sample_time <= 0) ? sc->start_pad : 0;
 
             if (stream_index == i)
                 continue;
 
             timestamp = av_rescale_q(seek_timestamp, s->streams[stream_index]->time_base, st->time_base);
-            sample = mov_seek_stream(s, st, timestamp, flags);
-            if (sample >= 0)
-                st->internal->skip_samples = mov_get_skip_samples(st, sample);
+            mov_seek_stream(s, st, timestamp, flags);
         }
     } else {
         for (i = 0; i < s->nb_streams; i++) {
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1f0aaf5..18fa3f9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1978,7 +1978,7 @@
     // Ref (MP4): ISO/IEC 14496-12:2012
 
     const uint8_t *icc_profile;
-    buffer_size_t icc_profile_size;
+    int icc_profile_size;
 
     if (prefer_icc) {
         icc_profile = av_stream_get_side_data(track->st, AV_PKT_DATA_ICC_PROFILE, &icc_profile_size);
@@ -2025,6 +2025,7 @@
 
     side_data = av_stream_get_side_data(track->st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, NULL);
     if (!side_data) {
+        av_log(NULL, AV_LOG_VERBOSE, "Not writing 'clli' atom. No content light level info.\n");
         return 0;
     }
     content_light_metadata = (const AVContentLightMetadata*)side_data;
@@ -2051,6 +2052,7 @@
     side_data = av_stream_get_side_data(track->st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL);
     metadata = (const AVMasteringDisplayMetadata*)side_data;
     if (!metadata || !metadata->has_primaries || !metadata->has_luminance) {
+        av_log(NULL, AV_LOG_VERBOSE, "Not writing 'mdcv' atom. Missing mastering metadata.\n");
         return 0;
     }
 
@@ -2258,7 +2260,7 @@
         AVStereo3D* stereo_3d = (AVStereo3D*) av_stream_get_side_data(track->st, AV_PKT_DATA_STEREO3D, NULL);
         AVSphericalMapping* spherical_mapping = (AVSphericalMapping*)av_stream_get_side_data(track->st, AV_PKT_DATA_SPHERICAL, NULL);
         AVDOVIDecoderConfigurationRecord *dovi = (AVDOVIDecoderConfigurationRecord *)
-                                                 av_stream_get_side_data(track->st, AV_PKT_DATA_DOVI_CONF, NULL);
+                                                 av_stream_get_side_data(track->st, AV_PKT_DATA_DOVI_CONF, NULL);;
 
         if (stereo_3d)
             mov_write_st3d_tag(s, pb, stereo_3d);
@@ -2902,50 +2904,21 @@
     return update_size(pb, pos);
 }
 
-static void get_pts_range(MOVMuxContext *mov, MOVTrack *track,
-                          int64_t *start, int64_t *end)
+static int64_t calc_pts_duration(MOVMuxContext *mov, MOVTrack *track)
 {
     if (track->tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd) {
         // tmcd tracks gets track_duration set in mov_write_moov_tag from
         // another track's duration, while the end_pts may be left at zero.
         // Calculate the pts duration for that track instead.
-        get_pts_range(mov, &mov->tracks[track->src_track], start, end);
-        *start = av_rescale(*start, track->timescale,
-                            mov->tracks[track->src_track].timescale);
-        *end   = av_rescale(*end, track->timescale,
-                            mov->tracks[track->src_track].timescale);
-        return;
+        return av_rescale(calc_pts_duration(mov, &mov->tracks[track->src_track]),
+                          track->timescale, mov->tracks[track->src_track].timescale);
     }
     if (track->end_pts != AV_NOPTS_VALUE &&
         track->start_dts != AV_NOPTS_VALUE &&
         track->start_cts != AV_NOPTS_VALUE) {
-        *start = track->start_dts + track->start_cts;
-        *end   = track->end_pts;
-        return;
+        return track->end_pts - (track->start_dts + track->start_cts);
     }
-    *start = 0;
-    *end   = track->track_duration;
-}
-
-static int64_t calc_samples_pts_duration(MOVMuxContext *mov, MOVTrack *track)
-{
-    int64_t start, end;
-    get_pts_range(mov, track, &start, &end);
-    return end - start;
-}
-
-// Calculate the actual duration of the track, after edits.
-// If it starts with a pts < 0, that is removed by the edit list.
-// If it starts with a pts > 0, the edit list adds a delay before that.
-// Thus, with edit lists enabled, the post-edit output of the file is
-// starting with pts=0.
-static int64_t calc_pts_duration(MOVMuxContext *mov, MOVTrack *track)
-{
-    int64_t start, end;
-    get_pts_range(mov, track, &start, &end);
-    if (mov->use_editlist != 0)
-        start = 0;
-    return end - start;
+    return track->track_duration;
 }
 
 static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov,
@@ -3033,8 +3006,7 @@
     int group   = 0;
 
     uint32_t *display_matrix = NULL;
-    buffer_size_t display_matrix_size;
-    int       i;
+    int      display_matrix_size, i;
 
     if (st) {
         if (mov->per_stream_grouping)
@@ -3173,7 +3145,7 @@
 static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
                               MOVTrack *track)
 {
-    int64_t duration = av_rescale_rnd(calc_samples_pts_duration(mov, track),
+    int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track),
                                       MOV_TIMESCALE, track->timescale,
                                       AV_ROUND_UP);
     int version = duration < INT32_MAX ? 0 : 1;
@@ -4174,8 +4146,7 @@
             track->tref_tag = MKTAG('h','i','n','t');
             track->tref_id = mov->tracks[track->src_track].track_id;
         } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
-            buffer_size_t size;
-            int *fallback;
+            int * fallback, size;
             fallback = (int*)av_stream_get_side_data(track->st,
                                                      AV_PKT_DATA_FALLBACK_TRACK,
                                                      &size);
@@ -5303,19 +5274,15 @@
     for (i = 0; i < s->nb_streams; i++) {
         MOVTrack *track = &mov->tracks[i];
         if (!track->end_reliable) {
-            const AVPacket *pkt = ff_interleaved_peek(s, i);
-            if (pkt) {
-                int64_t offset, dts, pts;
-                ff_get_muxer_ts_offset(s, i, &offset);
-                pts = pkt->pts + offset;
-                dts = pkt->dts + offset;
+            AVPacket pkt;
+            if (!ff_interleaved_peek(s, i, &pkt, 1)) {
                 if (track->dts_shift != AV_NOPTS_VALUE)
-                    dts += track->dts_shift;
-                track->track_duration = dts - track->start_dts;
-                if (pts != AV_NOPTS_VALUE)
-                    track->end_pts = pts;
+                    pkt.dts += track->dts_shift;
+                track->track_duration = pkt.dts - track->start_dts;
+                if (pkt.pts != AV_NOPTS_VALUE)
+                    track->end_pts = pkt.pts;
                 else
-                    track->end_pts = dts;
+                    track->end_pts = pkt.dts;
             }
         }
     }
@@ -5558,7 +5525,7 @@
     AVProducerReferenceTime *prft;
     unsigned int samples_in_chunk = 0;
     int size = pkt->size, ret = 0, offset = 0;
-    buffer_size_t prft_size;
+    int prft_size;
     uint8_t *reformatted_data = NULL;
 
     ret = check_pkt(s, pkt);
@@ -5910,7 +5877,7 @@
             trk->par->codec_id == AV_CODEC_ID_AAC ||
             trk->par->codec_id == AV_CODEC_ID_AV1 ||
             trk->par->codec_id == AV_CODEC_ID_FLAC) {
-        buffer_size_t side_size;
+        int side_size;
         uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
         if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
             void *newextra = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
@@ -6389,6 +6356,7 @@
 static int mov_init(AVFormatContext *s)
 {
     MOVMuxContext *mov = s->priv_data;
+    AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
     int i, ret;
 
     mov->fc = s;
@@ -6396,15 +6364,15 @@
     /* Default mode == MP4 */
     mov->mode = MODE_MP4;
 
-#define IS_MODE(muxer, config) (CONFIG_ ## config ## _MUXER && !strcmp(#muxer, s->oformat->name))
-    if      (IS_MODE(3gp,   TGP)) mov->mode = MODE_3GP;
-    else if (IS_MODE(3g2,   TG2)) mov->mode = MODE_3GP|MODE_3G2;
-    else if (IS_MODE(mov,   MOV)) mov->mode = MODE_MOV;
-    else if (IS_MODE(psp,   PSP)) mov->mode = MODE_PSP;
-    else if (IS_MODE(ipod, IPOD)) mov->mode = MODE_IPOD;
-    else if (IS_MODE(ismv, ISMV)) mov->mode = MODE_ISM;
-    else if (IS_MODE(f4v,   F4V)) mov->mode = MODE_F4V;
-#undef IS_MODE
+    if (s->oformat) {
+        if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
+        else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
+        else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
+        else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
+        else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
+        else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
+        else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
+    }
 
     if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
         mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
@@ -6506,9 +6474,6 @@
 
     if (   mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == MODE_MP4)
         || mov->write_tmcd == 1) {
-        AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode",
-                                                    NULL, 0);
-
         /* +1 tmcd track for each video stream with a timecode */
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
@@ -6729,6 +6694,7 @@
 {
     AVIOContext *pb = s->pb;
     MOVMuxContext *mov = s->priv_data;
+    AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
     int i, ret, hint_track = 0, tmcd_track = 0, nb_tracks = s->nb_streams;
 
     if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
@@ -6827,8 +6793,6 @@
     }
 
     if (mov->nb_meta_tmcd) {
-        const AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata,
-                                                              "timecode", NULL, 0);
         /* Initialize the tmcd tracks */
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
@@ -7136,7 +7100,6 @@
     return ret;
 }
 
-#if CONFIG_TGP_MUXER || CONFIG_TG2_MUXER
 static const AVCodecTag codec_3gp_tags[] = {
     { AV_CODEC_ID_H263,     MKTAG('s','2','6','3') },
     { AV_CODEC_ID_H264,     MKTAG('a','v','c','1') },
@@ -7147,8 +7110,6 @@
     { AV_CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') },
     { AV_CODEC_ID_NONE, 0 },
 };
-static const AVCodecTag *const codec_3gp_tags_list[] = { codec_3gp_tags, NULL };
-#endif
 
 static const AVCodecTag codec_mp4_tags[] = {
     { AV_CODEC_ID_MPEG4,           MKTAG('m', 'p', '4', 'v') },
@@ -7186,9 +7147,6 @@
     { AV_CODEC_ID_MPEGH_3D_AUDIO,  MKTAG('m', 'h', 'm', '1') },
     { AV_CODEC_ID_NONE,               0 },
 };
-#if CONFIG_MP4_MUXER || CONFIG_PSP_MUXER
-static const AVCodecTag *const mp4_codec_tags_list[] = { codec_mp4_tags, NULL };
-#endif
 
 static const AVCodecTag codec_ism_tags[] = {
     { AV_CODEC_ID_WMAPRO      , MKTAG('w', 'm', 'a', ' ') },
@@ -7253,7 +7211,7 @@
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = codec_3gp_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ codec_3gp_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &tgp_muxer_class,
 };
@@ -7275,7 +7233,7 @@
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = mp4_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ codec_mp4_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &mp4_muxer_class,
 };
@@ -7296,7 +7254,7 @@
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = mp4_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ codec_mp4_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &psp_muxer_class,
 };
@@ -7316,7 +7274,7 @@
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = codec_3gp_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ codec_3gp_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &tg2_muxer_class,
 };
diff --git a/libavformat/movenccenc.c b/libavformat/movenccenc.c
index 74f3c4c..b91294f 100644
--- a/libavformat/movenccenc.c
+++ b/libavformat/movenccenc.c
@@ -412,6 +412,4 @@
 void ff_mov_cenc_free(MOVMuxCencContext* ctx)
 {
     av_aes_ctr_free(ctx->aes_ctr);
-    av_freep(&ctx->auxiliary_info);
-    av_freep(&ctx->auxiliary_info_sizes);
 }
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index ce503e3..4f91c4f 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -355,7 +355,7 @@
 
         if (mp3->xing_offset) {
             uint8_t *side_data = NULL;
-            buffer_size_t side_data_size;
+            int side_data_size;
 
             mp3_xing_add_frame(mp3, pkt);
             mp3->audio_size += pkt->size;
@@ -402,8 +402,7 @@
     AVReplayGain *rg;
     uint16_t tag_crc;
     uint8_t *toc;
-    buffer_size_t rg_size;
-    int i;
+    int i, rg_size;
     int64_t old_pos = avio_tell(s->pb);
 
     /* replace "Xing" identification string with "Info" for CBR files. */
diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index ff7da2e..447a8d4 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -292,7 +292,7 @@
             return AVERROR_EOF;
 
         mpc8_get_chunk_header(s->pb, &tag, &size);
-        if (size < 0 || size > INT_MAX)
+        if (size < 0)
             return -1;
         if(tag == TAG_AUDIOPACKET){
             if ((ret = av_get_packet(s->pb, pkt, size)) < 0)
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index d37f181..9bd0a55 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -48,9 +48,9 @@
     uint8_t id;
     int max_buffer_size; /* in bytes */
     int buffer_index;
-    PacketDesc *predecode_packet; /* start of packet queue */
-    PacketDesc *last_packet;      /* end of packet queue */
+    PacketDesc *predecode_packet;
     PacketDesc *premux_packet;
+    PacketDesc **next_packet;
     int packet_number;
     uint8_t lpcm_header[3];
     int lpcm_align;
@@ -986,8 +986,6 @@
             }
             stream->buffer_index    -= pkt_desc->size;
             stream->predecode_packet = pkt_desc->next;
-            if (!stream->predecode_packet)
-                stream->last_packet = NULL;
             av_freep(&pkt_desc);
         }
     }
@@ -1151,7 +1149,7 @@
     StreamInfo *stream = st->priv_data;
     int64_t pts, dts;
     PacketDesc *pkt_desc;
-    int preload, ret;
+    int preload;
     const int is_iframe = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
                           (pkt->flags & AV_PKT_FLAG_KEY);
 
@@ -1179,6 +1177,14 @@
     av_log(ctx, AV_LOG_TRACE, "dts:%f pts:%f flags:%d stream:%d nopts:%d\n",
             dts / 90000.0, pts / 90000.0, pkt->flags,
             pkt->stream_index, pts != AV_NOPTS_VALUE);
+    if (!stream->premux_packet)
+        stream->next_packet = &stream->premux_packet;
+    *stream->next_packet     =
+    pkt_desc                 = av_mallocz(sizeof(PacketDesc));
+    if (!pkt_desc)
+        return AVERROR(ENOMEM);
+    pkt_desc->pts            = pts;
+    pkt_desc->dts            = dts;
 
     if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) {
         if (size < 3) {
@@ -1192,24 +1198,14 @@
         size -= 3;
     }
 
-    pkt_desc                 = av_mallocz(sizeof(PacketDesc));
-    if (!pkt_desc)
-        return AVERROR(ENOMEM);
-    if (!stream->predecode_packet) {
-        stream->predecode_packet  = pkt_desc;
-    } else
-        stream->last_packet->next = pkt_desc;
-    stream->last_packet = pkt_desc;
-    if (!stream->premux_packet)
-        stream->premux_packet = pkt_desc;
-    pkt_desc->pts            = pts;
-    pkt_desc->dts            = dts;
     pkt_desc->unwritten_size =
     pkt_desc->size           = size;
+    if (!stream->predecode_packet)
+        stream->predecode_packet = pkt_desc;
+    stream->next_packet = &pkt_desc->next;
 
-    ret = av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size);
-    if (ret < 0)
-        return ret;
+    if (av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size) < 0)
+        return -1;
 
     if (s->is_dvd) {
         // min VOBU length 0.4 seconds (mpucoder)
@@ -1263,11 +1259,6 @@
         StreamInfo *stream = ctx->streams[i]->priv_data;
         if (!stream)
             continue;
-        for (PacketDesc *pkt = stream->predecode_packet; pkt; ) {
-            PacketDesc *tmp = pkt->next;
-            av_free(pkt);
-            pkt = tmp;
-        }
         av_fifo_freep(&stream->fifo);
     }
 }
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index e283ec0..7549fc9 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -20,7 +20,6 @@
  */
 
 #include "libavutil/buffer.h"
-#include "libavutil/common.h"
 #include "libavutil/crc.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
@@ -107,19 +106,11 @@
     } u;
 };
 
-struct Stream {
-    int idx;
-    int stream_identifier;
-};
-
-#define MAX_STREAMS_PER_PROGRAM 128
-#define MAX_PIDS_PER_PROGRAM (MAX_STREAMS_PER_PROGRAM + 2)
+#define MAX_PIDS_PER_PROGRAM 64
 struct Program {
     unsigned int id; // program id/service id
     unsigned int nb_pids;
     unsigned int pids[MAX_PIDS_PER_PROGRAM];
-    unsigned int nb_streams;
-    struct Stream streams[MAX_STREAMS_PER_PROGRAM];
 
     /** have we found pmt for this program */
     int pmt_found;
@@ -144,7 +135,7 @@
     int fix_teletext_pts;
 
     int64_t cur_pcr;    /**< used to estimate the exact PCR */
-    int64_t pcr_incr;   /**< used to estimate the exact PCR */
+    int pcr_incr;       /**< used to estimate the exact PCR */
 
     /* data needed to handle file based ts */
     /** stop parsing loop */
@@ -294,13 +285,16 @@
     prg->nb_stream_indexes = 0;
 }
 
-static void clear_program(struct Program *p)
+static void clear_program(MpegTSContext *ts, unsigned int programid)
 {
-    if (!p)
-        return;
-    p->nb_pids = 0;
-    p->nb_streams = 0;
-    p->pmt_found = 0;
+    int i;
+
+    clear_avprogram(ts, programid);
+    for (i = 0; i < ts->nb_prg; i++)
+        if (ts->prg[i].id == programid) {
+            ts->prg[i].nb_pids = 0;
+            ts->prg[i].pmt_found = 0;
+        }
 }
 
 static void clear_programs(MpegTSContext *ts)
@@ -309,24 +303,24 @@
     ts->nb_prg = 0;
 }
 
-static struct Program * add_program(MpegTSContext *ts, unsigned int programid)
+static void add_pat_entry(MpegTSContext *ts, unsigned int programid)
 {
-    struct Program *p = get_program(ts, programid);
-    if (p)
-        return p;
+    struct Program *p;
     if (av_reallocp_array(&ts->prg, ts->nb_prg + 1, sizeof(*ts->prg)) < 0) {
         ts->nb_prg = 0;
-        return NULL;
+        return;
     }
     p = &ts->prg[ts->nb_prg];
     p->id = programid;
-    clear_program(p);
+    p->nb_pids = 0;
+    p->pmt_found = 0;
     ts->nb_prg++;
-    return p;
 }
 
-static void add_pid_to_program(struct Program *p, unsigned int pid)
+static void add_pid_to_pmt(MpegTSContext *ts, unsigned int programid,
+                           unsigned int pid)
 {
+    struct Program *p = get_program(ts, programid);
     int i;
     if (!p)
         return;
@@ -341,6 +335,15 @@
     p->pids[p->nb_pids++] = pid;
 }
 
+static void set_pmt_found(MpegTSContext *ts, unsigned int programid)
+{
+    struct Program *p = get_program(ts, programid);
+    if (!p)
+        return;
+
+    p->pmt_found = 1;
+}
+
 static void update_av_program_info(AVFormatContext *s, unsigned int programid,
                                    unsigned int pid, int version)
 {
@@ -377,9 +380,6 @@
     int used = 0, discarded = 0;
     struct Program *p;
 
-    if (pid == PAT_PID)
-        return 0;
-
     /* If none of the programs have .discard=AVDISCARD_ALL then there's
      * no way we have to discard this packet */
     for (k = 0; k < ts->stream->nb_programs; k++)
@@ -2202,20 +2202,25 @@
 }
 
 static AVStream *find_matching_stream(MpegTSContext *ts, int pid, unsigned int programid,
-                                      int stream_identifier, int pmt_stream_idx, struct Program *p)
+                                      int stream_identifier, int pmt_stream_idx)
 {
     AVFormatContext *s = ts->stream;
     int i;
     AVStream *found = NULL;
 
-    if (stream_identifier) { /* match based on "stream identifier descriptor" if present */
-        for (i = 0; i < p->nb_streams; i++) {
-            if (p->streams[i].stream_identifier == stream_identifier)
-                if (!found || pmt_stream_idx == i) /* fallback to idx based guess if multiple streams have the same identifier */
-                    found = s->streams[p->streams[i].idx];
+    for (i = 0; i < s->nb_streams; i++) {
+        AVStream *st = s->streams[i];
+        if (st->program_num != programid)
+            continue;
+        if (stream_identifier != -1) { /* match based on "stream identifier descriptor" if present */
+            if (st->stream_identifier == stream_identifier+1) {
+                found = st;
+                break;
+            }
+        } else if (st->pmt_stream_idx == pmt_stream_idx) { /* match based on position within the PMT */
+            found = st;
+            break;
         }
-    } else if (pmt_stream_idx < p->nb_streams) { /* match based on position within the PMT */
-        found = s->streams[p->streams[pmt_stream_idx].idx];
     }
 
     if (found) {
@@ -2274,7 +2279,6 @@
 {
     MpegTSContext *ts = filter->u.section_filter.opaque;
     MpegTSSectionFilter *tssf = &filter->u.section_filter;
-    struct Program old_program;
     SectionHeader h1, *h = &h1;
     PESContext *pes;
     AVStream *st;
@@ -2283,7 +2287,6 @@
     int desc_list_len;
     uint32_t prog_reg_desc = 0; /* registration descriptor */
     int stream_identifier = -1;
-    struct Program *prg;
 
     int mp4_descr_count = 0;
     Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } };
@@ -2307,26 +2310,16 @@
     if (!ts->scan_all_pmts && ts->skip_changes)
         return;
 
-    prg = get_program(ts, h->id);
-    if (prg)
-        old_program = *prg;
-    else
-        clear_program(&old_program);
-
-    if (ts->skip_unknown_pmt && !prg)
-        return;
-    if (prg && prg->nb_pids && prg->pids[0] != ts->current_pid)
+    if (ts->skip_unknown_pmt && !get_program(ts, h->id))
         return;
     if (!ts->skip_clear)
-        clear_avprogram(ts, h->id);
-    clear_program(prg);
-    add_pid_to_program(prg, ts->current_pid);
+        clear_program(ts, h->id);
 
     pcr_pid = get16(&p, p_end);
     if (pcr_pid < 0)
         return;
     pcr_pid &= 0x1fff;
-    add_pid_to_program(prg, pcr_pid);
+    add_pid_to_pmt(ts, h->id, pcr_pid);
     update_av_program_info(ts->stream, h->id, pcr_pid, h->version);
 
     av_log(ts->stream, AV_LOG_TRACE, "pcr_pid=0x%x\n", pcr_pid);
@@ -2366,10 +2359,10 @@
     if (!ts->pkt)
         ts->stop_parse = 2;
 
-    if (prg)
-        prg->pmt_found = 1;
+    set_pmt_found(ts, h->id);
 
-    for (i = 0; i < MAX_STREAMS_PER_PROGRAM; i++) {
+
+    for (i = 0; ; i++) {
         st = 0;
         pes = NULL;
         stream_type = get8(&p, p_end);
@@ -2382,13 +2375,14 @@
         if (pid == ts->current_pid)
             goto out;
 
-        stream_identifier = parse_stream_identifier_desc(p, p_end) + 1;
+        if (ts->merge_pmt_versions)
+            stream_identifier = parse_stream_identifier_desc(p, p_end);
 
         /* now create stream */
         if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {
             pes = ts->pids[pid]->u.pes_filter.opaque;
             if (ts->merge_pmt_versions && !pes->st) {
-                st = find_matching_stream(ts, pid, h->id, stream_identifier, i, &old_program);
+                st = find_matching_stream(ts, pid, h->id, stream_identifier, i);
                 if (st) {
                     pes->st = st;
                     pes->stream_type = stream_type;
@@ -2400,6 +2394,9 @@
                 if (!pes->st)
                     goto out;
                 pes->st->id = pes->pid;
+                pes->st->program_num = h->id;
+                pes->st->pmt_version = h->version;
+                pes->st->pmt_stream_idx = i;
             }
             st = pes->st;
         } else if (is_pes_stream(stream_type, prog_reg_desc)) {
@@ -2407,7 +2404,7 @@
                 mpegts_close_filter(ts, ts->pids[pid]); // wrongly added sdt filter probably
             pes = add_pes_stream(ts, pid, pcr_pid);
             if (ts->merge_pmt_versions && pes && !pes->st) {
-                st = find_matching_stream(ts, pid, h->id, stream_identifier, i, &old_program);
+                st = find_matching_stream(ts, pid, h->id, stream_identifier, i);
                 if (st) {
                     pes->st = st;
                     pes->stream_type = stream_type;
@@ -2419,6 +2416,9 @@
                 if (!st)
                     goto out;
                 st->id = pes->pid;
+                st->program_num = h->id;
+                st->pmt_version = h->version;
+                st->pmt_stream_idx = i;
             }
         } else {
             int idx = ff_find_stream_index(ts->stream, pid);
@@ -2426,13 +2426,16 @@
                 st = ts->stream->streams[idx];
             }
             if (ts->merge_pmt_versions && !st) {
-                st = find_matching_stream(ts, pid, h->id, stream_identifier, i, &old_program);
+                st = find_matching_stream(ts, pid, h->id, stream_identifier, i);
             }
             if (!st) {
                 st = avformat_new_stream(ts->stream, NULL);
                 if (!st)
                     goto out;
                 st->id = pid;
+                st->program_num = h->id;
+                st->pmt_version = h->version;
+                st->pmt_stream_idx = i;
                 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
                 if (stream_type == 0x86 && prog_reg_desc == AV_RL32("CUEI")) {
                     mpegts_find_stream_type(st, stream_type, SCTE_types);
@@ -2447,12 +2450,7 @@
         if (pes && !pes->stream_type)
             mpegts_set_stream_info(st, pes, stream_type, prog_reg_desc);
 
-        add_pid_to_program(prg, pid);
-        if (prg) {
-            prg->streams[i].idx = st->index;
-            prg->streams[i].stream_identifier = stream_identifier;
-            prg->nb_streams++;
-        }
+        add_pid_to_pmt(ts, h->id, pid);
 
         av_program_add_stream_index(ts->stream, h->id, st->index);
 
@@ -2494,7 +2492,6 @@
     SectionHeader h1, *h = &h1;
     const uint8_t *p, *p_end;
     int sid, pmt_pid;
-    int nb_prg = 0;
     AVProgram *program;
 
     av_log(ts->stream, AV_LOG_TRACE, "PAT:\n");
@@ -2513,6 +2510,7 @@
         return;
     ts->stream->ts_id = h->id;
 
+    clear_programs(ts);
     for (;;) {
         sid = get16(&p, p_end);
         if (sid < 0)
@@ -2531,7 +2529,6 @@
             /* NIT info */
         } else {
             MpegTSFilter *fil = ts->pids[pmt_pid];
-            struct Program *prg;
             program = av_new_program(ts->stream, sid);
             if (program) {
                 program->program_num = sid;
@@ -2545,20 +2542,11 @@
 
             if (!ts->pids[pmt_pid])
                 mpegts_open_section_filter(ts, pmt_pid, pmt_cb, ts, 1);
-            prg = add_program(ts, sid);
-            if (prg) {
-                unsigned prg_idx = prg - ts->prg;
-                if (prg->nb_pids && prg->pids[0] != pmt_pid)
-                    clear_program(prg);
-                add_pid_to_program(prg, pmt_pid);
-                if (prg_idx > nb_prg)
-                    FFSWAP(struct Program, ts->prg[nb_prg], ts->prg[prg_idx]);
-                if (prg_idx >= nb_prg)
-                    nb_prg++;
-            }
+            add_pat_entry(ts, sid);
+            add_pid_to_pmt(ts, sid, 0); // add pat pid to program
+            add_pid_to_pmt(ts, sid, pmt_pid);
         }
     }
-    ts->nb_prg = nb_prg;
 
     if (sid < 0) {
         int i,j;
@@ -3102,6 +3090,7 @@
         AVStream *st;
         int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l;
         int64_t pcrs[2], pcr_h;
+        int packet_count[2];
         uint8_t packet[TS_PACKET_SIZE];
         const uint8_t *data;
 
@@ -3127,6 +3116,7 @@
                 parse_pcr(&pcr_h, &pcr_l, data) == 0) {
                 finished_reading_packet(s, ts->raw_packet_size);
                 pcr_pid = pid;
+                packet_count[nb_pcrs] = nb_packets;
                 pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
                 nb_pcrs++;
                 if (nb_pcrs >= 2) {
@@ -3136,6 +3126,7 @@
                     } else {
                         av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= %"PRId64"\n", pcrs[0], pcrs[1]);
                         pcrs[0] = pcrs[1];
+                        packet_count[0] = packet_count[1];
                         nb_pcrs--;
                     }
                 }
@@ -3147,12 +3138,12 @@
 
         /* NOTE1: the bitrate is computed without the FEC */
         /* NOTE2: it is only the bitrate of the start of the stream */
-        ts->pcr_incr = pcrs[1] - pcrs[0];
-        ts->cur_pcr  = pcrs[0] - ts->pcr_incr * (nb_packets - 1);
+        ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]);
+        ts->cur_pcr  = pcrs[0] - ts->pcr_incr * packet_count[0];
         s->bit_rate  = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr;
         st->codecpar->bit_rate = s->bit_rate;
         st->start_time      = ts->cur_pcr;
-        av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%"PRId64"\n",
+        av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%d\n",
                 st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
     }
 
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 8158a20..45f8d5f 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1677,7 +1677,7 @@
     const int64_t max_audio_delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) / 2;
     int64_t dts = pkt->dts, pts = pkt->pts;
     int opus_samples = 0;
-    buffer_size_t side_data_size;
+    int side_data_size;
     uint8_t *side_data = NULL;
     int stream_id = -1;
 
@@ -1814,7 +1814,7 @@
         /* Add Opus control header */
         if ((AV_RB16(pkt->data) >> 5) != 0x3ff) {
             uint8_t *side_data;
-            buffer_size_t side_data_size;
+            int side_data_size;
             int i, n;
             int ctrl_header_size;
             int trim_start = 0, trim_end = 0;
diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c
index 2e6dc88..e7b83a1 100644
--- a/libavformat/mpsubdec.c
+++ b/libavformat/mpsubdec.c
@@ -72,8 +72,8 @@
                 fracval *= 10;
             for (;p2 - p1 > 7 + 1; p1++)
                 fracval /= 10;
-            if (intval > 0) intval = av_sat_add64(intval, fracval);
-            else            intval = av_sat_sub64(intval, fracval);
+            if (intval > 0) intval += fracval;
+            else            intval -= fracval;
             line += p2;
         } else
             line += p1;
diff --git a/libavformat/mspdec.c b/libavformat/mspdec.c
index 4845eb3..b81d835 100644
--- a/libavformat/mspdec.c
+++ b/libavformat/mspdec.c
@@ -70,12 +70,11 @@
 
     if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
         cntx->packet_size = av_image_get_buffer_size(st->codecpar->format, st->codecpar->width, st->codecpar->height, 1);
+        if (cntx->packet_size < 0)
+            return cntx->packet_size;
     } else
         cntx->packet_size = 2 * st->codecpar->height;
 
-    if (cntx->packet_size <= 0)
-        return cntx->packet_size < 0 ? cntx->packet_size : AVERROR_INVALIDDATA;
-
     return 0;
 }
 
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 062ba8d..84c56ac 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1046,32 +1046,30 @@
     }
 }
 
-int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset)
-{
-    AVStream *st;
-
-    if (stream_index < 0 || stream_index >= s->nb_streams)
-        return AVERROR(EINVAL);
-
-    st = s->streams[stream_index];
-    *offset = st->internal->mux_ts_offset;
-
-    if (s->output_ts_offset)
-        *offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
-
-    return 0;
-}
-
-const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
+int ff_interleaved_peek(AVFormatContext *s, int stream,
+                        AVPacket *pkt, int add_offset)
 {
     AVPacketList *pktl = s->internal->packet_buffer;
     while (pktl) {
         if (pktl->pkt.stream_index == stream) {
-            return &pktl->pkt;
+            *pkt = pktl->pkt;
+            if (add_offset) {
+                AVStream *st = s->streams[pkt->stream_index];
+                int64_t offset = st->internal->mux_ts_offset;
+
+                if (s->output_ts_offset)
+                    offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
+
+                if (pkt->dts != AV_NOPTS_VALUE)
+                    pkt->dts += offset;
+                if (pkt->pts != AV_NOPTS_VALUE)
+                    pkt->pts += offset;
+            }
+            return 0;
         }
         pktl = pktl->next;
     }
-    return NULL;
+    return AVERROR(ENOENT);
 }
 
 /**
diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index 2aef93a..d8f121b 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -159,10 +159,7 @@
         st->codecpar->sample_rate = var_read_int(pb, size);
         avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
     } else if (!strcmp(name, "SAMPLE_WIDTH")) {
-        uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;
-        if (bpc > 16)
-            return AVERROR_INVALIDDATA;
-        st->codecpar->bits_per_coded_sample = bpc;
+        st->codecpar->bits_per_coded_sample = var_read_int(pb, size) * 8;
     } else
         return AVERROR_INVALIDDATA;
 
@@ -213,12 +210,10 @@
         st->codecpar->width = var_read_int(pb, size);
     } else if (!strcmp(name, "ORIENTATION")) {
         if (var_read_int(pb, size) == 1101) {
-            if (!st->codecpar->extradata) {
-                st->codecpar->extradata = av_strdup("BottomUp");
-                if (!st->codecpar->extradata)
-                    return AVERROR(ENOMEM);
-                st->codecpar->extradata_size = 9;
-            }
+            st->codecpar->extradata      = av_strdup("BottomUp");
+            if (!st->codecpar->extradata)
+                return AVERROR(ENOMEM);
+            st->codecpar->extradata_size = 9;
         }
     } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {
         var_read_metadata(avctx, name, size);
@@ -271,8 +266,6 @@
         uint32_t pos  = avio_rb32(pb);
         uint32_t size = avio_rb32(pb);
         avio_skip(pb, 8);
-        if (avio_feof(pb))
-            return ;
         av_add_index_entry(st, pos, timestamp, size, 0, AVINDEX_KEYFRAME);
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             timestamp += size / (st->codecpar->channels * 2LL);
diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index 2d4b11a..06c9cfe 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -94,7 +94,7 @@
     vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     vst->codecpar->codec_id   = AV_CODEC_ID_MOTIONPIXELS;
 
-    mvi->get_int = (vst->codecpar->width * (int64_t)vst->codecpar->height < (1 << 16)) ? avio_rl16 : avio_rl24;
+    mvi->get_int = (vst->codecpar->width * vst->codecpar->height < (1 << 16)) ? avio_rl16 : avio_rl24;
 
     mvi->audio_frame_size   = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
     if (mvi->audio_frame_size <= 1 << MVI_FRAC_BITS - 1) {
diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index 85a65f8..88f69eb 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -22,7 +22,16 @@
 #include "libavutil/common.h"
 #include "mxf.h"
 
-const uint8_t ff_mxf_random_index_pack_key[16] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
+const uint8_t ff_mxf_mastering_display_prefix[13]           = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01 };
+
+/* be careful to update references to this array if reordering */
+/* local tags are dynamic and must not clash with others in mxfenc.c */
+const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4] = {
+    { 0x8301, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00 }}, /* Mastering Display Primaries */
+    { 0x8302, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }}, /* Mastering Display White Point Chromaticity */
+    { 0x8303, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }}, /* Mastering Display Maximum Luminance */
+    { 0x8304, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }}  /* Mastering Display Minimum Luminance */
+};
 
 /**
  * SMPTE RP224 http://www.smpte-ra.org/mdd/index.html
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index b1b1fed..7fa10bc 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -83,13 +83,8 @@
     UID uid;
 } MXFLocalTagPair;
 
-extern const uint8_t ff_mxf_random_index_pack_key[16];
-
-#define FF_MXF_MasteringDisplay_PREFIX                  0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01
-#define FF_MXF_MasteringDisplayPrimaries                { FF_MXF_MasteringDisplay_PREFIX,0x01,0x00,0x00 }
-#define FF_MXF_MasteringDisplayWhitePointChromaticity   { FF_MXF_MasteringDisplay_PREFIX,0x02,0x00,0x00 }
-#define FF_MXF_MasteringDisplayMaximumLuminance         { FF_MXF_MasteringDisplay_PREFIX,0x03,0x00,0x00 }
-#define FF_MXF_MasteringDisplayMinimumLuminance         { FF_MXF_MasteringDisplay_PREFIX,0x04,0x00,0x00 }
+extern const uint8_t ff_mxf_mastering_display_prefix[13];
+extern const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4];
 
 #define FF_MXF_MASTERING_CHROMA_DEN 50000
 #define FF_MXF_MASTERING_LUMA_DEN   10000
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index bb00838..1f79f3d 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -328,6 +328,7 @@
 static const uint8_t mxf_crypto_source_container_ul[]      = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 };
 static const uint8_t mxf_encrypted_triplet_key[]           = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
 static const uint8_t mxf_encrypted_essence_container[]     = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
+static const uint8_t mxf_random_index_pack_key[]           = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
 static const uint8_t mxf_sony_mpeg4_extradata[]            = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
 static const uint8_t mxf_avid_project_name[]               = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
 static const uint8_t mxf_jp2k_rsiz[]                       = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 };
@@ -336,14 +337,6 @@
 static const uint8_t mxf_apple_coll_max_cll[]              = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 };
 static const uint8_t mxf_apple_coll_max_fall[]             = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 };
 
-static const uint8_t mxf_mastering_display_prefix[13]      = { FF_MXF_MasteringDisplay_PREFIX };
-static const uint8_t mxf_mastering_display_uls[4][16] = {
-    FF_MXF_MasteringDisplayPrimaries,
-    FF_MXF_MasteringDisplayWhitePointChromaticity,
-    FF_MXF_MasteringDisplayMaximumLuminance,
-    FF_MXF_MasteringDisplayMinimumLuminance,
-};
-
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
 
 static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx)
@@ -351,10 +344,11 @@
     MXFIndexTableSegment *seg;
     switch ((*ctx)->type) {
     case Descriptor:
-    case MultipleDescriptor:
         av_freep(&((MXFDescriptor *)*ctx)->extradata);
         av_freep(&((MXFDescriptor *)*ctx)->mastering);
         av_freep(&((MXFDescriptor *)*ctx)->coll);
+        break;
+    case MultipleDescriptor:
         av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs);
         break;
     case Sequence:
@@ -1094,9 +1088,9 @@
     if(segment->nb_index_entries && length < 11)
         return AVERROR_INVALIDDATA;
 
-    if (!FF_ALLOC_TYPED_ARRAY(segment->temporal_offset_entries, segment->nb_index_entries) ||
-        !FF_ALLOC_TYPED_ARRAY(segment->flag_entries           , segment->nb_index_entries) ||
-        !FF_ALLOC_TYPED_ARRAY(segment->stream_offset_entries  , segment->nb_index_entries)) {
+    if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
+        !(segment->flag_entries          = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
+        !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
         av_freep(&segment->temporal_offset_entries);
         av_freep(&segment->flag_entries);
         return AVERROR(ENOMEM);
@@ -1288,13 +1282,13 @@
                 rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
                 descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
         }
-        if (IS_KLV_KEY(uid, mxf_mastering_display_prefix)) {
+        if (IS_KLV_KEY(uid, ff_mxf_mastering_display_prefix)) {
             if (!descriptor->mastering) {
                 descriptor->mastering = av_mastering_display_metadata_alloc();
                 if (!descriptor->mastering)
                     return AVERROR(ENOMEM);
             }
-            if (IS_KLV_KEY(uid, mxf_mastering_display_uls[0])) {
+            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[0].uid)) {
                 for (int i = 0; i < 3; i++) {
                     /* Order: large x, large y, other (i.e. RGB) */
                     descriptor->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
@@ -1304,20 +1298,20 @@
                 if (descriptor->mastering->white_point[0].den != 0)
                     descriptor->mastering->has_primaries = 1;
             }
-            if (IS_KLV_KEY(uid, mxf_mastering_display_uls[1])) {
+            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[1].uid)) {
                 descriptor->mastering->white_point[0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
                 descriptor->mastering->white_point[1] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
                 /* Check we have seen mxf_mastering_display_primaries */
                 if (descriptor->mastering->display_primaries[0][0].den != 0)
                     descriptor->mastering->has_primaries = 1;
             }
-            if (IS_KLV_KEY(uid, mxf_mastering_display_uls[2])) {
+            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[2].uid)) {
                 descriptor->mastering->max_luminance = av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
                 /* Check we have seen mxf_mastering_display_minimum_luminance */
                 if (descriptor->mastering->min_luminance.den != 0)
                     descriptor->mastering->has_luminance = 1;
             }
-            if (IS_KLV_KEY(uid, mxf_mastering_display_uls[3])) {
+            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[3].uid)) {
                 descriptor->mastering->min_luminance = av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
                 /* Check we have seen mxf_mastering_display_maximum_luminance */
                 if (descriptor->mastering->max_luminance.den != 0)
@@ -1978,15 +1972,6 @@
     return 0;
 }
 
-static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t tertiary,
-                              uint16_t patch, uint16_t release, char **str)
-{
-    *str = av_asprintf("%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
-    if (!*str)
-        return AVERROR(ENOMEM);
-    return 0;
-}
-
 static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage* package)
 {
     char *str;
@@ -2748,17 +2733,6 @@
     av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
 } while (0)
 
-#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
-    major = avio_rb16(pb); \
-    minor = avio_rb16(pb); \
-    tertiary = avio_rb16(pb); \
-    patch = avio_rb16(pb); \
-    release = avio_rb16(pb); \
-    if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
-        return ret; \
-    av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
-} while (0)
-
 #define SET_UID_METADATA(pb, name, var, str) do { \
     avio_read(pb, var, 16); \
     if ((ret = mxf_uid_to_str(var, &str)) < 0) \
@@ -2780,7 +2754,6 @@
     UID uid = { 0 };
     char *str = NULL;
     uint64_t ts;
-    uint16_t major, minor, tertiary, patch, release;
     switch (tag) {
     case 0x3C01:
         SET_STR_METADATA(pb, "company_name", str);
@@ -2788,9 +2761,6 @@
     case 0x3C02:
         SET_STR_METADATA(pb, "product_name", str);
         break;
-    case 0x3C03:
-        SET_VERSION_METADATA(pb, "product_version_num", major, minor, tertiary, patch, release, str);
-        break;
     case 0x3C04:
         SET_STR_METADATA(pb, "product_version", str);
         break;
@@ -2800,9 +2770,6 @@
     case 0x3C06:
         SET_TS_METADATA(pb, "modification_date", ts, str);
         break;
-    case 0x3C07:
-        SET_VERSION_METADATA(pb, "toolkit_version_num", major, minor, tertiary, patch, release, str);
-        break;
     case 0x3C08:
         SET_STR_METADATA(pb, "application_platform", str);
         break;
@@ -2900,11 +2867,8 @@
         int ret;
         int tag = avio_rb16(pb);
         int size = avio_rb16(pb); /* KLV specified by 0x53 */
-        int64_t next = avio_tell(pb);
+        uint64_t next = avio_tell(pb) + size;
         UID uid = {0};
-        if (next < 0 || next > INT64_MAX - size)
-            return next < 0 ? next : AVERROR_INVALIDDATA;
-        next += size;
 
         av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x size %d\n", tag, size);
         if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */
@@ -3300,7 +3264,7 @@
         goto end;
     avio_seek(s->pb, file_size - length, SEEK_SET);
     if (klv_read_packet(&klv, s->pb) < 0 ||
-        !IS_KLV_KEY(klv.key, ff_mxf_random_index_pack_key))
+        !IS_KLV_KEY(klv.key, mxf_random_index_pack_key))
         goto end;
     if (klv.next_klv != file_size || klv.length <= 4 || (klv.length - 4) % 12) {
         av_log(s, AV_LOG_WARNING, "Invalid RIP KLV length\n");
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 1c66899..d8678c9 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -228,6 +228,38 @@
     { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x06,0x01 }, // D-10 525/50 NTSC 30mb/s
 };
 
+typedef struct MXFContext {
+    AVClass *av_class;
+    int64_t footer_partition_offset;
+    int essence_container_count;
+    AVRational time_base;
+    int header_written;
+    MXFIndexEntry *index_entries;
+    unsigned edit_units_count;
+    uint64_t timestamp;   ///< timestamp, as year(16),month(8),day(8),hour(8),minutes(8),msec/4(8)
+    uint8_t slice_count;  ///< index slice count minus 1 (1 if no audio, 0 otherwise)
+    int last_indexed_edit_unit;
+    uint64_t *body_partition_offset;
+    unsigned body_partitions_count;
+    int last_key_index;  ///< index of last key frame
+    uint64_t duration;
+    AVTimecode tc;       ///< timecode context
+    AVStream *timecode_track;
+    int timecode_base;       ///< rounded time code base (25 or 30)
+    int edit_unit_byte_count; ///< fixed edit unit byte count
+    int content_package_rate; ///< content package rate in system element, see SMPTE 326M
+    uint64_t body_offset;
+    uint32_t instance_number;
+    uint8_t umid[16];        ///< unique material identifier
+    int channel_count;
+    int signal_standard;
+    uint32_t tagged_value_count;
+    AVRational audio_edit_rate;
+    int store_user_comments;
+    int track_instance_count; // used to generate MXFTrack uuids
+    int cbr_index;           ///< use a constant bitrate index
+} MXFContext;
+
 static const uint8_t uuid_base[]            = { 0xAD,0xAB,0x44,0x24,0x2f,0x25,0x4d,0xc7,0x92,0xff,0x29,0xbd };
 static const uint8_t umid_ul[]              = { 0x06,0x0A,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x01,0x0D,0x00,0x13 };
 
@@ -239,6 +271,7 @@
 static const uint8_t footer_partition_key[]        = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x04,0x04,0x00 }; // ClosedComplete
 static const uint8_t primer_pack_key[]             = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x05,0x01,0x00 };
 static const uint8_t index_table_segment_key[]     = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 };
+static const uint8_t random_index_pack_key[]       = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
 static const uint8_t header_open_partition_key[]   = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }; // OpenIncomplete
 static const uint8_t header_closed_partition_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x02,0x04,0x00 }; // ClosedComplete
 static const uint8_t klv_fill_key[]                = { 0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x10,0x01,0x00,0x00,0x00 };
@@ -329,8 +362,6 @@
     { 0x3217, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x07,0x00,0x00,0x00}}, /* Display F2 offset */
     { 0x320E, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x00,0x00,0x00}}, /* Aspect Ratio */
     { 0x3210, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x02,0x01,0x01,0x01,0x02,0x00}}, /* Transfer characteristic */
-    { 0x321A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x02,0x01,0x01,0x03,0x01,0x00}}, /* Coding Equations (color space) */
-    { 0x3219, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x09,0x04,0x01,0x02,0x01,0x01,0x06,0x01,0x00}}, /* Color Primaries */
     { 0x3213, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x02,0x00,0x00,0x00,0x00}}, /* Image Start Offset */
     { 0x3214, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x03,0x00,0x00,0x00,0x00}}, /* Image End Offset */
     { 0x3201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x06,0x01,0x00,0x00,0x00,0x00}}, /* Picture Essence Coding */
@@ -371,56 +402,20 @@
     // Wave Audio Essence Descriptor
     { 0x3D09, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x03,0x05,0x00,0x00,0x00}}, /* Average Bytes Per Second */
     { 0x3D0A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x02,0x01,0x00,0x00,0x00}}, /* Block Align */
-    // mxf_user_comments_local_tag
-    { 0x4406, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0C,0x00,0x00,0x00}}, /* User Comments */
-    { 0x5001, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x09,0x01,0x00,0x00}}, /* Name */
-    { 0x5003, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0A,0x01,0x00,0x00}}, /* Value */
-    // mxf_avc_subdescriptor_local_tags
+};
+
+static const MXFLocalTagPair mxf_avc_subdescriptor_local_tags[] = {
     { 0x8100, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00}}, /* SubDescriptors */
     { 0x8200, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0E,0x00,0x00}}, /* AVC Decoding Delay */
     { 0x8201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0A,0x00,0x00}}, /* AVC Profile */
     { 0x8202, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0D,0x00,0x00}}, /* AVC Level */
-    // ff_mxf_mastering_display_local_tags
-    { 0x8301, FF_MXF_MasteringDisplayPrimaries },
-    { 0x8302, FF_MXF_MasteringDisplayWhitePointChromaticity },
-    { 0x8303, FF_MXF_MasteringDisplayMaximumLuminance },
-    { 0x8304, FF_MXF_MasteringDisplayMinimumLuminance },
 };
 
-#define MXF_NUM_TAGS FF_ARRAY_ELEMS(mxf_local_tag_batch)
-
-typedef struct MXFContext {
-    AVClass *av_class;
-    int64_t footer_partition_offset;
-    int essence_container_count;
-    AVRational time_base;
-    int header_written;
-    MXFIndexEntry *index_entries;
-    unsigned edit_units_count;
-    uint64_t timestamp;   ///< timestamp, as year(16),month(8),day(8),hour(8),minutes(8),msec/4(8)
-    uint8_t slice_count;  ///< index slice count minus 1 (1 if no audio, 0 otherwise)
-    int last_indexed_edit_unit;
-    uint64_t *body_partition_offset;
-    unsigned body_partitions_count;
-    int last_key_index;  ///< index of last key frame
-    uint64_t duration;
-    AVTimecode tc;       ///< timecode context
-    AVStream *timecode_track;
-    int timecode_base;       ///< rounded time code base (25 or 30)
-    int edit_unit_byte_count; ///< fixed edit unit byte count
-    int content_package_rate; ///< content package rate in system element, see SMPTE 326M
-    uint64_t body_offset;
-    uint32_t instance_number;
-    uint8_t umid[16];        ///< unique material identifier
-    int channel_count;
-    int signal_standard;
-    uint32_t tagged_value_count;
-    AVRational audio_edit_rate;
-    int store_user_comments;
-    int track_instance_count; // used to generate MXFTrack uuids
-    int cbr_index;           ///< use a constant bitrate index
-    uint8_t unused_tags[MXF_NUM_TAGS];  ///< local tags that we know will not be used
-} MXFContext;
+static const MXFLocalTagPair mxf_user_comments_local_tag[] = {
+    { 0x4406, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0C,0x00,0x00,0x00}}, /* User Comments */
+    { 0x5001, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x09,0x01,0x00,0x00}}, /* Name */
+    { 0x5003, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0A,0x01,0x00,0x00}}, /* Value */
+};
 
 static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value)
 {
@@ -496,66 +491,38 @@
     return -1;
 }
 
-static const MXFLocalTagPair* mxf_lookup_local_tag(int tag)
+static void mxf_write_local_tags(AVIOContext *pb, const MXFLocalTagPair *local_tags, int count)
 {
-    for (int i = 0; i < MXF_NUM_TAGS; i++) {
-        if (mxf_local_tag_batch[i].local_tag == tag) {
-            return &mxf_local_tag_batch[i];
-        }
+    int i;
+    for (i = 0; i < count; i++) {
+        avio_wb16(pb, local_tags[i].local_tag);
+        avio_write(pb, local_tags[i].uid, 16);
     }
-
-    // this assert can only be hit during development
-    av_assert0(0 && "you forgot to add your new tag to mxf_local_tag_batch");
-}
-
-static void mxf_mark_tag_unused(MXFContext *mxf, int tag)
-{
-    const MXFLocalTagPair *pair = mxf_lookup_local_tag(tag);
-    mxf->unused_tags[pair - mxf_local_tag_batch] = 1;
 }
 
 static void mxf_write_primer_pack(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
     AVIOContext *pb = s->pb;
-    int local_tag_number = MXF_NUM_TAGS, i;
-    int will_have_avc_tags = 0, will_have_mastering_tags = 0;
+    int local_tag_number, i = 0;
+    int avc_tags_count = 0;
+    int mastering_tags_count = 0;
+
+    local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch);
+    local_tag_number += mxf->store_user_comments * FF_ARRAY_ELEMS(mxf_user_comments_local_tag);
 
     for (i = 0; i < s->nb_streams; i++) {
         MXFStreamContext *sc = s->streams[i]->priv_data;
         if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_H264 && !sc->avc_intra) {
-            will_have_avc_tags = 1;
+            avc_tags_count = FF_ARRAY_ELEMS(mxf_avc_subdescriptor_local_tags);
         }
         if (av_stream_get_side_data(s->streams[i], AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL)) {
-            will_have_mastering_tags = 1;
+            mastering_tags_count = FF_ARRAY_ELEMS(ff_mxf_mastering_display_local_tags);
         }
     }
 
-    if (!mxf->store_user_comments) {
-        mxf_mark_tag_unused(mxf, 0x4406);
-        mxf_mark_tag_unused(mxf, 0x5001);
-        mxf_mark_tag_unused(mxf, 0x5003);
-    }
-
-    if (!will_have_avc_tags) {
-        mxf_mark_tag_unused(mxf, 0x8100);
-        mxf_mark_tag_unused(mxf, 0x8200);
-        mxf_mark_tag_unused(mxf, 0x8201);
-        mxf_mark_tag_unused(mxf, 0x8202);
-    }
-
-    if (!will_have_mastering_tags) {
-        mxf_mark_tag_unused(mxf, 0x8301);
-        mxf_mark_tag_unused(mxf, 0x8302);
-        mxf_mark_tag_unused(mxf, 0x8303);
-        mxf_mark_tag_unused(mxf, 0x8304);
-    }
-
-    for (i = 0; i < MXF_NUM_TAGS; i++) {
-        if (mxf->unused_tags[i]) {
-            local_tag_number--;
-        }
-    }
+    local_tag_number += avc_tags_count;
+    local_tag_number += mastering_tags_count;
 
     avio_write(pb, primer_pack_key, 16);
     klv_encode_ber_length(pb, local_tag_number * 18 + 8);
@@ -563,23 +530,23 @@
     avio_wb32(pb, local_tag_number); // local_tag num
     avio_wb32(pb, 18); // item size, always 18 according to the specs
 
-    for (i = 0; i < MXF_NUM_TAGS; i++) {
-        if (mxf->unused_tags[i] == 0) {
-            avio_wb16(pb, mxf_local_tag_batch[i].local_tag);
-            avio_write(pb, mxf_local_tag_batch[i].uid, 16);
-        }
+    for (i = 0; i < FF_ARRAY_ELEMS(mxf_local_tag_batch); i++) {
+        avio_wb16(pb, mxf_local_tag_batch[i].local_tag);
+        avio_write(pb, mxf_local_tag_batch[i].uid, 16);
     }
+    if (mxf->store_user_comments)
+        for (i = 0; i < FF_ARRAY_ELEMS(mxf_user_comments_local_tag); i++) {
+            avio_wb16(pb, mxf_user_comments_local_tag[i].local_tag);
+            avio_write(pb, mxf_user_comments_local_tag[i].uid, 16);
+        }
+    if (avc_tags_count > 0)
+        mxf_write_local_tags(pb, mxf_avc_subdescriptor_local_tags, avc_tags_count);
+    if (mastering_tags_count > 0)
+        mxf_write_local_tags(pb, ff_mxf_mastering_display_local_tags, mastering_tags_count);
 }
 
-static void mxf_write_local_tag(AVFormatContext *s, int size, int tag)
+static void mxf_write_local_tag(AVIOContext *pb, int size, int tag)
 {
-    MXFContext *mxf = s->priv_data;
-    AVIOContext *pb = s->pb;
-    const MXFLocalTagPair *pair = mxf_lookup_local_tag(tag);
-
-    // make sure the tag was not declared unnecessary upfront
-    av_assert0(mxf->unused_tags[pair - mxf_local_tag_batch] == 0);
-
     avio_wb16(pb, tag);
     avio_wb16(pb, size);
 }
@@ -636,44 +603,44 @@
     klv_encode_ber_length(pb, 138 + 16LL * DESCRIPTOR_COUNT(mxf->essence_container_count));
 
     // write preface set uid
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, Preface, 0);
     PRINT_KEY(s, "preface uid", pb->buf_ptr - 16);
 
     // last modified date
-    mxf_write_local_tag(s, 8, 0x3B02);
+    mxf_write_local_tag(pb, 8, 0x3B02);
     avio_wb64(pb, mxf->timestamp);
 
     // write version
-    mxf_write_local_tag(s, 2, 0x3B05);
+    mxf_write_local_tag(pb, 2, 0x3B05);
     avio_wb16(pb, 259); // v1.3
 
     // Object Model Version
-    mxf_write_local_tag(s, 4, 0x3B07);
+    mxf_write_local_tag(pb, 4, 0x3B07);
     avio_wb32(pb, 1);
 
     // write identification_refs
-    mxf_write_local_tag(s, 16 + 8, 0x3B06);
+    mxf_write_local_tag(pb, 16 + 8, 0x3B06);
     mxf_write_refs_count(pb, 1);
     mxf_write_uuid(pb, Identification, 0);
 
     // write content_storage_refs
-    mxf_write_local_tag(s, 16, 0x3B03);
+    mxf_write_local_tag(pb, 16, 0x3B03);
     mxf_write_uuid(pb, ContentStorage, 0);
 
     // operational pattern
-    mxf_write_local_tag(s, 16, 0x3B09);
+    mxf_write_local_tag(pb, 16, 0x3B09);
     if (s->oformat == &ff_mxf_opatom_muxer)
         avio_write(pb, opatom_ul, 16);
     else
         avio_write(pb, op1a_ul, 16);
 
     // write essence_container_refs
-    mxf_write_local_tag(s, 8 + 16LL * DESCRIPTOR_COUNT(mxf->essence_container_count), 0x3B0A);
+    mxf_write_local_tag(pb, 8 + 16LL * DESCRIPTOR_COUNT(mxf->essence_container_count), 0x3B0A);
     mxf_write_essence_container_refs(s);
 
     // write dm_scheme_refs
-    mxf_write_local_tag(s, 8, 0x3B0B);
+    mxf_write_local_tag(pb, 8, 0x3B0B);
     avio_wb64(pb, 0);
 }
 
@@ -722,9 +689,8 @@
 /*
  * Write a local tag containing an utf-8 string as utf-16
  */
-static void mxf_write_local_tag_utf16(AVFormatContext *s, int tag, const char *value)
+static void mxf_write_local_tag_utf16(AVIOContext *pb, int tag, const char *value)
 {
-    AVIOContext *pb = s->pb;
     uint64_t size = mxf_utf16len(value);
 
     if (size >= UINT16_MAX/2) {
@@ -732,7 +698,7 @@
         return;
     }
 
-    mxf_write_local_tag(s, size*2, tag);
+    mxf_write_local_tag(pb, size*2, tag);
     avio_put_str16be(pb, value);
 }
 
@@ -752,57 +718,50 @@
     avio_wb16(pb, 0); // release
 }
 
-#define PLATFORM_IDENT "Lavf " AV_STRINGIFY((OS_NAME))
 static void mxf_write_identification(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
     AVIOContext *pb = s->pb;
-    AVDictionaryEntry *com_entry = av_dict_get(s->metadata, "company_name", NULL, 0);
-    AVDictionaryEntry *product_entry = av_dict_get(s->metadata, "product_name", NULL, 0);
-    AVDictionaryEntry *version_entry = av_dict_get(s->metadata, "product_version", NULL, 0);
-    const char *company = com_entry ? com_entry->value : "FFmpeg";
-    const char *product = product_entry ? product_entry->value : s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
-    const char *platform = s->flags & AVFMT_FLAG_BITEXACT ? "Lavf" : PLATFORM_IDENT;
-    const char *version = version_entry ? version_entry->value :
-                              s->flags & AVFMT_FLAG_BITEXACT ? "0.0.0" :
-                                  AV_STRINGIFY(LIBAVFORMAT_VERSION);
+    const char *company = "FFmpeg";
+    const char *product = s->oformat != &ff_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
+    const char *version;
     int length;
 
     mxf_write_metadata_key(pb, 0x013000);
     PRINT_KEY(s, "identification key", pb->buf_ptr - 16);
 
+    version = s->flags & AVFMT_FLAG_BITEXACT ?
+        "0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION);
     length = 100 +mxf_utf16_local_tag_length(company) +
                   mxf_utf16_local_tag_length(product) +
-                  mxf_utf16_local_tag_length(platform) +
                   mxf_utf16_local_tag_length(version);
     klv_encode_ber_length(pb, length);
 
     // write uid
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, Identification, 0);
     PRINT_KEY(s, "identification uid", pb->buf_ptr - 16);
 
     // write generation uid
-    mxf_write_local_tag(s, 16, 0x3C09);
+    mxf_write_local_tag(pb, 16, 0x3C09);
     mxf_write_uuid(pb, Identification, 1);
-    mxf_write_local_tag_utf16(s, 0x3C01, company); // Company Name
-    mxf_write_local_tag_utf16(s, 0x3C02, product); // Product Name
+    mxf_write_local_tag_utf16(pb, 0x3C01, company); // Company Name
+    mxf_write_local_tag_utf16(pb, 0x3C02, product); // Product Name
 
-    mxf_write_local_tag(s, 10, 0x3C03); // Product Version
+    mxf_write_local_tag(pb, 10, 0x3C03); // Product Version
     store_version(s);
 
-    mxf_write_local_tag_utf16(s, 0x3C04, version); // Version String
-    mxf_write_local_tag_utf16(s, 0x3C08, platform); // Platform
+    mxf_write_local_tag_utf16(pb, 0x3C04, version); // Version String
 
     // write product uid
-    mxf_write_local_tag(s, 16, 0x3C05);
+    mxf_write_local_tag(pb, 16, 0x3C05);
     mxf_write_uuid(pb, Identification, 2);
 
     // modification date
-    mxf_write_local_tag(s, 8, 0x3C06);
+    mxf_write_local_tag(pb, 8, 0x3C06);
     avio_wb64(pb, mxf->timestamp);
 
-    mxf_write_local_tag(s, 10, 0x3C07); // Toolkit Version
+    mxf_write_local_tag(pb, 10, 0x3C07); // Toolkit Version
     store_version(s);
 }
 
@@ -816,19 +775,19 @@
     klv_encode_ber_length(pb, 60 + (16 * package_count));
 
     // write uid
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, ContentStorage, 0);
     PRINT_KEY(s, "content storage uid", pb->buf_ptr - 16);
 
     // write package reference
-    mxf_write_local_tag(s, 16 * package_count + 8, 0x1901);
+    mxf_write_local_tag(pb, 16 * package_count + 8, 0x1901);
     mxf_write_refs_count(pb, package_count);
     for (i = 0; i < package_count; i++) {
         mxf_write_uuid(pb, packages[i].type, packages[i].instance);
     }
 
     // write essence container data
-    mxf_write_local_tag(s, 8 + 16, 0x1902);
+    mxf_write_local_tag(pb, 8 + 16, 0x1902);
     mxf_write_refs_count(pb, 1);
     mxf_write_uuid(pb, EssenceContainerData, 0);
 }
@@ -844,23 +803,23 @@
     klv_encode_ber_length(pb, 80);
 
     // write track uid
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, Track, mxf->track_instance_count);
     PRINT_KEY(s, "track uid", pb->buf_ptr - 16);
 
     // write track id
-    mxf_write_local_tag(s, 4, 0x4801);
+    mxf_write_local_tag(pb, 4, 0x4801);
     avio_wb32(pb, st->index+2);
 
     // write track number
-    mxf_write_local_tag(s, 4, 0x4804);
+    mxf_write_local_tag(pb, 4, 0x4804);
     if (package->type == MaterialPackage)
         avio_wb32(pb, 0); // track number of material package is 0
     else
         avio_write(pb, sc->track_essence_element_key + 12, 4);
 
     // write edit rate
-    mxf_write_local_tag(s, 8, 0x4B01);
+    mxf_write_local_tag(pb, 8, 0x4B01);
 
     if (st == mxf->timecode_track && s->oformat == &ff_mxf_opatom_muxer) {
         avio_wb32(pb, mxf->tc.rate.num);
@@ -871,11 +830,11 @@
     }
 
     // write origin
-    mxf_write_local_tag(s, 8, 0x4B02);
+    mxf_write_local_tag(pb, 8, 0x4B02);
     avio_wb64(pb, 0);
 
     // write sequence refs
-    mxf_write_local_tag(s, 16, 0x4803);
+    mxf_write_local_tag(pb, 16, 0x4803);
     mxf_write_uuid(pb, Sequence, mxf->track_instance_count);
 }
 
@@ -887,7 +846,7 @@
     AVIOContext *pb = s->pb;
 
     // find data define uls
-    mxf_write_local_tag(s, 16, 0x0201);
+    mxf_write_local_tag(pb, 16, 0x0201);
     if (st == mxf->timecode_track)
         avio_write(pb, smpte_12m_timecode_track_data_ul, 16);
     else {
@@ -896,7 +855,7 @@
     }
 
     // write duration
-    mxf_write_local_tag(s, 8, 0x0202);
+    mxf_write_local_tag(pb, 8, 0x0202);
 
     if (st != mxf->timecode_track && s->oformat == &ff_mxf_opatom_muxer && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
         avio_wb64(pb, mxf->body_offset / mxf->edit_unit_byte_count);
@@ -915,14 +874,14 @@
     PRINT_KEY(s, "sequence key", pb->buf_ptr - 16);
     klv_encode_ber_length(pb, 80);
 
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, Sequence, mxf->track_instance_count);
 
     PRINT_KEY(s, "sequence uid", pb->buf_ptr - 16);
     mxf_write_common_fields(s, st);
 
     // write structural component
-    mxf_write_local_tag(s, 16 + 8, 0x1001);
+    mxf_write_local_tag(pb, 16 + 8, 0x1001);
     mxf_write_refs_count(pb, 1);
     if (st == mxf->timecode_track)
         component = TimecodeComponent;
@@ -941,21 +900,21 @@
     klv_encode_ber_length(pb, 75);
 
     // UID
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, TimecodeComponent, mxf->track_instance_count);
 
     mxf_write_common_fields(s, st);
 
     // Start Time Code
-    mxf_write_local_tag(s, 8, 0x1501);
+    mxf_write_local_tag(pb, 8, 0x1501);
     avio_wb64(pb, mxf->tc.start);
 
     // Rounded Time Code Base
-    mxf_write_local_tag(s, 2, 0x1502);
+    mxf_write_local_tag(pb, 2, 0x1502);
     avio_wb16(pb, mxf->timecode_base);
 
     // Drop Frame
-    mxf_write_local_tag(s, 1, 0x1503);
+    mxf_write_local_tag(pb, 1, 0x1503);
     avio_w8(pb, !!(mxf->tc.flags & AV_TIMECODE_FLAG_DROPFRAME));
 }
 
@@ -970,18 +929,18 @@
     klv_encode_ber_length(pb, 108);
 
     // write uid
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, SourceClip, mxf->track_instance_count);
 
     PRINT_KEY(s, "structural component uid", pb->buf_ptr - 16);
     mxf_write_common_fields(s, st);
 
     // write start_position
-    mxf_write_local_tag(s, 8, 0x1201);
+    mxf_write_local_tag(pb, 8, 0x1201);
     avio_wb64(pb, 0);
 
     // write source package uid, end of the reference
-    mxf_write_local_tag(s, 32, 0x1101);
+    mxf_write_local_tag(pb, 32, 0x1101);
     if (!package->ref) {
         for (i = 0; i < 4; i++)
             avio_wb64(pb, 0);
@@ -989,7 +948,7 @@
         mxf_write_umid(s, package->ref->instance);
 
     // write source track id
-    mxf_write_local_tag(s, 4, 0x1102);
+    mxf_write_local_tag(pb, 4, 0x1102);
     if (package->type == SourcePackage && !package->ref)
         avio_wb32(pb, 0);
     else
@@ -1003,7 +962,7 @@
     mxf_write_metadata_key(pb, 0x012e00);
     PRINT_KEY(s, "tape descriptor key", pb->buf_ptr - 16);
     klv_encode_ber_length(pb, 20);
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, TapeDescriptor, 0);
     PRINT_KEY(s, "tape_desc uid", pb->buf_ptr - 16);
 }
@@ -1020,17 +979,17 @@
     PRINT_KEY(s, "multiple descriptor key", pb->buf_ptr - 16);
     klv_encode_ber_length(pb, 64 + 16LL * s->nb_streams);
 
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, MultipleDescriptor, 0);
     PRINT_KEY(s, "multi_desc uid", pb->buf_ptr - 16);
 
     // write sample rate
-    mxf_write_local_tag(s, 8, 0x3001);
+    mxf_write_local_tag(pb, 8, 0x3001);
     avio_wb32(pb, mxf->time_base.den);
     avio_wb32(pb, mxf->time_base.num);
 
     // write essence container ul
-    mxf_write_local_tag(s, 16, 0x3004);
+    mxf_write_local_tag(pb, 16, 0x3004);
     if (mxf->essence_container_count > 1)
         ul = multiple_desc_ul;
     else {
@@ -1040,7 +999,7 @@
     avio_write(pb, ul, 16);
 
     // write sub descriptor refs
-    mxf_write_local_tag(s, s->nb_streams * 16 + 8, 0x3F01);
+    mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);
     mxf_write_refs_count(pb, s->nb_streams);
     for (i = 0; i < s->nb_streams; i++)
         mxf_write_uuid(pb, SubDescriptor, i);
@@ -1057,13 +1016,13 @@
     klv_encode_ber4_length(pb, 0);
     pos = avio_tell(pb);
 
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, SubDescriptor, st->index);
 
-    mxf_write_local_tag(s, 4, 0x3006);
+    mxf_write_local_tag(pb, 4, 0x3006);
     avio_wb32(pb, st->index+2);
 
-    mxf_write_local_tag(s, 8, 0x3001);
+    mxf_write_local_tag(pb, 8, 0x3001);
     if (s->oformat == &ff_mxf_d10_muxer) {
         avio_wb32(pb, mxf->time_base.den);
         avio_wb32(pb, mxf->time_base.num);
@@ -1078,7 +1037,7 @@
         }
     }
 
-    mxf_write_local_tag(s, 16, 0x3004);
+    mxf_write_local_tag(pb, 16, 0x3004);
     avio_write(pb, *sc->container_ul, 16);
 
     return pos;
@@ -1130,43 +1089,43 @@
     if (!stored_width)
         stored_width = (st->codecpar->width+15)/16*16;
 
-    mxf_write_local_tag(s, 4, 0x3203);
+    mxf_write_local_tag(pb, 4, 0x3203);
     avio_wb32(pb, stored_width);
 
-    mxf_write_local_tag(s, 4, 0x3202);
+    mxf_write_local_tag(pb, 4, 0x3202);
     avio_wb32(pb, stored_height>>sc->interlaced);
 
     if (s->oformat == &ff_mxf_d10_muxer) {
         //Stored F2 Offset
-        mxf_write_local_tag(s, 4, 0x3216);
+        mxf_write_local_tag(pb, 4, 0x3216);
         avio_wb32(pb, 0);
 
         //Image Start Offset
-        mxf_write_local_tag(s, 4, 0x3213);
+        mxf_write_local_tag(pb, 4, 0x3213);
         avio_wb32(pb, 0);
 
         //Image End Offset
-        mxf_write_local_tag(s, 4, 0x3214);
+        mxf_write_local_tag(pb, 4, 0x3214);
         avio_wb32(pb, 0);
     }
 
     //Sampled width
-    mxf_write_local_tag(s, 4, 0x3205);
+    mxf_write_local_tag(pb, 4, 0x3205);
     avio_wb32(pb, stored_width);
 
     //Samples height
-    mxf_write_local_tag(s, 4, 0x3204);
+    mxf_write_local_tag(pb, 4, 0x3204);
     avio_wb32(pb, st->codecpar->height>>sc->interlaced);
 
     //Sampled X Offset
-    mxf_write_local_tag(s, 4, 0x3206);
+    mxf_write_local_tag(pb, 4, 0x3206);
     avio_wb32(pb, 0);
 
     //Sampled Y Offset
-    mxf_write_local_tag(s, 4, 0x3207);
+    mxf_write_local_tag(pb, 4, 0x3207);
     avio_wb32(pb, 0);
 
-    mxf_write_local_tag(s, 4, 0x3209);
+    mxf_write_local_tag(pb, 4, 0x3209);
     avio_wb32(pb, stored_width);
 
     if (st->codecpar->height == 608) // PAL + VBI
@@ -1176,41 +1135,41 @@
     else
         display_height = st->codecpar->height;
 
-    mxf_write_local_tag(s, 4, 0x3208);
+    mxf_write_local_tag(pb, 4, 0x3208);
     avio_wb32(pb, display_height>>sc->interlaced);
 
     // display X offset
-    mxf_write_local_tag(s, 4, 0x320A);
+    mxf_write_local_tag(pb, 4, 0x320A);
     avio_wb32(pb, 0);
 
     // display Y offset
-    mxf_write_local_tag(s, 4, 0x320B);
+    mxf_write_local_tag(pb, 4, 0x320B);
     avio_wb32(pb, (st->codecpar->height - display_height)>>sc->interlaced);
 
     if (sc->interlaced) {
         //Display F2 Offset
-        mxf_write_local_tag(s, 4, 0x3217);
+        mxf_write_local_tag(pb, 4, 0x3217);
         avio_wb32(pb, -((st->codecpar->height - display_height)&1));
     }
 
     // component depth
-    mxf_write_local_tag(s, 4, 0x3301);
+    mxf_write_local_tag(pb, 4, 0x3301);
     avio_wb32(pb, sc->component_depth);
 
     // horizontal subsampling
-    mxf_write_local_tag(s, 4, 0x3302);
+    mxf_write_local_tag(pb, 4, 0x3302);
     avio_wb32(pb, sc->h_chroma_sub_sample);
 
     // vertical subsampling
-    mxf_write_local_tag(s, 4, 0x3308);
+    mxf_write_local_tag(pb, 4, 0x3308);
     avio_wb32(pb, sc->v_chroma_sub_sample);
 
     // color siting
-    mxf_write_local_tag(s, 1, 0x3303);
+    mxf_write_local_tag(pb, 1, 0x3303);
     avio_w8(pb, sc->color_siting);
 
     // Padding Bits
-    mxf_write_local_tag(s, 2, 0x3307);
+    mxf_write_local_tag(pb, 2, 0x3307);
     avio_wb16(pb, 0);
 
     if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) {
@@ -1222,21 +1181,21 @@
             white = 235 << (sc->component_depth - 8);
             color = (14 << (sc->component_depth - 4)) + 1;
         }
-        mxf_write_local_tag(s, 4, 0x3304);
+        mxf_write_local_tag(pb, 4, 0x3304);
         avio_wb32(pb, black);
-        mxf_write_local_tag(s, 4, 0x3305);
+        mxf_write_local_tag(pb, 4, 0x3305);
         avio_wb32(pb, white);
-        mxf_write_local_tag(s, 4, 0x3306);
+        mxf_write_local_tag(pb, 4, 0x3306);
         avio_wb32(pb, color);
     }
 
     if (sc->signal_standard) {
-        mxf_write_local_tag(s, 1, 0x3215);
+        mxf_write_local_tag(pb, 1, 0x3215);
         avio_w8(pb, sc->signal_standard);
     }
 
     // frame layout
-    mxf_write_local_tag(s, 1, 0x320C);
+    mxf_write_local_tag(pb, 1, 0x320C);
     avio_w8(pb, sc->interlaced);
 
     // video line map
@@ -1256,32 +1215,32 @@
     }
 
 
-    mxf_write_local_tag(s, 16, 0x320D);
+    mxf_write_local_tag(pb, 16, 0x320D);
     avio_wb32(pb, 2);
     avio_wb32(pb, 4);
     avio_wb32(pb, f1);
     avio_wb32(pb, f2);
 
-    mxf_write_local_tag(s, 8, 0x320E);
+    mxf_write_local_tag(pb, 8, 0x320E);
     avio_wb32(pb, sc->aspect_ratio.num);
     avio_wb32(pb, sc->aspect_ratio.den);
 
     if (color_primaries_ul->uid[0]) {
-        mxf_write_local_tag(s, 16, 0x3219);
+        mxf_write_local_tag(pb, 16, 0x3219);
         avio_write(pb, color_primaries_ul->uid, 16);
     };
 
     if (color_trc_ul->uid[0]) {
-        mxf_write_local_tag(s, 16, 0x3210);
+        mxf_write_local_tag(pb, 16, 0x3210);
         avio_write(pb, color_trc_ul->uid, 16);
     };
 
     if (color_space_ul->uid[0]) {
-        mxf_write_local_tag(s, 16, 0x321A);
+        mxf_write_local_tag(pb, 16, 0x321A);
         avio_write(pb, color_space_ul->uid, 16);
     };
 
-    mxf_write_local_tag(s, 16, 0x3201);
+    mxf_write_local_tag(pb, 16, 0x3201);
     avio_write(pb, *sc->codec_ul, 16);
 
     // Mastering Display metadata
@@ -1289,23 +1248,23 @@
     if (side_data) {
         const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data;
         if (metadata->has_primaries) {
-            mxf_write_local_tag(s, 12, 0x8301);
+            mxf_write_local_tag(pb, 12, ff_mxf_mastering_display_local_tags[0].local_tag);
             avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[0][0]));
             avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[0][1]));
             avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[1][0]));
             avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[1][1]));
             avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[2][0]));
             avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[2][1]));
-            mxf_write_local_tag(s, 4, 0x8302);
+            mxf_write_local_tag(pb, 4, ff_mxf_mastering_display_local_tags[1].local_tag);
             avio_wb16(pb, rescale_mastering_chroma(metadata->white_point[0]));
             avio_wb16(pb, rescale_mastering_chroma(metadata->white_point[1]));
         } else {
             av_log(NULL, AV_LOG_VERBOSE, "Not writing mastering display primaries. Missing data.\n");
         }
         if (metadata->has_luminance) {
-            mxf_write_local_tag(s, 4, 0x8303);
+            mxf_write_local_tag(pb, 4, ff_mxf_mastering_display_local_tags[2].local_tag);
             avio_wb32(pb, rescale_mastering_luma(metadata->max_luminance));
-            mxf_write_local_tag(s, 4, 0x8304);
+            mxf_write_local_tag(pb, 4, ff_mxf_mastering_display_local_tags[3].local_tag);
             avio_wb32(pb, rescale_mastering_luma(metadata->min_luminance));
         } else {
             av_log(NULL, AV_LOG_VERBOSE, "Not writing mastering display luminances. Missing data.\n");
@@ -1313,13 +1272,13 @@
     }
 
     if (sc->interlaced && sc->field_dominance) {
-        mxf_write_local_tag(s, 1, 0x3212);
+        mxf_write_local_tag(pb, 1, 0x3212);
         avio_w8(pb, sc->field_dominance);
     }
 
     if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !sc->avc_intra) {
         // write avc sub descriptor ref
-        mxf_write_local_tag(s, 8 + 16, 0x8100);
+        mxf_write_local_tag(pb, 8 + 16, 0x8100);
         mxf_write_refs_count(pb, 1);
         mxf_write_uuid(pb, AVCSubDescriptor, 0);
     }
@@ -1345,16 +1304,16 @@
     klv_encode_ber4_length(pb, 0);
     pos = avio_tell(pb);
 
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, AVCSubDescriptor, 0);
 
-    mxf_write_local_tag(s, 1, 0x8200);
+    mxf_write_local_tag(pb, 1, 0x8200);
     avio_w8(pb, 0xFF); // AVC Decoding Delay, unknown
 
-    mxf_write_local_tag(s, 1, 0x8201);
+    mxf_write_local_tag(pb, 1, 0x8201);
     avio_w8(pb, st->codecpar->profile); // AVC Profile
 
-    mxf_write_local_tag(s, 1, 0x8202);
+    mxf_write_local_tag(pb, 1, 0x8202);
     avio_w8(pb, st->codecpar->level); // AVC Level
 
     mxf_update_klv_size(s->pb, pos);
@@ -1397,29 +1356,29 @@
 
     if (st->codecpar->codec_id != AV_CODEC_ID_H264) {
         // bit rate
-        mxf_write_local_tag(s, 4, 0x8000);
+        mxf_write_local_tag(pb, 4, 0x8000);
         avio_wb32(pb, sc->video_bit_rate);
 
         // profile and level
-        mxf_write_local_tag(s, 1, 0x8007);
+        mxf_write_local_tag(pb, 1, 0x8007);
         if (!st->codecpar->profile)
             profile_and_level |= 0x80; // escape bit
         avio_w8(pb, profile_and_level);
 
         // low delay
-        mxf_write_local_tag(s, 1, 0x8003);
+        mxf_write_local_tag(pb, 1, 0x8003);
         avio_w8(pb, sc->low_delay);
 
         // closed gop
-        mxf_write_local_tag(s, 1, 0x8004);
+        mxf_write_local_tag(pb, 1, 0x8004);
         avio_w8(pb, sc->seq_closed_gop);
 
         // max gop
-        mxf_write_local_tag(s, 2, 0x8006);
+        mxf_write_local_tag(pb, 2, 0x8006);
         avio_wb16(pb, sc->max_gop);
 
         // b picture count
-        mxf_write_local_tag(s, 2, 0x8008);
+        mxf_write_local_tag(pb, 2, 0x8008);
         avio_wb16(pb, sc->b_picture_count);
     }
 
@@ -1434,25 +1393,25 @@
     int64_t pos = mxf_write_generic_desc(s, st, key);
 
     if (s->oformat == &ff_mxf_opatom_muxer) {
-        mxf_write_local_tag(s, 8, 0x3002);
+        mxf_write_local_tag(pb, 8, 0x3002);
         avio_wb64(pb, mxf->body_offset / mxf->edit_unit_byte_count);
     }
 
     // audio locked
-    mxf_write_local_tag(s, 1, 0x3D02);
+    mxf_write_local_tag(pb, 1, 0x3D02);
     avio_w8(pb, 1);
 
     // write audio sampling rate
-    mxf_write_local_tag(s, 8, 0x3D03);
+    mxf_write_local_tag(pb, 8, 0x3D03);
     avio_wb32(pb, st->codecpar->sample_rate);
     avio_wb32(pb, 1);
 
     if (s->oformat == &ff_mxf_d10_muxer) {
-        mxf_write_local_tag(s, 1, 0x3D04);
+        mxf_write_local_tag(pb, 1, 0x3D04);
         avio_w8(pb, 0);
     }
 
-    mxf_write_local_tag(s, 4, 0x3D07);
+    mxf_write_local_tag(pb, 4, 0x3D07);
     if (mxf->channel_count == -1) {
         if (show_warnings && (s->oformat == &ff_mxf_d10_muxer) && (st->codecpar->channels != 4) && (st->codecpar->channels != 8))
             av_log(s, AV_LOG_WARNING, "the number of audio channels shall be 4 or 8 : the output will not comply to MXF D-10 specs, use -d10_channelcount to fix this\n");
@@ -1467,7 +1426,7 @@
         avio_wb32(pb, st->codecpar->channels);
     }
 
-    mxf_write_local_tag(s, 4, 0x3D01);
+    mxf_write_local_tag(pb, 4, 0x3D01);
     avio_wb32(pb, av_get_bits_per_sample(st->codecpar->codec_id));
 
     return pos;
@@ -1478,11 +1437,11 @@
     AVIOContext *pb = s->pb;
     int64_t pos = mxf_write_generic_sound_common(s, st, key);
 
-    mxf_write_local_tag(s, 2, 0x3D0A);
+    mxf_write_local_tag(pb, 2, 0x3D0A);
     avio_wb16(pb, st->codecpar->block_align);
 
     // avg bytes per sec
-    mxf_write_local_tag(s, 4, 0x3D09);
+    mxf_write_local_tag(pb, 4, 0x3D09);
     avio_wb32(pb, st->codecpar->block_align*st->codecpar->sample_rate);
 
     return pos;
@@ -1522,14 +1481,14 @@
     klv_encode_ber_length(pb, 24 + name_size + indirect_value_size);
 
     // write instance UID
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count);
 
     // write name
-    mxf_write_local_tag_utf16(s, 0x5001, name); // Name
+    mxf_write_local_tag_utf16(pb, 0x5001, name); // Name
 
     // write indirect value
-    mxf_write_local_tag(s, indirect_value_size, 0x5003);
+    mxf_write_local_tag(pb, indirect_value_size, 0x5003);
     avio_write(pb, mxf_indirect_value_utf16le, 17);
     avio_put_str16le(pb, value);
 
@@ -1576,30 +1535,30 @@
     }
 
     // write uid
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, package->type, package->instance);
     av_log(s, AV_LOG_DEBUG, "package type:%d\n", package->type);
     PRINT_KEY(s, "package uid", pb->buf_ptr - 16);
 
     // write package umid
-    mxf_write_local_tag(s, 32, 0x4401);
+    mxf_write_local_tag(pb, 32, 0x4401);
     mxf_write_umid(s, package->instance);
     PRINT_KEY(s, "package umid second part", pb->buf_ptr - 16);
 
     // package name
     if (name_size)
-        mxf_write_local_tag_utf16(s, 0x4402, package->name);
+        mxf_write_local_tag_utf16(pb, 0x4402, package->name);
 
     // package creation date
-    mxf_write_local_tag(s, 8, 0x4405);
+    mxf_write_local_tag(pb, 8, 0x4405);
     avio_wb64(pb, mxf->timestamp);
 
     // package modified date
-    mxf_write_local_tag(s, 8, 0x4404);
+    mxf_write_local_tag(pb, 8, 0x4404);
     avio_wb64(pb, mxf->timestamp);
 
     // write track refs
-    mxf_write_local_tag(s, track_count*16 + 8, 0x4403);
+    mxf_write_local_tag(pb, track_count*16 + 8, 0x4403);
     mxf_write_refs_count(pb, track_count);
     // these are the uuids of the tracks the will be written in mxf_write_track
     for (i = 0; i < track_count; i++)
@@ -1607,7 +1566,7 @@
 
     // write user comment refs
     if (mxf->store_user_comments) {
-        mxf_write_local_tag(s, user_comment_count*16 + 8, 0x4406);
+        mxf_write_local_tag(pb, user_comment_count*16 + 8, 0x4406);
         mxf_write_refs_count(pb, user_comment_count);
         for (i = 0; i < user_comment_count; i++)
             mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count - user_comment_count + i);
@@ -1615,14 +1574,14 @@
 
     // write multiple descriptor reference
     if (package->type == SourcePackage && package->instance == 1) {
-        mxf_write_local_tag(s, 16, 0x4701);
+        mxf_write_local_tag(pb, 16, 0x4701);
         if (s->nb_streams > 1) {
             mxf_write_uuid(pb, MultipleDescriptor, 0);
             mxf_write_multi_descriptor(s);
         } else
             mxf_write_uuid(pb, SubDescriptor, 0);
     } else if (package->type == SourcePackage && package->instance == 2) {
-        mxf_write_local_tag(s, 16, 0x4701);
+        mxf_write_local_tag(pb, 16, 0x4701);
         mxf_write_uuid(pb, TapeDescriptor, 0);
         mxf_write_tape_descriptor(s);
     }
@@ -1662,16 +1621,16 @@
     mxf_write_metadata_key(pb, 0x012300);
     klv_encode_ber_length(pb, 72);
 
-    mxf_write_local_tag(s, 16, 0x3C0A); // Instance UID
+    mxf_write_local_tag(pb, 16, 0x3C0A); // Instance UID
     mxf_write_uuid(pb, EssenceContainerData, 0);
 
-    mxf_write_local_tag(s, 32, 0x2701); // Linked Package UID
+    mxf_write_local_tag(pb, 32, 0x2701); // Linked Package UID
     mxf_write_umid(s, 1);
 
-    mxf_write_local_tag(s, 4, 0x3F07); // BodySID
+    mxf_write_local_tag(pb, 4, 0x3F07); // BodySID
     avio_wb32(pb, 1);
 
-    mxf_write_local_tag(s, 4, 0x3F06); // IndexSID
+    mxf_write_local_tag(pb, 4, 0x3F06); // IndexSID
     avio_wb32(pb, 2);
 
     return 0;
@@ -1756,43 +1715,43 @@
     pos = avio_tell(pb);
 
     // instance id
-    mxf_write_local_tag(s, 16, 0x3C0A);
+    mxf_write_local_tag(pb, 16, 0x3C0A);
     mxf_write_uuid(pb, IndexTableSegment, 0);
 
     // index edit rate
-    mxf_write_local_tag(s, 8, 0x3F0B);
+    mxf_write_local_tag(pb, 8, 0x3F0B);
     avio_wb32(pb, mxf->time_base.den);
     avio_wb32(pb, mxf->time_base.num);
 
     // index start position
-    mxf_write_local_tag(s, 8, 0x3F0C);
+    mxf_write_local_tag(pb, 8, 0x3F0C);
     avio_wb64(pb, mxf->last_indexed_edit_unit);
 
     // index duration
-    mxf_write_local_tag(s, 8, 0x3F0D);
+    mxf_write_local_tag(pb, 8, 0x3F0D);
     if (mxf->edit_unit_byte_count)
         avio_wb64(pb, 0); // index table covers whole container
     else
         avio_wb64(pb, mxf->edit_units_count);
 
     // edit unit byte count
-    mxf_write_local_tag(s, 4, 0x3F05);
+    mxf_write_local_tag(pb, 4, 0x3F05);
     avio_wb32(pb, mxf->edit_unit_byte_count);
 
     // index sid
-    mxf_write_local_tag(s, 4, 0x3F06);
+    mxf_write_local_tag(pb, 4, 0x3F06);
     avio_wb32(pb, 2);
 
     // body sid
-    mxf_write_local_tag(s, 4, 0x3F07);
+    mxf_write_local_tag(pb, 4, 0x3F07);
     avio_wb32(pb, 1);
 
     // real slice count - 1
-    mxf_write_local_tag(s, 1, 0x3F08);
+    mxf_write_local_tag(pb, 1, 0x3F08);
     avio_w8(pb, !mxf->edit_unit_byte_count); // only one slice for CBR
 
     // delta entry array
-    mxf_write_local_tag(s, 8 + (s->nb_streams+1)*6, 0x3F09);
+    mxf_write_local_tag(pb, 8 + (s->nb_streams+1)*6, 0x3F09);
     avio_wb32(pb, s->nb_streams+1); // num of entries
     avio_wb32(pb, 6);               // size of one entry
     // write system item delta entry
@@ -1824,7 +1783,7 @@
 
     if (!mxf->edit_unit_byte_count) {
         MXFStreamContext *sc = s->streams[0]->priv_data;
-        mxf_write_local_tag(s, 8 + mxf->edit_units_count*15, 0x3F0A);
+        mxf_write_local_tag(pb, 8 + mxf->edit_units_count*15, 0x3F0A);
         avio_wb32(pb, mxf->edit_units_count);  // num of entries
         avio_wb32(pb, 15);  // size of one entry
 
@@ -2019,6 +1978,7 @@
     if (mxf->header_written)
         return 1;
 
+    sc->codec_ul = NULL;
     profile = st->codecpar->profile;
     for (i = 0; i < FF_ARRAY_ELEMS(mxf_prores_codec_uls); i++) {
         if (profile == mxf_prores_codec_uls[i].profile) {
@@ -2026,7 +1986,7 @@
             break;
         }
     }
-    if (i == FF_ARRAY_ELEMS(mxf_prores_codec_uls))
+    if (!sc->codec_ul)
         return 0;
 
     sc->frame_size = pkt->size;
@@ -2072,6 +2032,7 @@
     if (pkt->size < 43)
         return 0;
 
+    sc->codec_ul = NULL;
     cid = AV_RB32(pkt->data + 0x28);
     for (i = 0; i < FF_ARRAY_ELEMS(mxf_dnxhd_codec_uls); i++) {
         if (cid == mxf_dnxhd_codec_uls[i].cid) {
@@ -2079,7 +2040,7 @@
             break;
         }
     }
-    if (i == FF_ARRAY_ELEMS(mxf_dnxhd_codec_uls))
+    if (!sc->codec_ul)
         return 0;
 
     sc->component_depth = 0;
@@ -2242,7 +2203,6 @@
     const uint8_t *buf = pkt->data;
     const uint8_t *buf_end = pkt->data + pkt->size;
     const uint8_t *nal_end;
-    const UID *codec_ul = NULL;
     uint32_t state = -1;
     int extra_size = 512; // support AVC Intra files without SPS/PPS header
     int i, frame_size, slice_type, has_sps = 0, intra_only = 0, ret;
@@ -2313,11 +2273,12 @@
 
     if (!has_sps)
         sc->interlaced = st->codecpar->field_order != AV_FIELD_PROGRESSIVE ? 1 : 0;
+    sc->codec_ul = NULL;
     frame_size = pkt->size + extra_size;
 
     for (i = 0; i < FF_ARRAY_ELEMS(mxf_h264_codec_uls); i++) {
         if (frame_size == mxf_h264_codec_uls[i].frame_size && sc->interlaced == mxf_h264_codec_uls[i].interlaced) {
-            codec_ul = &mxf_h264_codec_uls[i].uid;
+            sc->codec_ul = &mxf_h264_codec_uls[i].uid;
             sc->component_depth = 10; // AVC Intra is always 10 Bit
             sc->aspect_ratio = (AVRational){ 16, 9 }; // 16:9 is mandatory for broadcast HD
             st->codecpar->profile = mxf_h264_codec_uls[i].profile;
@@ -2331,18 +2292,17 @@
                    mxf_h264_codec_uls[i].profile == sps->profile_idc &&
                    (mxf_h264_codec_uls[i].intra_only < 0 ||
                     mxf_h264_codec_uls[i].intra_only == intra_only)) {
-            codec_ul = &mxf_h264_codec_uls[i].uid;
+            sc->codec_ul = &mxf_h264_codec_uls[i].uid;
             st->codecpar->profile = sps->profile_idc;
             st->codecpar->level = sps->level_idc;
             // continue to check for avc intra
         }
     }
 
-    if (!codec_ul) {
+    if (!sc->codec_ul) {
         av_log(s, AV_LOG_ERROR, "h264 profile not supported\n");
         return 0;
     }
-    sc->codec_ul = codec_ul;
 
     return 1;
 }
@@ -2439,13 +2399,9 @@
             }
         }
     }
-    if (s->oformat != &ff_mxf_d10_muxer) {
-        const UID *codec_ul = mxf_get_mpeg2_codec_ul(st->codecpar);
-        if (!codec_ul)
-            return 0;
-        sc->codec_ul = codec_ul;
-    }
-    return 1;
+    if (s->oformat != &ff_mxf_d10_muxer)
+        sc->codec_ul = mxf_get_mpeg2_codec_ul(st->codecpar);
+    return !!sc->codec_ul;
 }
 
 static uint64_t mxf_parse_timestamp(int64_t timestamp64)
@@ -2887,13 +2843,6 @@
     MXFIndexEntry ie = {0};
     int err;
 
-    if (!mxf->header_written && pkt->stream_index != 0 &&
-        s->oformat != &ff_mxf_opatom_muxer) {
-        av_log(s, AV_LOG_ERROR, "Received non-video packet before "
-                                "header has been written\n");
-        return AVERROR_INVALIDDATA;
-    }
-
     if (!mxf->cbr_index && !mxf->edit_unit_byte_count && !(mxf->edit_units_count % EDIT_UNITS_PER_BODY)) {
         if ((err = av_reallocp_array(&mxf->index_entries, mxf->edit_units_count
                                      + EDIT_UNITS_PER_BODY, sizeof(*mxf->index_entries))) < 0) {
@@ -3007,7 +2956,7 @@
     uint64_t pos = avio_tell(pb);
     int i;
 
-    avio_write(pb, ff_mxf_random_index_pack_key, 16);
+    avio_write(pb, random_index_pack_key, 16);
     klv_encode_ber_length(pb, 28 + 12LL*mxf->body_partitions_count);
 
     if (mxf->edit_unit_byte_count && s->oformat != &ff_mxf_opatom_muxer)
diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c
index 78e938d..0793699 100644
--- a/libavformat/nistspheredec.c
+++ b/libavformat/nistspheredec.c
@@ -90,8 +90,6 @@
             return 0;
         } else if (!memcmp(buffer, "channel_count", 13)) {
             sscanf(buffer, "%*s %*s %u", &st->codecpar->channels);
-            if (st->codecpar->channels <= 0 || st->codecpar->channels > INT16_MAX)
-                return AVERROR_INVALIDDATA;
         } else if (!memcmp(buffer, "sample_byte_format", 18)) {
             sscanf(buffer, "%*s %*s %31s", format);
 
@@ -111,14 +109,12 @@
             sscanf(buffer, "%*s %*s %"SCNd64, &st->duration);
         } else if (!memcmp(buffer, "sample_n_bytes", 14)) {
             sscanf(buffer, "%*s %*s %d", &bps);
-            if (bps > INT16_MAX/8U)
+            if (bps > INT_MAX/8U)
                 return AVERROR_INVALIDDATA;
         } else if (!memcmp(buffer, "sample_rate", 11)) {
             sscanf(buffer, "%*s %*s %d", &st->codecpar->sample_rate);
         } else if (!memcmp(buffer, "sample_sig_bits", 15)) {
             sscanf(buffer, "%*s %*s %d", &st->codecpar->bits_per_coded_sample);
-            if (st->codecpar->bits_per_coded_sample <= 0 || st->codecpar->bits_per_coded_sample > INT16_MAX)
-                return AVERROR_INVALIDDATA;
         } else {
             char key[32], value[32];
             if (sscanf(buffer, "%31s %*s %31s", key, value) == 2) {
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index ebb0623..53a0525 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -193,13 +193,13 @@
 {
     AVFormatContext *s = nut->avf;
     AVIOContext *bc    = s->pb;
-    uint64_t tmp, end, length;
+    uint64_t tmp, end;
     unsigned int stream_count;
     int i, j, count, ret;
     int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx;
 
-    length = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
-    end = length + avio_tell(bc);
+    end  = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
+    end += avio_tell(bc);
 
     nut->version = ffio_read_varlen(bc);
     if (nut->version < NUT_MIN_VERSION ||
@@ -219,7 +219,7 @@
         nut->max_distance = 65536;
     }
 
-    GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational) && tmp < length/2);
+    GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational));
     nut->time_base = av_malloc_array(nut->time_base_count, sizeof(AVRational));
     if (!nut->time_base)
         return AVERROR(ENOMEM);
@@ -260,7 +260,7 @@
         if (tmp_fields > 5)
             count = ffio_read_varlen(bc);
         else
-            count = tmp_mul - (unsigned)tmp_size;
+            count = tmp_mul - tmp_size;
         if (tmp_fields > 6)
             get_s(bc);
         if (tmp_fields > 7)
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index df90df4..d99770d 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -117,10 +117,6 @@
                 ast->codecpar->bits_per_coded_sample = avio_rl32(pb);
                 ast->codecpar->channels              = avio_rl32(pb);
                 ast->codecpar->channel_layout        = 0;
-                if (ast->codecpar->channels <= 0) {
-                    av_log(s, AV_LOG_ERROR, "Invalid channels %d\n", ast->codecpar->channels);
-                    return AVERROR_INVALIDDATA;
-                }
 
                 id = ff_wav_codec_get_id(ast->codecpar->codec_tag,
                                          ast->codecpar->bits_per_coded_sample);
diff --git a/libavformat/oma.c b/libavformat/oma.c
index 7282d46..f7ae3c9 100644
--- a/libavformat/oma.c
+++ b/libavformat/oma.c
@@ -18,10 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stddef.h>
-#include "libavcodec/codec_id.h"
 #include "internal.h"
 #include "oma.h"
+#include "libavcodec/avcodec.h"
+#include "libavutil/channel_layout.h"
 
 const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 };
 
@@ -35,4 +35,16 @@
     { 0 },
 };
 
-const AVCodecTag *const ff_oma_codec_tags_list[] = { ff_oma_codec_tags, NULL };
+/** map ATRAC-X channel id to internal channel layout */
+const uint64_t ff_oma_chid_to_native_layout[7] = {
+    AV_CH_LAYOUT_MONO,
+    AV_CH_LAYOUT_STEREO,
+    AV_CH_LAYOUT_SURROUND,
+    AV_CH_LAYOUT_4POINT0,
+    AV_CH_LAYOUT_5POINT1_BACK,
+    AV_CH_LAYOUT_6POINT1_BACK,
+    AV_CH_LAYOUT_7POINT1
+};
+
+/** map ATRAC-X channel id to total number of channels */
+const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8};
diff --git a/libavformat/oma.h b/libavformat/oma.h
index 85d5932..36fd012 100644
--- a/libavformat/oma.h
+++ b/libavformat/oma.h
@@ -42,6 +42,8 @@
 extern const uint16_t ff_oma_srate_tab[8];
 
 extern const AVCodecTag ff_oma_codec_tags[];
-extern const AVCodecTag *const ff_oma_codec_tags_list[];
+
+extern const uint64_t ff_oma_chid_to_native_layout[7];
+extern const int ff_oma_chid_to_num_channels[7];
 
 #endif /* AVFORMAT_OMA_H */
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index d31b475..5675d86 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -59,20 +59,6 @@
     0x1573cd93da7df623, 0x47f98d79620dd535
 };
 
-/** map ATRAC-X channel id to internal channel layout */
-static const uint64_t oma_chid_to_native_layout[7] = {
-    AV_CH_LAYOUT_MONO,
-    AV_CH_LAYOUT_STEREO,
-    AV_CH_LAYOUT_SURROUND,
-    AV_CH_LAYOUT_4POINT0,
-    AV_CH_LAYOUT_5POINT1_BACK,
-    AV_CH_LAYOUT_6POINT1_BACK,
-    AV_CH_LAYOUT_7POINT1
-};
-
-/** map ATRAC-X channel id to total number of channels */
-static const int oma_chid_to_num_channels[7] = { 1, 2, 3, 4, 6, 7, 8 };
-
 typedef struct OMAContext {
     uint64_t content_start;
     int encrypted;
@@ -506,8 +492,8 @@
             ret = AVERROR_INVALIDDATA;
             goto fail;
         }
-        st->codecpar->channel_layout = oma_chid_to_native_layout[channel_id - 1];
-        st->codecpar->channels       = oma_chid_to_num_channels[channel_id - 1];
+        st->codecpar->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
+        st->codecpar->channels       = ff_oma_chid_to_num_channels[channel_id - 1];
         framesize = ((codec_params & 0x3FF) * 8) + 8;
         samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
         if (!samplerate) {
@@ -635,5 +621,5 @@
     .read_close     = oma_read_close,
     .flags          = AVFMT_GENERIC_INDEX,
     .extensions     = "oma,omg,aa3",
-    .codec_tag      = ff_oma_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ff_oma_codec_tags, 0},
 };
diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
index d3c4f62..7952808 100644
--- a/libavformat/omaenc.c
+++ b/libavformat/omaenc.c
@@ -102,6 +102,6 @@
     .audio_codec       = AV_CODEC_ID_ATRAC3,
     .write_header      = oma_write_header,
     .write_packet      = ff_raw_write_packet,
-    .codec_tag         = ff_oma_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ff_oma_codec_tags, 0},
     .flags             = AVFMT_NOTIMESTAMPS,
 };
diff --git a/libavformat/paf.c b/libavformat/paf.c
index dbc5010..9587111 100644
--- a/libavformat/paf.c
+++ b/libavformat/paf.c
@@ -136,10 +136,6 @@
     p->start_offset   = avio_rl32(pb);
     p->max_video_blks = avio_rl32(pb);
     p->max_audio_blks = avio_rl32(pb);
-
-    if (avio_feof(pb))
-        return AVERROR_INVALIDDATA;
-
     if (p->buffer_size    < 175  ||
         p->max_audio_blks < 2    ||
         p->max_video_blks < 1    ||
@@ -153,11 +149,11 @@
         p->frame_blks     > INT_MAX / sizeof(uint32_t))
         return AVERROR_INVALIDDATA;
 
-    p->blocks_count_table  = av_malloc_array(p->nb_frames,
+    p->blocks_count_table  = av_mallocz(p->nb_frames *
                                         sizeof(*p->blocks_count_table));
-    p->frames_offset_table = av_malloc_array(p->nb_frames,
+    p->frames_offset_table = av_mallocz(p->nb_frames *
                                         sizeof(*p->frames_offset_table));
-    p->blocks_offset_table = av_malloc_array(p->frame_blks,
+    p->blocks_offset_table = av_mallocz(p->frame_blks *
                                         sizeof(*p->blocks_offset_table));
 
     p->video_size  = p->max_video_blks * p->buffer_size;
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 9b55293..9895af0 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
 #include "pcm.h"
@@ -36,33 +35,36 @@
 static int pcm_read_header(AVFormatContext *s)
 {
     PCMAudioDemuxerContext *s1 = s->priv_data;
-    AVCodecParameters *par;
     AVStream *st;
     uint8_t *mime_type = NULL;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    par = st->codecpar;
 
-    par->codec_type  = AVMEDIA_TYPE_AUDIO;
-    par->codec_id    = s->iformat->raw_codec_id;
-    par->sample_rate = s1->sample_rate;
-    par->channels    = s1->channels;
+
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id    = s->iformat->raw_codec_id;
+    st->codecpar->sample_rate = s1->sample_rate;
+    st->codecpar->channels    = s1->channels;
 
     av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
     if (mime_type && s->iformat->mime_type) {
         int rate = 0, channels = 0, little_endian = 0;
-        const char *options;
-        if (av_stristart(mime_type, s->iformat->mime_type, &options)) { /* audio/L16 */
-            while (options = strchr(options, ';')) {
-                options++;
+        size_t len = strlen(s->iformat->mime_type);
+        if (!av_strncasecmp(s->iformat->mime_type, mime_type, len)) { /* audio/L16 */
+            uint8_t *options = mime_type + len;
+            len = strlen(mime_type);
+            while (options < mime_type + len) {
+                options = strstr(options, ";");
+                if (!options++)
+                    break;
                 if (!rate)
                     sscanf(options, " rate=%d",     &rate);
                 if (!channels)
                     sscanf(options, " channels=%d", &channels);
                 if (!little_endian) {
-                     char val[sizeof("little-endian")];
+                     char val[14]; /* sizeof("little-endian") == 14 */
                      if (sscanf(options, " endianness=%13s", val) == 1) {
                          little_endian = strcmp(val, "little-endian") == 0;
                      }
@@ -75,22 +77,24 @@
                 av_freep(&mime_type);
                 return AVERROR_INVALIDDATA;
             }
-            par->sample_rate = rate;
+            st->codecpar->sample_rate = rate;
             if (channels > 0)
-                par->channels = channels;
+                st->codecpar->channels = channels;
             if (little_endian)
-                par->codec_id = AV_CODEC_ID_PCM_S16LE;
+                st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
         }
     }
     av_freep(&mime_type);
 
-    par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
+    st->codecpar->bits_per_coded_sample =
+        av_get_bits_per_sample(st->codecpar->codec_id);
 
-    av_assert0(par->bits_per_coded_sample > 0);
+    av_assert0(st->codecpar->bits_per_coded_sample > 0);
 
-    par->block_align = par->bits_per_coded_sample * par->channels / 8;
+    st->codecpar->block_align =
+        st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
 
-    avpriv_set_pts_info(st, 64, 1, par->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     return 0;
 }
 
@@ -100,8 +104,7 @@
     { NULL },
 };
 
-#define PCMDEF_0(name_, long_name_, ext, codec, ...)
-#define PCMDEF_1(name_, long_name_, ext, codec, ...)        \
+#define PCMDEF(name_, long_name_, ext, codec, ...)          \
 static const AVClass name_ ## _demuxer_class = {            \
     .class_name = #name_ " demuxer",                        \
     .item_name  = av_default_item_name,                     \
@@ -121,40 +124,70 @@
     .priv_class     = &name_ ## _demuxer_class,             \
     __VA_ARGS__                                             \
 };
-#define PCMDEF_2(name, long_name, ext, codec, enabled, ...) \
-    PCMDEF_ ## enabled(name, long_name, ext, codec, __VA_ARGS__)
-#define PCMDEF_3(name, long_name, ext, codec, config, ...)  \
-    PCMDEF_2(name, long_name, ext, codec, config,   __VA_ARGS__)
-#define PCMDEF_EXT(name, long_name, ext, uppercase, ...)    \
-    PCMDEF_3(name, long_name, ext, AV_CODEC_ID_PCM_ ## uppercase, \
-             CONFIG_PCM_ ## uppercase ## _DEMUXER,  __VA_ARGS__)
-#define PCMDEF(name, long_name, ext, uppercase)             \
-    PCMDEF_EXT(name, long_name, ext, uppercase, )
 
-PCMDEF(f64be, "PCM 64-bit floating-point big-endian",           NULL, F64BE)
-PCMDEF(f64le, "PCM 64-bit floating-point little-endian",        NULL, F64LE)
-PCMDEF(f32be, "PCM 32-bit floating-point big-endian",           NULL, F32BE)
-PCMDEF(f32le, "PCM 32-bit floating-point little-endian",        NULL, F32LE)
-PCMDEF(s32be, "PCM signed 32-bit big-endian",                   NULL, S32BE)
-PCMDEF(s32le, "PCM signed 32-bit little-endian",                NULL, S32LE)
-PCMDEF(s24be, "PCM signed 24-bit big-endian",                   NULL, S24BE)
-PCMDEF(s24le, "PCM signed 24-bit little-endian",                NULL, S24LE)
-PCMDEF_EXT(s16be, "PCM signed 16-bit big-endian",
-           AV_NE("sw", NULL), S16BE, .mime_type = "audio/L16")
-PCMDEF(s16le, "PCM signed 16-bit little-endian",   AV_NE(NULL, "sw"), S16LE)
-PCMDEF(s8,    "PCM signed 8-bit",                               "sb",    S8)
-PCMDEF(u32be, "PCM unsigned 32-bit big-endian",                 NULL, U32BE)
-PCMDEF(u32le, "PCM unsigned 32-bit little-endian",              NULL, U32LE)
-PCMDEF(u24be, "PCM unsigned 24-bit big-endian",                 NULL, U24BE)
-PCMDEF(u24le, "PCM unsigned 24-bit little-endian",              NULL, U24LE)
-PCMDEF(u16be, "PCM unsigned 16-bit big-endian",    AV_NE("uw", NULL), U16BE)
-PCMDEF(u16le, "PCM unsigned 16-bit little-endian", AV_NE(NULL, "uw"), U16LE)
-PCMDEF(u8,    "PCM unsigned 8-bit",                             "ub",    U8)
-PCMDEF(alaw,  "PCM A-law",                                      "al",  ALAW)
-PCMDEF(mulaw, "PCM mu-law",                                     "ul", MULAW)
-PCMDEF(vidc,  "PCM Archimedes VIDC",                            NULL,  VIDC)
+PCMDEF(f64be, "PCM 64-bit floating-point big-endian",
+       NULL, AV_CODEC_ID_PCM_F64BE)
 
-#if CONFIG_SLN_DEMUXER
+PCMDEF(f64le, "PCM 64-bit floating-point little-endian",
+       NULL, AV_CODEC_ID_PCM_F64LE)
+
+PCMDEF(f32be, "PCM 32-bit floating-point big-endian",
+       NULL, AV_CODEC_ID_PCM_F32BE)
+
+PCMDEF(f32le, "PCM 32-bit floating-point little-endian",
+       NULL, AV_CODEC_ID_PCM_F32LE)
+
+PCMDEF(s32be, "PCM signed 32-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_S32BE)
+
+PCMDEF(s32le, "PCM signed 32-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_S32LE)
+
+PCMDEF(s24be, "PCM signed 24-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_S24BE)
+
+PCMDEF(s24le, "PCM signed 24-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_S24LE)
+
+PCMDEF(s16be, "PCM signed 16-bit big-endian",
+       AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE, .mime_type = "audio/L16")
+
+PCMDEF(s16le, "PCM signed 16-bit little-endian",
+       AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE)
+
+PCMDEF(s8, "PCM signed 8-bit",
+       "sb", AV_CODEC_ID_PCM_S8)
+
+PCMDEF(u32be, "PCM unsigned 32-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_U32BE)
+
+PCMDEF(u32le, "PCM unsigned 32-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_U32LE)
+
+PCMDEF(u24be, "PCM unsigned 24-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_U24BE)
+
+PCMDEF(u24le, "PCM unsigned 24-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_U24LE)
+
+PCMDEF(u16be, "PCM unsigned 16-bit big-endian",
+       AV_NE("uw", NULL), AV_CODEC_ID_PCM_U16BE)
+
+PCMDEF(u16le, "PCM unsigned 16-bit little-endian",
+       AV_NE(NULL, "uw"), AV_CODEC_ID_PCM_U16LE)
+
+PCMDEF(u8, "PCM unsigned 8-bit",
+       "ub", AV_CODEC_ID_PCM_U8)
+
+PCMDEF(alaw, "PCM A-law",
+       "al", AV_CODEC_ID_PCM_ALAW)
+
+PCMDEF(mulaw, "PCM mu-law",
+       "ul", AV_CODEC_ID_PCM_MULAW)
+
+PCMDEF(vidc, "PCM Archimedes VIDC",
+       NULL, AV_CODEC_ID_PCM_VIDC)
+
 static const AVOption sln_options[] = {
     { "sample_rate", "", offsetof(PCMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 8000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "channels",    "", offsetof(PCMAudioDemuxerContext, channels),    AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
@@ -180,4 +213,3 @@
     .raw_codec_id   = AV_CODEC_ID_PCM_S16LE,
     .priv_class     = &sln_demuxer_class,
 };
-#endif
diff --git a/libavformat/pcmenc.c b/libavformat/pcmenc.c
index 050b9c4..1760b3b 100644
--- a/libavformat/pcmenc.c
+++ b/libavformat/pcmenc.c
@@ -22,8 +22,7 @@
 #include "avformat.h"
 #include "rawenc.h"
 
-#define PCMDEF_0(name_, long_name_, ext, codec)
-#define PCMDEF_1(name_, long_name_, ext, codec)             \
+#define PCMDEF(name_, long_name_, ext, codec)               \
 AVOutputFormat ff_pcm_ ## name_ ## _muxer = {               \
     .name         = #name_,                                 \
     .long_name    = NULL_IF_CONFIG_SMALL(long_name_),       \
@@ -33,32 +32,66 @@
     .write_packet = ff_raw_write_packet,                    \
     .flags        = AVFMT_NOTIMESTAMPS,                     \
 };
-#define PCMDEF_2(name, long_name, ext, codec, enabled)      \
-    PCMDEF_ ## enabled(name, long_name, ext, codec)
-#define PCMDEF_3(name, long_name, ext, codec, config)       \
-    PCMDEF_2(name, long_name, ext, codec, config)
-#define PCMDEF(name, long_name, ext, uppercase)             \
-    PCMDEF_3(name, long_name, ext, AV_CODEC_ID_PCM_ ## uppercase, \
-             CONFIG_PCM_ ## uppercase ## _MUXER)
 
-PCMDEF(f64be, "PCM 64-bit floating-point big-endian",           NULL, F64BE)
-PCMDEF(f64le, "PCM 64-bit floating-point little-endian",        NULL, F64LE)
-PCMDEF(f32be, "PCM 32-bit floating-point big-endian",           NULL, F32BE)
-PCMDEF(f32le, "PCM 32-bit floating-point little-endian",        NULL, F32LE)
-PCMDEF(s32be, "PCM signed 32-bit big-endian",                   NULL, S32BE)
-PCMDEF(s32le, "PCM signed 32-bit little-endian",                NULL, S32LE)
-PCMDEF(s24be, "PCM signed 24-bit big-endian",                   NULL, S24BE)
-PCMDEF(s24le, "PCM signed 24-bit little-endian",                NULL, S24LE)
-PCMDEF(s16be, "PCM signed 16-bit big-endian",      AV_NE("sw", NULL), S16BE)
-PCMDEF(s16le, "PCM signed 16-bit little-endian",   AV_NE(NULL, "sw"), S16LE)
-PCMDEF(s8,    "PCM signed 8-bit",                               "sb",    S8)
-PCMDEF(u32be, "PCM unsigned 32-bit big-endian",                 NULL, U32BE)
-PCMDEF(u32le, "PCM unsigned 32-bit little-endian",              NULL, U32LE)
-PCMDEF(u24be, "PCM unsigned 24-bit big-endian",                 NULL, U24BE)
-PCMDEF(u24le, "PCM unsigned 24-bit little-endian",              NULL, U24LE)
-PCMDEF(u16be, "PCM unsigned 16-bit big-endian",    AV_NE("uw", NULL), U16BE)
-PCMDEF(u16le, "PCM unsigned 16-bit little-endian", AV_NE(NULL, "uw"), U16LE)
-PCMDEF(u8,    "PCM unsigned 8-bit",                             "ub",    U8)
-PCMDEF(alaw,  "PCM A-law",                                      "al",  ALAW)
-PCMDEF(mulaw, "PCM mu-law",                                     "ul", MULAW)
-PCMDEF(vidc,  "PCM Archimedes VIDC",                            NULL,  VIDC)
+PCMDEF(f64be, "PCM 64-bit floating-point big-endian",
+       NULL, AV_CODEC_ID_PCM_F64BE)
+
+PCMDEF(f64le, "PCM 64-bit floating-point little-endian",
+       NULL, AV_CODEC_ID_PCM_F64LE)
+
+PCMDEF(f32be, "PCM 32-bit floating-point big-endian",
+       NULL, AV_CODEC_ID_PCM_F32BE)
+
+PCMDEF(f32le, "PCM 32-bit floating-point little-endian",
+       NULL, AV_CODEC_ID_PCM_F32LE)
+
+PCMDEF(s32be, "PCM signed 32-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_S32BE)
+
+PCMDEF(s32le, "PCM signed 32-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_S32LE)
+
+PCMDEF(s24be, "PCM signed 24-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_S24BE)
+
+PCMDEF(s24le, "PCM signed 24-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_S24LE)
+
+PCMDEF(s16be, "PCM signed 16-bit big-endian",
+       AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE)
+
+PCMDEF(s16le, "PCM signed 16-bit little-endian",
+       AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE)
+
+PCMDEF(s8, "PCM signed 8-bit",
+       "sb", AV_CODEC_ID_PCM_S8)
+
+PCMDEF(u32be, "PCM unsigned 32-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_U32BE)
+
+PCMDEF(u32le, "PCM unsigned 32-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_U32LE)
+
+PCMDEF(u24be, "PCM unsigned 24-bit big-endian",
+       NULL, AV_CODEC_ID_PCM_U24BE)
+
+PCMDEF(u24le, "PCM unsigned 24-bit little-endian",
+       NULL, AV_CODEC_ID_PCM_U24LE)
+
+PCMDEF(u16be, "PCM unsigned 16-bit big-endian",
+       AV_NE("uw", NULL), AV_CODEC_ID_PCM_U16BE)
+
+PCMDEF(u16le, "PCM unsigned 16-bit little-endian",
+       AV_NE(NULL, "uw"), AV_CODEC_ID_PCM_U16LE)
+
+PCMDEF(u8, "PCM unsigned 8-bit",
+       "ub", AV_CODEC_ID_PCM_U8)
+
+PCMDEF(alaw, "PCM A-law",
+       "al", AV_CODEC_ID_PCM_ALAW)
+
+PCMDEF(mulaw, "PCM mu-law",
+       "ul", AV_CODEC_ID_PCM_MULAW)
+
+PCMDEF(vidc, "PCM Archimedes VIDC",
+       NULL, AV_CODEC_ID_PCM_VIDC)
diff --git a/libavformat/qtpalette.c b/libavformat/qtpalette.c
index 046daf0..6833f0c 100644
--- a/libavformat/qtpalette.c
+++ b/libavformat/qtpalette.c
@@ -24,302 +24,10 @@
 #include <stdio.h>
 #include <stdint.h>
 
-#include "libavcodec/codec_id.h"
-#include "avio.h"
+#include "avformat.h"
+#include "libavutil/intreadwrite.h"
 #include "qtpalette.h"
 
-static const uint8_t qt_default_palette_2[2 * 3] = {
-  0xFF, 0xFF, 0xFF,
-  0x00, 0x00, 0x00
-};
-
-/* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
-static const uint8_t qt_default_palette_4[4 * 3] = {
-  0xFF, 0xFF, 0xFF,
-  0xAC, 0xAC, 0xAC,
-  0x55, 0x55, 0x55,
-  0x00, 0x00, 0x00
-};
-
-/* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
-static const uint8_t qt_default_palette_16[16 * 3] = {
-  0xFF, 0xFF, 0xFF,
-  0xFC, 0xF3, 0x05,
-  0xFF, 0x64, 0x02,
-  0xDD, 0x08, 0x06,
-  0xF2, 0x08, 0x84,
-  0x46, 0x00, 0xA5,
-  0x00, 0x00, 0xD4,
-  0x02, 0xAB, 0xEA,
-  0x1F, 0xB7, 0x14,
-  0x00, 0x64, 0x11,
-  0x56, 0x2C, 0x05,
-  0x90, 0x71, 0x3A,
-  0xC0, 0xC0, 0xC0,
-  0x80, 0x80, 0x80,
-  0x40, 0x40, 0x40,
-  0x00, 0x00, 0x00
-};
-
-static const uint8_t qt_default_palette_256[256 * 3] = {
-  /*   0, 0x00 */  0xFF, 0xFF, 0xFF,
-  /*   1, 0x01 */  0xFF, 0xFF, 0xCC,
-  /*   2, 0x02 */  0xFF, 0xFF, 0x99,
-  /*   3, 0x03 */  0xFF, 0xFF, 0x66,
-  /*   4, 0x04 */  0xFF, 0xFF, 0x33,
-  /*   5, 0x05 */  0xFF, 0xFF, 0x00,
-  /*   6, 0x06 */  0xFF, 0xCC, 0xFF,
-  /*   7, 0x07 */  0xFF, 0xCC, 0xCC,
-  /*   8, 0x08 */  0xFF, 0xCC, 0x99,
-  /*   9, 0x09 */  0xFF, 0xCC, 0x66,
-  /*  10, 0x0A */  0xFF, 0xCC, 0x33,
-  /*  11, 0x0B */  0xFF, 0xCC, 0x00,
-  /*  12, 0x0C */  0xFF, 0x99, 0xFF,
-  /*  13, 0x0D */  0xFF, 0x99, 0xCC,
-  /*  14, 0x0E */  0xFF, 0x99, 0x99,
-  /*  15, 0x0F */  0xFF, 0x99, 0x66,
-  /*  16, 0x10 */  0xFF, 0x99, 0x33,
-  /*  17, 0x11 */  0xFF, 0x99, 0x00,
-  /*  18, 0x12 */  0xFF, 0x66, 0xFF,
-  /*  19, 0x13 */  0xFF, 0x66, 0xCC,
-  /*  20, 0x14 */  0xFF, 0x66, 0x99,
-  /*  21, 0x15 */  0xFF, 0x66, 0x66,
-  /*  22, 0x16 */  0xFF, 0x66, 0x33,
-  /*  23, 0x17 */  0xFF, 0x66, 0x00,
-  /*  24, 0x18 */  0xFF, 0x33, 0xFF,
-  /*  25, 0x19 */  0xFF, 0x33, 0xCC,
-  /*  26, 0x1A */  0xFF, 0x33, 0x99,
-  /*  27, 0x1B */  0xFF, 0x33, 0x66,
-  /*  28, 0x1C */  0xFF, 0x33, 0x33,
-  /*  29, 0x1D */  0xFF, 0x33, 0x00,
-  /*  30, 0x1E */  0xFF, 0x00, 0xFF,
-  /*  31, 0x1F */  0xFF, 0x00, 0xCC,
-  /*  32, 0x20 */  0xFF, 0x00, 0x99,
-  /*  33, 0x21 */  0xFF, 0x00, 0x66,
-  /*  34, 0x22 */  0xFF, 0x00, 0x33,
-  /*  35, 0x23 */  0xFF, 0x00, 0x00,
-  /*  36, 0x24 */  0xCC, 0xFF, 0xFF,
-  /*  37, 0x25 */  0xCC, 0xFF, 0xCC,
-  /*  38, 0x26 */  0xCC, 0xFF, 0x99,
-  /*  39, 0x27 */  0xCC, 0xFF, 0x66,
-  /*  40, 0x28 */  0xCC, 0xFF, 0x33,
-  /*  41, 0x29 */  0xCC, 0xFF, 0x00,
-  /*  42, 0x2A */  0xCC, 0xCC, 0xFF,
-  /*  43, 0x2B */  0xCC, 0xCC, 0xCC,
-  /*  44, 0x2C */  0xCC, 0xCC, 0x99,
-  /*  45, 0x2D */  0xCC, 0xCC, 0x66,
-  /*  46, 0x2E */  0xCC, 0xCC, 0x33,
-  /*  47, 0x2F */  0xCC, 0xCC, 0x00,
-  /*  48, 0x30 */  0xCC, 0x99, 0xFF,
-  /*  49, 0x31 */  0xCC, 0x99, 0xCC,
-  /*  50, 0x32 */  0xCC, 0x99, 0x99,
-  /*  51, 0x33 */  0xCC, 0x99, 0x66,
-  /*  52, 0x34 */  0xCC, 0x99, 0x33,
-  /*  53, 0x35 */  0xCC, 0x99, 0x00,
-  /*  54, 0x36 */  0xCC, 0x66, 0xFF,
-  /*  55, 0x37 */  0xCC, 0x66, 0xCC,
-  /*  56, 0x38 */  0xCC, 0x66, 0x99,
-  /*  57, 0x39 */  0xCC, 0x66, 0x66,
-  /*  58, 0x3A */  0xCC, 0x66, 0x33,
-  /*  59, 0x3B */  0xCC, 0x66, 0x00,
-  /*  60, 0x3C */  0xCC, 0x33, 0xFF,
-  /*  61, 0x3D */  0xCC, 0x33, 0xCC,
-  /*  62, 0x3E */  0xCC, 0x33, 0x99,
-  /*  63, 0x3F */  0xCC, 0x33, 0x66,
-  /*  64, 0x40 */  0xCC, 0x33, 0x33,
-  /*  65, 0x41 */  0xCC, 0x33, 0x00,
-  /*  66, 0x42 */  0xCC, 0x00, 0xFF,
-  /*  67, 0x43 */  0xCC, 0x00, 0xCC,
-  /*  68, 0x44 */  0xCC, 0x00, 0x99,
-  /*  69, 0x45 */  0xCC, 0x00, 0x66,
-  /*  70, 0x46 */  0xCC, 0x00, 0x33,
-  /*  71, 0x47 */  0xCC, 0x00, 0x00,
-  /*  72, 0x48 */  0x99, 0xFF, 0xFF,
-  /*  73, 0x49 */  0x99, 0xFF, 0xCC,
-  /*  74, 0x4A */  0x99, 0xFF, 0x99,
-  /*  75, 0x4B */  0x99, 0xFF, 0x66,
-  /*  76, 0x4C */  0x99, 0xFF, 0x33,
-  /*  77, 0x4D */  0x99, 0xFF, 0x00,
-  /*  78, 0x4E */  0x99, 0xCC, 0xFF,
-  /*  79, 0x4F */  0x99, 0xCC, 0xCC,
-  /*  80, 0x50 */  0x99, 0xCC, 0x99,
-  /*  81, 0x51 */  0x99, 0xCC, 0x66,
-  /*  82, 0x52 */  0x99, 0xCC, 0x33,
-  /*  83, 0x53 */  0x99, 0xCC, 0x00,
-  /*  84, 0x54 */  0x99, 0x99, 0xFF,
-  /*  85, 0x55 */  0x99, 0x99, 0xCC,
-  /*  86, 0x56 */  0x99, 0x99, 0x99,
-  /*  87, 0x57 */  0x99, 0x99, 0x66,
-  /*  88, 0x58 */  0x99, 0x99, 0x33,
-  /*  89, 0x59 */  0x99, 0x99, 0x00,
-  /*  90, 0x5A */  0x99, 0x66, 0xFF,
-  /*  91, 0x5B */  0x99, 0x66, 0xCC,
-  /*  92, 0x5C */  0x99, 0x66, 0x99,
-  /*  93, 0x5D */  0x99, 0x66, 0x66,
-  /*  94, 0x5E */  0x99, 0x66, 0x33,
-  /*  95, 0x5F */  0x99, 0x66, 0x00,
-  /*  96, 0x60 */  0x99, 0x33, 0xFF,
-  /*  97, 0x61 */  0x99, 0x33, 0xCC,
-  /*  98, 0x62 */  0x99, 0x33, 0x99,
-  /*  99, 0x63 */  0x99, 0x33, 0x66,
-  /* 100, 0x64 */  0x99, 0x33, 0x33,
-  /* 101, 0x65 */  0x99, 0x33, 0x00,
-  /* 102, 0x66 */  0x99, 0x00, 0xFF,
-  /* 103, 0x67 */  0x99, 0x00, 0xCC,
-  /* 104, 0x68 */  0x99, 0x00, 0x99,
-  /* 105, 0x69 */  0x99, 0x00, 0x66,
-  /* 106, 0x6A */  0x99, 0x00, 0x33,
-  /* 107, 0x6B */  0x99, 0x00, 0x00,
-  /* 108, 0x6C */  0x66, 0xFF, 0xFF,
-  /* 109, 0x6D */  0x66, 0xFF, 0xCC,
-  /* 110, 0x6E */  0x66, 0xFF, 0x99,
-  /* 111, 0x6F */  0x66, 0xFF, 0x66,
-  /* 112, 0x70 */  0x66, 0xFF, 0x33,
-  /* 113, 0x71 */  0x66, 0xFF, 0x00,
-  /* 114, 0x72 */  0x66, 0xCC, 0xFF,
-  /* 115, 0x73 */  0x66, 0xCC, 0xCC,
-  /* 116, 0x74 */  0x66, 0xCC, 0x99,
-  /* 117, 0x75 */  0x66, 0xCC, 0x66,
-  /* 118, 0x76 */  0x66, 0xCC, 0x33,
-  /* 119, 0x77 */  0x66, 0xCC, 0x00,
-  /* 120, 0x78 */  0x66, 0x99, 0xFF,
-  /* 121, 0x79 */  0x66, 0x99, 0xCC,
-  /* 122, 0x7A */  0x66, 0x99, 0x99,
-  /* 123, 0x7B */  0x66, 0x99, 0x66,
-  /* 124, 0x7C */  0x66, 0x99, 0x33,
-  /* 125, 0x7D */  0x66, 0x99, 0x00,
-  /* 126, 0x7E */  0x66, 0x66, 0xFF,
-  /* 127, 0x7F */  0x66, 0x66, 0xCC,
-  /* 128, 0x80 */  0x66, 0x66, 0x99,
-  /* 129, 0x81 */  0x66, 0x66, 0x66,
-  /* 130, 0x82 */  0x66, 0x66, 0x33,
-  /* 131, 0x83 */  0x66, 0x66, 0x00,
-  /* 132, 0x84 */  0x66, 0x33, 0xFF,
-  /* 133, 0x85 */  0x66, 0x33, 0xCC,
-  /* 134, 0x86 */  0x66, 0x33, 0x99,
-  /* 135, 0x87 */  0x66, 0x33, 0x66,
-  /* 136, 0x88 */  0x66, 0x33, 0x33,
-  /* 137, 0x89 */  0x66, 0x33, 0x00,
-  /* 138, 0x8A */  0x66, 0x00, 0xFF,
-  /* 139, 0x8B */  0x66, 0x00, 0xCC,
-  /* 140, 0x8C */  0x66, 0x00, 0x99,
-  /* 141, 0x8D */  0x66, 0x00, 0x66,
-  /* 142, 0x8E */  0x66, 0x00, 0x33,
-  /* 143, 0x8F */  0x66, 0x00, 0x00,
-  /* 144, 0x90 */  0x33, 0xFF, 0xFF,
-  /* 145, 0x91 */  0x33, 0xFF, 0xCC,
-  /* 146, 0x92 */  0x33, 0xFF, 0x99,
-  /* 147, 0x93 */  0x33, 0xFF, 0x66,
-  /* 148, 0x94 */  0x33, 0xFF, 0x33,
-  /* 149, 0x95 */  0x33, 0xFF, 0x00,
-  /* 150, 0x96 */  0x33, 0xCC, 0xFF,
-  /* 151, 0x97 */  0x33, 0xCC, 0xCC,
-  /* 152, 0x98 */  0x33, 0xCC, 0x99,
-  /* 153, 0x99 */  0x33, 0xCC, 0x66,
-  /* 154, 0x9A */  0x33, 0xCC, 0x33,
-  /* 155, 0x9B */  0x33, 0xCC, 0x00,
-  /* 156, 0x9C */  0x33, 0x99, 0xFF,
-  /* 157, 0x9D */  0x33, 0x99, 0xCC,
-  /* 158, 0x9E */  0x33, 0x99, 0x99,
-  /* 159, 0x9F */  0x33, 0x99, 0x66,
-  /* 160, 0xA0 */  0x33, 0x99, 0x33,
-  /* 161, 0xA1 */  0x33, 0x99, 0x00,
-  /* 162, 0xA2 */  0x33, 0x66, 0xFF,
-  /* 163, 0xA3 */  0x33, 0x66, 0xCC,
-  /* 164, 0xA4 */  0x33, 0x66, 0x99,
-  /* 165, 0xA5 */  0x33, 0x66, 0x66,
-  /* 166, 0xA6 */  0x33, 0x66, 0x33,
-  /* 167, 0xA7 */  0x33, 0x66, 0x00,
-  /* 168, 0xA8 */  0x33, 0x33, 0xFF,
-  /* 169, 0xA9 */  0x33, 0x33, 0xCC,
-  /* 170, 0xAA */  0x33, 0x33, 0x99,
-  /* 171, 0xAB */  0x33, 0x33, 0x66,
-  /* 172, 0xAC */  0x33, 0x33, 0x33,
-  /* 173, 0xAD */  0x33, 0x33, 0x00,
-  /* 174, 0xAE */  0x33, 0x00, 0xFF,
-  /* 175, 0xAF */  0x33, 0x00, 0xCC,
-  /* 176, 0xB0 */  0x33, 0x00, 0x99,
-  /* 177, 0xB1 */  0x33, 0x00, 0x66,
-  /* 178, 0xB2 */  0x33, 0x00, 0x33,
-  /* 179, 0xB3 */  0x33, 0x00, 0x00,
-  /* 180, 0xB4 */  0x00, 0xFF, 0xFF,
-  /* 181, 0xB5 */  0x00, 0xFF, 0xCC,
-  /* 182, 0xB6 */  0x00, 0xFF, 0x99,
-  /* 183, 0xB7 */  0x00, 0xFF, 0x66,
-  /* 184, 0xB8 */  0x00, 0xFF, 0x33,
-  /* 185, 0xB9 */  0x00, 0xFF, 0x00,
-  /* 186, 0xBA */  0x00, 0xCC, 0xFF,
-  /* 187, 0xBB */  0x00, 0xCC, 0xCC,
-  /* 188, 0xBC */  0x00, 0xCC, 0x99,
-  /* 189, 0xBD */  0x00, 0xCC, 0x66,
-  /* 190, 0xBE */  0x00, 0xCC, 0x33,
-  /* 191, 0xBF */  0x00, 0xCC, 0x00,
-  /* 192, 0xC0 */  0x00, 0x99, 0xFF,
-  /* 193, 0xC1 */  0x00, 0x99, 0xCC,
-  /* 194, 0xC2 */  0x00, 0x99, 0x99,
-  /* 195, 0xC3 */  0x00, 0x99, 0x66,
-  /* 196, 0xC4 */  0x00, 0x99, 0x33,
-  /* 197, 0xC5 */  0x00, 0x99, 0x00,
-  /* 198, 0xC6 */  0x00, 0x66, 0xFF,
-  /* 199, 0xC7 */  0x00, 0x66, 0xCC,
-  /* 200, 0xC8 */  0x00, 0x66, 0x99,
-  /* 201, 0xC9 */  0x00, 0x66, 0x66,
-  /* 202, 0xCA */  0x00, 0x66, 0x33,
-  /* 203, 0xCB */  0x00, 0x66, 0x00,
-  /* 204, 0xCC */  0x00, 0x33, 0xFF,
-  /* 205, 0xCD */  0x00, 0x33, 0xCC,
-  /* 206, 0xCE */  0x00, 0x33, 0x99,
-  /* 207, 0xCF */  0x00, 0x33, 0x66,
-  /* 208, 0xD0 */  0x00, 0x33, 0x33,
-  /* 209, 0xD1 */  0x00, 0x33, 0x00,
-  /* 210, 0xD2 */  0x00, 0x00, 0xFF,
-  /* 211, 0xD3 */  0x00, 0x00, 0xCC,
-  /* 212, 0xD4 */  0x00, 0x00, 0x99,
-  /* 213, 0xD5 */  0x00, 0x00, 0x66,
-  /* 214, 0xD6 */  0x00, 0x00, 0x33,
-  /* 215, 0xD7 */  0xEE, 0x00, 0x00,
-  /* 216, 0xD8 */  0xDD, 0x00, 0x00,
-  /* 217, 0xD9 */  0xBB, 0x00, 0x00,
-  /* 218, 0xDA */  0xAA, 0x00, 0x00,
-  /* 219, 0xDB */  0x88, 0x00, 0x00,
-  /* 220, 0xDC */  0x77, 0x00, 0x00,
-  /* 221, 0xDD */  0x55, 0x00, 0x00,
-  /* 222, 0xDE */  0x44, 0x00, 0x00,
-  /* 223, 0xDF */  0x22, 0x00, 0x00,
-  /* 224, 0xE0 */  0x11, 0x00, 0x00,
-  /* 225, 0xE1 */  0x00, 0xEE, 0x00,
-  /* 226, 0xE2 */  0x00, 0xDD, 0x00,
-  /* 227, 0xE3 */  0x00, 0xBB, 0x00,
-  /* 228, 0xE4 */  0x00, 0xAA, 0x00,
-  /* 229, 0xE5 */  0x00, 0x88, 0x00,
-  /* 230, 0xE6 */  0x00, 0x77, 0x00,
-  /* 231, 0xE7 */  0x00, 0x55, 0x00,
-  /* 232, 0xE8 */  0x00, 0x44, 0x00,
-  /* 233, 0xE9 */  0x00, 0x22, 0x00,
-  /* 234, 0xEA */  0x00, 0x11, 0x00,
-  /* 235, 0xEB */  0x00, 0x00, 0xEE,
-  /* 236, 0xEC */  0x00, 0x00, 0xDD,
-  /* 237, 0xED */  0x00, 0x00, 0xBB,
-  /* 238, 0xEE */  0x00, 0x00, 0xAA,
-  /* 239, 0xEF */  0x00, 0x00, 0x88,
-  /* 240, 0xF0 */  0x00, 0x00, 0x77,
-  /* 241, 0xF1 */  0x00, 0x00, 0x55,
-  /* 242, 0xF2 */  0x00, 0x00, 0x44,
-  /* 243, 0xF3 */  0x00, 0x00, 0x22,
-  /* 244, 0xF4 */  0x00, 0x00, 0x11,
-  /* 245, 0xF5 */  0xEE, 0xEE, 0xEE,
-  /* 246, 0xF6 */  0xDD, 0xDD, 0xDD,
-  /* 247, 0xF7 */  0xBB, 0xBB, 0xBB,
-  /* 248, 0xF8 */  0xAA, 0xAA, 0xAA,
-  /* 249, 0xF9 */  0x88, 0x88, 0x88,
-  /* 250, 0xFA */  0x77, 0x77, 0x77,
-  /* 251, 0xFB */  0x55, 0x55, 0x55,
-  /* 252, 0xFC */  0x44, 0x44, 0x44,
-  /* 253, 0xFD */  0x22, 0x22, 0x22,
-  /* 254, 0xFE */  0x11, 0x11, 0x11,
-  /* 255, 0xFF */  0x00, 0x00, 0x00
-};
-
 int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette)
 {
     int tmp, bit_depth, color_table_id, greyscale, i;
@@ -365,13 +73,13 @@
             const uint8_t *color_table;
             color_count = 1 << bit_depth;
             if (bit_depth == 1)
-                color_table = qt_default_palette_2;
+                color_table = ff_qt_default_palette_2;
             else if (bit_depth == 2)
-                color_table = qt_default_palette_4;
+                color_table = ff_qt_default_palette_4;
             else if (bit_depth == 4)
-                color_table = qt_default_palette_16;
+                color_table = ff_qt_default_palette_16;
             else
-                color_table = qt_default_palette_256;
+                color_table = ff_qt_default_palette_256;
             for (i = 0; i < color_count; i++) {
                 r = color_table[i * 3 + 0];
                 g = color_table[i * 3 + 1];
diff --git a/libavformat/qtpalette.h b/libavformat/qtpalette.h
index 18a108e..016e91f 100644
--- a/libavformat/qtpalette.h
+++ b/libavformat/qtpalette.h
@@ -24,7 +24,299 @@
 #define AVFORMAT_QTPALETTE_H
 
 #include <stdint.h>
-#include "avio.h"
+#include "avformat.h"
+
+static const uint8_t ff_qt_default_palette_2[2 * 3] = {
+  0xFF, 0xFF, 0xFF,
+  0x00, 0x00, 0x00
+};
+
+/* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
+static const uint8_t ff_qt_default_palette_4[4 * 3] = {
+  0xFF, 0xFF, 0xFF,
+  0xAC, 0xAC, 0xAC,
+  0x55, 0x55, 0x55,
+  0x00, 0x00, 0x00
+};
+
+/* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
+static const uint8_t ff_qt_default_palette_16[16 * 3] = {
+  0xFF, 0xFF, 0xFF,
+  0xFC, 0xF3, 0x05,
+  0xFF, 0x64, 0x02,
+  0xDD, 0x08, 0x06,
+  0xF2, 0x08, 0x84,
+  0x46, 0x00, 0xA5,
+  0x00, 0x00, 0xD4,
+  0x02, 0xAB, 0xEA,
+  0x1F, 0xB7, 0x14,
+  0x00, 0x64, 0x11,
+  0x56, 0x2C, 0x05,
+  0x90, 0x71, 0x3A,
+  0xC0, 0xC0, 0xC0,
+  0x80, 0x80, 0x80,
+  0x40, 0x40, 0x40,
+  0x00, 0x00, 0x00
+};
+
+static const uint8_t ff_qt_default_palette_256[256 * 3] = {
+  /*   0, 0x00 */  0xFF, 0xFF, 0xFF,
+  /*   1, 0x01 */  0xFF, 0xFF, 0xCC,
+  /*   2, 0x02 */  0xFF, 0xFF, 0x99,
+  /*   3, 0x03 */  0xFF, 0xFF, 0x66,
+  /*   4, 0x04 */  0xFF, 0xFF, 0x33,
+  /*   5, 0x05 */  0xFF, 0xFF, 0x00,
+  /*   6, 0x06 */  0xFF, 0xCC, 0xFF,
+  /*   7, 0x07 */  0xFF, 0xCC, 0xCC,
+  /*   8, 0x08 */  0xFF, 0xCC, 0x99,
+  /*   9, 0x09 */  0xFF, 0xCC, 0x66,
+  /*  10, 0x0A */  0xFF, 0xCC, 0x33,
+  /*  11, 0x0B */  0xFF, 0xCC, 0x00,
+  /*  12, 0x0C */  0xFF, 0x99, 0xFF,
+  /*  13, 0x0D */  0xFF, 0x99, 0xCC,
+  /*  14, 0x0E */  0xFF, 0x99, 0x99,
+  /*  15, 0x0F */  0xFF, 0x99, 0x66,
+  /*  16, 0x10 */  0xFF, 0x99, 0x33,
+  /*  17, 0x11 */  0xFF, 0x99, 0x00,
+  /*  18, 0x12 */  0xFF, 0x66, 0xFF,
+  /*  19, 0x13 */  0xFF, 0x66, 0xCC,
+  /*  20, 0x14 */  0xFF, 0x66, 0x99,
+  /*  21, 0x15 */  0xFF, 0x66, 0x66,
+  /*  22, 0x16 */  0xFF, 0x66, 0x33,
+  /*  23, 0x17 */  0xFF, 0x66, 0x00,
+  /*  24, 0x18 */  0xFF, 0x33, 0xFF,
+  /*  25, 0x19 */  0xFF, 0x33, 0xCC,
+  /*  26, 0x1A */  0xFF, 0x33, 0x99,
+  /*  27, 0x1B */  0xFF, 0x33, 0x66,
+  /*  28, 0x1C */  0xFF, 0x33, 0x33,
+  /*  29, 0x1D */  0xFF, 0x33, 0x00,
+  /*  30, 0x1E */  0xFF, 0x00, 0xFF,
+  /*  31, 0x1F */  0xFF, 0x00, 0xCC,
+  /*  32, 0x20 */  0xFF, 0x00, 0x99,
+  /*  33, 0x21 */  0xFF, 0x00, 0x66,
+  /*  34, 0x22 */  0xFF, 0x00, 0x33,
+  /*  35, 0x23 */  0xFF, 0x00, 0x00,
+  /*  36, 0x24 */  0xCC, 0xFF, 0xFF,
+  /*  37, 0x25 */  0xCC, 0xFF, 0xCC,
+  /*  38, 0x26 */  0xCC, 0xFF, 0x99,
+  /*  39, 0x27 */  0xCC, 0xFF, 0x66,
+  /*  40, 0x28 */  0xCC, 0xFF, 0x33,
+  /*  41, 0x29 */  0xCC, 0xFF, 0x00,
+  /*  42, 0x2A */  0xCC, 0xCC, 0xFF,
+  /*  43, 0x2B */  0xCC, 0xCC, 0xCC,
+  /*  44, 0x2C */  0xCC, 0xCC, 0x99,
+  /*  45, 0x2D */  0xCC, 0xCC, 0x66,
+  /*  46, 0x2E */  0xCC, 0xCC, 0x33,
+  /*  47, 0x2F */  0xCC, 0xCC, 0x00,
+  /*  48, 0x30 */  0xCC, 0x99, 0xFF,
+  /*  49, 0x31 */  0xCC, 0x99, 0xCC,
+  /*  50, 0x32 */  0xCC, 0x99, 0x99,
+  /*  51, 0x33 */  0xCC, 0x99, 0x66,
+  /*  52, 0x34 */  0xCC, 0x99, 0x33,
+  /*  53, 0x35 */  0xCC, 0x99, 0x00,
+  /*  54, 0x36 */  0xCC, 0x66, 0xFF,
+  /*  55, 0x37 */  0xCC, 0x66, 0xCC,
+  /*  56, 0x38 */  0xCC, 0x66, 0x99,
+  /*  57, 0x39 */  0xCC, 0x66, 0x66,
+  /*  58, 0x3A */  0xCC, 0x66, 0x33,
+  /*  59, 0x3B */  0xCC, 0x66, 0x00,
+  /*  60, 0x3C */  0xCC, 0x33, 0xFF,
+  /*  61, 0x3D */  0xCC, 0x33, 0xCC,
+  /*  62, 0x3E */  0xCC, 0x33, 0x99,
+  /*  63, 0x3F */  0xCC, 0x33, 0x66,
+  /*  64, 0x40 */  0xCC, 0x33, 0x33,
+  /*  65, 0x41 */  0xCC, 0x33, 0x00,
+  /*  66, 0x42 */  0xCC, 0x00, 0xFF,
+  /*  67, 0x43 */  0xCC, 0x00, 0xCC,
+  /*  68, 0x44 */  0xCC, 0x00, 0x99,
+  /*  69, 0x45 */  0xCC, 0x00, 0x66,
+  /*  70, 0x46 */  0xCC, 0x00, 0x33,
+  /*  71, 0x47 */  0xCC, 0x00, 0x00,
+  /*  72, 0x48 */  0x99, 0xFF, 0xFF,
+  /*  73, 0x49 */  0x99, 0xFF, 0xCC,
+  /*  74, 0x4A */  0x99, 0xFF, 0x99,
+  /*  75, 0x4B */  0x99, 0xFF, 0x66,
+  /*  76, 0x4C */  0x99, 0xFF, 0x33,
+  /*  77, 0x4D */  0x99, 0xFF, 0x00,
+  /*  78, 0x4E */  0x99, 0xCC, 0xFF,
+  /*  79, 0x4F */  0x99, 0xCC, 0xCC,
+  /*  80, 0x50 */  0x99, 0xCC, 0x99,
+  /*  81, 0x51 */  0x99, 0xCC, 0x66,
+  /*  82, 0x52 */  0x99, 0xCC, 0x33,
+  /*  83, 0x53 */  0x99, 0xCC, 0x00,
+  /*  84, 0x54 */  0x99, 0x99, 0xFF,
+  /*  85, 0x55 */  0x99, 0x99, 0xCC,
+  /*  86, 0x56 */  0x99, 0x99, 0x99,
+  /*  87, 0x57 */  0x99, 0x99, 0x66,
+  /*  88, 0x58 */  0x99, 0x99, 0x33,
+  /*  89, 0x59 */  0x99, 0x99, 0x00,
+  /*  90, 0x5A */  0x99, 0x66, 0xFF,
+  /*  91, 0x5B */  0x99, 0x66, 0xCC,
+  /*  92, 0x5C */  0x99, 0x66, 0x99,
+  /*  93, 0x5D */  0x99, 0x66, 0x66,
+  /*  94, 0x5E */  0x99, 0x66, 0x33,
+  /*  95, 0x5F */  0x99, 0x66, 0x00,
+  /*  96, 0x60 */  0x99, 0x33, 0xFF,
+  /*  97, 0x61 */  0x99, 0x33, 0xCC,
+  /*  98, 0x62 */  0x99, 0x33, 0x99,
+  /*  99, 0x63 */  0x99, 0x33, 0x66,
+  /* 100, 0x64 */  0x99, 0x33, 0x33,
+  /* 101, 0x65 */  0x99, 0x33, 0x00,
+  /* 102, 0x66 */  0x99, 0x00, 0xFF,
+  /* 103, 0x67 */  0x99, 0x00, 0xCC,
+  /* 104, 0x68 */  0x99, 0x00, 0x99,
+  /* 105, 0x69 */  0x99, 0x00, 0x66,
+  /* 106, 0x6A */  0x99, 0x00, 0x33,
+  /* 107, 0x6B */  0x99, 0x00, 0x00,
+  /* 108, 0x6C */  0x66, 0xFF, 0xFF,
+  /* 109, 0x6D */  0x66, 0xFF, 0xCC,
+  /* 110, 0x6E */  0x66, 0xFF, 0x99,
+  /* 111, 0x6F */  0x66, 0xFF, 0x66,
+  /* 112, 0x70 */  0x66, 0xFF, 0x33,
+  /* 113, 0x71 */  0x66, 0xFF, 0x00,
+  /* 114, 0x72 */  0x66, 0xCC, 0xFF,
+  /* 115, 0x73 */  0x66, 0xCC, 0xCC,
+  /* 116, 0x74 */  0x66, 0xCC, 0x99,
+  /* 117, 0x75 */  0x66, 0xCC, 0x66,
+  /* 118, 0x76 */  0x66, 0xCC, 0x33,
+  /* 119, 0x77 */  0x66, 0xCC, 0x00,
+  /* 120, 0x78 */  0x66, 0x99, 0xFF,
+  /* 121, 0x79 */  0x66, 0x99, 0xCC,
+  /* 122, 0x7A */  0x66, 0x99, 0x99,
+  /* 123, 0x7B */  0x66, 0x99, 0x66,
+  /* 124, 0x7C */  0x66, 0x99, 0x33,
+  /* 125, 0x7D */  0x66, 0x99, 0x00,
+  /* 126, 0x7E */  0x66, 0x66, 0xFF,
+  /* 127, 0x7F */  0x66, 0x66, 0xCC,
+  /* 128, 0x80 */  0x66, 0x66, 0x99,
+  /* 129, 0x81 */  0x66, 0x66, 0x66,
+  /* 130, 0x82 */  0x66, 0x66, 0x33,
+  /* 131, 0x83 */  0x66, 0x66, 0x00,
+  /* 132, 0x84 */  0x66, 0x33, 0xFF,
+  /* 133, 0x85 */  0x66, 0x33, 0xCC,
+  /* 134, 0x86 */  0x66, 0x33, 0x99,
+  /* 135, 0x87 */  0x66, 0x33, 0x66,
+  /* 136, 0x88 */  0x66, 0x33, 0x33,
+  /* 137, 0x89 */  0x66, 0x33, 0x00,
+  /* 138, 0x8A */  0x66, 0x00, 0xFF,
+  /* 139, 0x8B */  0x66, 0x00, 0xCC,
+  /* 140, 0x8C */  0x66, 0x00, 0x99,
+  /* 141, 0x8D */  0x66, 0x00, 0x66,
+  /* 142, 0x8E */  0x66, 0x00, 0x33,
+  /* 143, 0x8F */  0x66, 0x00, 0x00,
+  /* 144, 0x90 */  0x33, 0xFF, 0xFF,
+  /* 145, 0x91 */  0x33, 0xFF, 0xCC,
+  /* 146, 0x92 */  0x33, 0xFF, 0x99,
+  /* 147, 0x93 */  0x33, 0xFF, 0x66,
+  /* 148, 0x94 */  0x33, 0xFF, 0x33,
+  /* 149, 0x95 */  0x33, 0xFF, 0x00,
+  /* 150, 0x96 */  0x33, 0xCC, 0xFF,
+  /* 151, 0x97 */  0x33, 0xCC, 0xCC,
+  /* 152, 0x98 */  0x33, 0xCC, 0x99,
+  /* 153, 0x99 */  0x33, 0xCC, 0x66,
+  /* 154, 0x9A */  0x33, 0xCC, 0x33,
+  /* 155, 0x9B */  0x33, 0xCC, 0x00,
+  /* 156, 0x9C */  0x33, 0x99, 0xFF,
+  /* 157, 0x9D */  0x33, 0x99, 0xCC,
+  /* 158, 0x9E */  0x33, 0x99, 0x99,
+  /* 159, 0x9F */  0x33, 0x99, 0x66,
+  /* 160, 0xA0 */  0x33, 0x99, 0x33,
+  /* 161, 0xA1 */  0x33, 0x99, 0x00,
+  /* 162, 0xA2 */  0x33, 0x66, 0xFF,
+  /* 163, 0xA3 */  0x33, 0x66, 0xCC,
+  /* 164, 0xA4 */  0x33, 0x66, 0x99,
+  /* 165, 0xA5 */  0x33, 0x66, 0x66,
+  /* 166, 0xA6 */  0x33, 0x66, 0x33,
+  /* 167, 0xA7 */  0x33, 0x66, 0x00,
+  /* 168, 0xA8 */  0x33, 0x33, 0xFF,
+  /* 169, 0xA9 */  0x33, 0x33, 0xCC,
+  /* 170, 0xAA */  0x33, 0x33, 0x99,
+  /* 171, 0xAB */  0x33, 0x33, 0x66,
+  /* 172, 0xAC */  0x33, 0x33, 0x33,
+  /* 173, 0xAD */  0x33, 0x33, 0x00,
+  /* 174, 0xAE */  0x33, 0x00, 0xFF,
+  /* 175, 0xAF */  0x33, 0x00, 0xCC,
+  /* 176, 0xB0 */  0x33, 0x00, 0x99,
+  /* 177, 0xB1 */  0x33, 0x00, 0x66,
+  /* 178, 0xB2 */  0x33, 0x00, 0x33,
+  /* 179, 0xB3 */  0x33, 0x00, 0x00,
+  /* 180, 0xB4 */  0x00, 0xFF, 0xFF,
+  /* 181, 0xB5 */  0x00, 0xFF, 0xCC,
+  /* 182, 0xB6 */  0x00, 0xFF, 0x99,
+  /* 183, 0xB7 */  0x00, 0xFF, 0x66,
+  /* 184, 0xB8 */  0x00, 0xFF, 0x33,
+  /* 185, 0xB9 */  0x00, 0xFF, 0x00,
+  /* 186, 0xBA */  0x00, 0xCC, 0xFF,
+  /* 187, 0xBB */  0x00, 0xCC, 0xCC,
+  /* 188, 0xBC */  0x00, 0xCC, 0x99,
+  /* 189, 0xBD */  0x00, 0xCC, 0x66,
+  /* 190, 0xBE */  0x00, 0xCC, 0x33,
+  /* 191, 0xBF */  0x00, 0xCC, 0x00,
+  /* 192, 0xC0 */  0x00, 0x99, 0xFF,
+  /* 193, 0xC1 */  0x00, 0x99, 0xCC,
+  /* 194, 0xC2 */  0x00, 0x99, 0x99,
+  /* 195, 0xC3 */  0x00, 0x99, 0x66,
+  /* 196, 0xC4 */  0x00, 0x99, 0x33,
+  /* 197, 0xC5 */  0x00, 0x99, 0x00,
+  /* 198, 0xC6 */  0x00, 0x66, 0xFF,
+  /* 199, 0xC7 */  0x00, 0x66, 0xCC,
+  /* 200, 0xC8 */  0x00, 0x66, 0x99,
+  /* 201, 0xC9 */  0x00, 0x66, 0x66,
+  /* 202, 0xCA */  0x00, 0x66, 0x33,
+  /* 203, 0xCB */  0x00, 0x66, 0x00,
+  /* 204, 0xCC */  0x00, 0x33, 0xFF,
+  /* 205, 0xCD */  0x00, 0x33, 0xCC,
+  /* 206, 0xCE */  0x00, 0x33, 0x99,
+  /* 207, 0xCF */  0x00, 0x33, 0x66,
+  /* 208, 0xD0 */  0x00, 0x33, 0x33,
+  /* 209, 0xD1 */  0x00, 0x33, 0x00,
+  /* 210, 0xD2 */  0x00, 0x00, 0xFF,
+  /* 211, 0xD3 */  0x00, 0x00, 0xCC,
+  /* 212, 0xD4 */  0x00, 0x00, 0x99,
+  /* 213, 0xD5 */  0x00, 0x00, 0x66,
+  /* 214, 0xD6 */  0x00, 0x00, 0x33,
+  /* 215, 0xD7 */  0xEE, 0x00, 0x00,
+  /* 216, 0xD8 */  0xDD, 0x00, 0x00,
+  /* 217, 0xD9 */  0xBB, 0x00, 0x00,
+  /* 218, 0xDA */  0xAA, 0x00, 0x00,
+  /* 219, 0xDB */  0x88, 0x00, 0x00,
+  /* 220, 0xDC */  0x77, 0x00, 0x00,
+  /* 221, 0xDD */  0x55, 0x00, 0x00,
+  /* 222, 0xDE */  0x44, 0x00, 0x00,
+  /* 223, 0xDF */  0x22, 0x00, 0x00,
+  /* 224, 0xE0 */  0x11, 0x00, 0x00,
+  /* 225, 0xE1 */  0x00, 0xEE, 0x00,
+  /* 226, 0xE2 */  0x00, 0xDD, 0x00,
+  /* 227, 0xE3 */  0x00, 0xBB, 0x00,
+  /* 228, 0xE4 */  0x00, 0xAA, 0x00,
+  /* 229, 0xE5 */  0x00, 0x88, 0x00,
+  /* 230, 0xE6 */  0x00, 0x77, 0x00,
+  /* 231, 0xE7 */  0x00, 0x55, 0x00,
+  /* 232, 0xE8 */  0x00, 0x44, 0x00,
+  /* 233, 0xE9 */  0x00, 0x22, 0x00,
+  /* 234, 0xEA */  0x00, 0x11, 0x00,
+  /* 235, 0xEB */  0x00, 0x00, 0xEE,
+  /* 236, 0xEC */  0x00, 0x00, 0xDD,
+  /* 237, 0xED */  0x00, 0x00, 0xBB,
+  /* 238, 0xEE */  0x00, 0x00, 0xAA,
+  /* 239, 0xEF */  0x00, 0x00, 0x88,
+  /* 240, 0xF0 */  0x00, 0x00, 0x77,
+  /* 241, 0xF1 */  0x00, 0x00, 0x55,
+  /* 242, 0xF2 */  0x00, 0x00, 0x44,
+  /* 243, 0xF3 */  0x00, 0x00, 0x22,
+  /* 244, 0xF4 */  0x00, 0x00, 0x11,
+  /* 245, 0xF5 */  0xEE, 0xEE, 0xEE,
+  /* 246, 0xF6 */  0xDD, 0xDD, 0xDD,
+  /* 247, 0xF7 */  0xBB, 0xBB, 0xBB,
+  /* 248, 0xF8 */  0xAA, 0xAA, 0xAA,
+  /* 249, 0xF9 */  0x88, 0x88, 0x88,
+  /* 250, 0xFA */  0x77, 0x77, 0x77,
+  /* 251, 0xFB */  0x55, 0x55, 0x55,
+  /* 252, 0xFC */  0x44, 0x44, 0x44,
+  /* 253, 0xFD */  0x22, 0x22, 0x22,
+  /* 254, 0xFE */  0x11, 0x11, 0x11,
+  /* 255, 0xFF */  0x00, 0x00, 0x00
+};
 
 /**
  * Retrieve the palette (or "color table" in QuickTime terms), either
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 9de0fb5..606ed01 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -325,8 +325,7 @@
 
     pkt->stream_index = 1;
     pkt->dts = dts;
-
-    if (st->codecpar->sample_rate && samples > 0)
+    if (st->codecpar->sample_rate)
         pkt->duration = av_rescale(samples, st->time_base.den, st->codecpar->sample_rate);
     av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %"PRId64" samples %d sample rate %d\n",
             pkt->dts, pkt->duration, samples, st->codecpar->sample_rate);
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index e5824f6..60c36f0 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -554,7 +554,7 @@
 }
 
 #define RDT_HANDLER(n, s, t) \
-const RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
+RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
     .enc_name         = s, \
     .codec_type       = t, \
     .codec_id         = AV_CODEC_ID_NONE, \
diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c
index f534774..390f8dd 100644
--- a/libavformat/realtextdec.c
+++ b/libavformat/realtextdec.c
@@ -54,7 +54,7 @@
     if (sscanf(s,    "%u:%u.%u",      &mm, &ss, &ms) == 3) return (            mm*60LL + ss) * 100LL + ms;
     if (sscanf(s,    "%u:%u"   ,      &mm, &ss     ) == 2) return (            mm*60LL + ss) * 100LL;
     if (sscanf(s,       "%u.%u",           &ss, &ms) == 2) return (                      ss) * 100LL + ms;
-    return strtoll(s, NULL, 10) * 100ULL;
+    return strtol(s, NULL, 10) * 100LL;
 }
 
 static int realtext_read_header(AVFormatContext *s)
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 270ff7c..388047f 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
 #include "libavutil/error.h"
 #include "libavcodec/avcodec.h"
 #include "avformat.h"
@@ -590,16 +589,6 @@
     { AV_CODEC_ID_NONE,      0 },
 };
 
-#if CONFIG_AVI_MUXER || CONFIG_WTV_MUXER
-const AVCodecTag *const ff_riff_codec_tags_list[] = {
-    ff_codec_bmp_tags, ff_codec_wav_tags, NULL
-};
-#endif
-
-#if CONFIG_WAV_DEMUXER || CONFIG_WAV_MUXER || CONFIG_W64_DEMUXER || CONFIG_W64_MUXER
-const AVCodecTag *const ff_wav_codec_tags_list[] = { ff_codec_wav_tags, NULL };
-#endif
-
 const AVMetadataConv ff_riff_info_conv[] = {
     { "IART", "artist"     },
     { "ICMT", "comment"    },
diff --git a/libavformat/riff.h b/libavformat/riff.h
index 0548279..127138d 100644
--- a/libavformat/riff.h
+++ b/libavformat/riff.h
@@ -72,10 +72,6 @@
 
 extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags()
 extern const AVCodecTag ff_codec_wav_tags[];
-/* The following list contains both ff_codec_bmp_tags and ff_codec_wav_tags. */
-extern const AVCodecTag *const ff_riff_codec_tags_list[];
-/* The following list contains only ff_codec_wav_tags. */
-extern const AVCodecTag *const ff_wav_codec_tags_list[];
 
 extern const AVCodecTag ff_codec_bmp_tags_unofficial[];
 
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 610189e..004c620 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -223,7 +223,7 @@
                 if (version == 5)
                     avio_r8(pb);
                 codecdata_length = avio_rb32(pb);
-                if((unsigned)codecdata_length > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE){
+                if(codecdata_length + AV_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
                     av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
                     return -1;
                 }
@@ -254,7 +254,7 @@
             if (version == 5)
                 avio_r8(pb);
             codecdata_length = avio_rb32(pb);
-            if((unsigned)codecdata_length > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE){
+            if(codecdata_length + AV_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
                 av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
                 return -1;
             }
@@ -719,9 +719,9 @@
                     av_log(s, AV_LOG_WARNING,
                            "Index size %d (%d pkts) is wrong, should be %"PRId64".\n",
                            len, n_pkts, expected_len);
-                if(len < 14)
-                    continue;
                 len -= 14; // we already read part of the index header
+                if(len<0)
+                    continue;
                 goto skip;
             } else if (state == MKBETAG('D','A','T','A')) {
                 av_log(s, AV_LOG_WARNING,
@@ -1290,11 +1290,8 @@
                 int j;
 
                 av_log(s, AV_LOG_DEBUG, "%s = '0x", key);
-                for (j = 0; j < len; j++) {
-                    if (avio_feof(pb))
-                        return AVERROR_INVALIDDATA;
+                for (j = 0; j < len; j++)
                     av_log(s, AV_LOG_DEBUG, "%X", avio_r8(pb));
-                }
                 av_log(s, AV_LOG_DEBUG, "'\n");
             } else if (len == 4 && type == 3 && !strncmp(key, "Duration", tlen)) {
                 st->duration = avio_rb32(pb);
diff --git a/libavformat/rsd.c b/libavformat/rsd.c
index 9785a55..ee0b955 100644
--- a/libavformat/rsd.c
+++ b/libavformat/rsd.c
@@ -131,8 +131,6 @@
             return ret;
 
         for (i = 0; i < par->channels; i++) {
-            if (avio_feof(pb))
-                return AVERROR_EOF;
             avio_read(s->pb, st->codecpar->extradata + 32 * i, 32);
             avio_skip(s->pb, 8);
         }
diff --git a/libavformat/rso.c b/libavformat/rso.c
index 765c0d0..7d88f0f 100644
--- a/libavformat/rso.c
+++ b/libavformat/rso.c
@@ -28,5 +28,3 @@
     { AV_CODEC_ID_ADPCM_IMA_WAV,   0x0101 },
     { AV_CODEC_ID_NONE, 0 },
 };
-
-const AVCodecTag *const ff_rso_codec_tags_list[] = { ff_codec_rso_tags, NULL };
diff --git a/libavformat/rso.h b/libavformat/rso.h
index 4f78b40..1f65dd9 100644
--- a/libavformat/rso.h
+++ b/libavformat/rso.h
@@ -28,6 +28,5 @@
 
 /* The libavcodec codecs we support, and the IDs they have in the file */
 extern const AVCodecTag ff_codec_rso_tags[];
-extern const AVCodecTag *const ff_rso_codec_tags_list[];
 
 #endif /* AVFORMAT_RSO_H */
diff --git a/libavformat/rsodec.c b/libavformat/rsodec.c
index 91b86bf..b2d9a7c 100644
--- a/libavformat/rsodec.c
+++ b/libavformat/rsodec.c
@@ -79,5 +79,5 @@
     .read_header    =   rso_read_header,
     .read_packet    =   ff_pcm_read_packet,
     .read_seek      =   ff_pcm_read_seek,
-    .codec_tag      =   ff_rso_codec_tags_list,
+    .codec_tag      =   (const AVCodecTag* const []){ff_codec_rso_tags, 0},
 };
diff --git a/libavformat/rsoenc.c b/libavformat/rsoenc.c
index 780538a..beba94b 100644
--- a/libavformat/rsoenc.c
+++ b/libavformat/rsoenc.c
@@ -100,6 +100,6 @@
     .write_header   =   rso_write_header,
     .write_packet   =   ff_raw_write_packet,
     .write_trailer  =   rso_write_trailer,
-    .codec_tag      =   ff_rso_codec_tags_list,
+    .codec_tag      =   (const AVCodecTag* const []){ff_codec_rso_tags, 0},
     .flags          =   AVFMT_NOTIMESTAMPS,
 };
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 00eb087..1eeae17 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -84,6 +84,14 @@
     bytestream_put_be24(dst, AMF_DATA_TYPE_OBJECT_END);
 }
 
+int ff_amf_read_bool(GetByteContext *bc, int *val)
+{
+    if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_BOOL)
+        return AVERROR_INVALIDDATA;
+    *val = bytestream2_get_byte(bc);
+    return 0;
+}
+
 int ff_amf_read_number(GetByteContext *bc, double *val)
 {
     uint64_t read;
@@ -561,7 +569,6 @@
     return amf_get_field_value2(&gb, name, dst, dst_size);
 }
 
-#ifdef DEBUG
 static const char* rtmp_packet_type(int type)
 {
     switch (type) {
@@ -678,7 +685,6 @@
         av_log(ctx, AV_LOG_DEBUG, "\n");
     }
 }
-#endif
 
 int ff_amf_match_string(const uint8_t *data, int size, const char *str)
 {
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5..eb68f1d 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -260,6 +260,15 @@
 void ff_amf_write_object_end(uint8_t **dst);
 
 /**
+ * Read AMF boolean value.
+ *
+ *@param[in,out] gbc GetByteContext initialized with AMF-formatted data
+ *@param[out]    val 0 or 1
+ *@return 0 on success or an AVERROR code on failure
+*/
+int ff_amf_read_bool(GetByteContext *gbc, int *val);
+
+/**
  * Read AMF number value.
  *
  *@param[in,out] gbc GetByteContext initialized with AMF-formatted data
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 5a540e3..d9741bc 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -3119,8 +3119,7 @@
     { NULL },
 };
 
-#define RTMP_PROTOCOL_0(flavor)
-#define RTMP_PROTOCOL_1(flavor)                  \
+#define RTMP_PROTOCOL(flavor)                    \
 static const AVClass flavor##_class = {          \
     .class_name = #flavor,                       \
     .item_name  = av_default_item_name,          \
@@ -3140,16 +3139,11 @@
     .flags          = URL_PROTOCOL_FLAG_NETWORK, \
     .priv_data_class= &flavor##_class,           \
 };
-#define RTMP_PROTOCOL_2(flavor, enabled)         \
-    RTMP_PROTOCOL_ ## enabled(flavor)
-#define RTMP_PROTOCOL_3(flavor, config)          \
-    RTMP_PROTOCOL_2(flavor, config)
-#define RTMP_PROTOCOL(flavor, uppercase)         \
-    RTMP_PROTOCOL_3(flavor, CONFIG_ ## uppercase ## _PROTOCOL)
 
-RTMP_PROTOCOL(rtmp,   RTMP)
-RTMP_PROTOCOL(rtmpe,  RTMPE)
-RTMP_PROTOCOL(rtmps,  RTMPS)
-RTMP_PROTOCOL(rtmpt,  RTMPT)
-RTMP_PROTOCOL(rtmpte, RTMPTE)
-RTMP_PROTOCOL(rtmpts, RTMPTS)
+
+RTMP_PROTOCOL(rtmp)
+RTMP_PROTOCOL(rtmpe)
+RTMP_PROTOCOL(rtmps)
+RTMP_PROTOCOL(rtmpt)
+RTMP_PROTOCOL(rtmpte)
+RTMP_PROTOCOL(rtmpts)
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index d592e34..3d5b200 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -24,60 +24,57 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/time.h"
 
-#include "libavcodec/bytestream.h"
-
 #include "avformat.h"
 #include "network.h"
 #include "srtp.h"
 #include "url.h"
 #include "rtpdec.h"
 #include "rtpdec_formats.h"
-#include "internal.h"
 
 #define MIN_FEEDBACK_INTERVAL 200000 /* 200 ms in us */
 
-static const RTPDynamicProtocolHandler l24_dynamic_handler = {
+static RTPDynamicProtocolHandler l24_dynamic_handler = {
     .enc_name   = "L24",
     .codec_type = AVMEDIA_TYPE_AUDIO,
     .codec_id   = AV_CODEC_ID_PCM_S24BE,
 };
 
-static const RTPDynamicProtocolHandler gsm_dynamic_handler = {
+static RTPDynamicProtocolHandler gsm_dynamic_handler = {
     .enc_name   = "GSM",
     .codec_type = AVMEDIA_TYPE_AUDIO,
     .codec_id   = AV_CODEC_ID_GSM,
 };
 
-static const RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler = {
+static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler = {
     .enc_name   = "X-MP3-draft-00",
     .codec_type = AVMEDIA_TYPE_AUDIO,
     .codec_id   = AV_CODEC_ID_MP3ADU,
 };
 
-static const RTPDynamicProtocolHandler speex_dynamic_handler = {
+static RTPDynamicProtocolHandler speex_dynamic_handler = {
     .enc_name   = "speex",
     .codec_type = AVMEDIA_TYPE_AUDIO,
     .codec_id   = AV_CODEC_ID_SPEEX,
 };
 
-static const RTPDynamicProtocolHandler opus_dynamic_handler = {
+static RTPDynamicProtocolHandler opus_dynamic_handler = {
     .enc_name   = "opus",
     .codec_type = AVMEDIA_TYPE_AUDIO,
     .codec_id   = AV_CODEC_ID_OPUS,
 };
 
-static const RTPDynamicProtocolHandler t140_dynamic_handler = { /* RFC 4103 */
+static RTPDynamicProtocolHandler t140_dynamic_handler = { /* RFC 4103 */
     .enc_name   = "t140",
     .codec_type = AVMEDIA_TYPE_SUBTITLE,
     .codec_id   = AV_CODEC_ID_TEXT,
 };
 
-extern const RTPDynamicProtocolHandler ff_rdt_video_handler;
-extern const RTPDynamicProtocolHandler ff_rdt_audio_handler;
-extern const RTPDynamicProtocolHandler ff_rdt_live_video_handler;
-extern const RTPDynamicProtocolHandler ff_rdt_live_audio_handler;
+extern RTPDynamicProtocolHandler ff_rdt_video_handler;
+extern RTPDynamicProtocolHandler ff_rdt_audio_handler;
+extern RTPDynamicProtocolHandler ff_rdt_live_video_handler;
+extern RTPDynamicProtocolHandler ff_rdt_live_audio_handler;
 
-static const RTPDynamicProtocolHandler *const rtp_dynamic_protocol_handler_list[] = {
+static const RTPDynamicProtocolHandler *rtp_dynamic_protocol_handler_list[] = {
     /* rtp */
     &ff_ac3_dynamic_handler,
     &ff_amr_nb_dynamic_handler,
@@ -404,26 +401,38 @@
 
 void ff_rtp_send_punch_packets(URLContext *rtp_handle)
 {
-    uint8_t buf[RTP_MIN_PACKET_LENGTH], *ptr = buf;
+    AVIOContext *pb;
+    uint8_t *buf;
+    int len;
 
     /* Send a small RTP packet */
+    if (avio_open_dyn_buf(&pb) < 0)
+        return;
 
-    bytestream_put_byte(&ptr, (RTP_VERSION << 6));
-    bytestream_put_byte(&ptr, 0); /* Payload type */
-    bytestream_put_be16(&ptr, 0); /* Seq */
-    bytestream_put_be32(&ptr, 0); /* Timestamp */
-    bytestream_put_be32(&ptr, 0); /* SSRC */
+    avio_w8(pb, (RTP_VERSION << 6));
+    avio_w8(pb, 0); /* Payload type */
+    avio_wb16(pb, 0); /* Seq */
+    avio_wb32(pb, 0); /* Timestamp */
+    avio_wb32(pb, 0); /* SSRC */
 
-    ffurl_write(rtp_handle, buf, ptr - buf);
+    len = avio_close_dyn_buf(pb, &buf);
+    if ((len > 0) && buf)
+        ffurl_write(rtp_handle, buf, len);
+    av_free(buf);
 
     /* Send a minimal RTCP RR */
-    ptr = buf;
-    bytestream_put_byte(&ptr, (RTP_VERSION << 6));
-    bytestream_put_byte(&ptr, RTCP_RR); /* receiver report */
-    bytestream_put_be16(&ptr, 1); /* length in words - 1 */
-    bytestream_put_be32(&ptr, 0); /* our own SSRC */
+    if (avio_open_dyn_buf(&pb) < 0)
+        return;
 
-    ffurl_write(rtp_handle, buf, ptr - buf);
+    avio_w8(pb, (RTP_VERSION << 6));
+    avio_w8(pb, RTCP_RR); /* receiver report */
+    avio_wb16(pb, 1); /* length in words - 1 */
+    avio_wb32(pb, 0); /* our own SSRC */
+
+    len = avio_close_dyn_buf(pb, &buf);
+    if ((len > 0) && buf)
+        ffurl_write(rtp_handle, buf, len);
+    av_free(buf);
 }
 
 static int find_missing_packets(RTPDemuxContext *s, uint16_t *first_missing,
@@ -520,43 +529,6 @@
     return 0;
 }
 
-static int opus_write_extradata(AVCodecParameters *codecpar)
-{
-    uint8_t *bs;
-    int ret;
-
-    /* This function writes an extradata with a channel mapping family of 0.
-     * This mapping family only supports mono and stereo layouts. And RFC7587
-     * specifies that the number of channels in the SDP must be 2.
-     */
-    if (codecpar->channels > 2) {
-        return AVERROR_INVALIDDATA;
-    }
-
-    ret = ff_alloc_extradata(codecpar, 19);
-    if (ret < 0)
-        return ret;
-
-    bs = (uint8_t *)codecpar->extradata;
-
-    /* Opus magic */
-    bytestream_put_buffer(&bs, "OpusHead", 8);
-    /* Version */
-    bytestream_put_byte  (&bs, 0x1);
-    /* Channel count */
-    bytestream_put_byte  (&bs, codecpar->channels);
-    /* Pre skip */
-    bytestream_put_le16  (&bs, 0);
-    /* Input sample rate */
-    bytestream_put_le32  (&bs, 48000);
-    /* Output gain */
-    bytestream_put_le16  (&bs, 0x0);
-    /* Mapping family */
-    bytestream_put_byte  (&bs, 0x0);
-
-    return 0;
-}
-
 /**
  * open a new RTP parse context for stream 'st'. 'st' can be NULL for
  * MPEG-2 TS streams.
@@ -565,7 +537,6 @@
                                    int payload_type, int queue_size)
 {
     RTPDemuxContext *s;
-    int ret;
 
     s = av_mallocz(sizeof(RTPDemuxContext));
     if (!s)
@@ -589,16 +560,6 @@
             if (st->codecpar->sample_rate == 8000)
                 st->codecpar->sample_rate = 16000;
             break;
-        case AV_CODEC_ID_OPUS:
-            ret = opus_write_extradata(st->codecpar);
-            if (ret < 0) {
-                av_log(s1, AV_LOG_ERROR,
-                       "Error creating opus extradata: %s\n",
-                       av_err2str(ret));
-                av_free(s);
-                return NULL;
-            }
-            break;
         default:
             break;
         }
diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h
index 701ce07..9144edb 100644
--- a/libavformat/rtpdec.h
+++ b/libavformat/rtpdec.h
@@ -134,6 +134,8 @@
     /** Parse handler for this dynamic packet */
     DynamicPayloadPacketHandlerProc parse_packet;
     int (*need_keyframe)(PayloadContext *context);
+
+    struct RTPDynamicProtocolHandler *next;
 };
 
 typedef struct RTPPacket {
diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c
index 93bf317..740c382 100644
--- a/libavformat/rtpdec_qt.c
+++ b/libavformat/rtpdec_qt.c
@@ -241,7 +241,7 @@
 }
 
 #define RTP_QT_HANDLER(m, n, s, t) \
-const RTPDynamicProtocolHandler ff_ ## m ## _rtp_ ## n ## _handler = { \
+RTPDynamicProtocolHandler ff_ ## m ## _rtp_ ## n ## _handler = { \
     .enc_name         = s, \
     .codec_type       = t, \
     .codec_id         = AV_CODEC_ID_NONE, \
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 38e4c65..9ef7e90 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -589,7 +589,7 @@
         break;
     case AV_CODEC_ID_H263:
         if (s->flags & FF_RTP_FLAG_RFC2190) {
-            buffer_size_t mb_info_size;
+            int mb_info_size;
             const uint8_t *mb_info =
                 av_packet_get_side_data(pkt, AV_PKT_DATA_H263_MB_INFO,
                                         &mb_info_size);
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 9a29333..c7ffa07 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -89,13 +89,12 @@
     RTSP_FLAG_OPTS("rtsp_flags", "set RTSP flags"),
     { "listen", "wait for incoming connections", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_LISTEN}, 0, 0, DEC, "rtsp_flags" },
     { "prefer_tcp", "try RTP via TCP first, if available", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_PREFER_TCP}, 0, 0, DEC|ENC, "rtsp_flags" },
-    { "satip_raw", "export raw MPEG-TS stream instead of demuxing", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_SATIP_RAW}, 0, 0, DEC, "rtsp_flags" },
     RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from the server"),
     { "min_port", "set minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC },
     { "max_port", "set maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
     { "listen_timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
 #if FF_API_OLD_RTSP_OPTIONS
-    { "timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen) (deprecated, use listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC|AV_OPT_FLAG_DEPRECATED },
+    { "timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen) (deprecated, use listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
     { "stimeout", "set timeout (in microseconds) of socket TCP I/O operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
 #else
     { "timeout", "set timeout (in microseconds) of socket TCP I/O operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
@@ -103,7 +102,7 @@
     COMMON_OPTS(),
     { "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
 #if FF_API_OLD_RTSP_OPTIONS
-    { "user-agent", "override User-Agent header (deprecated, use user_agent)", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC|AV_OPT_FLAG_DEPRECATED },
+    { "user-agent", "override User-Agent header (deprecated, use user_agent)", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
 #endif
     { NULL },
 };
@@ -253,35 +252,6 @@
     }
 }
 
-static int init_satip_stream(AVFormatContext *s)
-{
-    RTSPState *rt = s->priv_data;
-    RTSPStream *rtsp_st = av_mallocz(sizeof(RTSPStream));
-    if (!rtsp_st)
-        return AVERROR(ENOMEM);
-    dynarray_add(&rt->rtsp_streams,
-                 &rt->nb_rtsp_streams, rtsp_st);
-
-    rtsp_st->sdp_payload_type = 33; // MP2T
-    av_strlcpy(rtsp_st->control_url,
-               rt->control_uri, sizeof(rtsp_st->control_url));
-
-    if (rt->rtsp_flags & RTSP_FLAG_SATIP_RAW) {
-        AVStream *st = avformat_new_stream(s, NULL);
-        if (!st)
-            return AVERROR(ENOMEM);
-        st->id = rt->nb_rtsp_streams - 1;
-        rtsp_st->stream_index = st->index;
-        st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
-        st->codecpar->codec_id   = AV_CODEC_ID_MPEG2TS;
-    } else {
-        rtsp_st->stream_index = -1;
-        init_rtp_handler(&ff_mpegts_dynamic_handler, rtsp_st, NULL);
-        finalize_rtp_handler_init(s, rtsp_st, NULL);
-    }
-    return 0;
-}
-
 /* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
 static int sdp_parse_rtpmap(AVFormatContext *s,
                             AVStream *st, RTSPStream *rtsp_st,
@@ -571,7 +541,7 @@
         break;
     case 'a':
         if (av_strstart(p, "control:", &p)) {
-            if (rt->nb_rtsp_streams == 0) {
+            if (s->nb_streams == 0) {
                 if (!strncmp(p, "rtsp://", 7))
                     av_strlcpy(rt->control_uri, p,
                                sizeof(rt->control_uri));
@@ -1146,9 +1116,6 @@
     } else if (av_stristart(p, "Content-Type:", &p)) {
         p += strspn(p, SPACE_CHARS);
         av_strlcpy(reply->content_type, p, sizeof(reply->content_type));
-    } else if (av_stristart(p, "com.ses.streamID:", &p)) {
-        p += strspn(p, SPACE_CHARS);
-        av_strlcpy(reply->stream_id, p, sizeof(reply->stream_id));
     }
 }
 
@@ -1528,10 +1495,8 @@
         rtp_opened:
             port = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle);
         have_port:
-            av_strlcpy(transport, trans_pref, sizeof(transport));
-            av_strlcat(transport,
-                       rt->server_type == RTSP_SERVER_SATIP ? ";" : "/UDP;",
-                       sizeof(transport));
+            snprintf(transport, sizeof(transport) - 1,
+                     "%s/UDP;", trans_pref);
             if (rt->server_type != RTSP_SERVER_REAL)
                 av_strlcat(transport, "unicast;", sizeof(transport));
             av_strlcatf(transport, sizeof(transport),
@@ -1594,15 +1559,6 @@
             goto fail;
         }
 
-        if (rt->server_type == RTSP_SERVER_SATIP && reply->stream_id[0]) {
-            char proto[128], host[128], path[512], auth[128];
-            int port;
-            av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host),
-                        &port, path, sizeof(path), rt->control_uri);
-            ff_url_join(rt->control_uri, sizeof(rt->control_uri), proto, NULL, host,
-                        port, "/stream=%s", reply->stream_id);
-        }
-
         /* XXX: same protocol for all streams is required */
         if (i > 0) {
             if (reply->transports[0].lower_transport != rt->lower_transport ||
@@ -1754,9 +1710,6 @@
         lower_rtsp_proto         = "tls";
         default_port             = RTSPS_DEFAULT_PORT;
         rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP;
-    } else if (!strcmp(proto, "satip")) {
-        av_strlcpy(proto, "rtsp", sizeof(proto));
-        rt->server_type = RTSP_SERVER_SATIP;
     }
 
     if (*auth) {
@@ -1904,9 +1857,7 @@
 
     /* request options supported by the server; this also detects server
      * type */
-    if (rt->server_type != RTSP_SERVER_SATIP)
-        rt->server_type = RTSP_SERVER_RTP;
-    for (;;) {
+    for (rt->server_type = RTSP_SERVER_RTP;;) {
         cmd[0] = 0;
         if (rt->server_type == RTSP_SERVER_REAL)
             av_strlcat(cmd,
@@ -1941,15 +1892,9 @@
         break;
     }
 
-#if CONFIG_RTSP_DEMUXER
-    if (s->iformat) {
-        if (rt->server_type == RTSP_SERVER_SATIP)
-            err = init_satip_stream(s);
-        else
-            err = ff_rtsp_setup_input_streams(s, reply);
-    } else
-#endif
-           if (CONFIG_RTSP_MUXER)
+    if (CONFIG_RTSP_DEMUXER && s->iformat)
+        err = ff_rtsp_setup_input_streams(s, reply);
+    else if (CONFIG_RTSP_MUXER)
         err = ff_rtsp_setup_output_streams(s, host);
     else
         av_assert0(0);
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 1310dd9..b74cdc1 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -188,11 +188,6 @@
      * Content type header
      */
     char content_type[64];
-
-    /**
-     * SAT>IP com.ses.streamID header
-     */
-    char stream_id[64];
 } RTSPMessageHeader;
 
 /**
@@ -215,7 +210,6 @@
     RTSP_SERVER_RTP,  /**< Standards-compliant RTP-server */
     RTSP_SERVER_REAL, /**< Realmedia-style server */
     RTSP_SERVER_WMS,  /**< Windows Media server */
-    RTSP_SERVER_SATIP,/**< SAT>IP server */
     RTSP_SERVER_NB
 };
 
@@ -429,7 +423,6 @@
 #define RTSP_FLAG_RTCP_TO_SOURCE 0x8 /**< Send RTCP packets to the source
                                           address of received packets. */
 #define RTSP_FLAG_PREFER_TCP  0x10   /**< Try RTP via TCP first if possible. */
-#define RTSP_FLAG_SATIP_RAW   0x20   /**< Export SAT>IP stream as raw MPEG-TS */
 
 typedef struct RTSPSource {
     char addr[128]; /**< Source-specific multicast include source IP address (from SDP content) */
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 113da97..bfbb01d 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -724,7 +724,6 @@
 #if CONFIG_TLS_PROTOCOL
         av_strstart(p->filename, "rtsps:", NULL) ||
 #endif
-        av_strstart(p->filename, "satip:", NULL) ||
         av_strstart(p->filename, "rtsp:", NULL))
         return AVPROBE_SCORE_MAX;
     return 0;
diff --git a/libavformat/samidec.c b/libavformat/samidec.c
index cf5076c..3070ef9 100644
--- a/libavformat/samidec.c
+++ b/libavformat/samidec.c
@@ -95,11 +95,6 @@
                 const char *p = ff_smil_get_attr_ptr(buf.str, "Start");
                 sub->pos      = pos;
                 sub->pts      = p ? strtol(p, NULL, 10) : 0;
-                if (sub->pts <= INT64_MIN/2 || sub->pts >= INT64_MAX/2) {
-                    res = AVERROR_PATCHWELCOME;
-                    goto end;
-                }
-
                 sub->duration = -1;
             }
         }
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index 64c84c1..f56eb9f 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -181,7 +181,6 @@
     char *end;
     int hours, minutes;
     double seconds = 0;
-    int64_t ts = 0;
 
     if (*cur < '0' || *cur > '9')
         return 0;
@@ -197,9 +196,8 @@
         seconds = strtod(cur + 1, &end);
         if (end > cur + 1)
             cur = end;
-        ts = av_clipd(seconds * AV_TIME_BASE, INT64_MIN/2, INT64_MAX/2);
     }
-    *rtime = av_sat_add64((hours * 3600LL + minutes * 60LL) * AV_TIME_BASE, ts);
+    *rtime = (hours * 3600LL + minutes * 60LL + seconds) * AV_TIME_BASE;
     return cur - str;
 }
 
diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c
index 1786520..751dee7 100644
--- a/libavformat/sccdec.c
+++ b/libavformat/sccdec.c
@@ -93,7 +93,7 @@
                     break;
             }
 
-            ts = (hh * 3600LL + mm * 60LL + ss) * 1000LL + fs * 33LL;
+            ts = (hh * 3600LL + mm * 60LL + ss) * 1000LL + fs * 33;
 
             while (!ff_text_eof(&tr)) {
                 len = ff_subtitles_read_line(&tr, line2, sizeof(line2));
@@ -117,7 +117,7 @@
             }
         }
 
-        next_ts = (hh * 3600LL + mm * 60LL + ss) * 1000LL + fs * 33LL;
+        next_ts = (hh * 3600LL + mm * 60LL + ss) * 1000LL + fs * 33;
 
         pos = ff_text_pos(&tr);
         lline = (char *)&line;
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 5265eca..dff3d0e 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -859,7 +859,7 @@
         return AVERROR(EINVAL);
 
     if (!st->codecpar->extradata_size) {
-        buffer_size_t pkt_extradata_size;
+        int pkt_extradata_size;
         uint8_t *pkt_extradata = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &pkt_extradata_size);
         if (pkt_extradata && pkt_extradata_size > 0) {
             ret = ff_alloc_extradata(st->codecpar, pkt_extradata_size);
diff --git a/libavformat/sga.c b/libavformat/sga.c
deleted file mode 100644
index e7a41e9..0000000
--- a/libavformat/sga.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Digital Pictures SGA game demuxer
- *
- * Copyright (C) 2021 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/intreadwrite.h"
-#include "libavutil/avassert.h"
-#include "libavutil/internal.h"
-#include "avformat.h"
-#include "internal.h"
-#include "avio_internal.h"
-
-#define SEGA_CD_PCM_NUM 12500000
-#define SEGA_CD_PCM_DEN 786432
-
-typedef struct SGADemuxContext {
-    int video_stream_index;
-    int audio_stream_index;
-
-    uint8_t sector[65536 * 2];
-    int sector_headers;
-    int sample_rate;
-    int first_audio_size;
-    int payload_size;
-    int packet_type;
-    int flags;
-    int idx;
-    int left;
-    int64_t pkt_pos;
-} SGADemuxContext;
-
-static int sga_probe(const AVProbeData *p)
-{
-    const uint8_t *src = p->buf;
-    int score = 0, sectors = 1;
-    int last_left = 0;
-    int sample_rate = -1;
-
-    if (p->buf_size < 2048)
-        return 0;
-
-    for (int i = 0; i + 2 < p->buf_size; i += 2048) {
-        int header = AV_RB16(src + i);
-
-        if ((header > 0x07FE && header < 0x8100) ||
-            (header > 0x8200 && header < 0xA100) ||
-            (header > 0xA200 && header < 0xC100)) {
-            sectors = 0;
-            break;
-        }
-    }
-
-    for (int i = 0; i + 4 < p->buf_size;) {
-        int header = AV_RB16(src + i);
-        int left   = AV_RB16(src + i + 2);
-        int offset, type, size;
-
-        if (last_left < 0)
-            return 0;
-        if (sectors && header && last_left == 0) {
-            if (header >> 12) {
-                last_left = left;
-            } else {
-                last_left = left = header;
-            }
-        } else if (sectors && header) {
-            left = header;
-            last_left -= left;
-            if (header != 0x7FE && left < 7)
-                return 0;
-        } else if (sectors) {
-            if (left <= 8)
-                return 0;
-            i += sectors ? 2048 : left + 4;
-            last_left = 0;
-            continue;
-        }
-
-        if (sectors && (i > 0 && left < 0x7fe) &&
-            (i + left + 14 < p->buf_size)) {
-            offset = i + left + 2;
-        } else if (sectors && i > 0) {
-            i += 2048;
-            last_left -= FFMIN(last_left, 2046);
-            continue;
-        } else {
-            offset = 0;
-            last_left = left;
-        }
-
-        header = AV_RB16(src + offset);
-        size   = AV_RB16(src + offset + 2) + 4;
-
-        while ((header & 0xFF00) == 0) {
-            offset++;
-            if (offset + 4 >= p->buf_size)
-                break;
-            header = AV_RB16(src + offset);
-            size   = AV_RB16(src + offset + 2) + 4;
-        }
-
-        if (offset + 12 >= p->buf_size)
-            break;
-        if ((header & 0xFF) > 1)
-            return 0;
-        type = header >> 8;
-
-        if (type == 0xAA ||
-            type == 0xA1 ||
-            type == 0xA2 ||
-            type == 0xA3) {
-            int new_rate;
-
-            if (size <= 12)
-                return 0;
-            new_rate = AV_RB16(src + offset + 8);
-            if (sample_rate < 0)
-                sample_rate = new_rate;
-            if (sample_rate == 0 || new_rate != sample_rate)
-                return 0;
-            if (src[offset + 10] != 1)
-                return 0;
-
-            score += 10;
-        } else if (type == 0xC1 ||
-                   type == 0xC6 ||
-                   type == 0xC7 ||
-                   type == 0xC8 ||
-                   type == 0xC9 ||
-                   type == 0xCB ||
-                   type == 0xCD ||
-                   type == 0xE7) {
-            int nb_pals = src[offset + 9];
-            int tiles_w = src[offset + 10];
-            int tiles_h = src[offset + 11];
-
-            if (size <= 12)
-                return 0;
-            if (nb_pals == 0 || nb_pals > 4)
-                return 0;
-            if (tiles_w == 0 || tiles_w > 80)
-                return 0;
-            if (tiles_h == 0 || tiles_h > 60)
-                return 0;
-
-            score += 10;
-        } else if (header == 0x7FE) {
-            ;
-        } else {
-            return 0;
-        }
-
-        i += sectors ? 2048 : size + 4;
-        last_left -= FFMIN(last_left, 2046);
-
-        if (score < 0)
-            break;
-    }
-
-    return av_clip(score, 0, AVPROBE_SCORE_MAX);
-}
-
-static int sga_read_header(AVFormatContext *s)
-{
-    SGADemuxContext *sga = s->priv_data;
-    AVIOContext *pb = s->pb;
-
-    sga->sector_headers = 1;
-    sga->first_audio_size = 0;
-    sga->video_stream_index = -1;
-    sga->audio_stream_index = -1;
-    sga->left = 2048;
-    sga->idx = 0;
-
-    s->ctx_flags |= AVFMTCTX_NOHEADER;
-
-    if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
-        while (!avio_feof(pb)) {
-            int header = avio_rb16(pb);
-            int type = header >> 8;
-            int skip = 2046;
-            int clock;
-
-            if (!sga->first_audio_size &&
-                (type == 0xAA ||
-                 type == 0xA1 ||
-                 type == 0xA2 ||
-                 type == 0xA3)) {
-                sga->first_audio_size = avio_rb16(pb);
-                avio_skip(pb, 4);
-                clock = avio_rb16(pb);
-                sga->sample_rate = av_rescale(clock,
-                                              SEGA_CD_PCM_NUM,
-                                              SEGA_CD_PCM_DEN);
-                skip -= 8;
-            }
-            if ((header > 0x07FE && header < 0x8100) ||
-                (header > 0x8200 && header < 0xA100) ||
-                (header > 0xA200 && header < 0xC100)) {
-                sga->sector_headers = 0;
-                break;
-            }
-
-            avio_skip(pb, skip);
-        }
-
-        avio_seek(pb, 0, SEEK_SET);
-    }
-
-    return 0;
-}
-
-static void print_stats(AVFormatContext *s, const char *where)
-{
-    SGADemuxContext *sga = s->priv_data;
-
-    av_log(s, AV_LOG_DEBUG, "START %s\n", where);
-    av_log(s, AV_LOG_DEBUG, "pos: %"PRIX64"\n", avio_tell(s->pb));
-    av_log(s, AV_LOG_DEBUG, "idx: %X\n", sga->idx);
-    av_log(s, AV_LOG_DEBUG, "packet_type: %X\n", sga->packet_type);
-    av_log(s, AV_LOG_DEBUG, "payload_size: %X\n", sga->payload_size);
-    av_log(s, AV_LOG_DEBUG, "SECTOR: %016"PRIX64"\n", AV_RB64(sga->sector));
-    av_log(s, AV_LOG_DEBUG, "stream: %X\n", sga->sector[1]);
-    av_log(s, AV_LOG_DEBUG, "END %s\n", where);
-}
-
-static void update_type_size(AVFormatContext *s)
-{
-    SGADemuxContext *sga = s->priv_data;
-
-    if (sga->idx >= 4) {
-        sga->packet_type  = sga->sector[0];
-        sga->payload_size = AV_RB16(sga->sector + 2);
-    } else {
-        sga->packet_type  = 0;
-        sga->payload_size = 0;
-    }
-}
-
-static int sga_video_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    SGADemuxContext *sga = s->priv_data;
-    int ret;
-
-    if (sga->payload_size <= 8)
-        return AVERROR_INVALIDDATA;
-
-    if (sga->video_stream_index == -1) {
-        AVRational frame_rate;
-
-        AVStream *st = avformat_new_stream(s, NULL);
-        if (!st)
-            return AVERROR(ENOMEM);
-
-        st->start_time              = 0;
-        st->codecpar->codec_type    = AVMEDIA_TYPE_VIDEO;
-        st->codecpar->codec_tag     = 0;
-        st->codecpar->codec_id      = AV_CODEC_ID_SGA_VIDEO;
-        sga->video_stream_index     = st->index;
-
-        if (sga->first_audio_size > 0 && sga->sample_rate > 0) {
-            frame_rate.num = sga->sample_rate;
-            frame_rate.den = sga->first_audio_size;
-        } else {
-            frame_rate.num = 15;
-            frame_rate.den = 1;
-        }
-        avpriv_set_pts_info(st, 64, frame_rate.den, frame_rate.num);
-    }
-
-    ret = av_new_packet(pkt, sga->payload_size + 4);
-    if (ret < 0)
-        return AVERROR(ENOMEM);
-    memcpy(pkt->data, sga->sector, sga->payload_size + 4);
-    av_assert0(sga->idx >= sga->payload_size + 4);
-    memmove(sga->sector, sga->sector + sga->payload_size + 4, sga->idx - sga->payload_size - 4);
-
-    pkt->stream_index = sga->video_stream_index;
-    pkt->duration = 1;
-    pkt->pos = sga->pkt_pos;
-    pkt->flags |= sga->flags;
-    sga->idx -= sga->payload_size + 4;
-    sga->flags = 0;
-    update_type_size(s);
-
-    av_log(s, AV_LOG_DEBUG, "VIDEO PACKET: %d:%016"PRIX64" i:%X\n", pkt->size, AV_RB64(sga->sector), sga->idx);
-
-    return 0;
-}
-
-static int sga_audio_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    SGADemuxContext *sga = s->priv_data;
-    int ret;
-
-    if (sga->payload_size <= 8)
-        return AVERROR_INVALIDDATA;
-
-    if (sga->audio_stream_index == -1) {
-        AVStream *st = avformat_new_stream(s, NULL);
-        if (!st)
-            return AVERROR(ENOMEM);
-
-        st->start_time              = 0;
-        st->codecpar->codec_type    = AVMEDIA_TYPE_AUDIO;
-        st->codecpar->codec_tag     = 0;
-        st->codecpar->codec_id      = AV_CODEC_ID_PCM_SGA;
-        st->codecpar->channels      = 1;
-        st->codecpar->channel_layout= AV_CH_LAYOUT_MONO;
-        st->codecpar->sample_rate   = av_rescale(AV_RB16(sga->sector + 8),
-                                                 SEGA_CD_PCM_NUM,
-                                                 SEGA_CD_PCM_DEN);
-        sga->audio_stream_index     = st->index;
-
-        avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
-    }
-
-    ret = av_new_packet(pkt, sga->payload_size - 8);
-    if (ret < 0)
-        return AVERROR(ENOMEM);
-    memcpy(pkt->data, sga->sector + 12, sga->payload_size - 8);
-    av_assert0(sga->idx >= sga->payload_size + 4);
-    memmove(sga->sector, sga->sector + sga->payload_size + 4, sga->idx - sga->payload_size - 4);
-
-    pkt->stream_index = sga->audio_stream_index;
-    pkt->duration = pkt->size;
-    pkt->pos = sga->pkt_pos;
-    pkt->flags |= sga->flags;
-    sga->idx -= sga->payload_size + 4;
-    sga->flags = 0;
-    update_type_size(s);
-
-    av_log(s, AV_LOG_DEBUG, "AUDIO PACKET: %d:%016"PRIX64" i:%X\n", pkt->size, AV_RB64(sga->sector), sga->idx);
-
-    return 0;
-}
-
-static int sga_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    SGADemuxContext *sga = s->priv_data;
-    int ret = 0;
-
-    if (sga->packet_type == 0xCD ||
-        sga->packet_type == 0xCB ||
-        sga->packet_type == 0xC9 ||
-        sga->packet_type == 0xC8 ||
-        sga->packet_type == 0xC7 ||
-        sga->packet_type == 0xC6 ||
-        sga->packet_type == 0xC1 ||
-        sga->packet_type == 0xE7) {
-        ret = sga_video_packet(s, pkt);
-    } else if (sga->packet_type == 0xA1 ||
-               sga->packet_type == 0xA2 ||
-               sga->packet_type == 0xA3 ||
-               sga->packet_type == 0xAA) {
-        ret = sga_audio_packet(s, pkt);
-    } else {
-        if (sga->idx == 0)
-            return AVERROR_EOF;
-        if (sga->sector[0])
-            return AVERROR_INVALIDDATA;
-        memmove(sga->sector, sga->sector + 1, sga->idx - 1);
-        sga->idx--;
-        return AVERROR(EAGAIN);
-    }
-
-    return ret;
-}
-
-static int try_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    SGADemuxContext *sga = s->priv_data;
-    int ret = AVERROR(EAGAIN);
-
-    update_type_size(s);
-    if (sga->idx >= sga->payload_size + 4) {
-        print_stats(s, "before sga_packet");
-        ret = sga_packet(s, pkt);
-        print_stats(s,  "after sga_packet");
-        if (ret != AVERROR(EAGAIN))
-            return ret;
-    }
-
-    return sga->idx < sga->payload_size + 4 ? AVERROR(EAGAIN) : ret;
-}
-
-static int sga_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    SGADemuxContext *sga = s->priv_data;
-    AVIOContext *pb = s->pb;
-    int header, ret = 0;
-
-    sga->pkt_pos = avio_tell(pb);
-
-retry:
-    update_type_size(s);
-
-    print_stats(s, "start");
-    if (avio_feof(pb) &&
-        (!sga->payload_size || sga->idx < sga->payload_size + 4))
-        return AVERROR_EOF;
-
-    if (sga->idx < sga->payload_size + 4) {
-        ret = ffio_ensure_seekback(pb, 2);
-        if (ret < 0)
-            return ret;
-
-        print_stats(s, "before read header");
-        header = avio_rb16(pb);
-        if (!header) {
-            avio_skip(pb, 2046);
-            sga->left = 0;
-        } else if (!avio_feof(pb) &&
-                   ((header >> 15) ||
-                    !sga->sector_headers)) {
-            avio_seek(pb, -2, SEEK_CUR);
-            sga->flags = AV_PKT_FLAG_KEY;
-            sga->left = 2048;
-        } else {
-            sga->left = 2046;
-        }
-
-        av_assert0(sga->idx + sga->left < sizeof(sga->sector));
-        ret = avio_read(pb, sga->sector + sga->idx, sga->left);
-        if (ret > 0)
-            sga->idx += ret;
-        else if (ret != AVERROR_EOF && ret)
-            return ret;
-        print_stats(s, "after read header");
-
-        update_type_size(s);
-    }
-
-    ret = try_packet(s, pkt);
-    if (ret == AVERROR(EAGAIN))
-        goto retry;
-
-    return ret;
-}
-
-static int sga_seek(AVFormatContext *s, int stream_index,
-                     int64_t timestamp, int flags)
-{
-    SGADemuxContext *sga = s->priv_data;
-
-    sga->packet_type = sga->payload_size = sga->idx = 0;
-    memset(sga->sector, 0, sizeof(sga->sector));
-
-    return -1;
-}
-
-AVInputFormat ff_sga_demuxer = {
-    .name           = "sga",
-    .long_name      = NULL_IF_CONFIG_SMALL("Digital Pictures SGA"),
-    .priv_data_size = sizeof(SGADemuxContext),
-    .read_probe     = sga_probe,
-    .read_header    = sga_read_header,
-    .read_packet    = sga_read_packet,
-    .read_seek      = sga_seek,
-    .extensions     = "sga",
-    .flags          = AVFMT_GENERIC_INDEX,
-};
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index 61209e7..9966a67 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -105,8 +105,8 @@
     height = avio_rl32(pb);
     smk->frames = avio_rl32(pb);
     pts_inc = avio_rl32(pb);
-    if (pts_inc > INT_MAX / 100 || pts_inc == INT_MIN) {
-        av_log(s, AV_LOG_ERROR, "pts_inc %d is invalid\n", pts_inc);
+    if (pts_inc > INT_MAX / 100) {
+        av_log(s, AV_LOG_ERROR, "pts_inc %d is too large\n", pts_inc);
         return AVERROR_INVALIDDATA;
     }
 
diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c
index 35e11fe..d3f709f 100644
--- a/libavformat/soxdec.c
+++ b/libavformat/soxdec.c
@@ -90,7 +90,7 @@
                sample_rate_frac);
 
     if ((header_size + 4) & 7 || header_size < SOX_FIXED_HDR + comment_size
-        || st->codecpar->channels > 65535 || st->codecpar->channels <= 0) /* Reserve top 16 bits */ {
+        || st->codecpar->channels > 65535) /* Reserve top 16 bits */ {
         av_log(s, AV_LOG_ERROR, "invalid header\n");
         return AVERROR_INVALIDDATA;
     }
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index c3ba3a1..0288872 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -122,16 +122,14 @@
     IEC61937Context *ctx = s->priv_data;
     static const uint8_t eac3_repeat[4] = {6, 3, 2, 1};
     int repeat = 1;
-    uint8_t *tmp;
 
     int bsid = pkt->data[5] >> 3;
     if (bsid > 10 && (pkt->data[4] & 0xc0) != 0xc0) /* fscod */
         repeat = eac3_repeat[(pkt->data[4] & 0x30) >> 4]; /* numblkscod */
 
-    tmp = av_fast_realloc(ctx->hd_buf[0], &ctx->hd_buf_size, ctx->hd_buf_filled + pkt->size);
-    if (!tmp)
+    ctx->hd_buf[0] = av_fast_realloc(ctx->hd_buf[0], &ctx->hd_buf_size, ctx->hd_buf_filled + pkt->size);
+    if (!ctx->hd_buf[0])
         return AVERROR(ENOMEM);
-    ctx->hd_buf[0] = tmp;
 
     memcpy(&ctx->hd_buf[0][ctx->hd_buf_filled], pkt->data, pkt->size);
 
diff --git a/libavformat/srtenc.c b/libavformat/srtenc.c
index 484dd4d..d811a4d 100644
--- a/libavformat/srtenc.c
+++ b/libavformat/srtenc.c
@@ -61,8 +61,7 @@
     SRTContext *srt = avf->priv_data;
 
     int64_t s = pkt->pts, e, d = pkt->duration;
-    buffer_size_t size;
-    int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
+    int size, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
     const uint8_t *p;
 
     p = av_packet_get_side_data(pkt, AV_PKT_DATA_SUBTITLE_POSITION, &size);
diff --git a/libavformat/swf.c b/libavformat/swf.c
index a3471d9..1aa434a 100644
--- a/libavformat/swf.c
+++ b/libavformat/swf.c
@@ -23,9 +23,7 @@
 #include "internal.h"
 
 const AVCodecTag ff_swf_codec_tags[] = {
-    { AV_CODEC_ID_FLV1,     0x02 },
-    { AV_CODEC_ID_FLASHSV,  0x03 },
-    { AV_CODEC_ID_VP6F,     0x04 },
-    { AV_CODEC_ID_VP6A,     0x05 },
-    { AV_CODEC_ID_NONE,        0 },
+    { AV_CODEC_ID_FLV1, 0x02 },
+    { AV_CODEC_ID_VP6F, 0x04 },
+    { AV_CODEC_ID_NONE,    0 },
 };
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index f9a164b..fa11c05 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -33,7 +33,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/get_bits.h"
 #include "swf.h"
-#include "flv.h"
 
 typedef struct SWFDecContext {
     int samples_per_frame;
@@ -308,24 +307,15 @@
             for(i=0; i<s->nb_streams; i++) {
                 st = s->streams[i];
                 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
-                    int pkt_flags = 0;
                     frame = avio_rl16(pb);
                     len -= 2;
                     if (len <= 0)
                         goto skip;
-                    if (st->codecpar->codec_id == AV_CODEC_ID_FLASHSV) {
-                        unsigned flags = avio_r8(pb);
-                        len--;
-                        if (len <= 0)
-                            goto skip;
-                        pkt_flags |= (flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY ? AV_PKT_FLAG_KEY : 0;
-                    }
                     if ((res = av_get_packet(pb, pkt, len)) < 0)
                         return res;
                     pkt->pos = pos;
                     pkt->pts = frame;
                     pkt->stream_index = st->index;
-                    pkt->flags |= pkt_flags;
                     return pkt->size;
                 }
             }
@@ -377,25 +367,15 @@
             ff_dlog(s, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
                     ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
 
-            if (len * 17373LL < out_len)
-                goto bitmap_end_skip;
-
             zbuf = av_malloc(len);
-            if (!zbuf) {
+            buf  = av_malloc(out_len);
+            if (!zbuf || !buf) {
                 res = AVERROR(ENOMEM);
                 goto bitmap_end;
             }
 
             len = avio_read(pb, zbuf, len);
-            if (len < 0)
-                goto bitmap_end_skip;
-
-            buf  = av_malloc(out_len);
-            if (!buf) {
-                res = AVERROR(ENOMEM);
-                goto bitmap_end;
-            }
-            if ((res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
+            if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
                 av_log(s, AV_LOG_WARNING, "Failed to uncompress one bitmap\n");
                 goto bitmap_end_skip;
             }
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 7e4e214..14be2b7 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -24,7 +24,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/fifo.h"
 #include "avformat.h"
-#include "flv.h"
 #include "swf.h"
 
 #define AUDIO_FIFO_SIZE 65536
@@ -223,13 +222,13 @@
                 av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 video stream\n");
                 return AVERROR_INVALIDDATA;
             }
-            if (ff_codec_get_tag(ff_swf_codec_tags, par->codec_id) ||
-                par->codec_id == AV_CODEC_ID_PNG ||
+            if (par->codec_id == AV_CODEC_ID_VP6F ||
+                par->codec_id == AV_CODEC_ID_FLV1 ||
                 par->codec_id == AV_CODEC_ID_MJPEG) {
                 swf->video_st  = s->streams[i];
                 swf->video_par = par;
             } else {
-                av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV, Flash Screen Video, PNG and MJPEG\n");
+                av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n");
                 return -1;
             }
         }
@@ -258,12 +257,8 @@
 
     if (!strcmp("avm2", s->oformat->name))
         version = 9;
-    else if (swf->video_par && (swf->video_par->codec_id == AV_CODEC_ID_VP6A ||
-                                swf->video_par->codec_id == AV_CODEC_ID_VP6F ||
-                                swf->video_par->codec_id == AV_CODEC_ID_PNG))
-        version = 8; /* version 8 and above support VP6 and PNG codec */
-    else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_FLASHSV)
-        version = 7; /* version 7 and above support Flash Screen Video codec */
+    else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_VP6F)
+        version = 8; /* version 8 and above support VP6 codec */
     else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_FLV1)
         version = 6; /* version 6 and above support FLV1 codec */
     else
@@ -282,15 +277,15 @@
     swf->duration_pos = avio_tell(pb);
     avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
 
-    /* swf v8 and later files require a file attribute tag */
-    if (version >= 8) {
+    /* avm2/swf v9 (also v8?) files require a file attribute tag */
+    if (version == 9) {
         put_swf_tag(s, TAG_FILEATTRIBUTES);
-        avio_wl32(pb, (version >= 9) << 3); /* set ActionScript v3/AVM2 flag */
+        avio_wl32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
         put_swf_end_tag(s);
     }
 
     /* define a shape with the jpeg inside */
-    if (swf->video_par && (swf->video_par->codec_id == AV_CODEC_ID_MJPEG || swf->video_par->codec_id == AV_CODEC_ID_PNG)) {
+    if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_MJPEG) {
         put_swf_tag(s, TAG_DEFINESHAPE);
 
         avio_wl16(pb, SHAPE_ID); /* ID of shape */
@@ -363,17 +358,17 @@
 }
 
 static int swf_write_video(AVFormatContext *s,
-                           AVCodecParameters *par, const uint8_t *buf, int size, unsigned pkt_flags)
+                           AVCodecParameters *par, const uint8_t *buf, int size)
 {
     SWFEncContext *swf = s->priv_data;
     AVIOContext *pb = s->pb;
-    unsigned codec_tag = ff_codec_get_tag(ff_swf_codec_tags, par->codec_id);
 
     /* Flash Player limit */
     if (swf->swf_frame_number == 16000)
         av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
 
-    if (codec_tag) {
+    if (par->codec_id == AV_CODEC_ID_VP6F ||
+        par->codec_id == AV_CODEC_ID_FLV1) {
         if (swf->video_frame_number == 0) {
             /* create a new video object */
             put_swf_tag(s, TAG_VIDEOSTREAM);
@@ -383,7 +378,7 @@
             avio_wl16(pb, par->width);
             avio_wl16(pb, par->height);
             avio_w8(pb, 0);
-            avio_w8(pb, codec_tag);
+            avio_w8(pb,ff_codec_get_tag(ff_swf_codec_tags, par->codec_id));
             put_swf_end_tag(s);
 
             /* place the video object for the first time */
@@ -409,14 +404,9 @@
         put_swf_tag(s, TAG_VIDEOFRAME | TAG_LONG);
         avio_wl16(pb, VIDEO_ID);
         avio_wl16(pb, swf->video_frame_number++);
-        if (par->codec_id == AV_CODEC_ID_FLASHSV) {
-            /* FrameType and CodecId is needed here even if it is not documented correctly in the SWF specs */
-            int flags = codec_tag | (pkt_flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER);
-            avio_w8(pb, flags);
-        }
         avio_write(pb, buf, size);
         put_swf_end_tag(s);
-    } else if (par->codec_id == AV_CODEC_ID_MJPEG || par->codec_id == AV_CODEC_ID_PNG) {
+    } else if (par->codec_id == AV_CODEC_ID_MJPEG) {
         if (swf->swf_frame_number > 0) {
             /* remove the shape */
             put_swf_tag(s, TAG_REMOVEOBJECT);
@@ -435,9 +425,8 @@
         avio_wl16(pb, BITMAP_ID); /* ID of the image */
 
         /* a dummy jpeg header seems to be required */
-        if (par->codec_id == AV_CODEC_ID_MJPEG)
-            avio_wb32(pb, 0xffd8ffd9);
-        /* write the jpeg/png image */
+        avio_wb32(pb, 0xffd8ffd9);
+        /* write the jpeg image */
         avio_write(pb, buf, size);
 
         put_swf_end_tag(s);
@@ -492,7 +481,7 @@
 
     /* if audio only stream make sure we add swf frames */
     if (!swf->video_par)
-        swf_write_video(s, par, 0, 0, 0);
+        swf_write_video(s, par, 0, 0);
 
     return 0;
 }
@@ -503,7 +492,7 @@
     if (par->codec_type == AVMEDIA_TYPE_AUDIO)
         return swf_write_audio(s, par, pkt->data, pkt->size);
     else
-        return swf_write_video(s, par, pkt->data, pkt->size, pkt->flags);
+        return swf_write_video(s, par, pkt->data, pkt->size);
 }
 
 static int swf_write_trailer(AVFormatContext *s)
diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c
index c15aeea..6c25d60 100644
--- a/libavformat/tedcaptionsdec.c
+++ b/libavformat/tedcaptionsdec.c
@@ -172,8 +172,6 @@
     if ((unsigned)*cur_byte - '0' > 9)
         return AVERROR_INVALIDDATA;
     while (BETWEEN(*cur_byte, '0', '9')) {
-        if (val > INT_MAX/10 - (*cur_byte - '0'))
-            return AVERROR_INVALIDDATA;
         val = val * 10 + (*cur_byte - '0');
         next_byte(pb, cur_byte);
     }
diff --git a/libavformat/tls_securetransport.c b/libavformat/tls_securetransport.c
index f6a1a5e..b0cfab1 100644
--- a/libavformat/tls_securetransport.c
+++ b/libavformat/tls_securetransport.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 rcombs
+ * Copyright (c) 2015 Rodger Combs
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 46c2508..70e98b2 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -119,7 +119,7 @@
     for (i = 0; i < c->totalframes; i++) {
         uint32_t size = avio_rl32(s->pb);
         int r;
-        if ((r = av_add_index_entry(st, framepos, i * (int64_t)c->frame_size, size, 0,
+        if ((r = av_add_index_entry(st, framepos, i * c->frame_size, size, 0,
                                     AVINDEX_KEYFRAME)) < 0)
             return r;
         framepos += size;
diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c
deleted file mode 100644
index 940f8bb..0000000
--- a/libavformat/ttmlenc.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * TTML subtitle muxer
- * Copyright (c) 2020 24i
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * TTML subtitle muxer
- * @see https://www.w3.org/TR/ttml1/
- * @see https://www.w3.org/TR/ttml2/
- * @see https://www.w3.org/TR/ttml-imsc/rec
- */
-
-#include "avformat.h"
-#include "internal.h"
-#include "libavcodec/ttmlenc.h"
-#include "libavutil/internal.h"
-
-enum TTMLPacketType {
-    PACKET_TYPE_PARAGRAPH,
-    PACKET_TYPE_DOCUMENT,
-};
-
-typedef struct TTMLMuxContext {
-    enum TTMLPacketType input_type;
-    unsigned int document_written;
-} TTMLMuxContext;
-
-static const char ttml_header_text[] =
-"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-"<tt\n"
-"  xmlns=\"http://www.w3.org/ns/ttml\"\n"
-"  xmlns:ttm=\"http://www.w3.org/ns/ttml#metadata\"\n"
-"  xmlns:tts=\"http://www.w3.org/ns/ttml#styling\"\n"
-"  xml:lang=\"%s\">\n"
-"  <body>\n"
-"    <div>\n";
-
-static const char ttml_footer_text[] =
-"    </div>\n"
-"  </body>\n"
-"</tt>\n";
-
-static void ttml_write_time(AVIOContext *pb, const char tag[],
-                            int64_t millisec)
-{
-    int64_t sec, min, hour;
-    sec = millisec / 1000;
-    millisec -= 1000 * sec;
-    min = sec / 60;
-    sec -= 60 * min;
-    hour = min / 60;
-    min -= 60 * hour;
-
-    avio_printf(pb, "%s=\"%02"PRId64":%02"PRId64":%02"PRId64".%03"PRId64"\"",
-                tag, hour, min, sec, millisec);
-}
-
-static int ttml_write_header(AVFormatContext *ctx)
-{
-    TTMLMuxContext *ttml_ctx = ctx->priv_data;
-    ttml_ctx->document_written = 0;
-
-    if (ctx->nb_streams != 1 ||
-        ctx->streams[0]->codecpar->codec_id != AV_CODEC_ID_TTML) {
-        av_log(ctx, AV_LOG_ERROR, "Exactly one TTML stream is required!\n");
-        return AVERROR(EINVAL);
-    }
-
-    {
-        AVStream    *st = ctx->streams[0];
-        AVIOContext *pb = ctx->pb;
-
-        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,
-                                              0);
-        const char *printed_lang = (lang && lang->value) ? lang->value : "";
-
-        // Not perfect, but decide whether the packet is a document or not
-        // by the existence of the lavc ttmlenc extradata.
-        ttml_ctx->input_type = (st->codecpar->extradata &&
-                                st->codecpar->extradata_size >= TTMLENC_EXTRADATA_SIGNATURE_SIZE &&
-                                !memcmp(st->codecpar->extradata,
-                                        TTMLENC_EXTRADATA_SIGNATURE,
-                                        TTMLENC_EXTRADATA_SIGNATURE_SIZE)) ?
-                               PACKET_TYPE_PARAGRAPH :
-                               PACKET_TYPE_DOCUMENT;
-
-        avpriv_set_pts_info(st, 64, 1, 1000);
-
-        if (ttml_ctx->input_type == PACKET_TYPE_PARAGRAPH)
-            avio_printf(pb, ttml_header_text, printed_lang);
-    }
-
-    return 0;
-}
-
-static int ttml_write_packet(AVFormatContext *ctx, AVPacket *pkt)
-{
-    TTMLMuxContext *ttml_ctx = ctx->priv_data;
-    AVIOContext    *pb       = ctx->pb;
-
-    switch (ttml_ctx->input_type) {
-    case PACKET_TYPE_PARAGRAPH:
-        // write out a paragraph element with the given contents.
-        avio_printf(pb,     "      <p\n");
-        ttml_write_time(pb, "        begin", pkt->pts);
-        avio_w8(pb, '\n');
-        ttml_write_time(pb, "        end",   pkt->pts + pkt->duration);
-        avio_printf(pb, ">");
-        avio_write(pb, pkt->data, pkt->size);
-        avio_printf(pb, "</p>\n");
-        break;
-    case PACKET_TYPE_DOCUMENT:
-        // dump the given document out as-is.
-        if (ttml_ctx->document_written) {
-            av_log(ctx, AV_LOG_ERROR,
-                   "Attempting to write multiple TTML documents into a "
-                   "single document! The XML specification forbids this "
-                   "as there has to be a single root tag.\n");
-            return AVERROR(EINVAL);
-        }
-        avio_write(pb, pkt->data, pkt->size);
-        ttml_ctx->document_written = 1;
-        break;
-    default:
-        av_log(ctx, AV_LOG_ERROR,
-               "Internal error: invalid TTML input packet type: %d!\n",
-               ttml_ctx->input_type);
-        return AVERROR_BUG;
-    }
-
-    return 0;
-}
-
-static int ttml_write_trailer(AVFormatContext *ctx)
-{
-    TTMLMuxContext *ttml_ctx = ctx->priv_data;
-    AVIOContext    *pb       = ctx->pb;
-
-    if (ttml_ctx->input_type == PACKET_TYPE_PARAGRAPH)
-        avio_printf(pb, ttml_footer_text);
-
-    return 0;
-}
-
-AVOutputFormat ff_ttml_muxer = {
-    .name              = "ttml",
-    .long_name         = NULL_IF_CONFIG_SMALL("TTML subtitle"),
-    .extensions        = "ttml",
-    .mime_type         = "text/ttml",
-    .priv_data_size    = sizeof(TTMLMuxContext),
-    .flags             = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
-                         AVFMT_TS_NONSTRICT,
-    .subtitle_codec    = AV_CODEC_ID_TTML,
-    .write_header      = ttml_write_header,
-    .write_packet      = ttml_write_packet,
-    .write_trailer     = ttml_write_trailer,
-};
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 9b9d3de..13c346a 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -165,7 +165,7 @@
     if (addr->sa_family == AF_INET) {
         if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)");
-            return ff_neterrno();
+            return -1;
         }
     }
 #endif
@@ -173,7 +173,7 @@
     if (addr->sa_family == AF_INET6) {
         if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)");
-            return ff_neterrno();
+            return -1;
         }
     }
 #endif
@@ -193,7 +193,7 @@
             mreq.imr_interface.s_addr = INADDR_ANY;
         if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)");
-            return ff_neterrno();
+            return -1;
         }
     }
 #endif
@@ -206,7 +206,7 @@
         mreq6.ipv6mr_interface = 0;
         if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)");
-            return ff_neterrno();
+            return -1;
         }
     }
 #endif
@@ -633,7 +633,6 @@
     char buf[256];
     struct sockaddr_storage my_addr;
     socklen_t len;
-    int ret;
 
     h->is_streamed = 1;
 
@@ -642,12 +641,12 @@
         s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
 
     if (s->sources) {
-        if ((ret = ff_ip_parse_sources(h, s->sources, &s->filters)) < 0)
+        if (ff_ip_parse_sources(h, s->sources, &s->filters) < 0)
             goto fail;
     }
 
     if (s->block) {
-        if ((ret = ff_ip_parse_blocks(h, s->block, &s->filters)) < 0)
+        if (ff_ip_parse_blocks(h, s->block, &s->filters) < 0)
             goto fail;
     }
 
@@ -713,11 +712,11 @@
             av_strlcpy(localaddr, buf, sizeof(localaddr));
         }
         if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
-            if ((ret = ff_ip_parse_sources(h, buf, &s->filters)) < 0)
+            if (ff_ip_parse_sources(h, buf, &s->filters) < 0)
                 goto fail;
         }
         if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
-            if ((ret = ff_ip_parse_blocks(h, buf, &s->filters)) < 0)
+            if (ff_ip_parse_blocks(h, buf, &s->filters) < 0)
                 goto fail;
         }
         if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
@@ -743,7 +742,7 @@
         if (!(flags & AVIO_FLAG_READ))
             goto fail;
     } else {
-        if ((ret = ff_udp_set_remote_url(h, uri)) < 0)
+        if (ff_udp_set_remote_url(h, uri) < 0)
             goto fail;
     }
 
@@ -764,22 +763,15 @@
      */
     if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
         s->reuse_socket = 1;
-        if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) {
-            ret = ff_neterrno();
+        if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
             goto fail;
-        }
     }
 
     if (s->is_broadcast) {
 #ifdef SO_BROADCAST
-        if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0) {
-            ret = ff_neterrno();
-            goto fail;
-        }
-#else
-        ret = AVERROR(ENOSYS);
-        goto fail;
+        if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0)
 #endif
+           goto fail;
     }
 
     /* Set the checksum coverage for UDP-Lite (RFC 3828) for sending and receiving.
@@ -796,10 +788,8 @@
 
     if (dscp >= 0) {
         dscp <<= 2;
-        if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0) {
-            ret = ff_neterrno();
+        if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0)
             goto fail;
-        }
     }
 
     /* If multicast, try binding the multicast address first, to avoid
@@ -814,7 +804,6 @@
     /* the bind is needed to give a port to the socket now */
     if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
         ff_log_net_error(h, AV_LOG_ERROR, "bind failed");
-        ret = ff_neterrno();
         goto fail;
     }
 
@@ -825,28 +814,28 @@
     if (s->is_multicast) {
         if (h->flags & AVIO_FLAG_WRITE) {
             /* output */
-            if ((ret = udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr)) < 0)
+            if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
                 goto fail;
         }
         if (h->flags & AVIO_FLAG_READ) {
             /* input */
             if (s->filters.nb_include_addrs) {
-                if ((ret = udp_set_multicast_sources(h, udp_fd,
+                if (udp_set_multicast_sources(h, udp_fd,
                                               (struct sockaddr *)&s->dest_addr,
                                               s->dest_addr_len, &s->local_addr_storage,
                                               s->filters.include_addrs,
-                                              s->filters.nb_include_addrs, 1)) < 0)
+                                              s->filters.nb_include_addrs, 1) < 0)
                     goto fail;
             } else {
-                if ((ret = udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage)) < 0)
+                if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage) < 0)
                     goto fail;
             }
             if (s->filters.nb_exclude_addrs) {
-                if ((ret = udp_set_multicast_sources(h, udp_fd,
+                if (udp_set_multicast_sources(h, udp_fd,
                                               (struct sockaddr *)&s->dest_addr,
                                               s->dest_addr_len, &s->local_addr_storage,
                                               s->filters.exclude_addrs,
-                                              s->filters.nb_exclude_addrs, 0)) < 0)
+                                              s->filters.nb_exclude_addrs, 0) < 0)
                     goto fail;
             }
         }
@@ -857,7 +846,6 @@
         tmp = s->buffer_size;
         if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
             ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
-            ret = ff_neterrno();
             goto fail;
         }
     } else {
@@ -881,7 +869,6 @@
     if (s->is_connected) {
         if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
             ff_log_net_error(h, AV_LOG_ERROR, "connect");
-            ret = ff_neterrno();
             goto fail;
         }
     }
@@ -901,28 +888,23 @@
     }
 
     if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && s->circular_buffer_size)) {
+        int ret;
+
         /* start the task going */
         s->fifo = av_fifo_alloc(s->circular_buffer_size);
-        if (!s->fifo) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
-        }
         ret = pthread_mutex_init(&s->mutex, NULL);
         if (ret != 0) {
             av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
-            ret = AVERROR(ret);
             goto fail;
         }
         ret = pthread_cond_init(&s->cond, NULL);
         if (ret != 0) {
             av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
-            ret = AVERROR(ret);
             goto cond_fail;
         }
         ret = pthread_create(&s->circular_buffer_thread, NULL, is_output?circular_buffer_task_tx:circular_buffer_task_rx, h);
         if (ret != 0) {
             av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
-            ret = AVERROR(ret);
             goto thread_fail;
         }
         s->thread_started = 1;
@@ -941,7 +923,7 @@
         closesocket(udp_fd);
     av_fifo_freep(&s->fifo);
     ff_ip_reset_filters(&s->filters);
-    return ret;
+    return AVERROR(EIO);
 }
 
 static int udplite_open(URLContext *h, const char *uri, int flags)
diff --git a/libavformat/url.c b/libavformat/url.c
index 77d610d..6db4b4e 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -211,8 +211,8 @@
 
     if (!base)
         base = "";
-    if ((ret = ff_url_decompose(&ub, base, NULL)) < 0 ||
-        (ret = ff_url_decompose(&uc, rel,  NULL)) < 0)
+    if ((ret = ff_url_decompose(&ub, base, NULL) < 0) ||
+        (ret = ff_url_decompose(&uc, rel,  NULL) < 0))
         goto error;
 
     keep = ub.url;
diff --git a/libavformat/url.h b/libavformat/url.h
index f13e851..e33edf0 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -56,8 +56,8 @@
     int     (*url_open)( URLContext *h, const char *url, int flags);
     /**
      * This callback is to be used by protocols which open further nested
-     * protocols. options are then to be passed to ffurl_open_whitelist()
-     * or ffurl_connect() for those nested protocols.
+     * protocols. options are then to be passed to ffurl_open()/ffurl_connect()
+     * for those nested protocols.
      */
     int     (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options);
     int     (*url_accept)(URLContext *s, URLContext **c);
@@ -87,8 +87,8 @@
                                      int *numhandles);
     int (*url_get_short_seek)(URLContext *h);
     int (*url_shutdown)(URLContext *h, int flags);
-    const AVClass *priv_data_class;
     int priv_data_size;
+    const AVClass *priv_data_class;
     int flags;
     int (*url_check)(URLContext *h, int mask);
     int (*url_open_dir)(URLContext *h);
@@ -148,6 +148,9 @@
                const char *whitelist, const char* blacklist,
                URLContext *parent);
 
+int ffurl_open(URLContext **puc, const char *filename, int flags,
+               const AVIOInterruptCB *int_cb, AVDictionary **options);
+
 /**
  * Accept an URLContext c on an URLContext s
  *
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4a855d5..e117213 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -101,7 +101,7 @@
  */
 static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp)
 {
-    if (st->internal->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&
+    if (st->internal->pts_wrap_behavior != AV_PTS_WRAP_IGNORE &&
         st->internal->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
         if (st->internal->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
             timestamp < st->internal->pts_wrap_reference)
@@ -244,16 +244,13 @@
 int ffio_limit(AVIOContext *s, int size)
 {
     if (s->maxsize>= 0) {
-        int64_t pos = avio_tell(s);
-        int64_t remaining= s->maxsize - pos;
+        int64_t remaining= s->maxsize - avio_tell(s);
         if (remaining < size) {
             int64_t newsize = avio_size(s);
             if (!s->maxsize || s->maxsize<newsize)
                 s->maxsize = newsize - !newsize;
-            if (pos > s->maxsize && s->maxsize >= 0)
-                s->maxsize = AVERROR(EIO);
-            if (s->maxsize >= 0)
-                remaining = s->maxsize - pos;
+            remaining= s->maxsize - avio_tell(s);
+            remaining= FFMAX(remaining, 0);
         }
 
         if (s->maxsize >= 0 && remaining < size && size > 1) {
@@ -392,7 +389,6 @@
 /************************************************************/
 /* input media file */
 
-#if FF_API_DEMUXER_OPEN
 int av_demuxer_open(AVFormatContext *ic) {
     int err;
 
@@ -412,7 +408,7 @@
 
     return 0;
 }
-#endif
+
 /* Open input file and probe the format if necessary. */
 static int init_input(AVFormatContext *s, const char *filename,
                       AVDictionary **options)
@@ -595,11 +591,8 @@
     if (s->pb)
         ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
 
-#if FF_API_DEMUXER_OPEN
+
     if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
-#else
-    if (s->iformat->read_header)
-#endif
         if ((ret = s->iformat->read_header(s)) < 0)
             goto fail;
 
@@ -628,11 +621,7 @@
     if ((ret = avformat_queue_attached_pictures(s)) < 0)
         goto close;
 
-#if FF_API_DEMUXER_OPEN
     if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
-#else
-    if (s->pb && !s->internal->data_offset)
-#endif
         s->internal->data_offset = avio_tell(s->pb);
 
     s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
@@ -1114,7 +1103,6 @@
         dts           == AV_NOPTS_VALUE ||
         st->cur_dts   == AV_NOPTS_VALUE ||
         st->cur_dts < INT_MIN + RELATIVE_TS_BASE ||
-        dts  < INT_MIN + (st->cur_dts - RELATIVE_TS_BASE) ||
         is_relative(dts))
         return;
 
@@ -1263,7 +1251,7 @@
         presentation_delayed = 1;
 
     if (pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE &&
-        st->pts_wrap_bits < 63 && pkt->dts > INT64_MIN + (1LL << (st->pts_wrap_bits - 1)) &&
+        st->pts_wrap_bits < 63 &&
         pkt->dts - (1LL << (st->pts_wrap_bits - 1)) > pkt->pts) {
         if (is_relative(st->cur_dts) || pkt->dts - (1LL<<(st->pts_wrap_bits - 1)) > st->cur_dts) {
             pkt->dts -= 1LL << st->pts_wrap_bits;
@@ -1434,8 +1422,8 @@
         pkt->pts = pkt->dts = AV_NOPTS_VALUE;
         pkt->pos = -1;
         /* increment read pointer */
-        av_assert1(data || !len);
-        data  = len ? data + len : data;
+        if (data)
+            data += len;
         size -= len;
 
         got_output = !!out_pkt.size;
@@ -2887,7 +2875,7 @@
 }
 
 /* 1:1 map to AVDurationEstimationMethod */
-static const char *const duration_name[] = {
+static const char *duration_name[] = {
     [AVFMT_DURATION_FROM_PTS]     = "pts",
     [AVFMT_DURATION_FROM_STREAM]  = "stream",
     [AVFMT_DURATION_FROM_BITRATE] = "bit rate",
@@ -3030,10 +3018,6 @@
         /* Force thread count to 1 since the H.264 decoder will not extract
          * SPS and PPS to extradata during multi-threaded decoding. */
         av_dict_set(options ? options : &thread_opt, "threads", "1", 0);
-        /* Force lowres to 0. The decoder might reduce the video size by the
-         * lowres factor, and we don't want that propagated to the stream's
-         * codecpar */
-        av_dict_set(options ? options : &thread_opt, "lowres", "0", 0);
         if (s->codec_whitelist)
             av_dict_set(options ? options : &thread_opt, "codec_whitelist", s->codec_whitelist, 0);
         ret = avcodec_open2(avctx, codec, options ? options : &thread_opt);
@@ -3210,51 +3194,31 @@
     return AV_CODEC_ID_NONE;
 }
 
-static int chapter_start_cmp(const void *p1, const void *p2)
+static void compute_chapters_end(AVFormatContext *s)
 {
-    AVChapter *ch1 = *(AVChapter**)p1;
-    AVChapter *ch2 = *(AVChapter**)p2;
-    int delta = av_compare_ts(ch1->start, ch1->time_base, ch2->start, ch2->time_base);
-    if (delta)
-        return delta;
-    return (ch1 > ch2) - (ch1 < ch2);
-}
-
-static int compute_chapters_end(AVFormatContext *s)
-{
-    unsigned int i;
+    unsigned int i, j;
     int64_t max_time = 0;
-    AVChapter **timetable = av_malloc(s->nb_chapters * sizeof(*timetable));
-
-    if (!timetable)
-        return AVERROR(ENOMEM);
 
     if (s->duration > 0 && s->start_time < INT64_MAX - s->duration)
         max_time = s->duration +
                        ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time);
 
     for (i = 0; i < s->nb_chapters; i++)
-        timetable[i] = s->chapters[i];
-    qsort(timetable, s->nb_chapters, sizeof(*timetable), chapter_start_cmp);
-
-    for (i = 0; i < s->nb_chapters; i++)
-        if (timetable[i]->end == AV_NOPTS_VALUE) {
-            AVChapter *ch = timetable[i];
+        if (s->chapters[i]->end == AV_NOPTS_VALUE) {
+            AVChapter *ch = s->chapters[i];
             int64_t end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q,
-                                                ch->time_base)
-                                : INT64_MAX;
+                                                  ch->time_base)
+                                   : INT64_MAX;
 
-            if (i + 1 < s->nb_chapters) {
-                AVChapter *ch1     = timetable[i + 1];
+            for (j = 0; j < s->nb_chapters; j++) {
+                AVChapter *ch1     = s->chapters[j];
                 int64_t next_start = av_rescale_q(ch1->start, ch1->time_base,
-                                                ch->time_base);
-                if (next_start > ch->start && next_start < end)
+                                                  ch->time_base);
+                if (j != i && next_start > ch->start && next_start < end)
                     end = next_start;
             }
             ch->end = (end == INT64_MAX || end < ch->start) ? ch->start : end;
         }
-    av_free(timetable);
-    return 0;
 }
 
 static int get_std_framerate(int i)
@@ -3675,10 +3639,6 @@
         /* Force thread count to 1 since the H.264 decoder will not extract
          * SPS and PPS to extradata during multi-threaded decoding. */
         av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0);
-        /* Force lowres to 0. The decoder might reduce the video size by the
-         * lowres factor, and we don't want that propagated to the stream's
-         * codecpar */
-        av_dict_set(options ? &options[i] : &thread_opt, "lowres", "0", 0);
 
         if (ic->codec_whitelist)
             av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0);
@@ -3881,10 +3841,8 @@
             if (   t == 0
                 && st->codec_info_nb_frames>30
                 && st->internal->info->fps_first_dts != AV_NOPTS_VALUE
-                && st->internal->info->fps_last_dts  != AV_NOPTS_VALUE) {
-                int64_t dur = av_sat_sub64(st->internal->info->fps_last_dts, st->internal->info->fps_first_dts);
-                t = FFMAX(t, av_rescale_q(dur, st->time_base, AV_TIME_BASE_Q));
-            }
+                && st->internal->info->fps_last_dts  != AV_NOPTS_VALUE)
+                t = FFMAX(t, av_rescale_q(st->internal->info->fps_last_dts - st->internal->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q));
 
             if (analyzed_all_streams)                                limit = max_analyze_duration;
             else if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) limit = max_subtitle_analyze_duration;
@@ -4116,21 +4074,28 @@
         }
     }
 
-    ret = compute_chapters_end(ic);
-    if (ret < 0)
-        goto find_stream_info_err;
+    compute_chapters_end(ic);
 
     /* update the stream parameters from the internal codec contexts */
     for (i = 0; i < ic->nb_streams; i++) {
         st = ic->streams[i];
 
         if (st->internal->avctx_inited) {
+            int orig_w = st->codecpar->width;
+            int orig_h = st->codecpar->height;
             ret = avcodec_parameters_from_context(st->codecpar, st->internal->avctx);
             if (ret < 0)
                 goto find_stream_info_err;
             ret = add_coded_side_data(st, st->internal->avctx);
             if (ret < 0)
                 goto find_stream_info_err;
+#if FF_API_LOWRES
+            // The decoder might reduce the video size by the lowres factor.
+            if (st->internal->avctx->lowres && orig_w) {
+                st->codecpar->width = orig_w;
+                st->codecpar->height = orig_h;
+            }
+#endif
         }
 
 #if FF_API_LAVF_AVCTX
@@ -4139,6 +4104,7 @@
         if (ret < 0)
             goto find_stream_info_err;
 
+#if FF_API_LOWRES
         // The old API (AVStream.codec) "requires" the resolution to be adjusted
         // by the lowres factor.
         if (st->internal->avctx->lowres && st->internal->avctx->width) {
@@ -4146,6 +4112,7 @@
             st->codec->width = st->internal->avctx->width;
             st->codec->height = st->internal->avctx->height;
         }
+#endif
 
         if (st->codec->codec_tag != MKTAG('t','m','c','d')) {
             st->codec->time_base = st->internal->avctx->time_base;
@@ -4602,12 +4569,14 @@
         dynarray_add(&ac->programs, &ac->nb_programs, program);
         program->discard = AVDISCARD_NONE;
         program->pmt_version = -1;
-        program->id = id;
-        program->pts_wrap_reference = AV_NOPTS_VALUE;
-        program->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
-        program->start_time =
-        program->end_time   = AV_NOPTS_VALUE;
     }
+    program->id = id;
+    program->pts_wrap_reference = AV_NOPTS_VALUE;
+    program->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
+
+    program->start_time =
+    program->end_time   = AV_NOPTS_VALUE;
+
     return program;
 }
 
@@ -4622,14 +4591,9 @@
         return NULL;
     }
 
-    if (!s->nb_chapters) {
-        s->internal->chapter_ids_monotonic = 1;
-    } else if (!s->internal->chapter_ids_monotonic || s->chapters[s->nb_chapters-1]->id >= id) {
-        s->internal->chapter_ids_monotonic = 0;
-        for (i = 0; i < s->nb_chapters; i++)
-            if (s->chapters[i]->id == id)
-                chapter = s->chapters[i];
-    }
+    for (i = 0; i < s->nb_chapters; i++)
+        if (s->chapters[i]->id == id)
+            chapter = s->chapters[i];
 
     if (!chapter) {
         chapter = av_mallocz(sizeof(AVChapter));
@@ -4717,11 +4681,8 @@
         if (c == '%') {
             do {
                 nd = 0;
-                while (av_isdigit(*p)) {
-                    if (nd >= INT_MAX / 10 - 255)
-                        goto fail;
+                while (av_isdigit(*p))
                     nd = nd * 10 + *p++ - '0';
-                }
                 c = *p++;
             } while (av_isdigit(c));
 
@@ -5471,7 +5432,7 @@
 }
 
 uint8_t *av_stream_get_side_data(const AVStream *st,
-                                 enum AVPacketSideDataType type, buffer_size_t *size)
+                                 enum AVPacketSideDataType type, int *size)
 {
     int i;
 
@@ -5524,7 +5485,7 @@
 }
 
 uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
-                                 buffer_size_t size)
+                                 int size)
 {
     int ret;
     uint8_t *data = av_malloc(size);
@@ -5698,7 +5659,7 @@
 int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette)
 {
     uint8_t *side_data;
-    buffer_size_t size;
+    int size;
 
     side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
     if (side_data) {
diff --git a/libavformat/version.h b/libavformat/version.h
index 2a28045..b43193b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  72
+#define LIBAVFORMAT_VERSION_MINOR  65
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -106,12 +106,6 @@
 #ifndef FF_API_AVIOFORMAT
 #define FF_API_AVIOFORMAT               (LIBAVFORMAT_VERSION_MAJOR < 59)
 #endif
-#ifndef FF_API_DEMUXER_OPEN
-#define FF_API_DEMUXER_OPEN             (LIBAVFORMAT_VERSION_MAJOR < 59)
-#endif
-#ifndef FF_API_LAVF_PRIV_OPT
-#define FF_API_LAVF_PRIV_OPT            (LIBAVFORMAT_VERSION_MAJOR < 60)
-#endif
 
 
 #ifndef FF_API_R_FRAME_RATE
diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index d745770..96e0631 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -373,7 +373,7 @@
         avio_rl16(pb); //codec_subid
         st->codecpar->channels = avio_rl16(pb); // channels
         st->codecpar->sample_rate = avio_rl32(pb); // sample_rate
-        if (st->codecpar->sample_rate <= 0 || st->codecpar->channels <= 0)
+        if (st->codecpar->sample_rate <= 0)
             return AVERROR_INVALIDDATA;
         avio_seek(pb, 10, SEEK_CUR); // data_1
         q = avio_r8(pb);
diff --git a/libavformat/voc.c b/libavformat/voc.c
index 04ec0da..2a97234 100644
--- a/libavformat/voc.c
+++ b/libavformat/voc.c
@@ -19,10 +19,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
 #include "voc.h"
 #include "internal.h"
 
+const unsigned char ff_voc_magic[21] = "Creative Voice File\x1A";
 
 const AVCodecTag ff_voc_codec_tags[] = {
     {AV_CODEC_ID_PCM_U8,        0x00},
@@ -35,8 +35,3 @@
     {AV_CODEC_ID_ADPCM_CT,    0x0200},
     {AV_CODEC_ID_NONE,             0},
 };
-
-#if CONFIG_VOC_DEMUXER || CONFIG_VOC_MUXER
-const unsigned char ff_voc_magic[21] = "Creative Voice File\x1A";
-const AVCodecTag *const ff_voc_codec_tags_list[] = { ff_voc_codec_tags, NULL };
-#endif
diff --git a/libavformat/voc.h b/libavformat/voc.h
index 1fc6bb4..1f9a8be 100644
--- a/libavformat/voc.h
+++ b/libavformat/voc.h
@@ -45,7 +45,6 @@
 
 extern const unsigned char ff_voc_magic[21];
 extern const AVCodecTag ff_voc_codec_tags[];
-extern const AVCodecTag *const ff_voc_codec_tags_list[];
 
 int ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt,
                       AVStream *st, int max_size);
diff --git a/libavformat/voc_packet.c b/libavformat/voc_packet.c
index 9d7d202..1e2e19e 100644
--- a/libavformat/voc_packet.c
+++ b/libavformat/voc_packet.c
@@ -44,8 +44,6 @@
                        AVINDEX_KEYFRAME);
 
     while (!voc->remaining_size) {
-        if (max_size < 4)
-            max_size = 0;
         type = avio_r8(pb);
         if (type == VOC_TYPE_EOF)
             return AVERROR_EOF;
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
index 6cdc720..d388fce 100644
--- a/libavformat/vocdec.c
+++ b/libavformat/vocdec.c
@@ -106,5 +106,5 @@
     .read_header    = voc_read_header,
     .read_packet    = voc_read_packet,
     .read_seek      = voc_read_seek,
-    .codec_tag      = ff_voc_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ ff_voc_codec_tags, 0 },
 };
diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
index bdc6384..321b113 100644
--- a/libavformat/vocenc.c
+++ b/libavformat/vocenc.c
@@ -106,6 +106,6 @@
     .write_header      = voc_write_header,
     .write_packet      = voc_write_packet,
     .write_trailer     = voc_write_trailer,
-    .codec_tag         = ff_voc_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ ff_voc_codec_tags, 0 },
     .flags             = AVFMT_NOTIMESTAMPS,
 };
diff --git a/libavformat/vpk.c b/libavformat/vpk.c
index f7f2054..b1df4e0 100644
--- a/libavformat/vpk.c
+++ b/libavformat/vpk.c
@@ -121,10 +121,7 @@
     int64_t ret = 0;
 
     samples_per_block = av_get_audio_frame_duration2(par, par->block_align);
-    if (samples_per_block > 0)
-        timestamp /= samples_per_block;
-    else
-        return -1;
+    timestamp /= samples_per_block;
     ret = avio_seek(s->pb, vpk->data_start + timestamp * par->block_align, SEEK_SET);
     if (ret < 0)
         return ret;
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 811c4bc..6d6b950 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -27,7 +27,6 @@
 
 #include <stdint.h>
 
-#include "config.h"
 #include "libavutil/avassert.h"
 #include "libavutil/dict.h"
 #include "libavutil/intreadwrite.h"
@@ -64,17 +63,6 @@
     int rifx; // RIFX: integer byte order for parameters is big endian
 } WAVDemuxContext;
 
-#define OFFSET(x) offsetof(WAVDemuxContext, x)
-#define DEC AV_OPT_FLAG_DECODING_PARAM
-static const AVOption demux_options[] = {
-#define W64_DEMUXER_OPTIONS_OFFSET (1 * CONFIG_WAV_DEMUXER)
-#if CONFIG_WAV_DEMUXER
-    { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
-#endif
-    { "max_size",      "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
-    { NULL },
-};
-
 static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
 {
 #if CONFIG_SPDIF_DEMUXER
@@ -84,7 +72,7 @@
         int ret = ffio_ensure_seekback(s->pb, len);
 
         if (ret >= 0) {
-            uint8_t *buf = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE);
+            uint8_t *buf = av_malloc(len);
             if (!buf) {
                 ret = AVERROR(ENOMEM);
             } else {
@@ -657,8 +645,7 @@
     } else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 ||
                st->codecpar->codec_id == AV_CODEC_ID_XMA2) {
         st->codecpar->block_align = 2048;
-    } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->channels > 2 &&
-               st->codecpar->block_align < INT_MAX / st->codecpar->channels) {
+    } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->channels > 2) {
         st->codecpar->block_align *= st->codecpar->channels;
     }
 
@@ -816,6 +803,14 @@
     return ff_pcm_read_seek(s, stream_index, timestamp, flags);
 }
 
+#define OFFSET(x) offsetof(WAVDemuxContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption demux_options[] = {
+    { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
+    { "max_size",      "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
+    { NULL },
+};
+
 static const AVClass wav_demuxer_class = {
     .class_name = "WAV demuxer",
     .item_name  = av_default_item_name,
@@ -831,7 +826,7 @@
     .read_packet    = wav_read_packet,
     .read_seek      = wav_read_seek,
     .flags          = AVFMT_GENERIC_INDEX,
-    .codec_tag      = ff_wav_codec_tags_list,
+    .codec_tag      = (const AVCodecTag * const []) { ff_codec_wav_tags,  0 },
     .priv_class     = &wav_demuxer_class,
 };
 #endif /* CONFIG_WAV_DEMUXER */
@@ -928,15 +923,11 @@
                 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
                     return AVERROR_INVALIDDATA;
 
-                value = av_malloc(chunk_size + 1);
+                value = av_mallocz(chunk_size + 1);
                 if (!value)
                     return AVERROR(ENOMEM);
 
                 ret = avio_get_str16le(pb, chunk_size, value, chunk_size);
-                if (ret < 0) {
-                    av_free(value);
-                    return ret;
-                }
                 avio_skip(pb, chunk_size - ret);
 
                 av_dict_set(&s->metadata, chunk_key, value, AV_DICT_DONT_STRDUP_VAL);
@@ -965,10 +956,17 @@
     return 0;
 }
 
+#define OFFSET(x) offsetof(WAVDemuxContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption w64_demux_options[] = {
+    { "max_size", "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
+    { NULL }
+};
+
 static const AVClass w64_demuxer_class = {
     .class_name = "W64 demuxer",
     .item_name  = av_default_item_name,
-    .option     = &demux_options[W64_DEMUXER_OPTIONS_OFFSET],
+    .option     = w64_demux_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
@@ -981,7 +979,7 @@
     .read_packet    = wav_read_packet,
     .read_seek      = wav_read_seek,
     .flags          = AVFMT_GENERIC_INDEX,
-    .codec_tag      = ff_wav_codec_tags_list,
+    .codec_tag      = (const AVCodecTag * const []) { ff_codec_wav_tags, 0 },
     .priv_class     = &w64_demuxer_class,
 };
 #endif /* CONFIG_W64_DEMUXER */
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 563a30d..1027f10 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -50,6 +50,8 @@
 #define RF64_NEVER  0
 #define RF64_ALWAYS 1
 
+#define PEAK_BUFFER_SIZE   1024
+
 typedef enum {
     PEAK_OFF = 0,
     PEAK_ON,
@@ -70,9 +72,8 @@
     int64_t maxpts;
     int16_t *peak_maxpos, *peak_maxneg;
     uint32_t peak_num_frames;
-    unsigned peak_outbuf_size;
+    uint32_t peak_outbuf_size;
     uint32_t peak_outbuf_bytes;
-    unsigned size_increment;
     uint8_t *peak_output;
     int last_duration;
     int write_bext;
@@ -158,8 +159,9 @@
         par->codec_id != AV_CODEC_ID_PCM_S16LE &&
         par->codec_id != AV_CODEC_ID_PCM_U8 &&
         par->codec_id != AV_CODEC_ID_PCM_U16LE) {
-        av_log(s, AV_LOG_ERROR, "Codec %s not supported for Peak Chunk\n",
-               avcodec_get_name(par->codec_id));
+        AVCodec *codec = avcodec_find_decoder(s->streams[0]->codecpar->codec_id);
+        av_log(s, AV_LOG_ERROR, "%s codec not supported for Peak Chunk\n",
+               codec ? codec->name : "NONE");
         return -1;
     }
 
@@ -170,15 +172,15 @@
                "Writing 16 bit peak for 8 bit audio does not make sense\n");
         return AVERROR(EINVAL);
     }
-    if (par->channels > INT_MAX / (wav->peak_bps * wav->peak_ppv))
-        return AVERROR(ERANGE);
-    wav->size_increment = par->channels * wav->peak_bps * wav->peak_ppv;
 
     wav->peak_maxpos = av_mallocz_array(par->channels, sizeof(*wav->peak_maxpos));
     wav->peak_maxneg = av_mallocz_array(par->channels, sizeof(*wav->peak_maxneg));
-    if (!wav->peak_maxpos || !wav->peak_maxneg)
+    wav->peak_output = av_malloc(PEAK_BUFFER_SIZE);
+    if (!wav->peak_maxpos || !wav->peak_maxneg || !wav->peak_output)
         goto nomem;
 
+    wav->peak_outbuf_size = PEAK_BUFFER_SIZE;
+
     return 0;
 
 nomem:
@@ -186,24 +188,14 @@
     return AVERROR(ENOMEM);
 }
 
-static int peak_write_frame(AVFormatContext *s)
+static void peak_write_frame(AVFormatContext *s)
 {
     WAVMuxContext *wav = s->priv_data;
     AVCodecParameters *par = s->streams[0]->codecpar;
-    unsigned new_size = wav->peak_outbuf_bytes + wav->size_increment;
-    uint8_t *tmp;
     int c;
 
-    if (new_size > INT_MAX) {
-        wav->write_peak = PEAK_OFF;
-        return AVERROR(ERANGE);
-    }
-    tmp = av_fast_realloc(wav->peak_output, &wav->peak_outbuf_size, new_size);
-    if (!tmp) {
-        wav->write_peak = PEAK_OFF;
-        return AVERROR(ENOMEM);
-    }
-    wav->peak_output = tmp;
+    if (!wav->peak_output)
+        return;
 
     for (c = 0; c < par->channels; c++) {
         wav->peak_maxneg[c] = -wav->peak_maxneg[c];
@@ -217,6 +209,17 @@
             wav->peak_maxpos[c] =
                 FFMAX(wav->peak_maxpos[c], wav->peak_maxneg[c]);
 
+        if (wav->peak_outbuf_size - wav->peak_outbuf_bytes <
+            wav->peak_format * wav->peak_ppv) {
+            wav->peak_outbuf_size += PEAK_BUFFER_SIZE;
+            wav->peak_output = av_realloc(wav->peak_output,
+                                          wav->peak_outbuf_size);
+            if (!wav->peak_output) {
+                av_log(s, AV_LOG_ERROR, "No memory for peak data\n");
+                return;
+            }
+        }
+
         if (wav->peak_format == PEAK_FORMAT_UINT8) {
             wav->peak_output[wav->peak_outbuf_bytes++] =
                 wav->peak_maxpos[c];
@@ -238,8 +241,6 @@
         wav->peak_maxneg[c] = 0;
     }
     wav->peak_num_frames++;
-
-    return 0;
 }
 
 static int peak_write_chunk(AVFormatContext *s)
@@ -253,11 +254,8 @@
     char timestamp[28];
 
     /* Peak frame of incomplete block at end */
-    if (wav->peak_block_pos) {
-        int ret = peak_write_frame(s);
-        if (ret < 0)
-            return ret;
-    }
+    if (wav->peak_block_pos)
+        peak_write_frame(s);
 
     memset(timestamp, 0, sizeof(timestamp));
     if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
@@ -327,8 +325,9 @@
         /* format header */
         fmt = ff_start_tag(pb, "fmt ");
         if (ff_put_wav_header(s, pb, s->streams[0]->codecpar, 0) < 0) {
-            av_log(s, AV_LOG_ERROR, "Codec %s not supported in WAVE format\n",
-                   avcodec_get_name(s->streams[0]->codecpar->codec_id));
+            const AVCodecDescriptor *desc = avcodec_descriptor_get(s->streams[0]->codecpar->codec_id);
+            av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n",
+                   desc ? desc->name : "unknown");
             return AVERROR(ENOSYS);
         }
         ff_end_tag(pb, fmt);
@@ -387,9 +386,7 @@
             if (++c == s->streams[0]->codecpar->channels) {
                 c = 0;
                 if (++wav->peak_block_pos == wav->peak_block_size) {
-                    int ret = peak_write_frame(s);
-                    if (ret < 0)
-                        return ret;
+                    peak_write_frame(s);
                     wav->peak_block_pos = 0;
                 }
             }
@@ -517,7 +514,7 @@
     .write_trailer     = wav_write_trailer,
     .deinit            = wav_deinit,
     .flags             = AVFMT_TS_NONSTRICT,
-    .codec_tag         = ff_wav_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
     .priv_class        = &wav_muxer_class,
 };
 #endif /* CONFIG_WAV_MUXER */
@@ -556,8 +553,9 @@
     avio_write(pb, ff_w64_guid_wave, sizeof(ff_w64_guid_wave));
     start_guid(pb, ff_w64_guid_fmt, &start);
     if ((ret = ff_put_wav_header(s, pb, s->streams[0]->codecpar, 0)) < 0) {
-        av_log(s, AV_LOG_ERROR, "Codec %s not supported\n",
-               avcodec_get_name(s->streams[0]->codecpar->codec_id));
+        AVCodec *codec = avcodec_find_decoder(s->streams[0]->codecpar->codec_id);
+        av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
+               codec ? codec->name : "NONE");
         return ret;
     }
     end_guid(pb, start);
@@ -614,6 +612,6 @@
     .write_packet      = wav_write_packet,
     .write_trailer     = w64_write_trailer,
     .flags             = AVFMT_TS_NONSTRICT,
-    .codec_tag         = ff_wav_codec_tags_list,
+    .codec_tag         = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
 };
 #endif /* CONFIG_W64_MUXER */
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 332d046..04f8cbe 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -133,7 +133,7 @@
     for (i = 1; i < as->nb_streams; i++) {
         AVDictionaryEntry *ts = av_dict_get(s->streams[as->streams[i]]->metadata,
                                             CUE_TIMESTAMPS, NULL, 0);
-        if (!ts || !av_strstart(ts->value, gold->value, NULL)) return 0;
+        if (!ts || strncmp(gold->value, ts->value, strlen(gold->value))) return 0;
     }
     return 1;
 }
@@ -152,7 +152,7 @@
                                                    TRACK_NUMBER, NULL, 0);
         AVCodecParameters *par = st->codecpar;
         if (!track_num ||
-            !av_strstart(track_num->value, gold_track_num->value, NULL) ||
+            strncmp(gold_track_num->value, track_num->value, strlen(gold_track_num->value)) ||
             gold_par->codec_id != par->codec_id ||
             gold_par->extradata_size != par->extradata_size ||
             memcmp(gold_par->extradata, par->extradata, par->extradata_size)) {
diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index 552bc38..cbd989d 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -64,7 +64,7 @@
 static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt)
 {
     AVIOContext  *pb = ctx->pb;
-    buffer_size_t id_size, settings_size;
+    int id_size, settings_size;
     uint8_t *id, *settings;
 
     avio_printf(pb, "\n");
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 7def9d2..77908e6 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -794,7 +794,7 @@
 
         ff_get_guid(pb, &g);
         len = avio_rl32(pb);
-        if (len < 32 || len > INT_MAX - 7) {
+        if (len < 32) {
             int ret;
             if (avio_feof(pb))
                 return AVERROR_EOF;
@@ -953,9 +953,6 @@
         } else
             av_log(s, AV_LOG_WARNING, "unsupported chunk:"FF_PRI_GUID"\n", FF_ARG_GUID(g));
 
-        if (avio_feof(pb))
-            break;
-
         avio_skip(pb, WTV_PAD8(len) - consumed);
     }
     return AVERROR_EOF;
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 24fdbe1..b53fdf9 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -839,5 +839,6 @@
     .write_header   = write_header,
     .write_packet   = write_packet,
     .write_trailer  = write_trailer,
-    .codec_tag      = ff_riff_codec_tags_list,
+    .codec_tag      = (const AVCodecTag* const []){ ff_codec_bmp_tags,
+                                                    ff_codec_wav_tags, 0 },
 };
diff --git a/libavutil/aarch64/timer.h b/libavutil/aarch64/timer.h
index 8b28fd3..b570039 100644
--- a/libavutil/aarch64/timer.h
+++ b/libavutil/aarch64/timer.h
@@ -24,13 +24,7 @@
 #include <stdint.h>
 #include "config.h"
 
-#if defined(__APPLE__)
-
-#include <mach/mach_time.h>
-
-#define AV_READ_TIME mach_absolute_time
-
-#elif HAVE_INLINE_ASM
+#if HAVE_INLINE_ASM
 
 #define AV_READ_TIME read_time
 
diff --git a/libavutil/aes_internal.h b/libavutil/aes_internal.h
index c9d6c24..4944258 100644
--- a/libavutil/aes_internal.h
+++ b/libavutil/aes_internal.h
@@ -1,5 +1,5 @@
 /*
- * copyright (c) 2015 rcombs
+ * copyright (c) 2015 Rodger Combs <rodger.combs@gmail.com>
  *
  * This file is part of FFmpeg.
  *
@@ -21,7 +21,7 @@
 #ifndef AVUTIL_AES_INTERNAL_H
 #define AVUTIL_AES_INTERNAL_H
 
-#include "mem_internal.h"
+#include "mem.h"
 #include <stdint.h>
 
 typedef union {
diff --git a/libavutil/arm/timer.h b/libavutil/arm/timer.h
index caf23e2..5e8bc8e 100644
--- a/libavutil/arm/timer.h
+++ b/libavutil/arm/timer.h
@@ -24,13 +24,7 @@
 #include <stdint.h>
 #include "config.h"
 
-#if defined(__APPLE__)
-
-#include <mach/mach_time.h>
-
-#define AV_READ_TIME mach_absolute_time
-
-#elif HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__)
+#if HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__)
 
 #define AV_READ_TIME read_time
 
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index fae446c..ee22558 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -324,7 +324,6 @@
     AV_ESCAPE_MODE_AUTO,      ///< Use auto-selected escaping mode.
     AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
     AV_ESCAPE_MODE_QUOTE,     ///< Use single-quote escaping.
-    AV_ESCAPE_MODE_XML,       ///< Use XML non-markup character data escaping.
 };
 
 /**
@@ -345,19 +344,6 @@
 #define AV_ESCAPE_FLAG_STRICT (1 << 1)
 
 /**
- * Within AV_ESCAPE_MODE_XML, additionally escape single quotes for single
- * quoted attributes.
- */
-#define AV_ESCAPE_FLAG_XML_SINGLE_QUOTES (1 << 2)
-
-/**
- * Within AV_ESCAPE_MODE_XML, additionally escape double quotes for double
- * quoted attributes.
- */
-#define AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES (1 << 3)
-
-
-/**
  * Escape string in src, and put the escaped string in an allocated
  * string in *dst, which must be freed with av_free().
  *
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index e12fb26..2f059c5 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -283,35 +283,6 @@
         av_bprint_chars(dstbuf, '\'', 1);
         break;
 
-    case AV_ESCAPE_MODE_XML:
-        /* escape XML non-markup character data as per 2.4 by default: */
-        /*  [^<&]* - ([^<&]* ']]>' [^<&]*) */
-
-        /* additionally, given one of the AV_ESCAPE_FLAG_XML_* flags, */
-        /* escape those specific characters as required. */
-        for (; *src; src++) {
-            switch (*src) {
-            case '&' : av_bprintf(dstbuf, "%s", "&amp;");  break;
-            case '<' : av_bprintf(dstbuf, "%s", "&lt;");   break;
-            case '>' : av_bprintf(dstbuf, "%s", "&gt;");   break;
-            case '\'':
-                if (!(flags & AV_ESCAPE_FLAG_XML_SINGLE_QUOTES))
-                    goto XML_DEFAULT_HANDLING;
-
-                av_bprintf(dstbuf, "%s", "&apos;");
-                break;
-            case '"' :
-                if (!(flags & AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES))
-                    goto XML_DEFAULT_HANDLING;
-
-                av_bprintf(dstbuf, "%s", "&quot;");
-                break;
-XML_DEFAULT_HANDLING:
-            default: av_bprint_chars(dstbuf, *src, 1);
-            }
-        }
-        break;
-
     /* case AV_ESCAPE_MODE_BACKSLASH or unknown mode */
     default:
         /* \-escape characters */
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 858633e..d67b4bb 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -26,7 +26,7 @@
 #include "mem.h"
 #include "thread.h"
 
-AVBufferRef *av_buffer_create(uint8_t *data, buffer_size_t size,
+AVBufferRef *av_buffer_create(uint8_t *data, int size,
                               void (*free)(void *opaque, uint8_t *data),
                               void *opaque, int flags)
 {
@@ -64,7 +64,7 @@
     av_free(data);
 }
 
-AVBufferRef *av_buffer_alloc(buffer_size_t size)
+AVBufferRef *av_buffer_alloc(int size)
 {
     AVBufferRef *ret = NULL;
     uint8_t    *data = NULL;
@@ -80,7 +80,7 @@
     return ret;
 }
 
-AVBufferRef *av_buffer_allocz(buffer_size_t size)
+AVBufferRef *av_buffer_allocz(int size)
 {
     AVBufferRef *ret = av_buffer_alloc(size);
     if (!ret)
@@ -166,7 +166,7 @@
     return 0;
 }
 
-int av_buffer_realloc(AVBufferRef **pbuf, buffer_size_t size)
+int av_buffer_realloc(AVBufferRef **pbuf, int size)
 {
     AVBufferRef *buf = *pbuf;
     uint8_t *tmp;
@@ -242,8 +242,8 @@
     return 0;
 }
 
-AVBufferPool *av_buffer_pool_init2(buffer_size_t size, void *opaque,
-                                   AVBufferRef* (*alloc)(void *opaque, buffer_size_t size),
+AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
+                                   AVBufferRef* (*alloc)(void *opaque, int size),
                                    void (*pool_free)(void *opaque))
 {
     AVBufferPool *pool = av_mallocz(sizeof(*pool));
@@ -263,7 +263,7 @@
     return pool;
 }
 
-AVBufferPool *av_buffer_pool_init(buffer_size_t size, AVBufferRef* (*alloc)(buffer_size_t size))
+AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size))
 {
     AVBufferPool *pool = av_mallocz(sizeof(*pool));
     if (!pool)
@@ -279,7 +279,11 @@
     return pool;
 }
 
-static void buffer_pool_flush(AVBufferPool *pool)
+/*
+ * This function gets called when the pool has been uninited and
+ * all the buffers returned to it.
+ */
+static void buffer_pool_free(AVBufferPool *pool)
 {
     while (pool->pool) {
         BufferPoolEntry *buf = pool->pool;
@@ -288,15 +292,6 @@
         buf->free(buf->opaque, buf->data);
         av_freep(&buf);
     }
-}
-
-/*
- * This function gets called when the pool has been uninited and
- * all the buffers returned to it.
- */
-static void buffer_pool_free(AVBufferPool *pool)
-{
-    buffer_pool_flush(pool);
     ff_mutex_destroy(&pool->mutex);
 
     if (pool->pool_free)
@@ -314,10 +309,6 @@
     pool   = *ppool;
     *ppool = NULL;
 
-    ff_mutex_lock(&pool->mutex);
-    buffer_pool_flush(pool);
-    ff_mutex_unlock(&pool->mutex);
-
     if (atomic_fetch_sub_explicit(&pool->refcount, 1, memory_order_acq_rel) == 1)
         buffer_pool_free(pool);
 }
diff --git a/libavutil/buffer.h b/libavutil/buffer.h
index 241a80e..fd4e381 100644
--- a/libavutil/buffer.h
+++ b/libavutil/buffer.h
@@ -25,11 +25,8 @@
 #ifndef AVUTIL_BUFFER_H
 #define AVUTIL_BUFFER_H
 
-#include <stddef.h>
 #include <stdint.h>
 
-#include "version.h"
-
 /**
  * @defgroup lavu_buffer AVBuffer
  * @ingroup lavu_data
@@ -93,11 +90,7 @@
     /**
      * Size of data in bytes.
      */
-#if FF_API_BUFFER_SIZE_T
     int      size;
-#else
-    size_t   size;
-#endif
 } AVBufferRef;
 
 /**
@@ -105,21 +98,13 @@
  *
  * @return an AVBufferRef of given size or NULL when out of memory
  */
-#if FF_API_BUFFER_SIZE_T
 AVBufferRef *av_buffer_alloc(int size);
-#else
-AVBufferRef *av_buffer_alloc(size_t size);
-#endif
 
 /**
  * Same as av_buffer_alloc(), except the returned buffer will be initialized
  * to zero.
  */
-#if FF_API_BUFFER_SIZE_T
 AVBufferRef *av_buffer_allocz(int size);
-#else
-AVBufferRef *av_buffer_allocz(size_t size);
-#endif
 
 /**
  * Always treat the buffer as read-only, even when it has only one
@@ -142,11 +127,7 @@
  *
  * @return an AVBufferRef referring to data on success, NULL on failure.
  */
-#if FF_API_BUFFER_SIZE_T
 AVBufferRef *av_buffer_create(uint8_t *data, int size,
-#else
-AVBufferRef *av_buffer_create(uint8_t *data, size_t size,
-#endif
                               void (*free)(void *opaque, uint8_t *data),
                               void *opaque, int flags);
 
@@ -214,11 +195,7 @@
  * reference to it (i.e. the one passed to this function). In all other cases
  * a new buffer is allocated and the data is copied.
  */
-#if FF_API_BUFFER_SIZE_T
 int av_buffer_realloc(AVBufferRef **buf, int size);
-#else
-int av_buffer_realloc(AVBufferRef **buf, size_t size);
-#endif
 
 /**
  * Ensure dst refers to the same data as src.
@@ -285,11 +262,7 @@
  * (av_buffer_alloc()).
  * @return newly created buffer pool on success, NULL on error.
  */
-#if FF_API_BUFFER_SIZE_T
 AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));
-#else
-AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size));
-#endif
 
 /**
  * Allocate and initialize a buffer pool with a more complex allocator.
@@ -306,13 +279,8 @@
  *                  data. May be NULL.
  * @return newly created buffer pool on success, NULL on error.
  */
-#if FF_API_BUFFER_SIZE_T
 AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
                                    AVBufferRef* (*alloc)(void *opaque, int size),
-#else
-AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque,
-                                   AVBufferRef* (*alloc)(void *opaque, size_t size),
-#endif
                                    void (*pool_free)(void *opaque));
 
 /**
diff --git a/libavutil/buffer_internal.h b/libavutil/buffer_internal.h
index 0b549e3..70d2615 100644
--- a/libavutil/buffer_internal.h
+++ b/libavutil/buffer_internal.h
@@ -32,7 +32,7 @@
 
 struct AVBuffer {
     uint8_t *data; /**< data described by this buffer */
-    buffer_size_t size; /**< size of data in bytes */
+    int      size; /**< size of data in bytes */
 
     /**
      *  number of existing AVBufferRef instances referring to this buffer
@@ -89,10 +89,10 @@
      */
     atomic_uint refcount;
 
-    buffer_size_t size;
+    int size;
     void *opaque;
-    AVBufferRef* (*alloc)(buffer_size_t size);
-    AVBufferRef* (*alloc2)(void *opaque, buffer_size_t size);
+    AVBufferRef* (*alloc)(int size);
+    AVBufferRef* (*alloc2)(void *opaque, int size);
     void         (*pool_free)(void *opaque);
 };
 
diff --git a/libavutil/common.h b/libavutil/common.h
index aee353d..b9fbcc4 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -81,15 +81,6 @@
 #define FFNABS(a) ((a) <= 0 ? (a) : (-(a)))
 
 /**
- * Unsigned Absolute value.
- * This takes the absolute value of a signed int and returns it as a unsigned.
- * This also works with INT_MIN which would otherwise not be representable
- * As with many macros, this evaluates its argument twice.
- */
-#define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a))
-#define FFABS64U(a) ((a) <= 0 ? -(uint64_t)(a) : (uint64_t)(a))
-
-/**
  * Comparator.
  * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
  * if x == y. This is useful for instance in a qsort comparator callback.
@@ -115,72 +106,8 @@
 #   include "intmath.h"
 #endif
 
-#ifndef av_ceil_log2
-#   define av_ceil_log2     av_ceil_log2_c
-#endif
-#ifndef av_clip
-#   define av_clip          av_clip_c
-#endif
-#ifndef av_clip64
-#   define av_clip64        av_clip64_c
-#endif
-#ifndef av_clip_uint8
-#   define av_clip_uint8    av_clip_uint8_c
-#endif
-#ifndef av_clip_int8
-#   define av_clip_int8     av_clip_int8_c
-#endif
-#ifndef av_clip_uint16
-#   define av_clip_uint16   av_clip_uint16_c
-#endif
-#ifndef av_clip_int16
-#   define av_clip_int16    av_clip_int16_c
-#endif
-#ifndef av_clipl_int32
-#   define av_clipl_int32   av_clipl_int32_c
-#endif
-#ifndef av_clip_intp2
-#   define av_clip_intp2    av_clip_intp2_c
-#endif
-#ifndef av_clip_uintp2
-#   define av_clip_uintp2   av_clip_uintp2_c
-#endif
-#ifndef av_mod_uintp2
-#   define av_mod_uintp2    av_mod_uintp2_c
-#endif
-#ifndef av_sat_add32
-#   define av_sat_add32     av_sat_add32_c
-#endif
-#ifndef av_sat_dadd32
-#   define av_sat_dadd32    av_sat_dadd32_c
-#endif
-#ifndef av_sat_sub32
-#   define av_sat_sub32     av_sat_sub32_c
-#endif
-#ifndef av_sat_dsub32
-#   define av_sat_dsub32    av_sat_dsub32_c
-#endif
-#ifndef av_sat_add64
-#   define av_sat_add64     av_sat_add64_c
-#endif
-#ifndef av_sat_sub64
-#   define av_sat_sub64     av_sat_sub64_c
-#endif
-#ifndef av_clipf
-#   define av_clipf         av_clipf_c
-#endif
-#ifndef av_clipd
-#   define av_clipd         av_clipd_c
-#endif
-#ifndef av_popcount
-#   define av_popcount      av_popcount_c
-#endif
-#ifndef av_popcount64
-#   define av_popcount64    av_popcount64_c
-#endif
-#ifndef av_parity
-#   define av_parity        av_parity_c
-#endif
+/* Pull in unguarded fallback defines at the end of this file. */
+#include "common.h"
 
 #ifndef av_log2
 av_const int av_log2(unsigned v);
@@ -606,3 +533,75 @@
 #endif /* HAVE_AV_CONFIG_H */
 
 #endif /* AVUTIL_COMMON_H */
+
+/*
+ * The following definitions are outside the multiple inclusion guard
+ * to ensure they are immediately available in intmath.h.
+ */
+
+#ifndef av_ceil_log2
+#   define av_ceil_log2     av_ceil_log2_c
+#endif
+#ifndef av_clip
+#   define av_clip          av_clip_c
+#endif
+#ifndef av_clip64
+#   define av_clip64        av_clip64_c
+#endif
+#ifndef av_clip_uint8
+#   define av_clip_uint8    av_clip_uint8_c
+#endif
+#ifndef av_clip_int8
+#   define av_clip_int8     av_clip_int8_c
+#endif
+#ifndef av_clip_uint16
+#   define av_clip_uint16   av_clip_uint16_c
+#endif
+#ifndef av_clip_int16
+#   define av_clip_int16    av_clip_int16_c
+#endif
+#ifndef av_clipl_int32
+#   define av_clipl_int32   av_clipl_int32_c
+#endif
+#ifndef av_clip_intp2
+#   define av_clip_intp2    av_clip_intp2_c
+#endif
+#ifndef av_clip_uintp2
+#   define av_clip_uintp2   av_clip_uintp2_c
+#endif
+#ifndef av_mod_uintp2
+#   define av_mod_uintp2    av_mod_uintp2_c
+#endif
+#ifndef av_sat_add32
+#   define av_sat_add32     av_sat_add32_c
+#endif
+#ifndef av_sat_dadd32
+#   define av_sat_dadd32    av_sat_dadd32_c
+#endif
+#ifndef av_sat_sub32
+#   define av_sat_sub32     av_sat_sub32_c
+#endif
+#ifndef av_sat_dsub32
+#   define av_sat_dsub32    av_sat_dsub32_c
+#endif
+#ifndef av_sat_add64
+#   define av_sat_add64     av_sat_add64_c
+#endif
+#ifndef av_sat_sub64
+#   define av_sat_sub64     av_sat_sub64_c
+#endif
+#ifndef av_clipf
+#   define av_clipf         av_clipf_c
+#endif
+#ifndef av_clipd
+#   define av_clipd         av_clipd_c
+#endif
+#ifndef av_popcount
+#   define av_popcount      av_popcount_c
+#endif
+#ifndef av_popcount64
+#   define av_popcount64    av_popcount64_c
+#endif
+#ifndef av_parity
+#   define av_parity        av_parity_c
+#endif
diff --git a/libavutil/eval.c b/libavutil/eval.c
index d0bada9..d527f6a 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -306,7 +306,7 @@
             double d = eval_expr(p, e->param[0]);
             double d2 = eval_expr(p, e->param[1]);
             switch (e->type) {
-                case e_mod: return e->value * (d - floor(d2 ? d / d2 : d * INFINITY) * d2);
+                case e_mod: return e->value * (d - floor((!CONFIG_FTRAPV || d2) ? d / d2 : d * INFINITY) * d2);
                 case e_gcd: return e->value * av_gcd(d,d2);
                 case e_max: return e->value * (d >  d2 ?   d : d2);
                 case e_min: return e->value * (d <  d2 ?   d : d2);
@@ -317,7 +317,7 @@
                 case e_lte: return e->value * (d <= d2 ? 1.0 : 0.0);
                 case e_pow: return e->value * pow(d, d2);
                 case e_mul: return e->value * (d * d2);
-                case e_div: return e->value * (d2 ? (d / d2) : d * INFINITY);
+                case e_div: return e->value * ((!CONFIG_FTRAPV || d2 ) ? (d / d2) : d * INFINITY);
                 case e_add: return e->value * (d + d2);
                 case e_last:return e->value * d2;
                 case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 75e347b..eab51b6 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -725,7 +725,7 @@
 
 AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
                                         enum AVFrameSideDataType type,
-                                        buffer_size_t size)
+                                        int size)
 {
     AVFrameSideData *ret;
     AVBufferRef *buf = av_buffer_alloc(size);
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 7d1f8e2..392315f 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -194,7 +194,7 @@
     AV_FRAME_DATA_SEI_UNREGISTERED,
 
     /**
-     * Film grain parameters for a frame, described by AVFilmGrainParams.
+     * Film grain parameters for a frame, described by AVFilmGrainParameters.
      * Must be present for every frame which should have film grain applied.
      */
     AV_FRAME_DATA_FILM_GRAIN_PARAMS,
@@ -220,11 +220,7 @@
 typedef struct AVFrameSideData {
     enum AVFrameSideDataType type;
     uint8_t *data;
-#if FF_API_BUFFER_SIZE_T
     int      size;
-#else
-    size_t   size;
-#endif
     AVDictionary *metadata;
     AVBufferRef *buf;
 } AVFrameSideData;
@@ -917,11 +913,7 @@
  */
 AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
                                         enum AVFrameSideDataType type,
-#if FF_API_BUFFER_SIZE_T
                                         int size);
-#else
-                                        size_t size);
-#endif
 
 /**
  * Add a new side data to a frame from an existing AVBufferRef
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 3773cd9..58ffc81 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -93,7 +93,7 @@
     CHECK_CU(cu->cuCtxPopCurrent(&dummy));
 }
 
-static AVBufferRef *cuda_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *cuda_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext        *ctx = opaque;
     AVHWDeviceContext *device_ctx = ctx->device_ctx;
diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 2a3549e..c8ae58f 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -202,7 +202,7 @@
     return wrap_texture_buf(tex, 0);
 }
 
-static AVBufferRef *d3d11va_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *d3d11va_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext        *ctx = (AVHWFramesContext*)opaque;
     D3D11VAFramesContext       *s = ctx->internal->priv;
diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c
index 7a9fdbd..ceacf68 100644
--- a/libavutil/hwcontext_drm.c
+++ b/libavutil/hwcontext_drm.c
@@ -16,19 +16,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
-
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
-
-/* This was introduced in version 4.6. And may not exist all without an
- * optional package. So to prevent a hard dependency on needing the Linux
- * kernel headers to compile, make this optional. */
-#if HAVE_LINUX_DMA_BUF_H
 #include <linux/dma-buf.h>
 #include <sys/ioctl.h>
-#endif
 
 #include <drm.h>
 #include <xf86drm.h>
@@ -105,12 +97,14 @@
                             HWMapDescriptor *hwmap)
 {
     DRMMapping *map = hwmap->priv;
+    struct dma_buf_sync sync = { .flags = DMA_BUF_SYNC_END | map->sync_flags };
+    int i, ret;
 
-    for (int i = 0; i < map->nb_regions; i++) {
-#if HAVE_LINUX_DMA_BUF_H
-        struct dma_buf_sync sync = { .flags = DMA_BUF_SYNC_END | map->sync_flags };
-        ioctl(map->object[i], DMA_BUF_IOCTL_SYNC, &sync);
-#endif
+    for (i = 0; i < map->nb_regions; i++) {
+        ret = ioctl(map->object[i], DMA_BUF_IOCTL_SYNC, &sync);
+        if (ret)
+            av_log(hwfc, AV_LOG_ERROR, "Failed to issue ioctl sync to DRM object "
+                   "%d: %d.\n", map->object[i], errno);
         munmap(map->address[i], map->length[i]);
     }
 
@@ -121,9 +115,7 @@
                          AVFrame *dst, const AVFrame *src, int flags)
 {
     const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor*)src->data[0];
-#if HAVE_LINUX_DMA_BUF_H
     struct dma_buf_sync sync_start = { 0 };
-#endif
     DRMMapping *map;
     int err, i, p, plane;
     int mmap_prot;
@@ -134,18 +126,16 @@
         return AVERROR(ENOMEM);
 
     mmap_prot = 0;
-    if (flags & AV_HWFRAME_MAP_READ)
+    if (flags & AV_HWFRAME_MAP_READ) {
         mmap_prot |= PROT_READ;
-    if (flags & AV_HWFRAME_MAP_WRITE)
-        mmap_prot |= PROT_WRITE;
-
-#if HAVE_LINUX_DMA_BUF_H
-    if (flags & AV_HWFRAME_MAP_READ)
         map->sync_flags |= DMA_BUF_SYNC_READ;
-    if (flags & AV_HWFRAME_MAP_WRITE)
+    }
+    if (flags & AV_HWFRAME_MAP_WRITE) {
+        mmap_prot |= PROT_WRITE;
         map->sync_flags |= DMA_BUF_SYNC_WRITE;
+    }
+
     sync_start.flags = DMA_BUF_SYNC_START | map->sync_flags;
-#endif
 
     av_assert0(desc->nb_objects <= AV_DRM_MAX_PLANES);
     for (i = 0; i < desc->nb_objects; i++) {
@@ -162,11 +152,13 @@
         map->length[i]  = desc->objects[i].size;
         map->object[i] = desc->objects[i].fd;
 
-#if HAVE_LINUX_DMA_BUF_H
-        /* We're not checking for errors here because the kernel may not
-         * support the ioctl, in which case its okay to carry on */
-        ioctl(desc->objects[i].fd, DMA_BUF_IOCTL_SYNC, &sync_start);
-#endif
+        err = ioctl(desc->objects[i].fd, DMA_BUF_IOCTL_SYNC, &sync_start);
+        if (err) {
+            err = AVERROR(errno);
+            av_log(hwfc, AV_LOG_ERROR, "Failed to issue ioctl sync to DRM object "
+                   "%d: %d.\n", desc->objects[i].fd, errno);
+            goto fail;
+        }
     }
     map->nb_regions = i;
 
diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index 33b3dc8..64366ce 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -124,7 +124,7 @@
     // released in dxva2_frames_uninit()
 }
 
-static AVBufferRef *dxva2_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *dxva2_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext      *ctx = (AVHWFramesContext*)opaque;
     DXVA2FramesContext       *s = ctx->internal->priv;
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index ee81460..cd8638a 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1617,7 +1617,7 @@
     av_free(desc);
 }
 
-static AVBufferRef *opencl_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *opencl_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext      *hwfc = opaque;
     AVOpenCLDeviceContext *hwctx = hwfc->device_ctx->hwctx;
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 30b0d81..35a944f 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -194,7 +194,7 @@
 {
 }
 
-static AVBufferRef *qsv_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *qsv_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext    *ctx = (AVHWFramesContext*)opaque;
     QSVFramesContext       *s = ctx->internal->priv;
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 4b81bd1..2227d6e 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -464,7 +464,7 @@
     }
 }
 
-static AVBufferRef *vaapi_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *vaapi_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext     *hwfc = opaque;
     VAAPIFramesContext     *ctx = hwfc->internal->priv;
diff --git a/libavutil/hwcontext_vdpau.c b/libavutil/hwcontext_vdpau.c
index a6fd712..8f014ea 100644
--- a/libavutil/hwcontext_vdpau.c
+++ b/libavutil/hwcontext_vdpau.c
@@ -225,7 +225,7 @@
     device_priv->surf_destroy(surf);
 }
 
-static AVBufferRef *vdpau_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *vdpau_pool_alloc(void *opaque, int size)
 {
     AVHWFramesContext             *ctx = opaque;
     VDPAUFramesContext           *priv = ctx->internal->priv;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2e3faaa..d4ff4ae 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1693,7 +1693,7 @@
     }
 }
 
-static AVBufferRef *vulkan_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *vulkan_pool_alloc(void *opaque, int size)
 {
     int err;
     AVVkFrame *f;
@@ -2009,7 +2009,7 @@
 }
 
 static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **frame,
-                                          const AVFrame *src)
+                                          AVDRMFrameDescriptor *desc)
 {
     int err = 0;
     VkResult ret;
@@ -2020,7 +2020,6 @@
     VulkanDevicePriv *p = ctx->internal->priv;
     VulkanFramesPriv *fp = hwfc->internal->priv;
     AVVulkanFramesContext *frames_hwctx = hwfc->hwctx;
-    const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)src->data[0];
     const int has_modifiers = !!(p->extensions & EXT_DRM_MODIFIER_FLAGS);
     VkSubresourceLayout plane_data[AV_NUM_DATA_POINTERS] = { 0 };
     VkBindImageMemoryInfo bind_info[AV_NUM_DATA_POINTERS] = { 0 };
@@ -2086,7 +2085,7 @@
         };
 
         get_plane_wh(&create_info.extent.width, &create_info.extent.height,
-                     hwfc->sw_format, src->width, src->height, i);
+                     hwfc->sw_format, hwfc->width, hwfc->height, i);
 
         for (int j = 0; j < planes; j++) {
             plane_data[j].offset     = desc->layers[i].planes[j].offset;
@@ -2247,7 +2246,9 @@
     AVVkFrame *f;
     VulkanMapping *map = NULL;
 
-    if ((err = vulkan_map_from_drm_frame_desc(hwfc, &f, src)))
+    err = vulkan_map_from_drm_frame_desc(hwfc, &f,
+                                         (AVDRMFrameDescriptor *)src->data[0]);
+    if (err)
         return err;
 
     /* The unmapping function will free this */
diff --git a/libavutil/internal.h b/libavutil/internal.h
index ca8d93c..7c74549 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -43,6 +43,7 @@
 #include "cpu.h"
 #include "dict.h"
 #include "macros.h"
+#include "mem.h"
 #include "pixfmt.h"
 #include "version.h"
 
@@ -91,6 +92,10 @@
     type av_##name##_get_##field(const str *s) { return s->field; } \
     void av_##name##_set_##field(str *s, type v) { s->field = v; }
 
+// Some broken preprocessors need a second expansion
+// to be forced to tokenize __VA_ARGS__
+#define E1(x) x
+
 /* Check if the hard coded offset of a struct member still matches reality.
  * Induce a compilation failure if not.
  */
@@ -98,6 +103,39 @@
         int x_##o[offsetof(s, m) == o? 1: -1];         \
     }
 
+#define LOCAL_ALIGNED_A(a, t, v, s, o, ...)             \
+    uint8_t la_##v[sizeof(t s o) + (a)];                \
+    t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
+
+#define LOCAL_ALIGNED_D(a, t, v, s, o, ...)             \
+    DECLARE_ALIGNED(a, t, la_##v) s o;                  \
+    t (*v) o = la_##v
+
+#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__)
+
+#if HAVE_LOCAL_ALIGNED
+#   define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,))
+#else
+#   define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,))
+#endif
+
+#if HAVE_LOCAL_ALIGNED
+#   define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
+#else
+#   define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,))
+#endif
+
+#if HAVE_LOCAL_ALIGNED
+#   define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
+#else
+#   define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,))
+#endif
+
+#if HAVE_LOCAL_ALIGNED
+#   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,))
+#else
+#   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
+#endif
 
 #define FF_ALLOC_TYPED_ARRAY(p, nelem)  (p = av_malloc_array(nelem, sizeof(*p)))
 #define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, sizeof(*p)))
@@ -307,11 +345,4 @@
 #define FF_PSEUDOPAL 0
 #endif
 
-// Temporary typedef to simplify porting all AVBufferRef users to size_t
-#if FF_API_BUFFER_SIZE_T
-typedef int buffer_size_t;
-#else
-typedef size_t buffer_size_t;
-#endif
-
 #endif /* AVUTIL_INTERNAL_H */
diff --git a/libavutil/lls.h b/libavutil/lls.h
index 5f84920..1a276d5 100644
--- a/libavutil/lls.h
+++ b/libavutil/lls.h
@@ -24,7 +24,7 @@
 #define AVUTIL_LLS_H
 
 #include "macros.h"
-#include "mem_internal.h"
+#include "mem.h"
 #include "version.h"
 
 #define MAX_VARS 32
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 2de2b39..da0fc17 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -148,7 +148,7 @@
 {
     int64_t a = tb_a.num * (int64_t)tb_b.den;
     int64_t b = tb_b.num * (int64_t)tb_a.den;
-    if ((FFABS64U(ts_a)|a|FFABS64U(ts_b)|b) <= INT_MAX)
+    if ((FFABS(ts_a)|a|FFABS(ts_b)|b) <= INT_MAX)
         return (ts_a*a > ts_b*b) - (ts_a*a < ts_b*b);
     if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b)
         return -1;
diff --git a/libavutil/mem.h b/libavutil/mem.h
index e21a1fe..5fb1a02 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -33,7 +33,6 @@
 #include "attributes.h"
 #include "error.h"
 #include "avutil.h"
-#include "version.h"
 
 /**
  * @addtogroup lavu_mem
@@ -50,10 +49,6 @@
  * dealing with memory consistently possible on all platforms.
  *
  * @{
- */
-
-#if FF_API_DECLARE_ALIGNED
-/**
  *
  * @defgroup lavu_mem_macros Alignment Macros
  * Helper macros for declaring aligned variables.
@@ -130,7 +125,6 @@
 /**
  * @}
  */
-#endif
 
 /**
  * @defgroup lavu_mem_attrs Function Attributes
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
index ee2575c..6fdbcb0 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -21,120 +21,8 @@
 #ifndef AVUTIL_MEM_INTERNAL_H
 #define AVUTIL_MEM_INTERNAL_H
 
-#include "config.h"
-
-#include <stdint.h>
-
 #include "avassert.h"
 #include "mem.h"
-#include "version.h"
-
-#if !FF_API_DECLARE_ALIGNED
-/**
- * @def DECLARE_ALIGNED(n,t,v)
- * Declare a variable that is aligned in memory.
- *
- * @code{.c}
- * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42;
- * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128];
- *
- * // The default-alignment equivalent would be
- * uint16_t aligned_int = 42;
- * uint8_t aligned_array[128];
- * @endcode
- *
- * @param n Minimum alignment in bytes
- * @param t Type of the variable (or array element)
- * @param v Name of the variable
- */
-
-/**
- * @def DECLARE_ASM_ALIGNED(n,t,v)
- * Declare an aligned variable appropriate for use in inline assembly code.
- *
- * @code{.c}
- * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
- * @endcode
- *
- * @param n Minimum alignment in bytes
- * @param t Type of the variable (or array element)
- * @param v Name of the variable
- */
-
-/**
- * @def DECLARE_ASM_CONST(n,t,v)
- * Declare a static constant aligned variable appropriate for use in inline
- * assembly code.
- *
- * @code{.c}
- * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
- * @endcode
- *
- * @param n Minimum alignment in bytes
- * @param t Type of the variable (or array element)
- * @param v Name of the variable
- */
-
-#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
-    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
-    #define DECLARE_ASM_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
-    #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
-#elif defined(__DJGPP__)
-    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (FFMIN(n, 16)))) v
-    #define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
-    #define DECLARE_ASM_CONST(n,t,v)    static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
-#elif defined(__GNUC__) || defined(__clang__)
-    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
-    #define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned (n))) v
-    #define DECLARE_ASM_CONST(n,t,v)    static const t av_used __attribute__ ((aligned (n))) v
-#elif defined(_MSC_VER)
-    #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
-    #define DECLARE_ASM_ALIGNED(n,t,v)  __declspec(align(n)) t v
-    #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
-#else
-    #define DECLARE_ALIGNED(n,t,v)      t v
-    #define DECLARE_ASM_ALIGNED(n,t,v)  t v
-    #define DECLARE_ASM_CONST(n,t,v)    static const t v
-#endif
-#endif
-
-// Some broken preprocessors need a second expansion
-// to be forced to tokenize __VA_ARGS__
-#define E1(x) x
-
-#define LOCAL_ALIGNED_A(a, t, v, s, o, ...)             \
-    uint8_t la_##v[sizeof(t s o) + (a)];                \
-    t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
-
-#define LOCAL_ALIGNED_D(a, t, v, s, o, ...)             \
-    DECLARE_ALIGNED(a, t, la_##v) s o;                  \
-    t (*v) o = la_##v
-
-#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__)
-
-#if HAVE_LOCAL_ALIGNED
-#   define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,))
-#else
-#   define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,))
-#endif
-
-#if HAVE_LOCAL_ALIGNED
-#   define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
-#else
-#   define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,))
-#endif
-
-#if HAVE_LOCAL_ALIGNED
-#   define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
-#else
-#   define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,))
-#endif
-
-#if HAVE_LOCAL_ALIGNED
-#   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,))
-#else
-#   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
-#endif
 
 static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
 {
diff --git a/libavutil/mips/mmiutils.h b/libavutil/mips/mmiutils.h
index 6a82caa..8f692e8 100644
--- a/libavutil/mips/mmiutils.h
+++ b/libavutil/mips/mmiutils.h
@@ -25,8 +25,6 @@
 #define AVUTIL_MIPS_MMIUTILS_H
 
 #include "config.h"
-
-#include "libavutil/mem_internal.h"
 #include "libavutil/mips/asmdefs.h"
 
 #if HAVE_LOONGSON2
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 7f678cd..167e822 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -736,14 +736,12 @@
     if (*q)
         return AVERROR(EINVAL);
 
-    if (INT64_MAX / suffix < t || t < INT64_MIN / suffix)
+    if (INT64_MAX / suffix < t)
         return AVERROR(ERANGE);
     t *= suffix;
     if (INT64_MAX - microseconds < t)
         return AVERROR(ERANGE);
     t += microseconds;
-    if (t == INT64_MIN && negative)
-        return AVERROR(ERANGE);
     *timeval = negative ? -t : t;
     return 0;
 }
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 2a91946..8274713 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2702,13 +2702,11 @@
     if(desc->nb_components == 1 || desc->nb_components == 2)
         return FF_COLOR_GRAY;
 
-    if (desc->name) {
-        if (av_strstart(desc->name, "yuvj", NULL))
-            return FF_COLOR_YUV_JPEG;
+    if(desc->name && !strncmp(desc->name, "yuvj", 4))
+        return FF_COLOR_YUV_JPEG;
 
-        if (av_strstart(desc->name, "xyz", NULL))
-            return FF_COLOR_XYZ;
-    }
+    if(desc->name && !strncmp(desc->name, "xyz", 3))
+        return FF_COLOR_XYZ;
 
     if(desc->flags & AV_PIX_FMT_FLAG_RGB)
         return  FF_COLOR_RGB;
@@ -2909,7 +2907,8 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
-        if (av_strstart(name, color_range_names[i], NULL))
+        size_t len = strlen(color_range_names[i]);
+        if (!strncmp(color_range_names[i], name, len))
             return i;
     }
 
@@ -2927,10 +2926,13 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) {
+        size_t len;
+
         if (!color_primaries_names[i])
             continue;
 
-        if (av_strstart(name, color_primaries_names[i], NULL))
+        len = strlen(color_primaries_names[i]);
+        if (!strncmp(color_primaries_names[i], name, len))
             return i;
     }
 
@@ -2948,10 +2950,13 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) {
+        size_t len;
+
         if (!color_transfer_names[i])
             continue;
 
-        if (av_strstart(name, color_transfer_names[i], NULL))
+        len = strlen(color_transfer_names[i]);
+        if (!strncmp(color_transfer_names[i], name, len))
             return i;
     }
 
@@ -2969,10 +2974,13 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) {
+        size_t len;
+
         if (!color_space_names[i])
             continue;
 
-        if (av_strstart(name, color_space_names[i], NULL))
+        len = strlen(color_space_names[i]);
+        if (!strncmp(color_space_names[i], name, len))
             return i;
     }
 
@@ -2990,10 +2998,13 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) {
+        size_t len;
+
         if (!chroma_location_names[i])
             continue;
 
-        if (av_strstart(name, chroma_location_names[i], NULL))
+        len = strlen(chroma_location_names[i]);
+        if (!strncmp(chroma_location_names[i], name, len))
             return i;
     }
 
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index ed66344..4be55f3 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -18,7 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "avstring.h"
 #include "mem.h"
 #include "spherical.h"
 
@@ -52,7 +51,7 @@
     *bottom = orig_height - height - *top;
 }
 
-static const char *const spherical_projection_names[] = {
+static const char *spherical_projection_names[] = {
     [AV_SPHERICAL_EQUIRECTANGULAR]      = "equirectangular",
     [AV_SPHERICAL_CUBEMAP]              = "cubemap",
     [AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
@@ -71,7 +70,8 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
-        if (av_strstart(name, spherical_projection_names[i], NULL))
+        size_t len = strlen(spherical_projection_names[i]);
+        if (!strncmp(spherical_projection_names[i], name, len))
             return i;
     }
 
diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index 279fcc1..6edcdb1 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
 #include <string.h>
 
-#include "avstring.h"
 #include "common.h"
 #include "mem.h"
 #include "stereo3d.h"
@@ -67,7 +67,8 @@
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(stereo3d_type_names); i++) {
-        if (av_strstart(name, stereo3d_type_names[i], NULL))
+        size_t len = strlen(stereo3d_type_names[i]);
+        if (!strncmp(stereo3d_type_names[i], name, len))
             return i;
     }
 
diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c
index 53d0e4a..00fdb05 100644
--- a/libavutil/tests/aes_ctr.c
+++ b/libavutil/tests/aes_ctr.c
@@ -18,7 +18,6 @@
 
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/aes_ctr.h"
 
 static const DECLARE_ALIGNED(8, uint8_t, plain)[] = {
diff --git a/libavutil/tests/des.c b/libavutil/tests/des.c
index 8fa88df..f2a5c34 100644
--- a/libavutil/tests/des.c
+++ b/libavutil/tests/des.c
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/timer.h"
 
 #include "libavutil/des.c"
diff --git a/libavutil/tests/lls.c b/libavutil/tests/lls.c
index 4c14c0c..965b0f4 100644
--- a/libavutil/tests/lls.c
+++ b/libavutil/tests/lls.c
@@ -22,7 +22,6 @@
 #include "libavutil/internal.h"
 #include "libavutil/lfg.h"
 #include "libavutil/lls.h"
-#include "libavutil/mem_internal.h"
 
 int main(void)
 {
diff --git a/libavutil/time.c b/libavutil/time.c
index 740afc4..afa6658 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -57,7 +57,7 @@
 {
 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
 #ifdef __APPLE__
-    if (&clock_gettime)
+    if (clock_gettime)
 #endif
     {
         struct timespec ts;
@@ -72,7 +72,7 @@
 {
 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
 #ifdef __APPLE__
-    if (!&clock_gettime)
+    if (!clock_gettime)
         return 0;
 #endif
     return 1;
diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index b1b504e..c1fa445 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -46,7 +46,7 @@
     d = framenum / frames_per_10mins;
     m = framenum % frames_per_10mins;
 
-    return framenum + 9U * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
+    return framenum + 9 * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
 }
 
 uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
diff --git a/libavutil/tx.c b/libavutil/tx.c
index 1161df3..3b0568a 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -91,7 +91,7 @@
     return 0;
 }
 
-int ff_tx_gen_ptwo_revtab(AVTXContext *s, int invert_lookup)
+int ff_tx_gen_ptwo_revtab(AVTXContext *s)
 {
     const int m = s->m, inv = s->inv;
 
@@ -101,48 +101,12 @@
     /* Default */
     for (int i = 0; i < m; i++) {
         int k = -split_radix_permutation(i, m, inv) & (m - 1);
-        if (invert_lookup)
-            s->revtab[i] = k;
-        else
-            s->revtab[k] = i;
+        s->revtab[k] = i;
     }
 
     return 0;
 }
 
-int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s)
-{
-    int nb_inplace_idx = 0;
-
-    if (!(s->inplace_idx = av_malloc(s->m*sizeof(*s->inplace_idx))))
-        return AVERROR(ENOMEM);
-
-    for (int src = 1; src < s->m; src++) {
-        int dst = s->revtab[src];
-        int found = 0;
-
-        if (dst <= src)
-            continue;
-
-        do {
-            for (int j = 0; j < nb_inplace_idx; j++) {
-                if (dst == s->inplace_idx[j]) {
-                    found = 1;
-                    break;
-                }
-            }
-            dst = s->revtab[dst];
-        } while (dst != src && !found);
-
-        if (!found)
-            s->inplace_idx[nb_inplace_idx++] = src;
-    }
-
-    s->inplace_idx[nb_inplace_idx++] = 0;
-
-    return 0;
-}
-
 av_cold void av_tx_uninit(AVTXContext **ctx)
 {
     if (!(*ctx))
@@ -151,7 +115,6 @@
     av_free((*ctx)->pfatab);
     av_free((*ctx)->exptab);
     av_free((*ctx)->revtab);
-    av_free((*ctx)->inplace_idx);
     av_free((*ctx)->tmp);
 
     av_freep(ctx);
diff --git a/libavutil/tx.h b/libavutil/tx.h
index bfc0c7f..418e8ec 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -43,7 +43,6 @@
      * The stride parameter is ignored.
      */
     AV_TX_FLOAT_FFT = 0,
-
     /**
      * Standard MDCT with sample data type of float and a scale type of
      * float. Length is the frame size, not the window size (which is 2x frame)
@@ -52,27 +51,21 @@
      * For inverse transforms, the stride specifies the spacing between each
      * sample in the input array in bytes. The output will be a flat array.
      * Stride must be a non-zero multiple of sizeof(float).
-     * NOTE: the inverse transform is half-length, meaning the output will not
-     * contain redundant data. This is what most codecs work with.
      */
     AV_TX_FLOAT_MDCT = 1,
-
     /**
      * Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble.
      */
     AV_TX_DOUBLE_FFT = 2,
-
     /**
      * Same as AV_TX_FLOAT_MDCT with data and scale type of double.
      * Stride must be a non-zero multiple of sizeof(double).
      */
     AV_TX_DOUBLE_MDCT = 3,
-
     /**
      * Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32.
      */
     AV_TX_INT32_FFT = 4,
-
     /**
      * Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of float.
      * Only scale values less than or equal to 1.0 are supported.
@@ -99,20 +92,9 @@
 typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride);
 
 /**
- * Flags for av_tx_init()
- */
-enum AVTXFlags {
-    /**
-     * Performs an in-place transformation on the input. The output argument
-     * of av_tn_fn() MUST match the input. May be unsupported or slower for some
-     * transform types.
-     */
-    AV_TX_INPLACE = 1ULL << 0,
-};
-
-/**
  * Initialize a transform context with the given configuration
- * (i)MDCTs with an odd length are currently not supported.
+ * Currently power of two lengths from 2 to 131072 are supported, along with
+ * any length decomposable to a power of two and either 3, 5 or 15.
  *
  * @param ctx the context to allocate, will be NULL on error
  * @param tx pointer to the transform function pointer to set
@@ -120,7 +102,7 @@
  * @param inv whether to do an inverse or a forward transform
  * @param len the size of the transform in samples
  * @param scale pointer to the value to scale the output if supported by type
- * @param flags a bitmask of AVTXFlags or 0
+ * @param flags currently unused
  *
  * @return 0 on success, negative error code on failure
  */
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index e2f4314..e0d980a 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -23,7 +23,6 @@
 #include <stddef.h>
 #include "thread.h"
 #include "mem.h"
-#include "mem_internal.h"
 #include "avassert.h"
 #include "attributes.h"
 
@@ -58,7 +57,6 @@
         (dim) = (are) * (bim) - (aim) * (bre);                                 \
     } while (0)
 
-#define UNSCALE(x) (x)
 #define RESCALE(x) (x)
 
 #define FOLD(a, b) ((a) + (b))
@@ -86,8 +84,7 @@
         (dim)   = (int)(((accu) + 0x40000000) >> 31);                          \
     } while (0)
 
-#define UNSCALE(x) ((double)x/2147483648.0)
-#define RESCALE(x) (av_clip64(lrintf((x) * 2147483648.0), INT32_MIN, INT32_MAX))
+#define RESCALE(x) (lrintf((x) * 2147483648.0))
 
 #define FOLD(x, y) ((int)((x) + (unsigned)(y) + 32) >> 6)
 
@@ -106,25 +103,21 @@
 
 /* Used by asm, reorder with care */
 struct AVTXContext {
-    int n;              /* Non-power-of-two part */
-    int m;              /* Power-of-two part */
-    int inv;            /* Is inverse */
+    int n;              /* Nptwo part */
+    int m;              /* Ptwo part */
+    int inv;            /* Is inverted */
     int type;           /* Type */
-    uint64_t flags;     /* Flags */
-    double scale;       /* Scale */
 
     FFTComplex *exptab; /* MDCT exptab */
     FFTComplex *tmp;    /* Temporary buffer needed for all compound transforms */
     int        *pfatab; /* Input/Output mapping for compound transforms */
     int        *revtab; /* Input mapping for power of two transforms */
-    int   *inplace_idx; /* Required indices to revtab for in-place transforms */
 };
 
 /* Shared functions */
 int ff_tx_type_is_mdct(enum AVTXType type);
 int ff_tx_gen_compound_mapping(AVTXContext *s);
-int ff_tx_gen_ptwo_revtab(AVTXContext *s, int invert_lookup);
-int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s);
+int ff_tx_gen_ptwo_revtab(AVTXContext *s);
 
 /* Also used by SIMD init */
 static inline int split_radix_permutation(int i, int n, int inverse)
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index a436f42..7f4ca2f 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -392,55 +392,11 @@
     FFTComplex *in = _in;
     FFTComplex *out = _out;
     int m = s->m, mb = av_log2(m);
-
-    if (s->flags & AV_TX_INPLACE) {
-        FFTComplex tmp;
-        int src, dst, *inplace_idx = s->inplace_idx;
-
-        src = *inplace_idx++;
-
-        do {
-            tmp = out[src];
-            dst = s->revtab[src];
-            do {
-                FFSWAP(FFTComplex, tmp, out[dst]);
-                dst = s->revtab[dst];
-            } while (dst != src); /* Can be > as well, but is less predictable */
-            out[dst] = tmp;
-        } while ((src = *inplace_idx++));
-    } else {
-        for (int i = 0; i < m; i++)
-            out[i] = in[s->revtab[i]];
-    }
-
+    for (int i = 0; i < m; i++)
+        out[s->revtab[i]] = in[i];
     fft_dispatch[mb](out);
 }
 
-static void naive_fft(AVTXContext *s, void *_out, void *_in,
-                      ptrdiff_t stride)
-{
-    FFTComplex *in = _in;
-    FFTComplex *out = _out;
-    const int n = s->n;
-    double phase = s->inv ? 2.0*M_PI/n : -2.0*M_PI/n;
-
-    for(int i = 0; i < n; i++) {
-        FFTComplex tmp = { 0 };
-        for(int j = 0; j < n; j++) {
-            const double factor = phase*i*j;
-            const FFTComplex mult = {
-                RESCALE(cos(factor)),
-                RESCALE(sin(factor)),
-            };
-            FFTComplex res;
-            CMUL3(res, in[j], mult);
-            tmp.re += res.re;
-            tmp.im += res.im;
-        }
-        out[i] = tmp;
-    }
-}
-
 #define DECL_COMP_IMDCT(N)                                                     \
 static void compound_imdct_##N##xM(AVTXContext *s, void *_dst, void *_src,     \
                                    ptrdiff_t stride)                           \
@@ -597,57 +553,6 @@
     }
 }
 
-static void naive_imdct(AVTXContext *s, void *_dst, void *_src,
-                        ptrdiff_t stride)
-{
-    int len = s->n;
-    int len2 = len*2;
-    FFTSample *src = _src;
-    FFTSample *dst = _dst;
-    double scale = s->scale;
-    const double phase = M_PI/(4.0*len2);
-
-    stride /= sizeof(*src);
-
-    for (int i = 0; i < len; i++) {
-        double sum_d = 0.0;
-        double sum_u = 0.0;
-        double i_d = phase * (4*len  - 2*i - 1);
-        double i_u = phase * (3*len2 + 2*i + 1);
-        for (int j = 0; j < len2; j++) {
-            double a = (2 * j + 1);
-            double a_d = cos(a * i_d);
-            double a_u = cos(a * i_u);
-            double val = UNSCALE(src[j*stride]);
-            sum_d += a_d * val;
-            sum_u += a_u * val;
-        }
-        dst[i +   0] = RESCALE( sum_d*scale);
-        dst[i + len] = RESCALE(-sum_u*scale);
-    }
-}
-
-static void naive_mdct(AVTXContext *s, void *_dst, void *_src,
-                       ptrdiff_t stride)
-{
-    int len = s->n*2;
-    FFTSample *src = _src;
-    FFTSample *dst = _dst;
-    double scale = s->scale;
-    const double phase = M_PI/(4.0*len);
-
-    stride /= sizeof(*dst);
-
-    for (int i = 0; i < len; i++) {
-        double sum = 0.0;
-        for (int j = 0; j < len*2; j++) {
-            int a = (2*j + 1 + len) * (2*i + 1);
-            sum += UNSCALE(src[j]) * cos(a * phase);
-        }
-        dst[i*stride] = RESCALE(sum*scale);
-    }
-}
-
 static int gen_mdct_exptab(AVTXContext *s, int len4, double scale)
 {
     const double theta = (scale < 0 ? len4 : 0) + 1.0/8.0;
@@ -670,13 +575,11 @@
                                  const void *scale, uint64_t flags)
 {
     const int is_mdct = ff_tx_type_is_mdct(type);
-    int err, l, n = 1, m = 1, max_ptwo = 1 << (FF_ARRAY_ELEMS(fft_dispatch) - 1);
+    int err, n = 1, m = 1, max_ptwo = 1 << (FF_ARRAY_ELEMS(fft_dispatch) - 1);
 
     if (is_mdct)
         len >>= 1;
 
-    l = len;
-
 #define CHECK_FACTOR(DST, FACTOR, SRC)                                         \
     if (DST == 1 && !(SRC % FACTOR)) {                                         \
         DST = FACTOR;                                                          \
@@ -697,27 +600,13 @@
     s->m = m;
     s->inv = inv;
     s->type = type;
-    s->flags = flags;
 
-    /* If we weren't able to split the length into factors we can handle,
-     * resort to using the naive and slow FT. This also filters out
-     * direct 3, 5 and 15 transforms as they're too niche. */
+    /* Filter out direct 3, 5 and 15 transforms, too niche */
     if (len > 1 || m == 1) {
-        if (is_mdct && (l & 1)) /* Odd (i)MDCTs are not supported yet */
-            return AVERROR(ENOSYS);
-        if (flags & AV_TX_INPLACE) /* Neither are in-place naive transforms */
-            return AVERROR(ENOSYS);
-        s->n = l;
-        s->m = 1;
-        *tx = naive_fft;
-        if (is_mdct) {
-            s->scale = *((SCALE_TYPE *)scale);
-            *tx = inv ? naive_imdct : naive_mdct;
-        }
-        return 0;
-    }
-
-    if (n > 1 && m > 1) { /* 2D transform case */
+        av_log(NULL, AV_LOG_ERROR, "Unsupported transform size: n = %i, "
+               "m = %i, residual = %i!\n", n, m, len);
+        return AVERROR(EINVAL);
+    } else if (n > 1 && m > 1) { /* 2D transform case */
         if ((err = ff_tx_gen_compound_mapping(s)))
             return err;
         if (!(s->tmp = av_malloc(n*m*sizeof(*s->tmp))))
@@ -738,14 +627,7 @@
     if (n != 1)
         init_cos_tabs(0);
     if (m != 1) {
-        if ((err = ff_tx_gen_ptwo_revtab(s, n == 1 && !is_mdct && !(flags & AV_TX_INPLACE))))
-            return err;
-        if (flags & AV_TX_INPLACE) {
-            if (is_mdct) /* In-place MDCTs are not supported yet */
-                return AVERROR(ENOSYS);
-            if ((err = ff_tx_gen_ptwo_inplace_revtab_idx(s)))
-                return err;
-        }
+        ff_tx_gen_ptwo_revtab(s);
         for (int i = 4; i <= av_log2(m); i++)
             init_cos_tabs(i);
     }
diff --git a/libavutil/version.h b/libavutil/version.h
index 9a290d5..9b311b5 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  68
+#define LIBAVUTIL_VERSION_MINOR  62
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -132,15 +132,9 @@
 #ifndef FF_API_CHILD_CLASS_NEXT
 #define FF_API_CHILD_CLASS_NEXT         (LIBAVUTIL_VERSION_MAJOR < 57)
 #endif
-#ifndef FF_API_BUFFER_SIZE_T
-#define FF_API_BUFFER_SIZE_T            (LIBAVUTIL_VERSION_MAJOR < 57)
-#endif
 #ifndef FF_API_D2STR
 #define FF_API_D2STR                    (LIBAVUTIL_VERSION_MAJOR < 58)
 #endif
-#ifndef FF_API_DECLARE_ALIGNED
-#define FF_API_DECLARE_ALIGNED          (LIBAVUTIL_VERSION_MAJOR < 58)
-#endif
 
 /**
  * @}
diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
index 635176a..c46c0f1 100644
--- a/libavutil/video_enc_params.c
+++ b/libavutil/video_enc_params.c
@@ -33,7 +33,8 @@
     size_t size;
 
     size = sizeof(*par);
-    if (nb_blocks > (SIZE_MAX - size) / sizeof(AVVideoBlockParams))
+    if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||
+        nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size)
         return NULL;
     size += sizeof(AVVideoBlockParams) * nb_blocks;
 
@@ -63,10 +64,6 @@
     par = av_video_enc_params_alloc(type, nb_blocks, &size);
     if (!par)
         return NULL;
-    if (size > INT_MAX) {
-        av_free(par);
-        return NULL;
-    }
     buf = av_buffer_create((uint8_t *)par, size, NULL, NULL, 0);
     if (!buf) {
         av_freep(&par);
diff --git a/libavutil/video_enc_params.h b/libavutil/video_enc_params.h
index fc0c3bc..e3b422d 100644
--- a/libavutil/video_enc_params.h
+++ b/libavutil/video_enc_params.h
@@ -55,14 +55,6 @@
      *   as AVVideoBlockParams.qp_delta.
      */
     AV_VIDEO_ENC_PARAMS_H264,
-
-    /*
-     * MPEG-2-compatible quantizer.
-     *
-     * Summing the frame-level qp with the per-block delta_qp gives the
-     * resulting quantizer for the block.
-     */
-    AV_VIDEO_ENC_PARAMS_MPEG2,
 };
 
 /**
diff --git a/libpostproc/postprocess_altivec_template.c b/libpostproc/postprocess_altivec_template.c
index a9d4cd2..fa6ebe2 100644
--- a/libpostproc/postprocess_altivec_template.c
+++ b/libpostproc/postprocess_altivec_template.c
@@ -21,7 +21,6 @@
  */
 
 #include "libavutil/avutil.h"
-#include "libavutil/mem_internal.h"
 
 #define ALTIVEC_TRANSPOSE_8x8_SHORT(src_a,src_b,src_c,src_d,src_e,src_f,src_g,src_h) \
     do {                                                          \
diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h
index 5d1aee3..765fdeb 100644
--- a/libpostproc/postprocess_internal.h
+++ b/libpostproc/postprocess_internal.h
@@ -30,7 +30,6 @@
 #include "libavutil/avutil.h"
 #include "libavutil/intmath.h"
 #include "libavutil/log.h"
-#include "libavutil/mem_internal.h"
 #include "postprocess.h"
 
 #define V_DEBLOCK       0x01
diff --git a/libpostproc/postprocess_template.c b/libpostproc/postprocess_template.c
index 411fc41..df1684d 100644
--- a/libpostproc/postprocess_template.c
+++ b/libpostproc/postprocess_template.c
@@ -23,7 +23,6 @@
  * mmx/mmx2/3dnow postprocess code.
  */
 
-#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 
 /* A single TEMPLATE_PP_* should be defined (to 1) when this template is
diff --git a/libswscale/output.c b/libswscale/output.c
index e855ad6..4ef436e 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -30,7 +30,6 @@
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "config.h"
 #include "rgb2rgb.h"
diff --git a/libswscale/ppc/swscale_ppc_template.c b/libswscale/ppc/swscale_ppc_template.c
index 0ffa927..aff2dd7 100644
--- a/libswscale/ppc/swscale_ppc_template.c
+++ b/libswscale/ppc/swscale_ppc_template.c
@@ -21,8 +21,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem_internal.h"
-
 static void FUNC(yuv2planeX_8_16)(const int16_t *filter, int filterSize,
                                   const int16_t **src, uint8_t *dest,
                                   const uint8_t *dither, int offset, int x)
diff --git a/libswscale/ppc/swscale_vsx.c b/libswscale/ppc/swscale_vsx.c
index 8152ce7..af8b0e1 100644
--- a/libswscale/ppc/swscale_vsx.c
+++ b/libswscale/ppc/swscale_vsx.c
@@ -28,7 +28,6 @@
 #include "libswscale/swscale_internal.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "yuv2rgb_altivec.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index 5e1033a..5365452 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -96,7 +96,6 @@
 #include "libswscale/swscale_internal.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "yuv2rgb_altivec.h"
 
@@ -284,16 +283,6 @@
  * ------------------------------------------------------------------------------
  */
 
-#if !HAVE_VSX
-static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr)
-{
-    const vector unsigned char *v_addr = (const vector unsigned char *) (addr + offset);
-    vector unsigned char align_perm = vec_lvsl(offset, addr);
-
-    return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], align_perm);
-}
-#endif /* !HAVE_VSX */
-
 #define DEFCSP420_CVT(name, out_pixels)                                       \
 static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
                             int *instrides, int srcSliceY, int srcSliceH,     \
@@ -435,13 +424,13 @@
 }
 
 #define out_abgr(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), c, b, a, ptr)
+    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), c, b, a, ptr)
 #define out_bgra(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), ptr)
+    vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255 }), ptr)
 #define out_rgba(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), ptr)
+    vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255 }), ptr)
 #define out_argb(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), a, b, c, ptr)
+    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, b, c, ptr)
 #define out_rgb24(a, b, c, ptr) vec_mstrgb24(a, b, c, ptr)
 #define out_bgr24(a, b, c, ptr) vec_mstbgr24(a, b, c, ptr)
 
diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
index 42c6980..f7385e3 100644
--- a/libswscale/rgb2rgb_template.c
+++ b/libswscale/rgb2rgb_template.c
@@ -342,6 +342,7 @@
     }
 }
 
+#if !HAVE_BIGENDIAN
 #define DEFINE_SHUFFLE_BYTES(name, a, b, c, d)                          \
 static void shuffle_bytes_##name (const uint8_t *src,                   \
                                         uint8_t *dst, int src_size)     \
@@ -359,6 +360,7 @@
 DEFINE_SHUFFLE_BYTES(1230_c, 1, 2, 3, 0)
 DEFINE_SHUFFLE_BYTES(3012_c, 3, 0, 1, 2)
 DEFINE_SHUFFLE_BYTES(3210_c, 3, 2, 1, 0)
+#endif
 
 static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
 {
@@ -967,10 +969,10 @@
 #else
     shuffle_bytes_0321 = shuffle_bytes_0321_c;
     shuffle_bytes_2103 = shuffle_bytes_2103_c;
-#endif
     shuffle_bytes_1230 = shuffle_bytes_1230_c;
     shuffle_bytes_3012 = shuffle_bytes_3012_c;
     shuffle_bytes_3210 = shuffle_bytes_3210_c;
+#endif
     rgb32tobgr16       = rgb32tobgr16_c;
     rgb32tobgr15       = rgb32tobgr15_c;
     yv12toyuy2         = yv12toyuy2_c;
diff --git a/libswscale/slice.c b/libswscale/slice.c
index d96db13..7849b70 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -158,10 +158,14 @@
                         chrY + chrH,
                         lumY + lumH};
 
+    uint8_t *const src_[4] = {src[0] + (relative ? 0 : start[0]) * stride[0],
+                              src[1] + (relative ? 0 : start[1]) * stride[1],
+                              src[2] + (relative ? 0 : start[2]) * stride[2],
+                              src[3] + (relative ? 0 : start[3]) * stride[3]};
+
     s->width = srcW;
 
-    for (i = 0; i < 4 && src[i] != NULL; ++i) {
-        uint8_t *const src_i = src[i] + (relative ? 0 : start[i]) * stride[i];
+    for (i = 0; i < 4; ++i) {
         int j;
         int first = s->plane[i].sliceY;
         int n = s->plane[i].available_lines;
@@ -171,13 +175,13 @@
         if (start[i] >= first && n >= tot_lines) {
             s->plane[i].sliceH = FFMAX(tot_lines, s->plane[i].sliceH);
             for (j = 0; j < lines; j+= 1)
-                s->plane[i].line[start[i] - first + j] = src_i +  j * stride[i];
+                s->plane[i].line[start[i] - first + j] = src_[i] +  j * stride[i];
         } else {
             s->plane[i].sliceY = start[i];
             lines = lines > n ? n : lines;
             s->plane[i].sliceH = lines;
             for (j = 0; j < lines; j+= 1)
-                s->plane[i].line[j] = src_i +  j * stride[i];
+                s->plane[i].line[j] = src_[i] +  j * stride[i];
         }
 
     }
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 12160a1..9cb7e8f 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -30,7 +30,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "config.h"
 #include "rgb2rgb.h"
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index a1de95c..d207d3b 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -29,7 +29,6 @@
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/ppc/util_altivec.h"
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index c4dd8a4..563de39 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -30,7 +30,6 @@
 #include "libavutil/cpu.h"
 #include "libavutil/avutil.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/bswap.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/avassert.h"
@@ -1806,7 +1805,7 @@
     const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
     const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
     int plane, i, j;
-    for (plane = 0; plane < 4 && dst[plane] != NULL; plane++) {
+    for (plane = 0; plane < 4; plane++) {
         int length = (plane == 0 || plane == 3) ? c->srcW  : AV_CEIL_RSHIFT(c->srcW,   c->chrDstHSubSample);
         int y =      (plane == 0 || plane == 3) ? srcSliceY: AV_CEIL_RSHIFT(srcSliceY, c->chrDstVSubSample);
         int height = (plane == 0 || plane == 3) ? srcSliceH: AV_CEIL_RSHIFT(srcSliceH, c->chrDstVSubSample);
@@ -1814,6 +1813,8 @@
         uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
         int shiftonly = plane == 1 || plane == 2 || (!c->srcRange && plane == 0);
 
+        if (!dst[plane])
+            continue;
         // ignore palette for GRAY8
         if (plane == 1 && !dst[2]) continue;
         if (!src[plane] || (plane == 1 && !src[2])) {
diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile
index bfe3833..831d535 100644
--- a/libswscale/x86/Makefile
+++ b/libswscale/x86/Makefile
@@ -13,4 +13,3 @@
                                    x86/scale.o                          \
                                    x86/rgb_2_rgb.o                      \
                                    x86/yuv_2_rgb.o                      \
-                                   x86/yuv2yuvX.o                       \
diff --git a/libswscale/x86/hscale_fast_bilinear_simd.c b/libswscale/x86/hscale_fast_bilinear_simd.c
index 850f0ad..60a2cbf 100644
--- a/libswscale/x86/hscale_fast_bilinear_simd.c
+++ b/libswscale/x86/hscale_fast_bilinear_simd.c
@@ -21,7 +21,6 @@
 #include "../swscale_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
-#include "libavutil/mem_internal.h"
 
 #define RET 0xC3 // near return opcode for x86
 #define PREFETCH "prefetchnta"
diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
index c38a953..2d6fc2a 100644
--- a/libswscale/x86/rgb2rgb.c
+++ b/libswscale/x86/rgb2rgb.c
@@ -30,8 +30,6 @@
 #include "libavutil/x86/cpu.h"
 #include "libavutil/cpu.h"
 #include "libavutil/bswap.h"
-#include "libavutil/mem_internal.h"
-
 #include "libswscale/rgb2rgb.h"
 #include "libswscale/swscale.h"
 #include "libswscale/swscale_internal.h"
@@ -40,7 +38,12 @@
 
 DECLARE_ASM_CONST(8, uint64_t, mmx_ff)       = 0x00000000000000FFULL;
 DECLARE_ASM_CONST(8, uint64_t, mmx_null)     = 0x0000000000000000ULL;
+DECLARE_ASM_CONST(8, uint64_t, mmx_one)      = 0xFFFFFFFFFFFFFFFFULL;
+DECLARE_ASM_CONST(8, uint64_t, mask32b)      = 0x000000FF000000FFULL;
+DECLARE_ASM_CONST(8, uint64_t, mask32g)      = 0x0000FF000000FF00ULL;
+DECLARE_ASM_CONST(8, uint64_t, mask32r)      = 0x00FF000000FF0000ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask32a)      = 0xFF000000FF000000ULL;
+DECLARE_ASM_CONST(8, uint64_t, mask32)       = 0x00FFFFFF00FFFFFFULL;
 DECLARE_ASM_CONST(8, uint64_t, mask3216br)   = 0x00F800F800F800F8ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask3216g)    = 0x0000FC000000FC00ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask3215g)    = 0x0000F8000000F800ULL;
@@ -51,6 +54,9 @@
 DECLARE_ASM_CONST(8, uint64_t, mask24r)      = 0x0000FF0000FF0000ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask24l)      = 0x0000000000FFFFFFULL;
 DECLARE_ASM_CONST(8, uint64_t, mask24h)      = 0x0000FFFFFF000000ULL;
+DECLARE_ASM_CONST(8, uint64_t, mask24hh)     = 0xffff000000000000ULL;
+DECLARE_ASM_CONST(8, uint64_t, mask24hhh)    = 0xffffffff00000000ULL;
+DECLARE_ASM_CONST(8, uint64_t, mask24hhhh)   = 0xffffffffffff0000ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask15b)      = 0x001F001F001F001FULL; /* 00000000 00011111  xxB */
 DECLARE_ASM_CONST(8, uint64_t, mask15rg)     = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000  RGx */
 DECLARE_ASM_CONST(8, uint64_t, mask15s)      = 0xFFE0FFE0FFE0FFE0ULL;
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index cc9e8b0..3160fed 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -27,7 +27,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/x86/cpu.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 
 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
@@ -44,6 +43,15 @@
 
 DECLARE_ASM_CONST(8, uint64_t, bF8)=       0xF8F8F8F8F8F8F8F8LL;
 DECLARE_ASM_CONST(8, uint64_t, bFC)=       0xFCFCFCFCFCFCFCFCLL;
+DECLARE_ASM_CONST(8, uint64_t, w10)=       0x0010001000100010LL;
+DECLARE_ASM_CONST(8, uint64_t, w02)=       0x0002000200020002LL;
+
+DECLARE_ASM_CONST(8, uint64_t, b16Mask)=   0x001F001F001F001FLL;
+DECLARE_ASM_CONST(8, uint64_t, g16Mask)=   0x07E007E007E007E0LL;
+DECLARE_ASM_CONST(8, uint64_t, r16Mask)=   0xF800F800F800F800LL;
+DECLARE_ASM_CONST(8, uint64_t, b15Mask)=   0x001F001F001F001FLL;
+DECLARE_ASM_CONST(8, uint64_t, g15Mask)=   0x03E003E003E003E0LL;
+DECLARE_ASM_CONST(8, uint64_t, r15Mask)=   0x7C007C007C007C00LL;
 
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A)         = 0x00FF0000FF0000FFLL;
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B)         = 0xFF0000FF0000FF00LL;
@@ -187,54 +195,87 @@
         }
     }
 }
+
+#if HAVE_MMXEXT
+static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
+                           const int16_t **src, uint8_t *dest, int dstW,
+                           const uint8_t *dither, int offset)
+{
+    if(((uintptr_t)dest) & 15){
+        yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset);
+        return;
+    }
+    filterSize--;
+#define MAIN_FUNCTION \
+        "pxor       %%xmm0, %%xmm0 \n\t" \
+        "punpcklbw  %%xmm0, %%xmm3 \n\t" \
+        "movd           %4, %%xmm1 \n\t" \
+        "punpcklwd  %%xmm1, %%xmm1 \n\t" \
+        "punpckldq  %%xmm1, %%xmm1 \n\t" \
+        "punpcklqdq %%xmm1, %%xmm1 \n\t" \
+        "psllw          $3, %%xmm1 \n\t" \
+        "paddw      %%xmm1, %%xmm3 \n\t" \
+        "psraw          $4, %%xmm3 \n\t" \
+        "movdqa     %%xmm3, %%xmm4 \n\t" \
+        "movdqa     %%xmm3, %%xmm7 \n\t" \
+        "movl           %3, %%ecx  \n\t" \
+        "mov                                 %0, %%"FF_REG_d"        \n\t"\
+        "mov                        (%%"FF_REG_d"), %%"FF_REG_S"     \n\t"\
+        ".p2align                             4             \n\t" /* FIXME Unroll? */\
+        "1:                                                 \n\t"\
+        "movddup                  8(%%"FF_REG_d"), %%xmm0   \n\t" /* filterCoeff */\
+        "movdqa              (%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm2 \n\t" /* srcData */\
+        "movdqa            16(%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm5 \n\t" /* srcData */\
+        "add                                $16, %%"FF_REG_d"        \n\t"\
+        "mov                        (%%"FF_REG_d"), %%"FF_REG_S"     \n\t"\
+        "test                         %%"FF_REG_S", %%"FF_REG_S"     \n\t"\
+        "pmulhw                           %%xmm0, %%xmm2      \n\t"\
+        "pmulhw                           %%xmm0, %%xmm5      \n\t"\
+        "paddw                            %%xmm2, %%xmm3      \n\t"\
+        "paddw                            %%xmm5, %%xmm4      \n\t"\
+        " jnz                                1b             \n\t"\
+        "psraw                               $3, %%xmm3      \n\t"\
+        "psraw                               $3, %%xmm4      \n\t"\
+        "packuswb                         %%xmm4, %%xmm3      \n\t"\
+        "movntdq                          %%xmm3, (%1, %%"FF_REG_c") \n\t"\
+        "add                         $16, %%"FF_REG_c"        \n\t"\
+        "cmp                          %2, %%"FF_REG_c"        \n\t"\
+        "movdqa                   %%xmm7, %%xmm3            \n\t" \
+        "movdqa                   %%xmm7, %%xmm4            \n\t" \
+        "mov                                 %0, %%"FF_REG_d"        \n\t"\
+        "mov                        (%%"FF_REG_d"), %%"FF_REG_S"     \n\t"\
+        "jb                                  1b             \n\t"
+
+    if (offset) {
+        __asm__ volatile(
+            "movq          %5, %%xmm3  \n\t"
+            "movdqa    %%xmm3, %%xmm4  \n\t"
+            "psrlq        $24, %%xmm3  \n\t"
+            "psllq        $40, %%xmm4  \n\t"
+            "por       %%xmm4, %%xmm3  \n\t"
+            MAIN_FUNCTION
+              :: "g" (filter),
+              "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset),
+              "m"(filterSize), "m"(((uint64_t *) dither)[0])
+              : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,)
+                "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
+              );
+    } else {
+        __asm__ volatile(
+            "movq          %5, %%xmm3   \n\t"
+            MAIN_FUNCTION
+              :: "g" (filter),
+              "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset),
+              "m"(filterSize), "m"(((uint64_t *) dither)[0])
+              : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,)
+                "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
+              );
+    }
+}
+#endif
+
 #endif /* HAVE_INLINE_ASM */
 
-#define YUV2YUVX_FUNC_MMX(opt, step)  \
-void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
-                           uint8_t *dest, int dstW,  \
-                           const uint8_t *dither, int offset); \
-static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
-                           const int16_t **src, uint8_t *dest, int dstW, \
-                           const uint8_t *dither, int offset) \
-{ \
-    ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + offset, dither, offset); \
-    return; \
-}
-
-#define YUV2YUVX_FUNC(opt, step)  \
-void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
-                           uint8_t *dest, int dstW,  \
-                           const uint8_t *dither, int offset); \
-static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
-                           const int16_t **src, uint8_t *dest, int dstW, \
-                           const uint8_t *dither, int offset) \
-{ \
-    int remainder = (dstW % step); \
-    int pixelsProcessed = dstW - remainder; \
-    if(((uintptr_t)dest) & 15){ \
-        yuv2yuvX_mmx(filter, filterSize, src, dest, dstW, dither, offset); \
-        return; \
-    } \
-    ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, pixelsProcessed + offset, dither, offset); \
-    if(remainder > 0){ \
-      ff_yuv2yuvX_mmx(filter, filterSize - 1, pixelsProcessed, dest - offset, pixelsProcessed + remainder + offset, dither, offset); \
-    } \
-    return; \
-}
-
-#if HAVE_MMX_EXTERNAL
-YUV2YUVX_FUNC_MMX(mmx, 16)
-#endif
-#if HAVE_MMXEXT_EXTERNAL
-YUV2YUVX_FUNC_MMX(mmxext, 16)
-#endif
-#if HAVE_SSE3_EXTERNAL
-YUV2YUVX_FUNC(sse3, 32)
-#endif
-#if HAVE_AVX2_EXTERNAL
-YUV2YUVX_FUNC(avx2, 64)
-#endif
-
 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
                                                 SwsContext *c, int16_t *data, \
@@ -361,25 +402,11 @@
 #if HAVE_MMXEXT_INLINE
     if (INLINE_MMXEXT(cpu_flags))
         sws_init_swscale_mmxext(c);
-#endif
-    if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)) {
-#if HAVE_MMX_EXTERNAL
-        if (EXTERNAL_MMX(cpu_flags))
-            c->yuv2planeX = yuv2yuvX_mmx;
-#endif
-#if HAVE_MMXEXT_EXTERNAL
-        if (EXTERNAL_MMXEXT(cpu_flags))
-            c->yuv2planeX = yuv2yuvX_mmxext;
-#endif
-#if HAVE_SSE3_EXTERNAL
-        if (EXTERNAL_SSE3(cpu_flags))
+    if (cpu_flags & AV_CPU_FLAG_SSE3){
+        if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
             c->yuv2planeX = yuv2yuvX_sse3;
-#endif
-#if HAVE_AVX2_EXTERNAL
-        if (EXTERNAL_AVX2_FAST(cpu_flags))
-            c->yuv2planeX = yuv2yuvX_avx2;
-#endif
     }
+#endif
 
 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
     if (c->srcBpc == 8) { \
diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
index 97d8cae..823056c 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -38,6 +38,88 @@
 #endif
 #define MOVNTQ(a,b)  REAL_MOVNTQ(a,b)
 
+#if !COMPILE_TEMPLATE_MMXEXT
+static av_always_inline void
+dither_8to16(const uint8_t *srcDither, int rot)
+{
+    if (rot) {
+        __asm__ volatile("pxor      %%mm0, %%mm0\n\t"
+                         "movq       (%0), %%mm3\n\t"
+                         "movq      %%mm3, %%mm4\n\t"
+                         "psrlq       $24, %%mm3\n\t"
+                         "psllq       $40, %%mm4\n\t"
+                         "por       %%mm4, %%mm3\n\t"
+                         "movq      %%mm3, %%mm4\n\t"
+                         "punpcklbw %%mm0, %%mm3\n\t"
+                         "punpckhbw %%mm0, %%mm4\n\t"
+                         :: "r"(srcDither)
+                         );
+    } else {
+        __asm__ volatile("pxor      %%mm0, %%mm0\n\t"
+                         "movq       (%0), %%mm3\n\t"
+                         "movq      %%mm3, %%mm4\n\t"
+                         "punpcklbw %%mm0, %%mm3\n\t"
+                         "punpckhbw %%mm0, %%mm4\n\t"
+                         :: "r"(srcDither)
+                         );
+    }
+}
+#endif
+
+static void RENAME(yuv2yuvX)(const int16_t *filter, int filterSize,
+                           const int16_t **src, uint8_t *dest, int dstW,
+                           const uint8_t *dither, int offset)
+{
+    dither_8to16(dither, offset);
+    filterSize--;
+    __asm__ volatile(
+        "movd %0, %%mm1\n\t"
+        "punpcklwd %%mm1, %%mm1\n\t"
+        "punpckldq %%mm1, %%mm1\n\t"
+        "psllw        $3, %%mm1\n\t"
+        "paddw     %%mm1, %%mm3\n\t"
+        "paddw     %%mm1, %%mm4\n\t"
+        "psraw        $4, %%mm3\n\t"
+        "psraw        $4, %%mm4\n\t"
+        ::"m"(filterSize)
+     );
+
+    __asm__ volatile(\
+        "movq    %%mm3, %%mm6\n\t"
+        "movq    %%mm4, %%mm7\n\t"
+        "movl %3, %%ecx\n\t"
+        "mov                                 %0, %%"FF_REG_d"       \n\t"\
+        "mov                        (%%"FF_REG_d"), %%"FF_REG_S"    \n\t"\
+        ".p2align                             4                     \n\t" /* FIXME Unroll? */\
+        "1:                                                         \n\t"\
+        "movq                      8(%%"FF_REG_d"), %%mm0           \n\t" /* filterCoeff */\
+        "movq                (%%"FF_REG_S", %%"FF_REG_c", 2), %%mm2 \n\t" /* srcData */\
+        "movq               8(%%"FF_REG_S", %%"FF_REG_c", 2), %%mm5 \n\t" /* srcData */\
+        "add                                $16, %%"FF_REG_d"       \n\t"\
+        "mov                        (%%"FF_REG_d"), %%"FF_REG_S"    \n\t"\
+        "test                         %%"FF_REG_S", %%"FF_REG_S"    \n\t"\
+        "pmulhw                           %%mm0, %%mm2      \n\t"\
+        "pmulhw                           %%mm0, %%mm5      \n\t"\
+        "paddw                            %%mm2, %%mm3      \n\t"\
+        "paddw                            %%mm5, %%mm4      \n\t"\
+        " jnz                                1b             \n\t"\
+        "psraw                               $3, %%mm3      \n\t"\
+        "psraw                               $3, %%mm4      \n\t"\
+        "packuswb                         %%mm4, %%mm3      \n\t"
+        MOVNTQ2 "                         %%mm3, (%1, %%"FF_REG_c")\n\t"
+        "add                          $8, %%"FF_REG_c"      \n\t"\
+        "cmp                          %2, %%"FF_REG_c"      \n\t"\
+        "movq    %%mm6, %%mm3\n\t"
+        "movq    %%mm7, %%mm4\n\t"
+        "mov                                 %0, %%"FF_REG_d"     \n\t"\
+        "mov                        (%%"FF_REG_d"), %%"FF_REG_S"  \n\t"\
+        "jb                                  1b                   \n\t"\
+        :: "g" (filter),
+           "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
+        : "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
+    );
+}
+
 #define YSCALEYUV2PACKEDX_UV \
     __asm__ volatile(\
         "xor                %%"FF_REG_a", %%"FF_REG_a"  \n\t"\
@@ -1435,6 +1517,7 @@
                 }
             } else {
                 c->use_mmx_vfilter= 1;
+                c->yuv2planeX = RENAME(yuv2yuvX    );
                 if (!(c->flags & SWS_FULL_CHR_H_INT)) {
                     switch (c->dstFormat) {
                     case AV_PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X);   break;
diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
index 47f45bd..2143026 100644
--- a/libswscale/x86/yuv2rgb.c
+++ b/libswscale/x86/yuv2rgb.c
@@ -41,6 +41,14 @@
 
 #define DITHER1XBPP // only for MMX
 
+/* hope these constant values are cache line aligned */
+DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw)   = 0x00ff00ff00ff00ffULL;
+DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
+DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
+DECLARE_ASM_CONST(8, uint64_t, pb_e0) = 0xe0e0e0e0e0e0e0e0ULL;
+DECLARE_ASM_CONST(8, uint64_t, pb_03) = 0x0303030303030303ULL;
+DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
+
 //MMX versions
 #if HAVE_MMX
 #undef RENAME
diff --git a/libswscale/x86/yuv2yuvX.asm b/libswscale/x86/yuv2yuvX.asm
deleted file mode 100644
index 521880d..0000000
--- a/libswscale/x86/yuv2yuvX.asm
+++ /dev/null
@@ -1,124 +0,0 @@
-;******************************************************************************
-;* x86-optimized yuv2yuvX
-;* Copyright 2020 Google LLC
-;* Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
-;*
-;* This file is part of FFmpeg.
-;*
-;* FFmpeg is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* FFmpeg is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with FFmpeg; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; yuv2yuvX
-;
-; void ff_yuv2yuvX_<opt>(const int16_t *filter, int filterSize,
-;                        int srcOffset, uint8_t *dest, int dstW,
-;                        const uint8_t *dither, int offset);
-;
-;-----------------------------------------------------------------------------
-
-%macro YUV2YUVX_FUNC 0
-cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, dstW, dither, offset
-%if notcpuflag(sse3)
-%define movr mova
-%else
-%define movr movdqu
-%endif
-    movsxdifnidn         dstWq, dstWd
-    movsxdifnidn         offsetq, offsetd
-    movsxdifnidn         srcq, srcd
-%if cpuflag(avx2)
-    vpbroadcastq         m3, [ditherq]
-%else
-    movq                 xm3, [ditherq]
-%endif ; avx2
-    cmp                  offsetd, 0
-    jz                   .offset
-
-    ; offset != 0 path.
-    psrlq                m5, m3, $18
-    psllq                m3, m3, $28
-    por                  m3, m3, m5
-
-.offset:
-    add offsetq, srcq
-    movd                 xm1, filterSized
-    SPLATW               m1, xm1, 0
-    pxor                 m0, m0, m0
-    mov                  filterSizeq, filterq
-    mov                  srcq, [filterSizeq]
-    punpcklbw            m3, m0
-    psllw                m1, m1, 3
-    paddw                m3, m3, m1
-    psraw                m7, m3, 4
-.outerloop:
-    mova                 m4, m7
-    mova                 m3, m7
-    mova                 m6, m7
-    mova                 m1, m7
-.loop:
-%if cpuflag(avx2)
-    vpbroadcastq         m0, [filterSizeq + 8]
-%elif cpuflag(sse3)
-    movddup              m0, [filterSizeq + 8]
-%else
-    mova                 m0, [filterSizeq + 8]
-%endif
-    pmulhw               m2, m0, [srcq + offsetq * 2]
-    pmulhw               m5, m0, [srcq + offsetq * 2 + mmsize]
-    paddw                m3, m3, m2
-    paddw                m4, m4, m5
-    pmulhw               m2, m0, [srcq + offsetq * 2 + 2 * mmsize]
-    pmulhw               m5, m0, [srcq + offsetq * 2 + 3 * mmsize]
-    paddw                m6, m6, m2
-    paddw                m1, m1, m5
-    add                  filterSizeq, $10
-    mov                  srcq, [filterSizeq]
-    test                 srcq, srcq
-    jnz                  .loop
-    psraw                m3, m3, 3
-    psraw                m4, m4, 3
-    psraw                m6, m6, 3
-    psraw                m1, m1, 3
-    packuswb             m3, m3, m4
-    packuswb             m6, m6, m1
-    mov                  srcq, [filterq]
-%if cpuflag(avx2)
-    vpermq               m3, m3, 216
-    vpermq               m6, m6, 216
-%endif
-    movr                 [destq + offsetq], m3
-    movr                 [destq + offsetq + mmsize], m6
-    add                  offsetq, mmsize * 2
-    mov                  filterSizeq, filterq
-    cmp                  offsetq, dstWq
-    jb                  .outerloop
-    REP_RET
-%endmacro
-
-INIT_MMX mmx
-YUV2YUVX_FUNC
-INIT_MMX mmxext
-YUV2YUVX_FUNC
-INIT_XMM sse3
-YUV2YUVX_FUNC
-%if HAVE_AVX2_EXTERNAL
-INIT_YMM avx2
-YUV2YUVX_FUNC
-%endif
diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
index 717c944..257e741 100644
--- a/tests/api/api-band-test.c
+++ b/tests/api/api-band-test.c
@@ -71,12 +71,14 @@
     AVCodecParameters *origin_par = NULL;
     uint8_t *byte_buffer = NULL;
     AVFrame *fr = NULL;
-    AVPacket *pkt;
+    AVPacket pkt;
     AVFormatContext *fmt_ctx = NULL;
     int number_of_written_bytes;
     int video_stream;
+    int got_frame = 0;
     int byte_buffer_size;
     int result;
+    int end_of_stream = 0;
 
     draw_horiz_band_called = 0;
 
@@ -133,12 +135,6 @@
         return AVERROR(ENOMEM);
     }
 
-    pkt = av_packet_alloc();
-    if (!pkt) {
-        av_log(NULL, AV_LOG_ERROR, "Cannot allocate packet\n");
-        return AVERROR(ENOMEM);
-    }
-
     if (strcmp(codec->name, "flv") && strcmp(codec->name, "mpeg4") && strcmp(codec->name, "huffyuv")) {
         av_log(NULL, AV_LOG_ERROR, "Wrong codec\n");
         return -1;
@@ -159,58 +155,48 @@
     memset(slice_byte_buffer, 0, byte_buffer_size);
     slice_byte_buffer_size = byte_buffer_size;
 
-    result = 0;
-    while (result >= 0) {
-        result = av_read_frame(fmt_ctx, pkt);
-        if (result >= 0 && pkt->stream_index != video_stream) {
-            av_packet_unref(pkt);
-            continue;
+    av_init_packet(&pkt);
+    do {
+        if (!end_of_stream) {
+            if (av_read_frame(fmt_ctx, &pkt) < 0) {
+                end_of_stream = 1;
+            }
         }
-
-        // pkt will be empty on read error/EOF
-        result = avcodec_send_packet(ctx, pkt);
-
-        av_packet_unref(pkt);
-
-        if (result < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
-            return result;
+        if (end_of_stream) {
+            pkt.data = NULL;
+            pkt.size = 0;
         }
-
-        while (result >= 0) {
-            result = avcodec_receive_frame(ctx, fr);
-            if (result == AVERROR_EOF)
-                goto finish;
-            else if (result == AVERROR(EAGAIN)) {
-                result = 0;
-                break;
-            } else if (result < 0) {
+        if (pkt.stream_index == video_stream || end_of_stream) {
+            got_frame = 0;
+            result = avcodec_decode_video2(ctx, fr, &got_frame, &pkt);
+            if (result < 0) {
                 av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n");
                 return result;
             }
-
-            number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
-                                    (const uint8_t* const *)fr->data, (const int*) fr->linesize,
-                                    ctx->pix_fmt, ctx->width, ctx->height, 1);
-            if (number_of_written_bytes < 0) {
-                av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
-                return number_of_written_bytes;
+            if (got_frame) {
+                number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
+                                        (const uint8_t* const *)fr->data, (const int*) fr->linesize,
+                                        ctx->pix_fmt, ctx->width, ctx->height, 1);
+                if (number_of_written_bytes < 0) {
+                    av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
+                    return number_of_written_bytes;
+                }
+                if (draw_horiz_band_called == 0) {
+                    av_log(NULL, AV_LOG_ERROR, "draw_horiz_band haven't been called!\n");
+                    return -1;
+                }
+                if (av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes) !=
+                    av_adler32_update(0, (const uint8_t*)slice_byte_buffer, number_of_written_bytes)) {
+                    av_log(NULL, AV_LOG_ERROR, "Decoded frames with and without draw_horiz_band are not the same!\n");
+                    return -1;
+                }
             }
-            if (draw_horiz_band_called == 0) {
-                av_log(NULL, AV_LOG_ERROR, "draw_horiz_band haven't been called!\n");
-                return -1;
-            }
-            if (av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes) !=
-                av_adler32_update(0, (const uint8_t*)slice_byte_buffer, number_of_written_bytes)) {
-                av_log(NULL, AV_LOG_ERROR, "Decoded frames with and without draw_horiz_band are not the same!\n");
-                return -1;
-            }
-            av_frame_unref(fr);
+            av_packet_unref(&pkt);
+            av_init_packet(&pkt);
         }
-    }
+    } while (!end_of_stream || got_frame);
 
-finish:
-    av_packet_free(&pkt);
+    av_packet_unref(&pkt);
     av_frame_free(&fr);
     avformat_close_input(&fmt_ctx);
     avcodec_free_context(&ctx);
diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index b67c3d7..3fea325 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -113,6 +113,7 @@
     uint8_t *raw_in = NULL, *raw_out = NULL;
     int in_offset = 0, out_offset = 0;
     int result = 0;
+    int got_output = 0;
     int i = 0;
     int in_frame_bytes, out_frame_bytes;
 
@@ -153,10 +154,6 @@
         enc_pkt.data = NULL;
         enc_pkt.size = 0;
 
-        result = av_frame_make_writable(in_frame);
-        if (result < 0)
-            return result;
-
         generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate,
                            enc_ctx->channels, enc_ctx->frame_size);
         in_frame_bytes = in_frame->nb_samples * in_frame->channels * sizeof(uint16_t);
@@ -166,63 +163,50 @@
         }
         memcpy(raw_in + in_offset, in_frame->data[0], in_frame_bytes);
         in_offset += in_frame_bytes;
-        result = avcodec_send_frame(enc_ctx, in_frame);
+        result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, &got_output);
         if (result < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Error submitting a frame for encoding\n");
+            av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
             return result;
         }
 
-        while (result >= 0) {
-            result = avcodec_receive_packet(enc_ctx, &enc_pkt);
-            if (result == AVERROR(EAGAIN))
-                break;
-            else if (result < 0 && result != AVERROR_EOF) {
-                av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
-                return result;
-            }
-
-            /* if we get an encoded packet, feed it straight to the decoder */
-            result = avcodec_send_packet(dec_ctx, &enc_pkt);
-            av_packet_unref(&enc_pkt);
+        /* if we get an encoded packet, feed it straight to the decoder */
+        if (got_output) {
+            result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, &enc_pkt);
             if (result < 0) {
-                av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
-                return result;
-            }
-
-            result = avcodec_receive_frame(dec_ctx, out_frame);
-            if (result == AVERROR(EAGAIN)) {
-                result = 0;
-                continue;
-            } else if (result == AVERROR(EOF)) {
-                result = 0;
-                break;
-            } else if (result < 0) {
                 av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
                 return result;
             }
 
-            if (in_frame->nb_samples != out_frame->nb_samples) {
-                av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n");
-                return AVERROR_UNKNOWN;
-            }
+            if (got_output) {
+                if (result != enc_pkt.size) {
+                    av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n");
+                    return AVERROR_UNKNOWN;
+                }
 
-            if (in_frame->channel_layout != out_frame->channel_layout) {
-                av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n");
-                return AVERROR_UNKNOWN;
-            }
+                if (in_frame->nb_samples != out_frame->nb_samples) {
+                    av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n");
+                    return AVERROR_UNKNOWN;
+                }
 
-            if (in_frame->format != out_frame->format) {
-                av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n");
-                return AVERROR_UNKNOWN;
+                if (in_frame->channel_layout != out_frame->channel_layout) {
+                    av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n");
+                    return AVERROR_UNKNOWN;
+                }
+
+                if (in_frame->format != out_frame->format) {
+                    av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n");
+                    return AVERROR_UNKNOWN;
+                }
+                out_frame_bytes = out_frame->nb_samples * out_frame->channels * sizeof(uint16_t);
+                if (out_frame_bytes > out_frame->linesize[0]) {
+                    av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame linesize\n");
+                    return 1;
+                }
+                memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes);
+                out_offset += out_frame_bytes;
             }
-            out_frame_bytes = out_frame->nb_samples * out_frame->channels * sizeof(uint16_t);
-            if (out_frame_bytes > out_frame->linesize[0]) {
-                av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame linesize\n");
-                return 1;
-            }
-            memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes);
-            out_offset += out_frame_bytes;
         }
+        av_packet_unref(&enc_pkt);
     }
 
     if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_AUDIO_FRAMES) != 0) {
diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index 04bdfbc..678a1ea 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -37,13 +37,15 @@
     AVCodecParameters *origin_par = NULL;
     AVFrame *fr = NULL;
     uint8_t *byte_buffer = NULL;
-    AVPacket *pkt;
+    AVPacket pkt;
     AVFormatContext *fmt_ctx = NULL;
     int number_of_written_bytes;
     int video_stream;
+    int got_frame = 0;
     int byte_buffer_size;
     int i = 0;
     int result;
+    int end_of_stream = 0;
 
     result = avformat_open_input(&fmt_ctx, input_filename, NULL, NULL);
     if (result < 0) {
@@ -95,12 +97,6 @@
         return AVERROR(ENOMEM);
     }
 
-    pkt = av_packet_alloc();
-    if (!pkt) {
-        av_log(NULL, AV_LOG_ERROR, "Cannot allocate packet\n");
-        return AVERROR(ENOMEM);
-    }
-
     byte_buffer_size = av_image_get_buffer_size(ctx->pix_fmt, ctx->width, ctx->height, 16);
     byte_buffer = av_malloc(byte_buffer_size);
     if (!byte_buffer) {
@@ -110,60 +106,43 @@
 
     printf("#tb %d: %d/%d\n", video_stream, fmt_ctx->streams[video_stream]->time_base.num, fmt_ctx->streams[video_stream]->time_base.den);
     i = 0;
-
-    result = 0;
-    while (result >= 0) {
-        result = av_read_frame(fmt_ctx, pkt);
-        if (result >= 0 && pkt->stream_index != video_stream) {
-            av_packet_unref(pkt);
-            continue;
+    av_init_packet(&pkt);
+    do {
+        if (!end_of_stream)
+            if (av_read_frame(fmt_ctx, &pkt) < 0)
+                end_of_stream = 1;
+        if (end_of_stream) {
+            pkt.data = NULL;
+            pkt.size = 0;
         }
-
-        if (result < 0)
-            result = avcodec_send_packet(ctx, NULL);
-        else {
-            if (pkt->pts == AV_NOPTS_VALUE)
-                pkt->pts = pkt->dts = i;
-            result = avcodec_send_packet(ctx, pkt);
-        }
-        av_packet_unref(pkt);
-
-        if (result < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
-            return result;
-        }
-
-        while (result >= 0) {
-            result = avcodec_receive_frame(ctx, fr);
-            if (result == AVERROR_EOF)
-                goto finish;
-            else if (result == AVERROR(EAGAIN)) {
-                result = 0;
-                break;
-            } else if (result < 0) {
+        if (pkt.stream_index == video_stream || end_of_stream) {
+            got_frame = 0;
+            if (pkt.pts == AV_NOPTS_VALUE)
+                pkt.pts = pkt.dts = i;
+            result = avcodec_decode_video2(ctx, fr, &got_frame, &pkt);
+            if (result < 0) {
                 av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n");
                 return result;
             }
-
-            number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
-                                    (const uint8_t* const *)fr->data, (const int*) fr->linesize,
-                                    ctx->pix_fmt, ctx->width, ctx->height, 1);
-            if (number_of_written_bytes < 0) {
-                av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
-                av_frame_unref(fr);
-                return number_of_written_bytes;
+            if (got_frame) {
+                number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
+                                        (const uint8_t* const *)fr->data, (const int*) fr->linesize,
+                                        ctx->pix_fmt, ctx->width, ctx->height, 1);
+                if (number_of_written_bytes < 0) {
+                    av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
+                    return number_of_written_bytes;
+                }
+                printf("%d, %s, %s, %8"PRId64", %8d, 0x%08lx\n", video_stream,
+                       av_ts2str(fr->pts), av_ts2str(fr->pkt_dts), fr->pkt_duration,
+                       number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes));
             }
-            printf("%d, %s, %s, %8"PRId64", %8d, 0x%08lx\n", video_stream,
-                   av_ts2str(fr->pts), av_ts2str(fr->pkt_dts), fr->pkt_duration,
-                   number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes));
-
-            av_frame_unref(fr);
+            av_packet_unref(&pkt);
+            av_init_packet(&pkt);
         }
         i++;
-    }
+    } while (!end_of_stream || got_frame);
 
-finish:
-    av_packet_free(&pkt);
+    av_packet_unref(&pkt);
     av_frame_free(&fr);
     avformat_close_input(&fmt_ctx);
     avcodec_free_context(&ctx);
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
index bb9f5c8..ae33581 100644
--- a/tests/api/api-seek-test.c
+++ b/tests/api/api-seek-test.c
@@ -73,14 +73,16 @@
 }
 
 static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream,
-                                AVCodecContext *ctx, AVPacket *pkt, AVFrame *fr,
-                                uint64_t ts_start, uint64_t ts_end, int no_seeking)
+                                AVCodecContext *ctx, AVFrame *fr, uint64_t ts_start, uint64_t ts_end, int no_seeking)
 {
     int number_of_written_bytes;
+    int got_frame = 0;
     int result;
+    int end_of_stream = 0;
     int byte_buffer_size;
     uint8_t *byte_buffer;
     uint32_t crc;
+    AVPacket pkt;
 
     byte_buffer_size = av_image_get_buffer_size(ctx->pix_fmt, ctx->width, ctx->height, 16);
     byte_buffer = av_malloc(byte_buffer_size);
@@ -99,66 +101,53 @@
         avcodec_flush_buffers(ctx);
     }
 
+    av_init_packet(&pkt);
     do {
-        result = av_read_frame(fmt_ctx, pkt);
-        if (result >= 0 && pkt->stream_index != video_stream) {
-            av_packet_unref(pkt);
-            continue;
+        if (!end_of_stream)
+            if (av_read_frame(fmt_ctx, &pkt) < 0)
+                end_of_stream = 1;
+        if (end_of_stream) {
+            pkt.data = NULL;
+            pkt.size = 0;
         }
-
-        if (result < 0)
-            result = avcodec_send_packet(ctx, NULL);
-        else {
-            if (pkt->pts == AV_NOPTS_VALUE) {
+        if (pkt.stream_index == video_stream || end_of_stream) {
+            got_frame = 0;
+            if ((pkt.pts == AV_NOPTS_VALUE) && (!end_of_stream)) {
                 av_log(NULL, AV_LOG_ERROR, "Error: frames doesn't have pts values\n");
                 return -1;
             }
-            result = avcodec_send_packet(ctx, pkt);
-        }
-
-        av_packet_unref(pkt);
-
-        if (result < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
-            return result;
-        }
-
-        while (result >= 0) {
-            result = avcodec_receive_frame(ctx, fr);
-            if (result == AVERROR_EOF)
-                goto finish;
-            else if (result == AVERROR(EAGAIN)) {
-                result = 0;
-                break;
-            } else if (result < 0) {
+            result = avcodec_decode_video2(ctx, fr, &got_frame, &pkt);
+            if (result < 0) {
                 av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n");
                 return result;
             }
-
-            number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
-                                    (const uint8_t* const *)fr->data, (const int*) fr->linesize,
-                                    ctx->pix_fmt, ctx->width, ctx->height, 1);
-            if (number_of_written_bytes < 0) {
-                av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
-                return number_of_written_bytes;
+            if (got_frame) {
+                number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
+                                        (const uint8_t* const *)fr->data, (const int*) fr->linesize,
+                                        ctx->pix_fmt, ctx->width, ctx->height, 1);
+                if (number_of_written_bytes < 0) {
+                    av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
+                    return number_of_written_bytes;
+                }
+                if ((!no_seeking) && (fr->pts > ts_end))
+                    break;
+                crc = av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes);
+                printf("%10"PRId64", 0x%08"PRIx32"\n", fr->pts, crc);
+                if (no_seeking) {
+                    if (add_crc_to_array(crc, fr->pts) < 0)
+                        return -1;
+                }
+                else {
+                    if (compare_crc_in_array(crc, fr->pts) < 0)
+                        return -1;
+                }
             }
-            if ((!no_seeking) && (fr->pts > ts_end))
-                break;
-            crc = av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes);
-            printf("%10"PRId64", 0x%08"PRIx32"\n", fr->pts, crc);
-            if (no_seeking) {
-                if (add_crc_to_array(crc, fr->pts) < 0)
-                    return -1;
-            }
-            else {
-                if (compare_crc_in_array(crc, fr->pts) < 0)
-                    return -1;
-            }
-            av_frame_unref(fr);
         }
-    } while (result >= 0 && (no_seeking || (fr->pts + fr->pkt_duration <= ts_end)));
+        av_packet_unref(&pkt);
+        av_init_packet(&pkt);
+    } while ((!end_of_stream || got_frame) && (no_seeking || (fr->pts + fr->pkt_duration <= ts_end)));
 
-finish:
+    av_packet_unref(&pkt);
     av_freep(&byte_buffer);
 
     return 0;
@@ -187,7 +176,6 @@
     AVCodec *codec = NULL;
     AVCodecContext *ctx= NULL;
     AVCodecParameters *origin_par = NULL;
-    AVPacket *pkt = NULL;
     AVFrame *fr = NULL;
     AVFormatContext *fmt_ctx = NULL;
     int video_stream;
@@ -262,20 +250,13 @@
         goto end;
     }
 
-    pkt = av_packet_alloc();
-    if (!pkt) {
-        av_log(NULL, AV_LOG_ERROR, "Cannot allocate packet\n");
-        result = AVERROR(ENOMEM);
-        goto end;
-    }
-
-    result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, pkt, fr, 0, 0, 1);
+    result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, fr, 0, 0, 1);
     if (result != 0)
         goto end;
 
     for (i = start_ts; i < end_ts; i += 100) {
         for (j = i + 100; j < end_ts; j += 100) {
-            result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, pkt, fr, i, j, 0);
+            result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, fr, i, j, 0);
             if (result != 0)
                 break;
         }
@@ -284,7 +265,6 @@
 end:
     av_freep(&crc_array);
     av_freep(&pts_array);
-    av_packet_free(&pkt);
     av_frame_free(&fr);
     avformat_close_input(&fmt_ctx);
     avcodec_free_context(&ctx);
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 1827a4e..9e95697 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -24,7 +24,7 @@
 AVCODECOBJS-$(CONFIG_JPEG2000_DECODER)  += jpeg2000dsp.o
 AVCODECOBJS-$(CONFIG_OPUS_DECODER)      += opusdsp.o
 AVCODECOBJS-$(CONFIG_PIXBLOCKDSP)       += pixblockdsp.o
-AVCODECOBJS-$(CONFIG_HEVC_DECODER)      += hevc_add_res.o hevc_idct.o hevc_sao.o hevc_pel.o
+AVCODECOBJS-$(CONFIG_HEVC_DECODER)      += hevc_add_res.o hevc_idct.o hevc_sao.o
 AVCODECOBJS-$(CONFIG_UTVIDEO_DECODER)   += utvideodsp.o
 AVCODECOBJS-$(CONFIG_V210_DECODER)      += v210dec.o
 AVCODECOBJS-$(CONFIG_V210_ENCODER)      += v210enc.o
diff --git a/tests/checkasm/aacpsdsp.c b/tests/checkasm/aacpsdsp.c
index 359b1e9..2ceef43 100644
--- a/tests/checkasm/aacpsdsp.c
+++ b/tests/checkasm/aacpsdsp.c
@@ -18,7 +18,6 @@
 
 #include "libavcodec/aacpsdsp.h"
 #include "libavutil/intfloat.h"
-#include "libavutil/mem_internal.h"
 
 #include "checkasm.h"
 
diff --git a/tests/checkasm/af_afir.c b/tests/checkasm/af_afir.c
index b8a845d..8d1f815 100644
--- a/tests/checkasm/af_afir.c
+++ b/tests/checkasm/af_afir.c
@@ -23,7 +23,6 @@
 
 #include "libavfilter/af_afir.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 #include "checkasm.h"
 
 #define LEN 256
diff --git a/tests/checkasm/alacdsp.c b/tests/checkasm/alacdsp.c
index b822c72..cbf03f8 100644
--- a/tests/checkasm/alacdsp.c
+++ b/tests/checkasm/alacdsp.c
@@ -24,7 +24,6 @@
 #include "libavcodec/mathops.h"
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 256
 #define MAX_CHANNELS 2
diff --git a/tests/checkasm/audiodsp.c b/tests/checkasm/audiodsp.c
index d3a5604..7c4e16e 100644
--- a/tests/checkasm/audiodsp.c
+++ b/tests/checkasm/audiodsp.c
@@ -25,7 +25,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #include "checkasm.h"
 
diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c
index 9e6ce9d..c753506 100644
--- a/tests/checkasm/blockdsp.c
+++ b/tests/checkasm/blockdsp.c
@@ -27,7 +27,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define randomize_buffers(size)             \
     do {                                    \
diff --git a/tests/checkasm/bswapdsp.c b/tests/checkasm/bswapdsp.c
index d789e90..5f75550 100644
--- a/tests/checkasm/bswapdsp.c
+++ b/tests/checkasm/bswapdsp.c
@@ -24,7 +24,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 512
 
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 8338e8f..b3ac76c 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -116,16 +116,6 @@
     #if CONFIG_HEVC_DECODER
         { "hevc_add_res", checkasm_check_hevc_add_res },
         { "hevc_idct", checkasm_check_hevc_idct },
-        { "hevc_qpel", checkasm_check_hevc_qpel },
-        { "hevc_qpel_uni", checkasm_check_hevc_qpel_uni },
-        { "hevc_qpel_uni_w", checkasm_check_hevc_qpel_uni_w },
-        { "hevc_qpel_bi", checkasm_check_hevc_qpel_bi },
-        { "hevc_qpel_bi_w", checkasm_check_hevc_qpel_bi_w },
-        { "hevc_epel", checkasm_check_hevc_epel },
-        { "hevc_epel_uni", checkasm_check_hevc_epel_uni },
-        { "hevc_epel_uni_w", checkasm_check_hevc_epel_uni_w },
-        { "hevc_epel_bi", checkasm_check_hevc_epel_bi },
-        { "hevc_epel_bi_w", checkasm_check_hevc_epel_bi_w },
         { "hevc_sao", checkasm_check_hevc_sao },
     #endif
     #if CONFIG_HUFFYUV_DECODER
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index ef6645e..0190bc9 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -58,16 +58,6 @@
 void checkasm_check_h264qpel(void);
 void checkasm_check_hevc_add_res(void);
 void checkasm_check_hevc_idct(void);
-void checkasm_check_hevc_qpel(void);
-void checkasm_check_hevc_qpel_uni(void);
-void checkasm_check_hevc_qpel_uni_w(void);
-void checkasm_check_hevc_qpel_bi(void);
-void checkasm_check_hevc_qpel_bi_w(void);
-void checkasm_check_hevc_epel(void);
-void checkasm_check_hevc_epel_uni(void);
-void checkasm_check_hevc_epel_uni_w(void);
-void checkasm_check_hevc_epel_bi(void);
-void checkasm_check_hevc_epel_bi_w(void);
 void checkasm_check_hevc_sao(void);
 void checkasm_check_huffyuvdsp(void);
 void checkasm_check_jpeg2000dsp(void);
diff --git a/tests/checkasm/exrdsp.c b/tests/checkasm/exrdsp.c
index 2a5febb..754a079 100644
--- a/tests/checkasm/exrdsp.c
+++ b/tests/checkasm/exrdsp.c
@@ -24,7 +24,6 @@
 #include "libavcodec/avcodec.h"
 #include "libavcodec/exrdsp.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 5120
 #define PADDED_BUF_SIZE BUF_SIZE+AV_INPUT_BUFFER_PADDING_SIZE*2
diff --git a/tests/checkasm/fixed_dsp.c b/tests/checkasm/fixed_dsp.c
index 4e610a1..fa11f2e 100644
--- a/tests/checkasm/fixed_dsp.c
+++ b/tests/checkasm/fixed_dsp.c
@@ -23,7 +23,6 @@
 #include "libavutil/fixed_dsp.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 256
 
diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index 6cd8ac5..dccb54d 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -24,7 +24,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 256
 #define MAX_CHANNELS 8
diff --git a/tests/checkasm/float_dsp.c b/tests/checkasm/float_dsp.c
index 1437d8e..a1616a6 100644
--- a/tests/checkasm/float_dsp.c
+++ b/tests/checkasm/float_dsp.c
@@ -23,8 +23,6 @@
 
 #include "libavutil/float_dsp.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem_internal.h"
-
 #include "checkasm.h"
 
 #define LEN 256
diff --git a/tests/checkasm/fmtconvert.c b/tests/checkasm/fmtconvert.c
index aef7447..50ad3ca 100644
--- a/tests/checkasm/fmtconvert.c
+++ b/tests/checkasm/fmtconvert.c
@@ -24,8 +24,6 @@
 
 #include "libavutil/internal.h"
 #include "libavutil/common.h"
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/fmtconvert.h"
 
 #include "checkasm.h"
diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index 7392452..6975205 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -26,7 +26,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
 static const uint32_t pixel_mask_lf[3] = { 0xff0fff0f, 0x01ff000f, 0x03ff000f };
diff --git a/tests/checkasm/h264pred.c b/tests/checkasm/h264pred.c
index a3077f6..59dcb2f 100644
--- a/tests/checkasm/h264pred.c
+++ b/tests/checkasm/h264pred.c
@@ -25,7 +25,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 };
 
diff --git a/tests/checkasm/h264qpel.c b/tests/checkasm/h264qpel.c
index e47d659..ba069f1 100644
--- a/tests/checkasm/h264qpel.c
+++ b/tests/checkasm/h264qpel.c
@@ -24,7 +24,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
 
diff --git a/tests/checkasm/hevc_add_res.c b/tests/checkasm/hevc_add_res.c
index 0c896ad..0a3bcbb 100644
--- a/tests/checkasm/hevc_add_res.c
+++ b/tests/checkasm/hevc_add_res.c
@@ -21,7 +21,6 @@
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #include "libavcodec/hevcdsp.h"
 
diff --git a/tests/checkasm/hevc_idct.c b/tests/checkasm/hevc_idct.c
index 338b8a2..c20111c 100644
--- a/tests/checkasm/hevc_idct.c
+++ b/tests/checkasm/hevc_idct.c
@@ -21,7 +21,6 @@
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #include "libavcodec/hevcdsp.h"
 
diff --git a/tests/checkasm/hevc_pel.c b/tests/checkasm/hevc_pel.c
deleted file mode 100644
index 4d1545e..0000000
--- a/tests/checkasm/hevc_pel.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Copyright (c) 2015 Henrik Gramner
- * Copyright (c) 2021 Josh Dekker
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <string.h>
-#include "checkasm.h"
-#include "libavcodec/hevcdsp.h"
-#include "libavutil/common.h"
-#include "libavutil/internal.h"
-#include "libavutil/intreadwrite.h"
-
-static const uint32_t pixel_mask[] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff, 0x07ff07ff, 0x0fff0fff };
-static const uint32_t pixel_mask16[] = { 0x00ff00ff, 0x01ff01ff, 0x03ff03ff, 0x07ff07ff, 0x0fff0fff };
-static const int sizes[] = { -1, 4, 6, 8, 12, 16, 24, 32, 48, 64 };
-static const int weights[] = { 0, 128, 255, -1 };
-static const int denoms[] = {0, 7, 12, -1 };
-static const int offsets[] = {0, 255, -1 };
-
-#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
-#define BUF_SIZE (2 * MAX_PB_SIZE * (2 * 4 + MAX_PB_SIZE))
-
-#define randomize_buffers()                          \
-    do {                                             \
-        uint32_t mask = pixel_mask[bit_depth - 8];   \
-        int k;                                       \
-        for (k = 0; k < BUF_SIZE; k += 4) {          \
-            uint32_t r = rnd() & mask;               \
-            AV_WN32A(buf0 + k, r);                   \
-            AV_WN32A(buf1 + k, r);                   \
-            r = rnd();                               \
-            AV_WN32A(dst0 + k, r);                   \
-            AV_WN32A(dst1 + k, r);                   \
-        }                                            \
-    } while (0)
-
-#define randomize_buffers_ref()                      \
-    randomize_buffers();                             \
-    do {                                             \
-        uint32_t mask = pixel_mask16[bit_depth - 8]; \
-        int k;                                       \
-        for (k = 0; k < BUF_SIZE; k += 2) {          \
-            uint32_t r = rnd() & mask;               \
-            AV_WN32A(ref0 + k, r);                   \
-            AV_WN32A(ref1 + k, r);                   \
-        }                                            \
-    } while (0)
-
-#define src0 (buf0 + 2 * 4 * MAX_PB_SIZE) /* hevc qpel functions read data from negative src pointer offsets */
-#define src1 (buf1 + 2 * 4 * MAX_PB_SIZE)
-
-void checkasm_check_hevc_qpel(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j, row;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int height, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_pixels"; break; // 0 0
-                    case 1: type = "qpel_h"; break; // 0 1
-                    case 2: type = "qpel_v"; break; // 1 0
-                    case 3: type = "qpel_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_qpel[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        int16_t *dstw0 = (int16_t *) dst0, *dstw1 = (int16_t *) dst1;
-                        randomize_buffers();
-                        call_ref(dstw0, src0, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        call_new(dstw1, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        for (row = 0; row < size[sizes]; row++) {
-                            if (memcmp(dstw0 + row * MAX_PB_SIZE, dstw1 + row * MAX_PB_SIZE, sizes[size] * SIZEOF_PIXEL))
-                                fail();
-                        }
-                        bench_new(dstw1, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                    }
-                }
-            }
-        }
-    }
-    report("qpel");
-}
-
-void checkasm_check_hevc_qpel_uni(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int height, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_uni_pixels"; break; // 0 0
-                    case 1: type = "qpel_uni_h"; break; // 0 1
-                    case 2: type = "qpel_uni_v"; break; // 1 0
-                    case 3: type = "qpel_uni_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_qpel_uni[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        randomize_buffers();
-                        call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                            fail();
-                        bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                    }
-                }
-            }
-        }
-    }
-    report("qpel_uni");
-}
-
-void checkasm_check_hevc_qpel_uni_w(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    const int *denom, *wx, *ox;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_uni_w_pixels"; break; // 0 0
-                    case 1: type = "qpel_uni_w_h"; break; // 0 1
-                    case 2: type = "qpel_uni_w_v"; break; // 1 0
-                    case 3: type = "qpel_uni_w_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_qpel_uni_w[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        for (denom = denoms; *denom >= 0; denom++) {
-                            for (wx = weights; *wx >= 0; wx++) {
-                                for (ox = offsets; *ox >= 0; ox++) {
-                                    randomize_buffers();
-                                    call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, sizes[size], *denom, *wx, *ox, i, j, sizes[size]);
-                                    call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], *denom, *wx, *ox, i, j, sizes[size]);
-                                    if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                                        fail();
-                                    bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], *denom, *wx, *ox, i, j, sizes[size]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    report("qpel_uni_w");
-}
-
-void checkasm_check_hevc_qpel_bi(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int16_t *src2,
-                                                                  int height, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_bi_pixels"; break; // 0 0
-                    case 1: type = "qpel_bi_h"; break; // 0 1
-                    case 2: type = "qpel_bi_v"; break; // 1 0
-                    case 3: type = "qpel_bi_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_qpel_bi[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        randomize_buffers_ref();
-                        call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, ref0, sizes[size], i, j, sizes[size]);
-                        call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], i, j, sizes[size]);
-                        if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                            fail();
-                        bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], i, j, sizes[size]);
-                    }
-                }
-            }
-        }
-    }
-    report("qpel_bi");
-}
-
-void checkasm_check_hevc_qpel_bi_w(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    const int *denom, *wx, *ox;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int16_t *src2,
-                                                                  int height, int denom, int wx0, int wx1,
-                                                                  int ox0, int ox1, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_bi_w_pixels"; break; // 0 0
-                    case 1: type = "qpel_bi_w_h"; break; // 0 1
-                    case 2: type = "qpel_bi_w_v"; break; // 1 0
-                    case 3: type = "qpel_bi_w_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_qpel_bi_w[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        for (denom = denoms; *denom >= 0; denom++) {
-                            for (wx = weights; *wx >= 0; wx++) {
-                                for (ox = offsets; *ox >= 0; ox++) {
-                                    randomize_buffers_ref();
-                                    call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, ref0, sizes[size], *denom, *wx, *wx, *ox, *ox, i, j, sizes[size]);
-                                    call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], *denom, *wx, *wx, *ox, *ox, i, j, sizes[size]);
-                                    if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                                        fail();
-                                    bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], *denom, *wx, *wx, *ox, *ox, i, j, sizes[size]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    report("qpel_bi_w");
-}
-
-void checkasm_check_hevc_epel(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j, row;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int height, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_pixels"; break; // 0 0
-                    case 1: type = "epel_h"; break; // 0 1
-                    case 2: type = "epel_v"; break; // 1 0
-                    case 3: type = "epel_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_epel[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        int16_t *dstw0 = (int16_t *) dst0, *dstw1 = (int16_t *) dst1;
-                        randomize_buffers();
-                        call_ref(dstw0, src0, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        call_new(dstw1, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        for (row = 0; row < size[sizes]; row++) {
-                            if (memcmp(dstw0 + row * MAX_PB_SIZE, dstw1 + row * MAX_PB_SIZE, sizes[size] * SIZEOF_PIXEL))
-                                fail();
-                        }
-                        bench_new(dstw1, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                    }
-                }
-            }
-        }
-    }
-    report("epel");
-}
-
-void checkasm_check_hevc_epel_uni(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int height, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_uni_pixels"; break; // 0 0
-                    case 1: type = "epel_uni_h"; break; // 0 1
-                    case 2: type = "epel_uni_v"; break; // 1 0
-                    case 3: type = "epel_uni_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_epel_uni[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        randomize_buffers();
-                        call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                        if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                            fail();
-                        bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], i, j, sizes[size]);
-                    }
-                }
-            }
-        }
-    }
-    report("epel_uni");
-}
-
-void checkasm_check_hevc_epel_uni_w(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    const int *denom, *wx, *ox;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_uni_w_pixels"; break; // 0 0
-                    case 1: type = "epel_uni_w_h"; break; // 0 1
-                    case 2: type = "epel_uni_w_v"; break; // 1 0
-                    case 3: type = "epel_uni_w_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_epel_uni_w[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        for (denom = denoms; *denom >= 0; denom++) {
-                            for (wx = weights; *wx >= 0; wx++) {
-                                for (ox = offsets; *ox >= 0; ox++) {
-                                    randomize_buffers();
-                                    call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, sizes[size], *denom, *wx, *ox, i, j, sizes[size]);
-                                    call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], *denom, *wx, *ox, i, j, sizes[size]);
-                                    if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                                        fail();
-                                    bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, sizes[size], *denom, *wx, *ox, i, j, sizes[size]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    report("epel_uni_w");
-}
-
-void checkasm_check_hevc_epel_bi(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int16_t *src2,
-                                                                  int height, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_bi_pixels"; break; // 0 0
-                    case 1: type = "epel_bi_h"; break; // 0 1
-                    case 2: type = "epel_bi_v"; break; // 1 0
-                    case 3: type = "epel_bi_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_epel_bi[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        randomize_buffers_ref();
-                        call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, ref0, sizes[size], i, j, sizes[size]);
-                        call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], i, j, sizes[size]);
-                        if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                            fail();
-                        bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], i, j, sizes[size]);
-                    }
-                }
-            }
-        }
-    }
-    report("epel_bi");
-}
-
-void checkasm_check_hevc_epel_bi_w(void)
-{
-    LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref0, [BUF_SIZE]);
-    LOCAL_ALIGNED_32(int16_t, ref1, [BUF_SIZE]);
-
-    HEVCDSPContext h;
-    int size, bit_depth, i, j;
-    const int *denom, *wx, *ox;
-    declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                                                  int16_t *src2,
-                                                                  int height, int denom, int wx0, int wx1,
-                                                                  int ox0, int ox1, intptr_t mx, intptr_t my, int width);
-
-    for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
-        ff_hevc_dsp_init(&h, bit_depth);
-
-        for (i = 0; i < 2; i++) {
-            for (j = 0; j < 2; j++) {
-                for (size = 1; size < 10; size++) {
-                    const char *type;
-                    switch ((j << 1) | i) {
-                    case 0: type = "pel_bi_w_pixels"; break; // 0 0
-                    case 1: type = "epel_bi_w_h"; break; // 0 1
-                    case 2: type = "epel_bi_w_v"; break; // 1 0
-                    case 3: type = "epel_bi_w_hv"; break; // 1 1
-                    }
-
-                    if (check_func(h.put_hevc_epel_bi_w[size][j][i], "put_hevc_%s%d_%d", type, sizes[size], bit_depth)) {
-                        for (denom = denoms; *denom >= 0; denom++) {
-                            for (wx = weights; *wx >= 0; wx++) {
-                                for (ox = offsets; *ox >= 0; ox++) {
-                                    randomize_buffers_ref();
-                                    call_ref(dst0, sizes[size] * SIZEOF_PIXEL, src0, sizes[size] * SIZEOF_PIXEL, ref0, sizes[size], *denom, *wx, *wx, *ox, *ox, i, j, sizes[size]);
-                                    call_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], *denom, *wx, *wx, *ox, *ox, i, j, sizes[size]);
-                                    if (memcmp(dst0, dst1, sizes[size] * sizes[size] * SIZEOF_PIXEL))
-                                        fail();
-                                    bench_new(dst1, sizes[size] * SIZEOF_PIXEL, src1, sizes[size] * SIZEOF_PIXEL, ref1, sizes[size], *denom, *wx, *wx, *ox, *ox, i, j, sizes[size]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    report("epel_bi_w");
-}
diff --git a/tests/checkasm/hevc_sao.c b/tests/checkasm/hevc_sao.c
index 6b75075..8d0cf80 100644
--- a/tests/checkasm/hevc_sao.c
+++ b/tests/checkasm/hevc_sao.c
@@ -21,7 +21,6 @@
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #include "libavcodec/avcodec.h"
 
diff --git a/tests/checkasm/jpeg2000dsp.c b/tests/checkasm/jpeg2000dsp.c
index c9158ab..bce534d 100644
--- a/tests/checkasm/jpeg2000dsp.c
+++ b/tests/checkasm/jpeg2000dsp.c
@@ -23,7 +23,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 512
 
diff --git a/tests/checkasm/llviddspenc.c b/tests/checkasm/llviddspenc.c
index 132f6d2..31eafd5 100644
--- a/tests/checkasm/llviddspenc.c
+++ b/tests/checkasm/llviddspenc.c
@@ -23,7 +23,6 @@
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 
 #include "libavcodec/lossless_videoencdsp.h"
 
diff --git a/tests/checkasm/opusdsp.c b/tests/checkasm/opusdsp.c
index 34ee5a4..828ecf9 100644
--- a/tests/checkasm/opusdsp.c
+++ b/tests/checkasm/opusdsp.c
@@ -16,8 +16,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/opusdsp.h"
 
 #include "checkasm.h"
diff --git a/tests/checkasm/pixblockdsp.c b/tests/checkasm/pixblockdsp.c
index 9a7865a..79ab156 100644
--- a/tests/checkasm/pixblockdsp.c
+++ b/tests/checkasm/pixblockdsp.c
@@ -24,7 +24,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_UNITS 8
 #define BUF_SIZE (BUF_UNITS * 128 + 8 * BUF_UNITS)
diff --git a/tests/checkasm/sbrdsp.c b/tests/checkasm/sbrdsp.c
index 2fb14d5..516b9f0 100644
--- a/tests/checkasm/sbrdsp.c
+++ b/tests/checkasm/sbrdsp.c
@@ -16,8 +16,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/sbrdsp.h"
 #include <float.h>
 
diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c
index c29b75d..e5aad20 100644
--- a/tests/checkasm/sw_rgb.c
+++ b/tests/checkasm/sw_rgb.c
@@ -22,7 +22,6 @@
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 
 #include "libswscale/rgb2rgb.h"
 
diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index a101187..9efa2b4 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -22,7 +22,6 @@
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
-#include "libavutil/mem_internal.h"
 
 #include "libswscale/swscale.h"
 #include "libswscale/swscale_internal.h"
@@ -36,105 +35,6 @@
             AV_WN32(buf + j, rnd());      \
     } while (0)
 
-// This reference function is the same approximate algorithm employed by the
-// SIMD functions
-static void ref_function(const int16_t *filter, int filterSize,
-                                                 const int16_t **src, uint8_t *dest, int dstW,
-                                                 const uint8_t *dither, int offset)
-{
-    int i, d;
-    d = ((filterSize - 1) * 8 + dither[0]) >> 4;
-    for ( i = 0; i < dstW; i++) {
-        int16_t val = d;
-        int j;
-        union {
-            int val;
-            int16_t v[2];
-        } t;
-        for (j = 0; j < filterSize; j++){
-            t.val = (int)src[j][i + offset] * (int)filter[j];
-            val += t.v[1];
-        }
-        dest[i]= av_clip_uint8(val>>3);
-    }
-}
-
-static void check_yuv2yuvX(void)
-{
-    struct SwsContext *ctx;
-    int fsi, osi, isi, i, j;
-    int dstW;
-#define LARGEST_FILTER 16
-#define FILTER_SIZES 4
-    static const int filter_sizes[FILTER_SIZES] = {1, 4, 8, 16};
-#define LARGEST_INPUT_SIZE 512
-#define INPUT_SIZES 4
-    static const int input_sizes[INPUT_SIZES] = {128, 144, 256, 512};
-
-    declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *filter,
-                      int filterSize, const int16_t **src, uint8_t *dest,
-                      int dstW, const uint8_t *dither, int offset);
-
-    const int16_t **src;
-    LOCAL_ALIGNED_8(int16_t, src_pixels, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
-    LOCAL_ALIGNED_8(int16_t, filter_coeff, [LARGEST_FILTER]);
-    LOCAL_ALIGNED_8(uint8_t, dst0, [LARGEST_INPUT_SIZE]);
-    LOCAL_ALIGNED_8(uint8_t, dst1, [LARGEST_INPUT_SIZE]);
-    LOCAL_ALIGNED_8(uint8_t, dither, [LARGEST_INPUT_SIZE]);
-    union VFilterData{
-        const int16_t *src;
-        uint16_t coeff[8];
-    } *vFilterData;
-    uint8_t d_val = rnd();
-    memset(dither, d_val, LARGEST_INPUT_SIZE);
-    randomize_buffers((uint8_t*)src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t));
-    randomize_buffers((uint8_t*)filter_coeff, LARGEST_FILTER * sizeof(int16_t));
-    ctx = sws_alloc_context();
-    if (sws_init_context(ctx, NULL, NULL) < 0)
-        fail();
-
-    ff_getSwsFunc(ctx);
-    for(isi = 0; isi < INPUT_SIZES; ++isi){
-        dstW = input_sizes[isi];
-        for(osi = 0; osi < 64; osi += 16){
-            for(fsi = 0; fsi < FILTER_SIZES; ++fsi){
-                src = av_malloc(sizeof(int16_t*) * filter_sizes[fsi]);
-                vFilterData = av_malloc((filter_sizes[fsi] + 2) * sizeof(union VFilterData));
-                memset(vFilterData, 0, (filter_sizes[fsi] + 2) * sizeof(union VFilterData));
-                for(i = 0; i < filter_sizes[fsi]; ++i){
-                    src[i] = &src_pixels[i * LARGEST_INPUT_SIZE];
-                    vFilterData[i].src = src[i];
-                    for(j = 0; j < 4; ++j)
-                        vFilterData[i].coeff[j + 4] = filter_coeff[i];
-                }
-                if (check_func(ctx->yuv2planeX, "yuv2yuvX_%d_%d", filter_sizes[fsi], osi)){
-                    memset(dst0, 0, LARGEST_INPUT_SIZE * sizeof(dst0[0]));
-                    memset(dst1, 0, LARGEST_INPUT_SIZE * sizeof(dst1[0]));
-
-                    // The reference function is not the scalar function selected when mmx
-                    // is deactivated as the SIMD functions do not give the same result as
-                    // the scalar ones due to rounding. The SIMD functions are activated by
-                    // the flag SWS_ACCURATE_RND
-                    ref_function(&filter_coeff[0], filter_sizes[fsi], src, dst0, dstW - osi, dither, osi);
-                    // There's no point in calling new for the reference function
-                    if(ctx->use_mmx_vfilter){
-                        call_new((const int16_t*)vFilterData, filter_sizes[fsi], src, dst1, dstW - osi, dither, osi);
-                        if (memcmp(dst0, dst1, LARGEST_INPUT_SIZE * sizeof(dst0[0])))
-                            fail();
-                        if(dstW == LARGEST_INPUT_SIZE)
-                            bench_new((const int16_t*)vFilterData, filter_sizes[fsi], src, dst1, dstW - osi, dither, osi);
-                    }
-                }
-                av_freep(&src);
-                av_freep(&vFilterData);
-            }
-        }
-    }
-    sws_freeContext(ctx);
-#undef FILTER_SIZES
-}
-
-#undef SRC_PIXELS
 #define SRC_PIXELS 128
 
 static void check_hscale(void)
@@ -231,6 +131,4 @@
 {
     check_hscale();
     report("hscale");
-    check_yuv2yuvX();
-    report("yuv2yuvX");
 }
diff --git a/tests/checkasm/synth_filter.c b/tests/checkasm/synth_filter.c
index 9a0d746..87e32eb 100644
--- a/tests/checkasm/synth_filter.c
+++ b/tests/checkasm/synth_filter.c
@@ -25,8 +25,6 @@
 
 #include "libavutil/internal.h"
 #include "libavutil/intfloat.h"
-#include "libavutil/mem_internal.h"
-
 #include "libavcodec/dcadata.h"
 #include "libavcodec/synth_filter.h"
 
diff --git a/tests/checkasm/utvideodsp.c b/tests/checkasm/utvideodsp.c
index bdede61..080b428 100644
--- a/tests/checkasm/utvideodsp.c
+++ b/tests/checkasm/utvideodsp.c
@@ -24,7 +24,6 @@
 #include "libavcodec/avcodec.h"
 #include "libavcodec/utvideodsp.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define WIDTH 240
 #define HEIGHT 120
diff --git a/tests/checkasm/v210enc.c b/tests/checkasm/v210enc.c
index c3d5cc5..ed36776 100644
--- a/tests/checkasm/v210enc.c
+++ b/tests/checkasm/v210enc.c
@@ -24,7 +24,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define BUF_SIZE 512
 
diff --git a/tests/checkasm/vf_colorspace.c b/tests/checkasm/vf_colorspace.c
index 31efa67..10b7b83 100644
--- a/tests/checkasm/vf_colorspace.c
+++ b/tests/checkasm/vf_colorspace.c
@@ -24,7 +24,6 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define W 64
 #define H 64
diff --git a/tests/checkasm/vf_eq.c b/tests/checkasm/vf_eq.c
index 1315b08..48dccdd 100644
--- a/tests/checkasm/vf_eq.c
+++ b/tests/checkasm/vf_eq.c
@@ -21,7 +21,6 @@
 #include "libavfilter/avfilter.h"
 #include "libavfilter/vf_eq.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define WIDTH 256
 #define HEIGHT 256
diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c
index b9fe2f9..1d63fc2 100644
--- a/tests/checkasm/vf_gblur.c
+++ b/tests/checkasm/vf_gblur.c
@@ -16,7 +16,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <float.h>
 #include <string.h>
 #include "checkasm.h"
 #include "libavfilter/gblur.h"
@@ -34,57 +33,34 @@
             tmp_buf[j] = (float)(rnd() & 0xFF); \
     } while (0)
 
-static void check_horiz_slice(float *dst_ref, float *dst_new)
-{
-    int steps = 2;
-    float nu = 0.101f;
-    float bscale = 1.112f;
-
-    declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale);
-    call_ref(dst_ref, WIDTH, HEIGHT, steps, nu, bscale);
-    call_new(dst_new, WIDTH, HEIGHT, steps, nu, bscale);
-    if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
-         fail();
-    }
-    bench_new(dst_new, WIDTH, HEIGHT, 1, nu, bscale);
-}
-
-static void check_postscale_slice(float *dst_ref, float *dst_new)
-{
-    float postscale = 0.0603f;
-
-    declare_func(void, float *dst, int len, float postscale, float min, float max);
-    call_ref(dst_ref, PIXELS, postscale, -FLT_MAX, FLT_MAX);
-    call_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX);
-    if (!float_near_abs_eps_array(dst_ref, dst_new, FLT_EPSILON, PIXELS)) {
-        fail();
-    }
-    bench_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX);
-}
-
 void checkasm_check_vf_gblur(void)
 {
     float *dst_ref = av_malloc(BUF_SIZE);
     float *dst_new = av_malloc(BUF_SIZE);
+    int w = WIDTH;
+    int h = HEIGHT;
+    int steps = 2;
+    float nu = 0.101f;
+    float bscale = 1.112f;
     GBlurContext s;
 
+    declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale);
+
     randomize_buffers(dst_ref, PIXELS);
     memcpy(dst_new, dst_ref, BUF_SIZE);
 
     ff_gblur_init(&s);
 
     if (check_func(s.horiz_slice, "horiz_slice")) {
-        check_horiz_slice(dst_ref, dst_new);
+        call_ref(dst_ref, w, h, steps, nu, bscale);
+        call_new(dst_new, w, h, steps, nu, bscale);
+
+        if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
+            fail();
+        }
+        bench_new(dst_new, w, h, 1, nu, bscale);
     }
     report("horiz_slice");
-
-    randomize_buffers(dst_ref, PIXELS);
-    memcpy(dst_new, dst_ref, BUF_SIZE);
-    if (check_func(s.postscale_slice, "postscale_slice")) {
-        check_postscale_slice(dst_ref, dst_new);
-    }
-    report("postscale_slice");
-
     av_freep(&dst_ref);
     av_freep(&dst_new);
 }
diff --git a/tests/checkasm/vf_hflip.c b/tests/checkasm/vf_hflip.c
index a3b6e61..2d6fdec 100644
--- a/tests/checkasm/vf_hflip.c
+++ b/tests/checkasm/vf_hflip.c
@@ -20,7 +20,6 @@
 #include "checkasm.h"
 #include "libavfilter/hflip.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define WIDTH 256
 #define WIDTH_PADDED 256 + 32
diff --git a/tests/checkasm/vf_threshold.c b/tests/checkasm/vf_threshold.c
index 2c5cc80..5a2fc0e 100644
--- a/tests/checkasm/vf_threshold.c
+++ b/tests/checkasm/vf_threshold.c
@@ -20,7 +20,6 @@
 #include "checkasm.h"
 #include "libavfilter/threshold.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define WIDTH 256
 #define WIDTH_PADDED 256 + 32
diff --git a/tests/checkasm/videodsp.c b/tests/checkasm/videodsp.c
index eb2845a..0a4424a 100644
--- a/tests/checkasm/videodsp.c
+++ b/tests/checkasm/videodsp.c
@@ -23,7 +23,6 @@
 #include "libavcodec/videodsp.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #define randomize_buffers(w, h)                         \
     do {                                                \
diff --git a/tests/checkasm/vp8dsp.c b/tests/checkasm/vp8dsp.c
index c3af54f..d93f730 100644
--- a/tests/checkasm/vp8dsp.c
+++ b/tests/checkasm/vp8dsp.c
@@ -25,7 +25,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem_internal.h"
 
 #include "checkasm.h"
 
diff --git a/tests/checkasm/vp9dsp.c b/tests/checkasm/vp9dsp.c
index 99c0238..a91577b 100644
--- a/tests/checkasm/vp9dsp.c
+++ b/tests/checkasm/vp9dsp.c
@@ -27,7 +27,6 @@
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem_internal.h"
 
 static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index ef82752..8afdfab 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -1,7 +1,6 @@
 DNNTESTPROGS += dnn-layer-pad
 DNNTESTPROGS += dnn-layer-conv2d
 DNNTESTPROGS += dnn-layer-depth2space
-DNNTESTPROGS += dnn-layer-dense
 DNNTESTPROGS += dnn-layer-mathbinary
 DNNTESTPROGS += dnn-layer-maximum
 DNNTESTPROGS += dnn-layer-mathunary
diff --git a/tests/dnn/dnn-layer-avgpool-test.c b/tests/dnn/dnn-layer-avgpool-test.c
index 4a925ea..0e6be8b 100644
--- a/tests/dnn/dnn-layer-avgpool-test.c
+++ b/tests/dnn/dnn-layer-avgpool-test.c
@@ -91,7 +91,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_avg_pool(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_avg_pool(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); ++i) {
@@ -171,7 +171,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_avg_pool(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_avg_pool(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); ++i) {
diff --git a/tests/dnn/dnn-layer-conv2d-test.c b/tests/dnn/dnn-layer-conv2d-test.c
index 5ee60ee..378a05e 100644
--- a/tests/dnn/dnn-layer-conv2d-test.c
+++ b/tests/dnn/dnn-layer-conv2d-test.c
@@ -25,6 +25,8 @@
 
 #define EPSON 0.00001
 
+extern const AVClass dnn_native_class;
+
 static int test_with_same_dilate(void)
 {
     // the input data and expected data are generated with below python code.
@@ -97,7 +99,7 @@
     float bias[2] = { -1.6574852, -0.72915393 };
 
     NativeContext ctx;
-    ctx.class = NULL;
+    ctx.class = &dnn_native_class;
     ctx.options.conv2d_threads = 1;
 
     params.activation = TANH;
@@ -118,7 +120,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_conv2d(operands, input_indexes, 1, &params, &ctx);
+    dnn_execute_layer_conv2d(operands, input_indexes, 1, &params, &ctx);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
@@ -201,7 +203,7 @@
     float bias[2] = { -0.4773722, -0.19620377 };
 
     NativeContext ctx;
-    ctx.class = NULL;
+    ctx.class = &dnn_native_class;
     ctx.options.conv2d_threads = 1;
 
     params.activation = TANH;
@@ -222,7 +224,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_conv2d(operands, input_indexes, 1, &params, &ctx);
+    dnn_execute_layer_conv2d(operands, input_indexes, 1, &params, &ctx);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
diff --git a/tests/dnn/dnn-layer-dense-test.c b/tests/dnn/dnn-layer-dense-test.c
index 696f750..2c11ec5 100644
--- a/tests/dnn/dnn-layer-dense-test.c
+++ b/tests/dnn/dnn-layer-dense-test.c
@@ -59,7 +59,7 @@
     print(list(output.flatten()))
     */
 
-    DenseParams params;
+    ConvolutionalParams params;
     DnnOperand operands[2];
     int32_t input_indexes[1];
     float input[1*5*6*3] = {
@@ -107,7 +107,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_dense(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_dense(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
diff --git a/tests/dnn/dnn-layer-depth2space-test.c b/tests/dnn/dnn-layer-depth2space-test.c
index 958247e..2c64188 100644
--- a/tests/dnn/dnn-layer-depth2space-test.c
+++ b/tests/dnn/dnn-layer-depth2space-test.c
@@ -81,7 +81,7 @@
 
     input_indexes[0] = 0;
     params.block_size = 2;
-    ff_dnn_execute_layer_depth2space(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_depth2space(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
diff --git a/tests/dnn/dnn-layer-mathbinary-test.c b/tests/dnn/dnn-layer-mathbinary-test.c
index 2e41dc1..c4da3f6 100644
--- a/tests/dnn/dnn-layer-mathbinary-test.c
+++ b/tests/dnn/dnn-layer-mathbinary-test.c
@@ -71,7 +71,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_math_binary(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_math_binary(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(input) / sizeof(float); i++) {
@@ -111,7 +111,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_math_binary(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_math_binary(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(input) / sizeof(float); i++) {
@@ -159,7 +159,7 @@
 
     input_indexes[0] = 0;
     input_indexes[1] = 1;
-    ff_dnn_execute_layer_math_binary(operands, input_indexes, 2, &params, NULL);
+    dnn_execute_layer_math_binary(operands, input_indexes, 2, &params, NULL);
 
     output = operands[2].data;
     for (int i = 0; i < sizeof(input0) / sizeof(float); i++) {
diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c
index a8c5ab0..ce14c41 100644
--- a/tests/dnn/dnn-layer-mathunary-test.c
+++ b/tests/dnn/dnn-layer-mathunary-test.c
@@ -87,7 +87,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_math_unary(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_math_unary(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(input) / sizeof(float); ++i) {
diff --git a/tests/dnn/dnn-layer-maximum-test.c b/tests/dnn/dnn-layer-maximum-test.c
index bf22f37..c982670 100644
--- a/tests/dnn/dnn-layer-maximum-test.c
+++ b/tests/dnn/dnn-layer-maximum-test.c
@@ -45,7 +45,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_maximum(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_maximum(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(input) / sizeof(float); i++) {
diff --git a/tests/dnn/dnn-layer-pad-test.c b/tests/dnn/dnn-layer-pad-test.c
index a8443ce..6a72adb 100644
--- a/tests/dnn/dnn-layer-pad-test.c
+++ b/tests/dnn/dnn-layer-pad-test.c
@@ -79,7 +79,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_pad(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_pad(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
@@ -144,7 +144,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_pad(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_pad(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
@@ -210,7 +210,7 @@
     operands[1].data = NULL;
 
     input_indexes[0] = 0;
-    ff_dnn_execute_layer_pad(operands, input_indexes, 1, &params, NULL);
+    dnn_execute_layer_pad(operands, input_indexes, 1, &params, NULL);
 
     output = operands[1].data;
     for (int i = 0; i < sizeof(expected_output) / sizeof(float); i++) {
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index b69176f..58d5fdb 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -158,7 +158,7 @@
 md5(){
     encfile="${outdir}/${test}.out"
     cleanfiles="$cleanfiles $encfile"
-    ffmpeg -y "$@" $(target_path $encfile) || return
+    ffmpeg -y "$@" $(target_path $encfile)
     do_md5sum $encfile | awk '{print $1}'
 }
 
diff --git a/tests/fate/ac3.mak b/tests/fate/ac3.mak
index d76e22b..757cd51 100644
--- a/tests/fate/ac3.mak
+++ b/tests/fate/ac3.mak
@@ -90,7 +90,7 @@
 fate-ac3-fixed-encode: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
 fate-ac3-fixed-encode: CMD = md5 -i $(SRC) -c ac3_fixed -ab 128k -f ac3 -flags +bitexact -af aresample
 fate-ac3-fixed-encode: CMP = oneline
-fate-ac3-fixed-encode: REF = 1f548175e11a95e62ce20e442fcc8d08
+fate-ac3-fixed-encode: REF = a1d1fc116463b771abf5aef7ed37d7b1
 
 FATE_EAC3-$(call ALLYES, EAC3_DEMUXER EAC3_MUXER EAC3_CORE_BSF) += fate-eac3-core-bsf
 fate-eac3-core-bsf: CMD = md5pipe -i $(TARGET_SAMPLES)/eac3/the_great_wall_7.1.eac3 -c:a copy -bsf:a eac3_core -fflags +bitexact -f eac3
diff --git a/tests/fate/acodec.mak b/tests/fate/acodec.mak
index 1b8c32b..35b5978 100644
--- a/tests/fate/acodec.mak
+++ b/tests/fate/acodec.mak
@@ -1,6 +1,6 @@
 fate-acodec-%: CODEC = $(@:fate-acodec-%=%)
 fate-acodec-%: SRC = tests/data/asynth-44100-2.wav
-fate-acodec-%: CMD = enc_dec wav $(SRC) $(FMT) "-b:a 128k -c $(CODEC) $(ENCOPTS)" wav "-c pcm_s16le $(DECOPTS)" "$(KEEP_OVERRIDE)"
+fate-acodec-%: CMD = enc_dec wav $(SRC) $(FMT) "-b:a 128k -c $(CODEC) $(ENCOPTS)" wav "-c pcm_s16le $(DECOPTS)" -keep
 fate-acodec-%: CMP_UNIT = 2
 fate-acodec-%: REF = $(SRC_PATH)/tests/ref/acodec/$(@:fate-acodec-%=%)
 
diff --git a/tests/fate/apng.mak b/tests/fate/apng.mak
index 0a5f542..bc138b4 100644
--- a/tests/fate/apng.mak
+++ b/tests/fate/apng.mak
@@ -4,9 +4,6 @@
 FATE_APNG += fate-apng-osample
 fate-apng-osample: CMD = framecrc -i $(TARGET_SAMPLES)/apng/o_sample.png
 
-FATE_APNG += fate-apng-dispose-previous
-fate-apng-dispose-previous: CMD = framecrc -i $(TARGET_SAMPLES)/apng/apng_out_of_order_frames.png
-
 FATE_APNG-$(call DEMDEC, APNG, APNG) += $(FATE_APNG)
 
 FATE_SAMPLES_FFMPEG += $(FATE_APNG-yes)
diff --git a/tests/fate/dnn.mak b/tests/fate/dnn.mak
index ef07ee4..c5e4587 100644
--- a/tests/fate/dnn.mak
+++ b/tests/fate/dnn.mak
@@ -8,11 +8,6 @@
 fate-dnn-layer-conv2d: CMD = run $(DNNTESTSDIR)/dnn-layer-conv2d-test$(EXESUF)
 fate-dnn-layer-conv2d: CMP = null
 
-FATE_DNN += fate-dnn-layer-dense
-fate-dnn-layer-dense: $(DNNTESTSDIR)/dnn-layer-dense-test$(EXESUF)
-fate-dnn-layer-dense: CMD = run $(DNNTESTSDIR)/dnn-layer-dense-test$(EXESUF)
-fate-dnn-layer-dense: CMP = null
-
 FATE_DNN += fate-dnn-layer-depth2space
 fate-dnn-layer-depth2space: $(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
 fate-dnn-layer-depth2space: CMD = run $(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index 4dfb77d..c6d8dc2 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -83,7 +83,7 @@
 FATE_FFMPEG-$(call ALLYES, PCM_S16LE_DEMUXER AC3_MUXER PCM_S16LE_DECODER AC3_FIXED_ENCODER) += fate-unknown_layout-ac3
 fate-unknown_layout-ac3: $(AREF)
 fate-unknown_layout-ac3: CMD = md5 -auto_conversion_filters \
-  -guess_layout_max 0 -f s32le -ac 1 -ar 44100 -i $(TARGET_PATH)/$(AREF) \
+  -guess_layout_max 0 -f s16le -ac 1 -ar 44100 -i $(TARGET_PATH)/$(AREF) \
   -f ac3 -flags +bitexact -c ac3_fixed
 
 
diff --git a/tests/fate/fft.mak b/tests/fate/fft.mak
index 76701dc..5da6e68 100644
--- a/tests/fate/fft.mak
+++ b/tests/fate/fft.mak
@@ -26,7 +26,27 @@
 $(FATE_FFT_ALL): libavcodec/tests/fft$(EXESUF)
 $(FATE_FFT_ALL): CMD = run libavcodec/tests/fft$(EXESUF) $(CPUFLAGS:%=-c%) $(ARGS)
 
-$(FATE_FFT_ALL): CMP = null
+define DEF_FFT_FIXED
+FATE_FFT_FIXED-$(CONFIG_FFT)   += fate-fft-fixed-$(1)  fate-ifft-fixed-$(1)
+FATE_MDCT_FIXED-$(CONFIG_MDCT) += fate-mdct-fixed-$(1) fate-imdct-fixed-$(1)
+
+fate-fft-fixed-$(1):   ARGS = -n$(1)
+fate-ifft-fixed-$(1):  ARGS = -n$(1) -i
+fate-mdct-fixed-$(1):  ARGS = -n$(1) -m
+fate-imdct-fixed-$(1): ARGS = -n$(1) -m -i
+endef
+
+$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT_FIXED,$(N))))
+
+fate-fft-fixed: $(FATE_FFT_FIXED-yes)
+fate-mdct-fixed: $(FATE_MDCT_FIXED-yes)
+
+FATE_FFT_FIXED_ALL = $(FATE_FFT_FIXED-yes) $(FATE_MDCT_FIXED-yes)
+
+$(FATE_FFT_FIXED_ALL): libavcodec/tests/fft-fixed$(EXESUF)
+$(FATE_FFT_FIXED_ALL): CMD = run libavcodec/tests/fft-fixed$(EXESUF) $(CPUFLAGS:%=-c%) $(ARGS)
+
+$(FATE_FFT_ALL) $(FATE_FFT_FIXED_ALL): CMP = null
 
 define DEF_FFT_FIXED32
 FATE_FFT_FIXED32 += fate-fft-fixed32-$(1)   fate-ifft-fixed32-$(1)  \
@@ -75,9 +95,9 @@
 $(FATE_AV_FFT_ALL): CMP = null
 
 fate-dct: fate-dct-float
-fate-fft: fate-fft-float fate-fft-fixed32
-fate-mdct: fate-mdct-float
+fate-fft: fate-fft-float fate-fft-fixed fate-fft-fixed32
+fate-mdct: fate-mdct-float fate-mdct-fixed
 fate-rdft: fate-rdft-float
 
-FATE-$(call ALLYES, AVCODEC FFT MDCT) += $(FATE_FFT_ALL) $(FATE_FFT_FIXED32) $(FATE_AV_FFT_ALL)
-fate-fft-all: $(FATE_FFT_ALL) $(FATE_FFT_FIXED32) $(FATE_AV_FFT_ALL)
+FATE-$(call ALLYES, AVCODEC FFT MDCT) += $(FATE_FFT_ALL) $(FATE_FFT_FIXED_ALL) $(FATE_FFT_FIXED32) $(FATE_AV_FFT_ALL)
+fate-fft-all: $(FATE_FFT_ALL) $(FATE_FFT_FIXED_ALL) $(FATE_FFT_FIXED32) $(FATE_AV_FFT_ALL)
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index a0d645c..f9059f4 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -423,9 +423,9 @@
 
 FATE_FILTER_HQX-$(call ALLYES, IMAGE2_DEMUXER PNG_DECODER HQX_FILTER) = fate-filter-hq2x fate-filter-hq3x fate-filter-hq4x
 FATE_FILTER_SAMPLES-yes += $(FATE_FILTER_HQX-yes)
-fate-filter-hq2x: CMD = framecrc -i $(TARGET_SAMPLES)/filter/pixelart%d.png -vf scale,format=rgb32,hqx=2,scale,format=bgra
-fate-filter-hq3x: CMD = framecrc -i $(TARGET_SAMPLES)/filter/pixelart%d.png -vf scale,format=rgb32,hqx=3,scale,format=bgra
-fate-filter-hq4x: CMD = framecrc -i $(TARGET_SAMPLES)/filter/pixelart%d.png -vf scale,format=rgb32,hqx=4,scale,format=bgra
+fate-filter-hq2x: CMD = framecrc -i $(TARGET_SAMPLES)/filter/pixelart%d.png -vf scale,hqx=2 -pix_fmt bgra
+fate-filter-hq3x: CMD = framecrc -i $(TARGET_SAMPLES)/filter/pixelart%d.png -vf scale,hqx=3 -pix_fmt bgra
+fate-filter-hq4x: CMD = framecrc -i $(TARGET_SAMPLES)/filter/pixelart%d.png -vf scale,hqx=4 -pix_fmt bgra
 fate-filter-hqx: $(FATE_FILTER_HQX-yes)
 
 FATE_FILTER_XBR-$(call ALLYES, IMAGE2_DEMUXER PNG_DECODER XBR_FILTER) = fate-filter-2xbr fate-filter-3xbr fate-filter-4xbr
@@ -564,30 +564,29 @@
 FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6
 FATE_FILTER_VSYNTH-$(CONFIG_PP_FILTER) += $(FATE_FILTER_PP)
 $(FATE_FILTER_PP): fate-vsynth1-mpeg4-qprd
-fate-vsynth1-mpeg4-qprd: KEEP_OVERRIDE= -keep
 
-fate-filter-pp:  CMD = framecrc -flags bitexact -export_side_data venc_params -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp=be/hb/vb/tn/l5/al"
+fate-filter-pp:  CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp=be/hb/vb/tn/l5/al"
 fate-filter-pp1: CMD = video_filter "pp=fq|4/be/hb/vb/tn/l5/al"
-fate-filter-pp2: CMD = video_filter "qp=2*(x+y),pp=be/h1/v1/lb"
-fate-filter-pp3: CMD = video_filter "qp=2*(x+y),pp=be/ha|128|7/va/li"
+fate-filter-pp2: CMD = video_filter "qp=x+y,pp=be/h1/v1/lb"
+fate-filter-pp3: CMD = video_filter "qp=x+y,pp=be/ha|128|7/va/li"
 fate-filter-pp4: CMD = video_filter "pp=be/ci"
 fate-filter-pp5: CMD = video_filter "pp=md"
 fate-filter-pp6: CMD = video_filter "pp=be/fd"
 
 FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7
 fate-filter-pp7: fate-vsynth1-mpeg4-qprd
-fate-filter-pp7: CMD = framecrc -flags bitexact -export_side_data venc_params -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"
+fate-filter-pp7: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"
 
 FATE_FILTER_VSYNTH-$(CONFIG_SPP_FILTER) += fate-filter-spp
 fate-filter-spp: fate-vsynth1-mpeg4-qprd
-fate-filter-spp: CMD = framecrc -flags bitexact -export_side_data venc_params -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "spp=idct=simple:dct=int"
+fate-filter-spp: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "spp=idct=simple:dct=int"
 
 FATE_FILTER_VSYNTH-$(CONFIG_CODECVIEW_FILTER) += fate-filter-codecview
 fate-filter-codecview: fate-vsynth1-mpeg4-qprd
 fate-filter-codecview: CMD = framecrc -flags bitexact -idct simple -flags2 +export_mvs -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf codecview=mv=pf+bf+bb
 
 FATE_FILTER_VSYNTH-$(call ALLYES, QP_FILTER PP_FILTER) += fate-filter-qp
-fate-filter-qp: CMD = video_filter "qp=34,pp=be/hb/vb/tn/l5/al"
+fate-filter-qp: CMD = video_filter "qp=17,pp=be/hb/vb/tn/l5/al"
 
 FATE_FILTER_VSYNTH-$(CONFIG_SELECT_FILTER) += fate-filter-select
 fate-filter-select: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf "select=not(eq(mod(n\,2)\,0)+eq(mod(n\,3)\,0))" -frames:v 25 -flags +bitexact
diff --git a/tests/fate/fits.mak b/tests/fate/fits.mak
index 8c2995a..0ed8cdb 100644
--- a/tests/fate/fits.mak
+++ b/tests/fate/fits.mak
@@ -5,7 +5,6 @@
         -y $(TARGET_PATH)/$(@) 2>/dev/null
 
 #mapping of fits file formats to png filenames
-# TODO: Use an actual 64bit input file and fix the gbrp16 test on big-endian
 map.tests/data/lena-gray.fits    := gray8
 map.tests/data/lena-gbrp.fits    := rgb24
 map.tests/data/lena-gbrp16.fits  := rgb48
diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak
index aff81a8..1509784 100644
--- a/tests/fate/hlsenc.mak
+++ b/tests/fate/hlsenc.mak
@@ -105,10 +105,9 @@
 	-hls_time 2 -hls_segment_filename "$(TARGET_PATH)/tests/data/hls_fmp4_ac3_%d.m4s" \
 	$(TARGET_PATH)/tests/data/hls_fmp4_ac3.m3u8 2>/dev/null
 
-FATE_HLSENC_PROBE-$(call ALLYES, HLS_DEMUXER EAC3_DEMUXER) += fate-hls-fmp4_ac3
+FATE_HLSENC-$(call ALLYES, HLS_DEMUXER EAC3_DEMUXER) += fate-hls-fmp4_ac3
 fate-hls-fmp4_ac3: tests/data/hls_fmp4_ac3.m3u8
 fate-hls-fmp4_ac3: CMD = probeaudiostream $(TARGET_PATH)/tests/data/now_ac3.mp4
 
 FATE_SAMPLES_FFMPEG += $(FATE_HLSENC-yes)
-FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_HLSENC_PROBE-yes)
-fate-hlsenc: $(FATE_HLSENC-yes) $(FATE_HLSENC_PROBE-yes)
+fate-hlsenc: $(FATE_HLSENC-yes)
diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index eca8d5a..c453f0f 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -97,9 +97,6 @@
 FATE_SAMPLES_AVCONV-$(call PARSERDEMDEC, DPX, IMAGE2PIPE, DPX) += fate-dpxparser
 fate-dpxparser: CMD = framecrc -f image2pipe -i $(TARGET_SAMPLES)/dpx/lena_4x_concat.dpx -sws_flags +accurate_rnd+bitexact
 
-FATE_IMAGE_PROBE-$(call DEMDEC, IMAGE2, DPX) += fate-dpx-probe
-fate-dpx-probe: CMD = probeframes -show_entries frame=color_transfer,color_range,color_space,color_primaries,sample_aspect_ratio $(TARGET_SAMPLES)/dpx/cyan.dpx
-
 FATE_EXR += fate-exr-slice-raw
 fate-exr-slice-raw: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_slice_raw.exr -pix_fmt gbrapf32le
 
@@ -517,9 +514,6 @@
 fate-xbm: $(FATE_XBM-yes)
 
 FATE_IMAGE += $(FATE_IMAGE-yes)
-FATE_IMAGE_PROBE += $(FATE_IMAGE_PROBE-yes)
 
 FATE_SAMPLES_FFMPEG += $(FATE_IMAGE)
-FATE_SAMPLES_FFPROBE += $(FATE_IMAGE_PROBE)
-
-fate-image: $(FATE_IMAGE) $(FATE_IMAGE_PROBE)
+fate-image: $(FATE_IMAGE)
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 6822969..747dae3 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -65,6 +65,10 @@
 fate-mpeg12framerate: CMD = run libavcodec/tests/mpeg12framerate$(EXESUF)
 fate-mpeg12framerate: REF = /dev/null
 
+FATE_LIBAVCODEC-yes += fate-libavcodec-options
+fate-libavcodec-options: libavcodec/tests/options$(EXESUF)
+fate-libavcodec-options: CMD = run libavcodec/tests/options$(EXESUF)
+
 FATE_LIBAVCODEC-$(CONFIG_RANGECODER) += fate-rangecoder
 fate-rangecoder: libavcodec/tests/rangecoder$(EXESUF)
 fate-rangecoder: CMD = run libavcodec/tests/rangecoder$(EXESUF)
diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
index 8a46b1f..17fbf46 100644
--- a/tests/fate/matroska.mak
+++ b/tests/fate/matroska.mak
@@ -57,62 +57,9 @@
                                += fate-webm-dash-chapters
 fate-webm-dash-chapters: CMD = transcode ogg $(TARGET_SAMPLES)/vorbis/vorbis_chapter_extension_demo.ogg webm "-c copy -cluster_time_limit 1500 -dash 1 -dash_track_number 124 -reserve_index_space 400" "-c copy -t 0.5" "" -show_chapters
 
-# The input file has a Block whose payload has a size of zero before reversing
-# header removal compression; it furthermore uses chained SeekHeads and has
-# level 1-elements after the Cluster. This is tested on the demuxer's side.
-# For the muxer this tests that it can correctly write huge TrackNumbers and
-# that it can expand the Cues element's length field by one byte if necessary.
-# It furthermore tests correct propagation of the description tag.
-FATE_MATROSKA_FFMPEG_FFPROBE-$(call DEMMUX, MATROSKA, MATROSKA) \
-                               += fate-matroska-zero-length-block
-fate-matroska-zero-length-block: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/zero_length_block.mks matroska "-c:s copy -dash 1 -dash_track_number 2000000000 -reserve_index_space 62 -metadata_header_padding 1" "-c:s copy" "" "-show_entries stream_tags=description"
-
-# This test the following features of the Matroska muxer: Writing projection
-# stream side-data; not setting any track to default if the user requested it;
-# and modifying and writing colorspace properties.
-FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER MATROSKA_MUXER \
-                                            H264_DECODER H264_PARSER) \
-                               += fate-matroska-spherical-mono-remux
-fate-matroska-spherical-mono-remux: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/spherical.mkv matroska "-map 0 -map 0 -c copy -disposition:0 -default+forced -disposition:1 -default -default_mode passthrough -color_primaries:1 bt709 -color_trc:1 smpte170m -colorspace:1 bt2020c -color_range:1 pc"  "-map 0 -c copy -t 0" "" "-show_entries stream_side_data_list:stream_disposition=default,forced:stream=color_range,color_space,color_primaries,color_transfer"
-
-# The input file of the following test contains Content Light Level as well as
-# Mastering Display Metadata and so this test tests correct muxing and demuxing
-# of these. It furthermore also tests that this data is correctly propagated
-# when reencoding (here to ffv1).
-# Both input audio tracks are completely zero, so the noise bsf is used
-# to make this test interesting.
-FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MXF_DEMUXER        \
-                                            PRORES_DECODER PCM_S24LE_DECODER \
-                                            FFV1_ENCODER ARESAMPLE_FILTER    \
-                                            PCM_S16BE_ENCODER NOISE_BSF      \
-                                            MATROSKA_MUXER MATROSKA_DEMUXER  \
-                                            FRAMECRC_MUXER PIPE_PROTOCOL)    \
-                               += fate-matroska-mastering-display-metadata
-fate-matroska-mastering-display-metadata: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf matroska "-map 0 -map 0:0 -c:v:0 copy -c:v:1 ffv1 -c:a:0 copy -bsf:a:0 noise=amount=3 -filter:a:1 aresample -c:a:1 pcm_s16be -bsf:a:1 noise=dropamount=4" "-map 0 -c copy" "" "-show_entries stream_side_data_list:stream=index,codec_name"
-
-# Tests writing BlockAdditional and BlockGroups with ReferenceBlock elements;
-# it also tests setting a track as suitable for hearing impaired.
-# It also tests the capability of the VP8 parser to set the keyframe flag
-# (the input file lacks ReferenceBlock elements making everything a keyframe).
-FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MATROSKA_DEMUXER \
-                                            VP8_PARSER MATROSKA_MUXER      \
-                                            FRAMECRC_MUXER PIPE_PROTOCOL)  \
-                               += fate-matroska-vp8-alpha-remux
-fate-matroska-vp8-alpha-remux: CMD = transcode matroska $(TARGET_SAMPLES)/vp8_alpha/vp8_video_with_alpha.webm matroska "-c copy -disposition +hearing_impaired -cluster_size_limit 100000" "-c copy -t 0.2" "" "-show_entries stream_disposition:stream_side_data_list"
-
-# The audio stream to be remuxed here has AV_DISPOSITION_VISUAL_IMPAIRED.
-FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MPEGTS_DEMUXER    \
-                                            AC3_DECODER MATROSKA_MUXER      \
-                                            MATROSKA_DEMUXER FRAMECRC_MUXER \
-                                            PIPE_PROTOCOL)                  \
-                               += fate-matroska-mpegts-remux
-fate-matroska-mpegts-remux: CMD = transcode mpegts $(TARGET_SAMPLES)/mpegts/pmtchange.ts matroska "-map 0:2 -map 0:2 -c copy -disposition:a:1 -visual_impaired+hearing_impaired" "-map 0 -c copy" "" "-show_entries stream_disposition:stream=index"
-
 FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += fate-matroska-spherical-mono
 fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream_side_data_list -select_streams v -v 0 $(TARGET_SAMPLES)/mkv/spherical.mkv
 
 FATE_SAMPLES_AVCONV += $(FATE_MATROSKA-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_MATROSKA_FFPROBE-yes)
 FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MATROSKA_FFMPEG_FFPROBE-yes)
-
-fate-matroska: $(FATE_MATROSKA-yes) $(FATE_MATROSKA_FFPROBE-yes) $(FATE_MATROSKA_FFMPEG_FFPROBE-yes)
diff --git a/tests/fate/mxf.mak b/tests/fate/mxf.mak
index 3a10961..ca119fa 100644
--- a/tests/fate/mxf.mak
+++ b/tests/fate/mxf.mak
@@ -45,8 +45,9 @@
 fate-mxf-user-comments: $(SAMPLES)/mxf/Sony-00001.mxf
 fate-mxf-user-comments: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -c copy -metadata "comment_test=value" -fflags +bitexact -f mxf
 
-FATE_MXF_D10_USER_COMMENTS-$(call ALLYES, FILE_PROTOCOL MXF_DEMUXER DVVIDEO_DECODER SCALE_FILTER MPEG2VIDEO_ENCODER MXF_D10_MUXER EXTRACT_EXTRADATA_BSF MPEGVIDEO_PARSER PIPE_PROTOCOL FRAMECRC_MUXER) += fate-mxf-d10-user-comments
-fate-mxf-d10-user-comments: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Avid-00005.mxf mxf_d10 "-c:v mpeg2video -b:v 30000k -minrate:v 30000k -maxrate:v 30000k -bufsize:v 30000k -rc_init_occupancy 30000k -vf scale=w=1280:h=720 -an -metadata comment_test=value -metadata company_name=FATE-company -metadata product_name=FATE-test -metadata product_version=3.14159 -store_user_comments 1" "-c copy -frames:v 5" "" "-show_entries format_tags"
+FATE_MXF_D10_USER_COMMENTS-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += fate-mxf-d10-user-comments
+fate-mxf-d10-user-comments: $(SAMPLES)/mxf/Sony-00001.mxf
+fate-mxf-d10-user-comments: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -c copy -metadata "comment_test=value" -store_user_comments 1 -fflags +bitexact -f mxf_d10
 
 FATE_MXF_OPATOM_USER_COMMENTS-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += fate-mxf-opatom-user-comments
 fate-mxf-opatom-user-comments: $(SAMPLES)/mxf/Sony-00001.mxf
@@ -55,8 +56,7 @@
 FATE_MXF-$(CONFIG_MXF_DEMUXER) += $(FATE_MXF)
 
 FATE_SAMPLES_AVCONV += $(FATE_MXF-yes) $(FATE_MXF_REEL_NAME-yes)
-FATE_SAMPLES_AVCONV += $(FATE_MXF_USER_COMMENTS-yes) $(FATE_MXF_OPATOM_USER_COMMENTS-yes)
-FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MXF_D10_USER_COMMENTS-yes)
+FATE_SAMPLES_AVCONV += $(FATE_MXF_USER_COMMENTS-yes) $(FATE_MXF_D10_USER_COMMENTS-yes) $(FATE_MXF_OPATOM_USER_COMMENTS-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_MXF_PROBE-yes)
 
 fate-mxf: $(FATE_MXF-yes) $(FATE_MXF_PROBE-yes) $(FATE_MXF_REEL_NAME-yes) $(FATE_MXF_USER_COMMENTS-yes) $(FATE_MXF_D10_USER_COMMENTS-yes) $(FATE_MXF_OPATOM_USER_COMMENTS-yes)
diff --git a/tests/fate/seek.mak b/tests/fate/seek.mak
index 5efec32..98d2b54 100644
--- a/tests/fate/seek.mak
+++ b/tests/fate/seek.mak
@@ -270,7 +270,6 @@
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK) $(FATE_SEEK_EXTRA): libavformat/tests/seek$(EXESUF)
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK): CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_PATH)/tests/data/$(SRC)
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK): fate-seek-%: fate-%
-$(subst fate-seek-,fate-,$(FATE_SAMPLES_SEEK) $(FATE_SEEK)): KEEP_OVERRIDE = -keep
 fate-seek-%: REF = $(SRC_PATH)/tests/ref/seek/$(@:fate-seek-%=%)
 
 FATE_AVCONV += $(FATE_SEEK)
diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak
index ee65afe..6323d0f 100644
--- a/tests/fate/subtitles.mak
+++ b/tests/fate/subtitles.mak
@@ -106,9 +106,6 @@
 FATE_SUBTITLES-$(call ALLYES, MPEGTS_DEMUXER DVBSUB_DECODER DVBSUB_ENCODER) += fate-sub-dvb
 fate-sub-dvb: CMD = framecrc -i $(TARGET_SAMPLES)/sub/dvbsubtest_filter.ts -map s:0 -c dvbsub
 
-FATE_SUBTITLES-$(call ALLYES, FILE_PROTOCOL PIPE_PROTOCOL SRT_DEMUXER SUBRIP_DECODER TTML_ENCODER TTML_MUXER) += fate-sub-ttmlenc
-fate-sub-ttmlenc: CMD = fmtstdout ttml -i $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt
-
 FATE_SUBTITLES-$(call ENCMUX, ASS, ASS) += $(FATE_SUBTITLES_ASS-yes)
 FATE_SUBTITLES += $(FATE_SUBTITLES-yes)
 
diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index ef89236..1e9c0d5 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -4,8 +4,8 @@
 fate-vsynth3-%: SRC = tests/data/vsynth3.yuv
 fate-vsynth%: CODEC = $(word 3, $(subst -, ,$(@)))
 fate-vsynth%: FMT = avi
-fate-vsynth%: CMD = enc_dec "rawvideo -s 352x288 -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 352x288 -pix_fmt yuv420p -vsync 0 $(DECOPTS)" "$(KEEP_OVERRIDE)" "$(DECINOPTS)"
-fate-vsynth3-%: CMD = enc_dec "rawvideo -s $(FATEW)x$(FATEH) -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s $(FATEW)x$(FATEH) -pix_fmt yuv420p -vsync 0 $(DECOPTS)" "" "$(DECINOPTS)"
+fate-vsynth%: CMD = enc_dec "rawvideo -s 352x288 -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 352x288 -pix_fmt yuv420p -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
+fate-vsynth3-%: CMD = enc_dec "rawvideo -s $(FATEW)x$(FATEH) -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s $(FATEW)x$(FATEH) -pix_fmt yuv420p -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
 fate-vsynth%: CMP_UNIT = 1
 fate-vsynth%: REF = $(SRC_PATH)/tests/ref/vsynth/$(@:fate-%=%)
 
diff --git a/tests/fate/video.mak b/tests/fate/video.mak
index d6b5770..4877740 100644
--- a/tests/fate/video.mak
+++ b/tests/fate/video.mak
@@ -43,12 +43,6 @@
 FATE_VIDEO-$(call DEMDEC, AVI, AURA2) += fate-auravision-v2
 fate-auravision-v2: CMD = framecrc -i $(TARGET_SAMPLES)/auravision/salma-hayek-in-ugly-betty-partial-avi -an
 
-FATE_VIDEO-$(call DEMDEC, AVI, AVRN) += fate-avid-interlaced
-fate-avid-interlaced: CMD = framecrc -i $(TARGET_SAMPLES)/avid/avid_ntsc_interlaced.avi
-
-FATE_VIDEO-$(call DEMDEC, MOV, MJPEG) += fate-avid-meridian
-fate-avid-meridian: CMD = framecrc -i $(TARGET_SAMPLES)/avid/avidmeridianntsc.mov
-
 FATE_VIDEO-$(call DEMDEC, BETHSOFTVID, BETHSOFTVID) += fate-bethsoft-vid
 fate-bethsoft-vid: CMD = framecrc -i $(TARGET_SAMPLES)/bethsoft-vid/ANIM0001.VID -t 5 -pix_fmt rgb24 -vf scale -af aresample
 
@@ -207,9 +201,6 @@
 FATE_VIDEO-$(call DEMDEC, AVI, KMVC) += fate-kmvc
 fate-kmvc: CMD = framecrc -i $(TARGET_SAMPLES)/KMVC/LOGO1.AVI -an -t 3 -pix_fmt rgb24 -vf scale
 
-FATE_VIDEO-$(call DEMDEC, AVI, LSCR) += fate-lscr
-fate-lscr: CMD = framecrc -i $(TARGET_SAMPLES)/lscr/lscr_compr9_short.avi
-
 FATE_MAGICYUV += fate-magicyuv-y4444i \
                  fate-magicyuv-y400i  \
                  fate-magicyuv-y420   \
diff --git a/tests/ref/fate/apng-dispose-previous b/tests/ref/fate/apng-dispose-previous
deleted file mode 100644
index 8c45639..0000000
--- a/tests/ref/fate/apng-dispose-previous
+++ /dev/null
@@ -1,139 +0,0 @@
-#tb 0: 1/10
-#media_type 0: video
-#codec_id 0: rawvideo
-#dimensions 0: 85x128
-#sar 0: 0/1
-0,          0,          0,        1,    43520, 0xff012b7c
-0,          1,          1,        1,    43520, 0x76842464
-0,          2,          2,        1,    43520, 0xa35de191
-0,          3,          3,        1,    43520, 0x7ece479c
-0,          4,          4,        1,    43520, 0xea12fa4a
-0,          5,          5,        1,    43520, 0xcb2c2256
-0,          6,          6,        1,    43520, 0x7d225965
-0,          7,          7,        1,    43520, 0xc0d95d3f
-0,          8,          8,        1,    43520, 0xee864d84
-0,          9,          9,        1,    43520, 0x1fadbb0e
-0,         10,         10,        1,    43520, 0xab89647b
-0,         11,         11,        1,    43520, 0x206141bc
-0,         12,         12,        1,    43520, 0x6432e720
-0,         13,         13,        1,    43520, 0xe25ab561
-0,         14,         14,        1,    43520, 0xc2df7c6b
-0,         15,         15,        1,    43520, 0x372768c3
-0,         16,         16,        1,    43520, 0xfeea0d7b
-0,         17,         17,        1,    43520, 0x89c1f76d
-0,         18,         18,        1,    43520, 0xae16c8b3
-0,         19,         19,        1,    43520, 0x98949570
-0,         20,         20,        1,    43520, 0x5bb75099
-0,         21,         21,        1,    43520, 0xb4c73263
-0,         22,         22,        1,    43520, 0xcf26f441
-0,         23,         23,        1,    43520, 0xba47d23b
-0,         24,         24,        1,    43520, 0x4c3e87da
-0,         25,         25,        1,    43520, 0xe95b7398
-0,         26,         26,        1,    43520, 0x00575c74
-0,         27,         27,        1,    43520, 0xea1d59f6
-0,         28,         28,        1,    43520, 0xbede4d2e
-0,         29,         29,        1,    43520, 0x9ed736a6
-0,         30,         30,        1,    43520, 0x8b027f56
-0,         31,         31,        1,    43520, 0x1db24f15
-0,         32,         32,        1,    43520, 0x1835a2dd
-0,         33,         33,        1,    43520, 0xfda26b24
-0,         34,         34,        1,    43520, 0x52f3e8eb
-0,         35,         35,        1,    43520, 0xda01102f
-0,         36,         36,        1,    43520, 0x443adff3
-0,         37,         37,        1,    43520, 0x46c72f9a
-0,         38,         38,        1,    43520, 0x3ec78642
-0,         39,         39,        1,    43520, 0x12033c40
-0,         40,         40,        1,    43520, 0x41fe0964
-0,         41,         41,        1,    43520, 0xc7a53be5
-0,         42,         42,        1,    43520, 0x4b185aa0
-0,         43,         43,        1,    43520, 0xf45cc1f0
-0,         44,         44,        1,    43520, 0x8bdc77cd
-0,         45,         45,        1,    43520, 0x94c5ac41
-0,         46,         46,        1,    43520, 0xfbabeefe
-0,         47,         47,        1,    43520, 0x92d657d9
-0,         48,         48,        1,    43520, 0x09dbd475
-0,         49,         49,        1,    43520, 0x5f9926e4
-0,         50,         50,        1,    43520, 0x4fdb5a64
-0,         51,         51,        1,    43520, 0xc0a382f6
-0,         52,         52,        1,    43520, 0x104f9b45
-0,         53,         53,        1,    43520, 0xfaf5d8f7
-0,         54,         54,        1,    43520, 0x2559e38b
-0,         55,         55,        1,    43520, 0x82890381
-0,         56,         56,        1,    43520, 0xfe7aec01
-0,         57,         57,        1,    43520, 0x4543f499
-0,         58,         58,        1,    43520, 0x60d7cbd1
-0,         59,         59,        1,    43520, 0x576fc249
-0,         60,         60,        1,    43520, 0xc96d9035
-0,         61,         61,        1,    43520, 0x40857b3a
-0,         62,         62,        1,    43520, 0x422a2eef
-0,         63,         63,        1,    43520, 0xb1510101
-0,         64,         64,        1,    43520, 0x3f619ad7
-0,         65,         65,        1,    43520, 0x497f42fa
-0,         66,         66,        1,    43520, 0x8b4b1ce2
-0,         67,         67,        1,    43520, 0x21f2f75b
-0,         68,         68,        1,    43520, 0x8b4b1ce2
-0,         69,         69,        1,    43520, 0x497f42fa
-0,         70,         70,        1,    43520, 0x3f619ad7
-0,         71,         71,        1,    43520, 0xb1510101
-0,         72,         72,        1,    43520, 0x422a2eef
-0,         73,         73,        1,    43520, 0x40857b3a
-0,         74,         74,        1,    43520, 0xc96d9035
-0,         75,         75,        1,    43520, 0x576fc249
-0,         76,         76,        1,    43520, 0x60d7cbd1
-0,         77,         77,        1,    43520, 0x4543f499
-0,         78,         78,        1,    43520, 0xfe7aec01
-0,         79,         79,        1,    43520, 0x82890381
-0,         80,         80,        1,    43520, 0x2559e38b
-0,         81,         81,        1,    43520, 0xfaf5d8f7
-0,         82,         82,        1,    43520, 0x104f9b45
-0,         83,         83,        1,    43520, 0xc0a382f6
-0,         84,         84,        1,    43520, 0x4fdb5a64
-0,         85,         85,        1,    43520, 0x5f9926e4
-0,         86,         86,        1,    43520, 0x09dbd475
-0,         87,         87,        1,    43520, 0x92d657d9
-0,         88,         88,        1,    43520, 0xfbabeefe
-0,         89,         89,        1,    43520, 0x94c5ac41
-0,         90,         90,        1,    43520, 0x8bdc77cd
-0,         91,         91,        1,    43520, 0xf45cc1f0
-0,         92,         92,        1,    43520, 0x4b185aa0
-0,         93,         93,        1,    43520, 0xc7a53be5
-0,         94,         94,        1,    43520, 0x41fe0964
-0,         95,         95,        1,    43520, 0x12033c40
-0,         96,         96,        1,    43520, 0x3ec78642
-0,         97,         97,        1,    43520, 0x46c72f9a
-0,         98,         98,        1,    43520, 0x443adff3
-0,         99,         99,        1,    43520, 0xda01102f
-0,        100,        100,        1,    43520, 0x52f3e8eb
-0,        101,        101,        1,    43520, 0xfda26b24
-0,        102,        102,        1,    43520, 0x1835a2dd
-0,        103,        103,        1,    43520, 0x1db24f15
-0,        104,        104,        1,    43520, 0x8b027f56
-0,        105,        105,        1,    43520, 0x9ed736a6
-0,        106,        106,        1,    43520, 0xbede4d2e
-0,        107,        107,        1,    43520, 0xea1d59f6
-0,        108,        108,        1,    43520, 0x00575c74
-0,        109,        109,        1,    43520, 0xe95b7398
-0,        110,        110,        1,    43520, 0x4c3e87da
-0,        111,        111,        1,    43520, 0xba47d23b
-0,        112,        112,        1,    43520, 0xcf26f441
-0,        113,        113,        1,    43520, 0xb4c73263
-0,        114,        114,        1,    43520, 0x5bb75099
-0,        115,        115,        1,    43520, 0x98949570
-0,        116,        116,        1,    43520, 0xae16c8b3
-0,        117,        117,        1,    43520, 0x89c1f76d
-0,        118,        118,        1,    43520, 0xfeea0d7b
-0,        119,        119,        1,    43520, 0x372768c3
-0,        120,        120,        1,    43520, 0xc2df7c6b
-0,        121,        121,        1,    43520, 0xe25ab561
-0,        122,        122,        1,    43520, 0x6432e720
-0,        123,        123,        1,    43520, 0x206141bc
-0,        124,        124,        1,    43520, 0xab89647b
-0,        125,        125,        1,    43520, 0x1fadbb0e
-0,        126,        126,        1,    43520, 0xee864d84
-0,        127,        127,        1,    43520, 0xc0d95d3f
-0,        128,        128,        1,    43520, 0x7d225965
-0,        129,        129,        1,    43520, 0xcb2c2256
-0,        130,        130,        1,    43520, 0xea12fa4a
-0,        131,        131,        1,    43520, 0x7ece479c
-0,        132,        132,        1,    43520, 0xa35de191
-0,        133,        133,        1,    43520, 0x76842464
diff --git a/tests/ref/fate/avid-interlaced b/tests/ref/fate/avid-interlaced
deleted file mode 100644
index 2efa583..0000000
--- a/tests/ref/fate/avid-interlaced
+++ /dev/null
@@ -1,7 +0,0 @@
-#tb 0: 100/2397
-#media_type 0: video
-#codec_id 0: rawvideo
-#dimensions 0: 720x486
-#sar 0: 0/1
-0,          0,          0,        1,   699840, 0xc59a264e
-0,          1,          1,        1,   699840, 0x06f13712
diff --git a/tests/ref/fate/avid-meridian b/tests/ref/fate/avid-meridian
deleted file mode 100644
index 313351e..0000000
--- a/tests/ref/fate/avid-meridian
+++ /dev/null
@@ -1,15 +0,0 @@
-#tb 0: 20859/500000
-#media_type 0: video
-#codec_id 0: rawvideo
-#dimensions 0: 320x240
-#sar 0: 0/1
-0,          0,          0,        1,   153600, 0xbfd35869
-0,          1,          1,        1,   153600, 0xbe7c74a0
-0,          2,          2,        1,   153600, 0x9f2524ee
-0,          3,          3,        1,   153600, 0x3c8df375
-0,          4,          4,        1,   153600, 0xe0ac5d7d
-0,          5,          5,        1,   153600, 0xf0c6da50
-0,          6,          6,        1,   153600, 0xbd50751f
-0,          7,          7,        1,   153600, 0x51caf5f7
-0,          8,          8,        1,   153600, 0x27752d4f
-0,          9,          9,        1,   153600, 0x63a0d0dc
diff --git a/tests/ref/fate/cdxl-bitline-ham6 b/tests/ref/fate/cdxl-bitline-ham6
index 9d30e66..37c1459 100644
--- a/tests/ref/fate/cdxl-bitline-ham6
+++ b/tests/ref/fate/cdxl-bitline-ham6
@@ -1,4 +1,4 @@
-#tb 0: 1/15
+#tb 0: 1/50
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 162x130
diff --git a/tests/ref/fate/cdxl-demux b/tests/ref/fate/cdxl-demux
index 324a40f..f133475 100644
--- a/tests/ref/fate/cdxl-demux
+++ b/tests/ref/fate/cdxl-demux
@@ -1,30 +1,30 @@
-#tb 0: 628/3675
+#tb 0: 1/11025
 #media_type 0: video
 #codec_id 0: cdxl
 #dimensions 0: 176x128
 #sar 0: 0/1
 #tb 1: 1/11025
 #media_type 1: audio
-#codec_id 1: pcm_s8_planar
+#codec_id 1: pcm_s8
 #sample_rate 1: 11025
 #channel_layout 1: 4
 #channel_layout_name 1: mono
-0,          0,          0,        1,    22688, 0xc954a244
+0,          0,          0,     1884,    22688, 0xc954a244
 1,          0,          0,     1884,     1884, 0x06925e3e
-0,          1,          1,        1,    22688, 0x3ee4a304
+0,       1884,       1884,     1884,    22688, 0x3ee4a304
 1,       1884,       1884,     1884,     1884, 0x1957ab65
-0,          2,          2,        1,    22688, 0x9777a305
+0,       3768,       3768,     1884,    22688, 0x9777a305
 1,       3768,       3768,     1884,     1884, 0x7fcd6e47
-0,          3,          3,        1,    22688, 0xf00aa306
+0,       5652,       5652,     1884,    22688, 0xf00aa306
 1,       5652,       5652,     1884,     1884, 0xc974878e
-0,          4,          4,        1,    22688, 0x48aca307
+0,       7536,       7536,     1884,    22688, 0x48aca307
 1,       7536,       7536,     1884,     1884, 0xecb5c4c8
-0,          5,          5,        1,    22688, 0xa13fa308
+0,       9420,       9420,     1884,    22688, 0xa13fa308
 1,       9420,       9420,     1884,     1884, 0x87adce5f
-0,          6,          6,        1,    22688, 0xf9d2a309
+0,      11304,      11304,     1884,    22688, 0xf9d2a309
 1,      11304,      11304,     1884,     1884, 0x3cf097e4
-0,          7,          7,        1,    22688, 0x5274a30a
+0,      13188,      13188,     1884,    22688, 0x5274a30a
 1,      13188,      13188,     1884,     1884, 0xcc218105
-0,          8,          8,        1,    22688, 0xab07a30b
+0,      15072,      15072,     1884,    22688, 0xab07a30b
 1,      15072,      15072,     1884,     1884, 0xf685762f
-0,          9,          9,        1,    17896, 0x1a696b6e
+0,      16956,      16956,     1884,    17896, 0x1a696b6e
diff --git a/tests/ref/fate/cdxl-ham6 b/tests/ref/fate/cdxl-ham6
index 4c2c14b..1602c8a 100644
--- a/tests/ref/fate/cdxl-ham6
+++ b/tests/ref/fate/cdxl-ham6
@@ -1,4 +1,4 @@
-#tb 0: 12/121
+#tb 0: 52/525
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 160x120
diff --git a/tests/ref/fate/cdxl-ham8 b/tests/ref/fate/cdxl-ham8
index cdd4f59..ab1f76a 100644
--- a/tests/ref/fate/cdxl-ham8
+++ b/tests/ref/fate/cdxl-ham8
@@ -1,4 +1,4 @@
-#tb 0: 628/3675
+#tb 0: 12/281
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 176x128
diff --git a/tests/ref/fate/cdxl-pal8 b/tests/ref/fate/cdxl-pal8
index 71e44bf..a242b0c 100644
--- a/tests/ref/fate/cdxl-pal8
+++ b/tests/ref/fate/cdxl-pal8
@@ -1,4 +1,4 @@
-#tb 0: 1/15
+#tb 0: 1/50
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 176x128
diff --git a/tests/ref/fate/cdxl-pal8-small b/tests/ref/fate/cdxl-pal8-small
index 3481238..326eef7 100644
--- a/tests/ref/fate/cdxl-pal8-small
+++ b/tests/ref/fate/cdxl-pal8-small
@@ -1,4 +1,4 @@
-#tb 0: 1001/30000
+#tb 0: 368/11025
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 128x80
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
index 8788321..e49915e 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
@@ -1 +1 @@
-c70ba87645ddecc8554036eb83a90e59 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
+861b9c23587d0a09caa78c3651faf5a0 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
index 2a55890..f6efc00 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
@@ -1 +1 @@
-d17d5c3291b408d624205aca9e7ad6b4 *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
+84496cfe2d668db395280ea67e5c6fbe *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
index 3e3e3a5..a590f6f 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
@@ -1,124 +1,124 @@
-video|0|0|0.000000|-1|-0.040000|1|0.040000|24801|7168|K_
-audio|1|0|0.000000|0|0.000000|1920|0.040000|3840|32256|K_
-video|0|3|0.120000|0|0.000000|1|0.040000|16743|36864|__
-audio|1|1920|0.040000|1920|0.040000|1920|0.040000|3840|53760|K_
-video|0|1|0.040000|1|0.040000|1|0.040000|13812|58368|__
-audio|1|3840|0.080000|3840|0.080000|1920|0.040000|3840|72704|K_
-video|0|2|0.080000|2|0.080000|1|0.040000|13607|77312|__
-audio|1|5760|0.120000|5760|0.120000|1920|0.040000|3840|91136|K_
-video|0|6|0.240000|3|0.120000|1|0.040000|16158|95744|__
-audio|1|7680|0.160000|7680|0.160000|1920|0.040000|3840|112128|K_
-video|0|4|0.160000|4|0.160000|1|0.040000|13943|116736|__
-audio|1|9600|0.200000|9600|0.200000|1920|0.040000|3840|131072|K_
-video|0|5|0.200000|5|0.200000|1|0.040000|11223|135680|__
-audio|1|11520|0.240000|11520|0.240000|1920|0.040000|3840|146944|K_
-video|0|9|0.360000|6|0.240000|1|0.040000|20298|151552|__
-audio|1|13440|0.280000|13440|0.280000|1920|0.040000|3840|172032|K_
-video|0|7|0.280000|7|0.280000|1|0.040000|13341|176640|__
-audio|1|15360|0.320000|15360|0.320000|1920|0.040000|3840|190464|K_
-video|0|8|0.320000|8|0.320000|1|0.040000|12362|195072|__
-audio|1|17280|0.360000|17280|0.360000|1920|0.040000|3840|207872|K_
-video|0|12|0.480000|9|0.360000|1|0.040000|24786|212480|K_
-audio|1|19200|0.400000|19200|0.400000|1920|0.040000|3840|237568|K_
-video|0|10|0.400000|10|0.400000|1|0.040000|13377|242176|__
-audio|1|21120|0.440000|21120|0.440000|1920|0.040000|3840|256000|K_
-video|0|11|0.440000|11|0.440000|1|0.040000|15624|260608|__
-audio|1|23040|0.480000|23040|0.480000|1920|0.040000|3840|276480|K_
-video|0|15|0.600000|12|0.480000|1|0.040000|22597|281088|__
-audio|1|24960|0.520000|24960|0.520000|1920|0.040000|3840|304128|K_
-video|0|13|0.520000|13|0.520000|1|0.040000|15028|308736|__
-audio|1|26880|0.560000|26880|0.560000|1920|0.040000|3840|324096|K_
-video|0|14|0.560000|14|0.560000|1|0.040000|14014|328704|__
-audio|1|28800|0.600000|28800|0.600000|1920|0.040000|3840|343040|K_
-video|0|18|0.720000|15|0.600000|1|0.040000|20731|347648|__
-audio|1|30720|0.640000|30720|0.640000|1920|0.040000|3840|368640|K_
-video|0|16|0.640000|16|0.640000|1|0.040000|11946|373248|__
-audio|1|32640|0.680000|32640|0.680000|1920|0.040000|3840|385536|K_
-video|0|17|0.680000|17|0.680000|1|0.040000|14464|390144|__
-audio|1|34560|0.720000|34560|0.720000|1920|0.040000|3840|404992|K_
-video|0|21|0.840000|18|0.720000|1|0.040000|16189|409600|__
-audio|1|36480|0.760000|36480|0.760000|1920|0.040000|3840|425984|K_
-video|0|19|0.760000|19|0.760000|1|0.040000|10524|430592|__
-audio|1|38400|0.800000|38400|0.800000|1920|0.040000|3840|441344|K_
-video|0|20|0.800000|20|0.800000|1|0.040000|10599|445952|__
-audio|1|40320|0.840000|40320|0.840000|1920|0.040000|3840|456704|K_
-video|0|24|0.960000|21|0.840000|1|0.040000|24711|461312|K_
-audio|1|42240|0.880000|42240|0.880000|1920|0.040000|3840|486400|K_
-video|0|22|0.880000|22|0.880000|1|0.040000|10840|491008|__
-audio|1|44160|0.920000|44160|0.920000|1920|0.040000|3840|502272|K_
-video|0|23|0.920000|23|0.920000|1|0.040000|13350|506880|__
-audio|1|46080|0.960000|46080|0.960000|1920|0.040000|3840|520704|K_
-video|0|17|0.680000|14|0.560000|1|0.040000|24786|212480|K_
-audio|1|28800|0.600000|28800|0.600000|1920|0.040000|3840|237568|K_
-video|0|15|0.600000|15|0.600000|1|0.040000|13377|242176|__
-audio|1|30720|0.640000|30720|0.640000|1920|0.040000|3840|256000|K_
-video|0|16|0.640000|16|0.640000|1|0.040000|15624|260608|__
-audio|1|32640|0.680000|32640|0.680000|1920|0.040000|3840|276480|K_
-video|0|20|0.800000|17|0.680000|1|0.040000|22597|281088|__
-audio|1|34560|0.720000|34560|0.720000|1920|0.040000|3840|304128|K_
-video|0|18|0.720000|18|0.720000|1|0.040000|15028|308736|__
-audio|1|36480|0.760000|36480|0.760000|1920|0.040000|3840|324096|K_
-video|0|19|0.760000|19|0.760000|1|0.040000|14014|328704|__
-audio|1|38400|0.800000|38400|0.800000|1920|0.040000|3840|343040|K_
-video|0|23|0.920000|20|0.800000|1|0.040000|20731|347648|__
-audio|1|40320|0.840000|40320|0.840000|1920|0.040000|3840|368640|K_
-video|0|21|0.840000|21|0.840000|1|0.040000|11946|373248|__
-audio|1|42240|0.880000|42240|0.880000|1920|0.040000|3840|385536|K_
-video|0|22|0.880000|22|0.880000|1|0.040000|14464|390144|__
-audio|1|44160|0.920000|44160|0.920000|1920|0.040000|3840|404992|K_
-video|0|26|1.040000|23|0.920000|1|0.040000|16189|409600|__
-audio|1|46080|0.960000|46080|0.960000|1920|0.040000|3840|425984|K_
-video|0|24|0.960000|24|0.960000|1|0.040000|10524|430592|__
-audio|1|48000|1.000000|48000|1.000000|1920|0.040000|3840|441344|K_
-video|0|25|1.000000|25|1.000000|1|0.040000|10599|445952|__
-audio|1|49920|1.040000|49920|1.040000|1920|0.040000|3840|456704|K_
-video|0|29|1.160000|26|1.040000|1|0.040000|24711|461312|K_
-audio|1|51840|1.080000|51840|1.080000|1920|0.040000|3840|486400|K_
-video|0|27|1.080000|27|1.080000|1|0.040000|10840|491008|__
-audio|1|53760|1.120000|53760|1.120000|1920|0.040000|3840|502272|K_
-video|0|28|1.120000|28|1.120000|1|0.040000|13350|506880|__
-audio|1|55680|1.160000|55680|1.160000|1920|0.040000|3840|520704|K_
-video|0|25|1.000000|24|0.960000|1|0.040000|24801|7168|K_|1
+video|0|0|0.000000|-1|-0.040000|1|0.040000|N/A|N/A|24801|7168|K_
+audio|1|0|0.000000|0|0.000000|1920|0.040000|N/A|N/A|3840|32256|K_
+video|0|3|0.120000|0|0.000000|1|0.040000|N/A|N/A|16743|36864|__
+audio|1|1920|0.040000|1920|0.040000|1920|0.040000|N/A|N/A|3840|53760|K_
+video|0|1|0.040000|1|0.040000|1|0.040000|N/A|N/A|13812|58368|__
+audio|1|3840|0.080000|3840|0.080000|1920|0.040000|N/A|N/A|3840|72704|K_
+video|0|2|0.080000|2|0.080000|1|0.040000|N/A|N/A|13607|77312|__
+audio|1|5760|0.120000|5760|0.120000|1920|0.040000|N/A|N/A|3840|91136|K_
+video|0|6|0.240000|3|0.120000|1|0.040000|N/A|N/A|16158|95744|__
+audio|1|7680|0.160000|7680|0.160000|1920|0.040000|N/A|N/A|3840|112128|K_
+video|0|4|0.160000|4|0.160000|1|0.040000|N/A|N/A|13943|116736|__
+audio|1|9600|0.200000|9600|0.200000|1920|0.040000|N/A|N/A|3840|131072|K_
+video|0|5|0.200000|5|0.200000|1|0.040000|N/A|N/A|11223|135680|__
+audio|1|11520|0.240000|11520|0.240000|1920|0.040000|N/A|N/A|3840|146944|K_
+video|0|9|0.360000|6|0.240000|1|0.040000|N/A|N/A|20298|151552|__
+audio|1|13440|0.280000|13440|0.280000|1920|0.040000|N/A|N/A|3840|172032|K_
+video|0|7|0.280000|7|0.280000|1|0.040000|N/A|N/A|13341|176640|__
+audio|1|15360|0.320000|15360|0.320000|1920|0.040000|N/A|N/A|3840|190464|K_
+video|0|8|0.320000|8|0.320000|1|0.040000|N/A|N/A|12362|195072|__
+audio|1|17280|0.360000|17280|0.360000|1920|0.040000|N/A|N/A|3840|207872|K_
+video|0|12|0.480000|9|0.360000|1|0.040000|N/A|N/A|24786|212480|K_
+audio|1|19200|0.400000|19200|0.400000|1920|0.040000|N/A|N/A|3840|237568|K_
+video|0|10|0.400000|10|0.400000|1|0.040000|N/A|N/A|13377|242176|__
+audio|1|21120|0.440000|21120|0.440000|1920|0.040000|N/A|N/A|3840|256000|K_
+video|0|11|0.440000|11|0.440000|1|0.040000|N/A|N/A|15624|260608|__
+audio|1|23040|0.480000|23040|0.480000|1920|0.040000|N/A|N/A|3840|276480|K_
+video|0|15|0.600000|12|0.480000|1|0.040000|N/A|N/A|22597|281088|__
+audio|1|24960|0.520000|24960|0.520000|1920|0.040000|N/A|N/A|3840|304128|K_
+video|0|13|0.520000|13|0.520000|1|0.040000|N/A|N/A|15028|308736|__
+audio|1|26880|0.560000|26880|0.560000|1920|0.040000|N/A|N/A|3840|324096|K_
+video|0|14|0.560000|14|0.560000|1|0.040000|N/A|N/A|14014|328704|__
+audio|1|28800|0.600000|28800|0.600000|1920|0.040000|N/A|N/A|3840|343040|K_
+video|0|18|0.720000|15|0.600000|1|0.040000|N/A|N/A|20731|347648|__
+audio|1|30720|0.640000|30720|0.640000|1920|0.040000|N/A|N/A|3840|368640|K_
+video|0|16|0.640000|16|0.640000|1|0.040000|N/A|N/A|11946|373248|__
+audio|1|32640|0.680000|32640|0.680000|1920|0.040000|N/A|N/A|3840|385536|K_
+video|0|17|0.680000|17|0.680000|1|0.040000|N/A|N/A|14464|390144|__
+audio|1|34560|0.720000|34560|0.720000|1920|0.040000|N/A|N/A|3840|404992|K_
+video|0|21|0.840000|18|0.720000|1|0.040000|N/A|N/A|16189|409600|__
+audio|1|36480|0.760000|36480|0.760000|1920|0.040000|N/A|N/A|3840|425984|K_
+video|0|19|0.760000|19|0.760000|1|0.040000|N/A|N/A|10524|430592|__
+audio|1|38400|0.800000|38400|0.800000|1920|0.040000|N/A|N/A|3840|441344|K_
+video|0|20|0.800000|20|0.800000|1|0.040000|N/A|N/A|10599|445952|__
+audio|1|40320|0.840000|40320|0.840000|1920|0.040000|N/A|N/A|3840|456704|K_
+video|0|24|0.960000|21|0.840000|1|0.040000|N/A|N/A|24711|461312|K_
+audio|1|42240|0.880000|42240|0.880000|1920|0.040000|N/A|N/A|3840|486400|K_
+video|0|22|0.880000|22|0.880000|1|0.040000|N/A|N/A|10840|491008|__
+audio|1|44160|0.920000|44160|0.920000|1920|0.040000|N/A|N/A|3840|502272|K_
+video|0|23|0.920000|23|0.920000|1|0.040000|N/A|N/A|13350|506880|__
+audio|1|46080|0.960000|46080|0.960000|1920|0.040000|N/A|N/A|3840|520704|K_
+video|0|17|0.680000|14|0.560000|1|0.040000|N/A|N/A|24786|212480|K_
+audio|1|28800|0.600000|28800|0.600000|1920|0.040000|N/A|N/A|3840|237568|K_
+video|0|15|0.600000|15|0.600000|1|0.040000|N/A|N/A|13377|242176|__
+audio|1|30720|0.640000|30720|0.640000|1920|0.040000|N/A|N/A|3840|256000|K_
+video|0|16|0.640000|16|0.640000|1|0.040000|N/A|N/A|15624|260608|__
+audio|1|32640|0.680000|32640|0.680000|1920|0.040000|N/A|N/A|3840|276480|K_
+video|0|20|0.800000|17|0.680000|1|0.040000|N/A|N/A|22597|281088|__
+audio|1|34560|0.720000|34560|0.720000|1920|0.040000|N/A|N/A|3840|304128|K_
+video|0|18|0.720000|18|0.720000|1|0.040000|N/A|N/A|15028|308736|__
+audio|1|36480|0.760000|36480|0.760000|1920|0.040000|N/A|N/A|3840|324096|K_
+video|0|19|0.760000|19|0.760000|1|0.040000|N/A|N/A|14014|328704|__
+audio|1|38400|0.800000|38400|0.800000|1920|0.040000|N/A|N/A|3840|343040|K_
+video|0|23|0.920000|20|0.800000|1|0.040000|N/A|N/A|20731|347648|__
+audio|1|40320|0.840000|40320|0.840000|1920|0.040000|N/A|N/A|3840|368640|K_
+video|0|21|0.840000|21|0.840000|1|0.040000|N/A|N/A|11946|373248|__
+audio|1|42240|0.880000|42240|0.880000|1920|0.040000|N/A|N/A|3840|385536|K_
+video|0|22|0.880000|22|0.880000|1|0.040000|N/A|N/A|14464|390144|__
+audio|1|44160|0.920000|44160|0.920000|1920|0.040000|N/A|N/A|3840|404992|K_
+video|0|26|1.040000|23|0.920000|1|0.040000|N/A|N/A|16189|409600|__
+audio|1|46080|0.960000|46080|0.960000|1920|0.040000|N/A|N/A|3840|425984|K_
+video|0|24|0.960000|24|0.960000|1|0.040000|N/A|N/A|10524|430592|__
+audio|1|48000|1.000000|48000|1.000000|1920|0.040000|N/A|N/A|3840|441344|K_
+video|0|25|1.000000|25|1.000000|1|0.040000|N/A|N/A|10599|445952|__
+audio|1|49920|1.040000|49920|1.040000|1920|0.040000|N/A|N/A|3840|456704|K_
+video|0|29|1.160000|26|1.040000|1|0.040000|N/A|N/A|24711|461312|K_
+audio|1|51840|1.080000|51840|1.080000|1920|0.040000|N/A|N/A|3840|486400|K_
+video|0|27|1.080000|27|1.080000|1|0.040000|N/A|N/A|10840|491008|__
+audio|1|53760|1.120000|53760|1.120000|1920|0.040000|N/A|N/A|3840|502272|K_
+video|0|28|1.120000|28|1.120000|1|0.040000|N/A|N/A|13350|506880|__
+audio|1|55680|1.160000|55680|1.160000|1920|0.040000|N/A|N/A|3840|520704|K_
+video|0|25|1.000000|24|0.960000|1|0.040000|N/A|N/A|24801|7168|K_|1
 Strings Metadata
-audio|1|48000|1.000000|48000|1.000000|1920|0.040000|3840|32256|K_|1
+audio|1|48000|1.000000|48000|1.000000|1920|0.040000|N/A|N/A|3840|32256|K_|1
 Strings Metadata
-video|0|28|1.120000|25|1.000000|1|0.040000|16743|36864|__|1
+video|0|28|1.120000|25|1.000000|1|0.040000|N/A|N/A|16743|36864|__|1
 Strings Metadata
-audio|1|49920|1.040000|49920|1.040000|1920|0.040000|3840|53760|K_|1
+audio|1|49920|1.040000|49920|1.040000|1920|0.040000|N/A|N/A|3840|53760|K_|1
 Strings Metadata
-video|0|26|1.040000|26|1.040000|1|0.040000|13812|58368|__|1
+video|0|26|1.040000|26|1.040000|1|0.040000|N/A|N/A|13812|58368|__|1
 Strings Metadata
-audio|1|51840|1.080000|51840|1.080000|1920|0.040000|3840|72704|K_|1
+audio|1|51840|1.080000|51840|1.080000|1920|0.040000|N/A|N/A|3840|72704|K_|1
 Strings Metadata
-video|0|27|1.080000|27|1.080000|1|0.040000|13607|77312|__|1
+video|0|27|1.080000|27|1.080000|1|0.040000|N/A|N/A|13607|77312|__|1
 Strings Metadata
-audio|1|53760|1.120000|53760|1.120000|1920|0.040000|3840|91136|K_|1
+audio|1|53760|1.120000|53760|1.120000|1920|0.040000|N/A|N/A|3840|91136|K_|1
 Strings Metadata
-video|0|31|1.240000|28|1.120000|1|0.040000|16158|95744|__|1
+video|0|31|1.240000|28|1.120000|1|0.040000|N/A|N/A|16158|95744|__|1
 Strings Metadata
-audio|1|55680|1.160000|55680|1.160000|1920|0.040000|3840|112128|K_|1
+audio|1|55680|1.160000|55680|1.160000|1920|0.040000|N/A|N/A|3840|112128|K_|1
 Strings Metadata
-video|0|29|1.160000|29|1.160000|1|0.040000|13943|116736|__|1
+video|0|29|1.160000|29|1.160000|1|0.040000|N/A|N/A|13943|116736|__|1
 Strings Metadata
-audio|1|57600|1.200000|57600|1.200000|1920|0.040000|3840|131072|K_|1
+audio|1|57600|1.200000|57600|1.200000|1920|0.040000|N/A|N/A|3840|131072|K_|1
 Strings Metadata
-video|0|30|1.200000|30|1.200000|1|0.040000|11223|135680|__|1
+video|0|30|1.200000|30|1.200000|1|0.040000|N/A|N/A|11223|135680|__|1
 Strings Metadata
-audio|1|59520|1.240000|59520|1.240000|1920|0.040000|3840|146944|K_|1
+audio|1|59520|1.240000|59520|1.240000|1920|0.040000|N/A|N/A|3840|146944|K_|1
 Strings Metadata
-video|0|34|1.360000|31|1.240000|1|0.040000|20298|151552|__|1
+video|0|34|1.360000|31|1.240000|1|0.040000|N/A|N/A|20298|151552|__|1
 Strings Metadata
-audio|1|61440|1.280000|61440|1.280000|1920|0.040000|3840|172032|K_|1
+audio|1|61440|1.280000|61440|1.280000|1920|0.040000|N/A|N/A|3840|172032|K_|1
 Strings Metadata
-video|0|32|1.280000|32|1.280000|1|0.040000|13341|176640|__|1
+video|0|32|1.280000|32|1.280000|1|0.040000|N/A|N/A|13341|176640|__|1
 Strings Metadata
-audio|1|63360|1.320000|63360|1.320000|1920|0.040000|3840|190464|K_|1
+audio|1|63360|1.320000|63360|1.320000|1920|0.040000|N/A|N/A|3840|190464|K_|1
 Strings Metadata
-video|0|33|1.320000|33|1.320000|1|0.040000|12362|195072|__|1
+video|0|33|1.320000|33|1.320000|1|0.040000|N/A|N/A|12362|195072|__|1
 Strings Metadata
-audio|1|65280|1.360000|65280|1.360000|1920|0.040000|3840|207872|K_|1
+audio|1|65280|1.360000|65280|1.360000|1920|0.040000|N/A|N/A|3840|207872|K_|1
 Strings Metadata
-video|0|37|1.480000|34|1.360000|1|0.040000|24786|212480|K_|1
+video|0|37|1.480000|34|1.360000|1|0.040000|N/A|N/A|24786|212480|K_|1
 Strings Metadata
-0|mpeg2video|4|video|[0][0][0][0]|0x0000|352|288|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
-1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
+0|mpeg2video|4|video|1/25|[0][0][0][0]|0x0000|352|288|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|N/A|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
+1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x0000|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
index f329bba..8f3f2e5 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
@@ -1,82 +1,82 @@
-video|0|0|0.000000|0|0.000000|1|0.040000|150000|7168|K_
-audio|1|0|0.000000|0|0.000000|1920|0.040000|7680|157696|K_
-video|0|1|0.040000|1|0.040000|1|0.040000|150000|220160|K_
-audio|1|1920|0.040000|1920|0.040000|1920|0.040000|7680|370688|K_
-video|0|2|0.080000|2|0.080000|1|0.040000|150000|433152|K_
-audio|1|3840|0.080000|3840|0.080000|1920|0.040000|7680|583680|K_
-video|0|3|0.120000|3|0.120000|1|0.040000|150000|646144|K_
-audio|1|5760|0.120000|5760|0.120000|1920|0.040000|7680|796672|K_
-video|0|4|0.160000|4|0.160000|1|0.040000|150000|859136|K_
-audio|1|7680|0.160000|7680|0.160000|1920|0.040000|7680|1009664|K_
-video|0|5|0.200000|5|0.200000|1|0.040000|150000|1072128|K_
-audio|1|9600|0.200000|9600|0.200000|1920|0.040000|7680|1222656|K_
-video|0|6|0.240000|6|0.240000|1|0.040000|150000|1285120|K_
-audio|1|11520|0.240000|11520|0.240000|1920|0.040000|7680|1435648|K_
-video|0|7|0.280000|7|0.280000|1|0.040000|150000|1498112|K_
-audio|1|13440|0.280000|13440|0.280000|1920|0.040000|7680|1648640|K_
-video|0|8|0.320000|8|0.320000|1|0.040000|150000|1711104|K_
-audio|1|15360|0.320000|15360|0.320000|1920|0.040000|7680|1861632|K_
-video|0|9|0.360000|9|0.360000|1|0.040000|150000|1924096|K_
-audio|1|17280|0.360000|17280|0.360000|1920|0.040000|7680|2074624|K_
-video|0|10|0.400000|10|0.400000|1|0.040000|150000|2137088|K_
-audio|1|19200|0.400000|19200|0.400000|1920|0.040000|7680|2287616|K_
-video|0|11|0.440000|11|0.440000|1|0.040000|150000|2350080|K_
-audio|1|21120|0.440000|21120|0.440000|1920|0.040000|7680|2500608|K_
-video|0|12|0.480000|12|0.480000|1|0.040000|150000|2563072|K_
-audio|1|23040|0.480000|23040|0.480000|1920|0.040000|7680|2713600|K_
-video|0|13|0.520000|13|0.520000|1|0.040000|150000|2776064|K_
-audio|1|24960|0.520000|24960|0.520000|1920|0.040000|7680|2926592|K_
-video|0|14|0.560000|14|0.560000|1|0.040000|150000|2989056|K_
-audio|1|26880|0.560000|26880|0.560000|1920|0.040000|7680|3139584|K_
-video|0|15|0.600000|15|0.600000|1|0.040000|150000|3202048|K_
-audio|1|28800|0.600000|28800|0.600000|1920|0.040000|7680|3352576|K_
-video|0|16|0.640000|16|0.640000|1|0.040000|150000|3415040|K_
-audio|1|30720|0.640000|30720|0.640000|1920|0.040000|7680|3565568|K_
-video|0|17|0.680000|17|0.680000|1|0.040000|150000|3628032|K_
-audio|1|32640|0.680000|32640|0.680000|1920|0.040000|7680|3778560|K_
-video|0|18|0.720000|18|0.720000|1|0.040000|150000|3841024|K_
-audio|1|34560|0.720000|34560|0.720000|1920|0.040000|7680|3991552|K_
-video|0|19|0.760000|19|0.760000|1|0.040000|150000|4054016|K_
-audio|1|36480|0.760000|36480|0.760000|1920|0.040000|7680|4204544|K_
-video|0|20|0.800000|20|0.800000|1|0.040000|150000|4267008|K_
-audio|1|38400|0.800000|38400|0.800000|1920|0.040000|7680|4417536|K_
-video|0|21|0.840000|21|0.840000|1|0.040000|150000|4480000|K_
-audio|1|40320|0.840000|40320|0.840000|1920|0.040000|7680|4630528|K_
-video|0|22|0.880000|22|0.880000|1|0.040000|150000|4692992|K_
-audio|1|42240|0.880000|42240|0.880000|1920|0.040000|7680|4843520|K_
-video|0|23|0.920000|23|0.920000|1|0.040000|150000|4905984|K_
-audio|1|44160|0.920000|44160|0.920000|1920|0.040000|7680|5056512|K_
-video|0|24|0.960000|24|0.960000|1|0.040000|150000|5118976|K_
-audio|1|46080|0.960000|46080|0.960000|1920|0.040000|7680|5269504|K_
-video|0|25|1.000000|25|1.000000|1|0.040000|150000|4267008|K_
-audio|1|48000|1.000000|48000|1.000000|1920|0.040000|7680|4417536|K_
-video|0|26|1.040000|26|1.040000|1|0.040000|150000|4480000|K_
-audio|1|49920|1.040000|49920|1.040000|1920|0.040000|7680|4630528|K_
-video|0|27|1.080000|27|1.080000|1|0.040000|150000|4692992|K_
-audio|1|51840|1.080000|51840|1.080000|1920|0.040000|7680|4843520|K_
-video|0|28|1.120000|28|1.120000|1|0.040000|150000|4905984|K_
-audio|1|53760|1.120000|53760|1.120000|1920|0.040000|7680|5056512|K_
-video|0|29|1.160000|29|1.160000|1|0.040000|150000|5118976|K_
-audio|1|55680|1.160000|55680|1.160000|1920|0.040000|7680|5269504|K_
-video|0|30|1.200000|30|1.200000|1|0.040000|150000|1072128|K_|1
+video|0|0|0.000000|0|0.000000|1|0.040000|N/A|N/A|150000|7168|K_
+audio|1|0|0.000000|0|0.000000|1920|0.040000|N/A|N/A|7680|157696|K_
+video|0|1|0.040000|1|0.040000|1|0.040000|N/A|N/A|150000|220160|K_
+audio|1|1920|0.040000|1920|0.040000|1920|0.040000|N/A|N/A|7680|370688|K_
+video|0|2|0.080000|2|0.080000|1|0.040000|N/A|N/A|150000|433152|K_
+audio|1|3840|0.080000|3840|0.080000|1920|0.040000|N/A|N/A|7680|583680|K_
+video|0|3|0.120000|3|0.120000|1|0.040000|N/A|N/A|150000|646144|K_
+audio|1|5760|0.120000|5760|0.120000|1920|0.040000|N/A|N/A|7680|796672|K_
+video|0|4|0.160000|4|0.160000|1|0.040000|N/A|N/A|150000|859136|K_
+audio|1|7680|0.160000|7680|0.160000|1920|0.040000|N/A|N/A|7680|1009664|K_
+video|0|5|0.200000|5|0.200000|1|0.040000|N/A|N/A|150000|1072128|K_
+audio|1|9600|0.200000|9600|0.200000|1920|0.040000|N/A|N/A|7680|1222656|K_
+video|0|6|0.240000|6|0.240000|1|0.040000|N/A|N/A|150000|1285120|K_
+audio|1|11520|0.240000|11520|0.240000|1920|0.040000|N/A|N/A|7680|1435648|K_
+video|0|7|0.280000|7|0.280000|1|0.040000|N/A|N/A|150000|1498112|K_
+audio|1|13440|0.280000|13440|0.280000|1920|0.040000|N/A|N/A|7680|1648640|K_
+video|0|8|0.320000|8|0.320000|1|0.040000|N/A|N/A|150000|1711104|K_
+audio|1|15360|0.320000|15360|0.320000|1920|0.040000|N/A|N/A|7680|1861632|K_
+video|0|9|0.360000|9|0.360000|1|0.040000|N/A|N/A|150000|1924096|K_
+audio|1|17280|0.360000|17280|0.360000|1920|0.040000|N/A|N/A|7680|2074624|K_
+video|0|10|0.400000|10|0.400000|1|0.040000|N/A|N/A|150000|2137088|K_
+audio|1|19200|0.400000|19200|0.400000|1920|0.040000|N/A|N/A|7680|2287616|K_
+video|0|11|0.440000|11|0.440000|1|0.040000|N/A|N/A|150000|2350080|K_
+audio|1|21120|0.440000|21120|0.440000|1920|0.040000|N/A|N/A|7680|2500608|K_
+video|0|12|0.480000|12|0.480000|1|0.040000|N/A|N/A|150000|2563072|K_
+audio|1|23040|0.480000|23040|0.480000|1920|0.040000|N/A|N/A|7680|2713600|K_
+video|0|13|0.520000|13|0.520000|1|0.040000|N/A|N/A|150000|2776064|K_
+audio|1|24960|0.520000|24960|0.520000|1920|0.040000|N/A|N/A|7680|2926592|K_
+video|0|14|0.560000|14|0.560000|1|0.040000|N/A|N/A|150000|2989056|K_
+audio|1|26880|0.560000|26880|0.560000|1920|0.040000|N/A|N/A|7680|3139584|K_
+video|0|15|0.600000|15|0.600000|1|0.040000|N/A|N/A|150000|3202048|K_
+audio|1|28800|0.600000|28800|0.600000|1920|0.040000|N/A|N/A|7680|3352576|K_
+video|0|16|0.640000|16|0.640000|1|0.040000|N/A|N/A|150000|3415040|K_
+audio|1|30720|0.640000|30720|0.640000|1920|0.040000|N/A|N/A|7680|3565568|K_
+video|0|17|0.680000|17|0.680000|1|0.040000|N/A|N/A|150000|3628032|K_
+audio|1|32640|0.680000|32640|0.680000|1920|0.040000|N/A|N/A|7680|3778560|K_
+video|0|18|0.720000|18|0.720000|1|0.040000|N/A|N/A|150000|3841024|K_
+audio|1|34560|0.720000|34560|0.720000|1920|0.040000|N/A|N/A|7680|3991552|K_
+video|0|19|0.760000|19|0.760000|1|0.040000|N/A|N/A|150000|4054016|K_
+audio|1|36480|0.760000|36480|0.760000|1920|0.040000|N/A|N/A|7680|4204544|K_
+video|0|20|0.800000|20|0.800000|1|0.040000|N/A|N/A|150000|4267008|K_
+audio|1|38400|0.800000|38400|0.800000|1920|0.040000|N/A|N/A|7680|4417536|K_
+video|0|21|0.840000|21|0.840000|1|0.040000|N/A|N/A|150000|4480000|K_
+audio|1|40320|0.840000|40320|0.840000|1920|0.040000|N/A|N/A|7680|4630528|K_
+video|0|22|0.880000|22|0.880000|1|0.040000|N/A|N/A|150000|4692992|K_
+audio|1|42240|0.880000|42240|0.880000|1920|0.040000|N/A|N/A|7680|4843520|K_
+video|0|23|0.920000|23|0.920000|1|0.040000|N/A|N/A|150000|4905984|K_
+audio|1|44160|0.920000|44160|0.920000|1920|0.040000|N/A|N/A|7680|5056512|K_
+video|0|24|0.960000|24|0.960000|1|0.040000|N/A|N/A|150000|5118976|K_
+audio|1|46080|0.960000|46080|0.960000|1920|0.040000|N/A|N/A|7680|5269504|K_
+video|0|25|1.000000|25|1.000000|1|0.040000|N/A|N/A|150000|4267008|K_
+audio|1|48000|1.000000|48000|1.000000|1920|0.040000|N/A|N/A|7680|4417536|K_
+video|0|26|1.040000|26|1.040000|1|0.040000|N/A|N/A|150000|4480000|K_
+audio|1|49920|1.040000|49920|1.040000|1920|0.040000|N/A|N/A|7680|4630528|K_
+video|0|27|1.080000|27|1.080000|1|0.040000|N/A|N/A|150000|4692992|K_
+audio|1|51840|1.080000|51840|1.080000|1920|0.040000|N/A|N/A|7680|4843520|K_
+video|0|28|1.120000|28|1.120000|1|0.040000|N/A|N/A|150000|4905984|K_
+audio|1|53760|1.120000|53760|1.120000|1920|0.040000|N/A|N/A|7680|5056512|K_
+video|0|29|1.160000|29|1.160000|1|0.040000|N/A|N/A|150000|5118976|K_
+audio|1|55680|1.160000|55680|1.160000|1920|0.040000|N/A|N/A|7680|5269504|K_
+video|0|30|1.200000|30|1.200000|1|0.040000|N/A|N/A|150000|1072128|K_|1
 Strings Metadata
-audio|1|57600|1.200000|57600|1.200000|1920|0.040000|7680|1222656|K_|1
+audio|1|57600|1.200000|57600|1.200000|1920|0.040000|N/A|N/A|7680|1222656|K_|1
 Strings Metadata
-video|0|31|1.240000|31|1.240000|1|0.040000|150000|1285120|K_|1
+video|0|31|1.240000|31|1.240000|1|0.040000|N/A|N/A|150000|1285120|K_|1
 Strings Metadata
-audio|1|59520|1.240000|59520|1.240000|1920|0.040000|7680|1435648|K_|1
+audio|1|59520|1.240000|59520|1.240000|1920|0.040000|N/A|N/A|7680|1435648|K_|1
 Strings Metadata
-video|0|32|1.280000|32|1.280000|1|0.040000|150000|1498112|K_|1
+video|0|32|1.280000|32|1.280000|1|0.040000|N/A|N/A|150000|1498112|K_|1
 Strings Metadata
-audio|1|61440|1.280000|61440|1.280000|1920|0.040000|7680|1648640|K_|1
+audio|1|61440|1.280000|61440|1.280000|1920|0.040000|N/A|N/A|7680|1648640|K_|1
 Strings Metadata
-video|0|33|1.320000|33|1.320000|1|0.040000|150000|1711104|K_|1
+video|0|33|1.320000|33|1.320000|1|0.040000|N/A|N/A|150000|1711104|K_|1
 Strings Metadata
-audio|1|63360|1.320000|63360|1.320000|1920|0.040000|7680|1861632|K_|1
+audio|1|63360|1.320000|63360|1.320000|1920|0.040000|N/A|N/A|7680|1861632|K_|1
 Strings Metadata
-video|0|34|1.360000|34|1.360000|1|0.040000|150000|1924096|K_|1
+video|0|34|1.360000|34|1.360000|1|0.040000|N/A|N/A|150000|1924096|K_|1
 Strings Metadata
-audio|1|65280|1.360000|65280|1.360000|1920|0.040000|7680|2074624|K_|1
+audio|1|65280|1.360000|65280|1.360000|1920|0.040000|N/A|N/A|7680|2074624|K_|1
 Strings Metadata
-0|mpeg2video|0|video|[0][0][0][0]|0x0000|720|608|0|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|tb|1|N/A|25/1|25/1|1/25|0|0.000000|N/A|N/A|30000000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
-1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
+0|mpeg2video|0|video|1/25|[0][0][0][0]|0x0000|720|608|0|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|tb|N/A|1|N/A|25/1|25/1|1/25|0|0.000000|N/A|N/A|30000000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
+1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x0000|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index e99a9aa..a364b76 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -1,215 +1,215 @@
-video|1|982|0.010911|-2618|-0.029089|3600|0.040000|24801|564|K_MPEGTS Stream ID
+video|1|982|0.010911|-2618|-0.029089|3600|0.040000|N/A|N/A|24801|564|K_MPEGTS Stream ID
 
-video|1|4582|0.050911|982|0.010911|3600|0.040000|16429|25944|__MPEGTS Stream ID
+video|1|4582|0.050911|982|0.010911|3600|0.040000|N/A|N/A|16429|25944|__MPEGTS Stream ID
 
-video|1|8182|0.090911|4582|0.050911|3600|0.040000|14508|42864|__MPEGTS Stream ID
+video|1|8182|0.090911|4582|0.050911|3600|0.040000|N/A|N/A|14508|42864|__MPEGTS Stream ID
 
-video|1|11782|0.130911|8182|0.090911|3600|0.040000|12622|58092|__MPEGTS Stream ID
+video|1|11782|0.130911|8182|0.090911|3600|0.040000|N/A|N/A|12622|58092|__MPEGTS Stream ID
 
-video|1|15382|0.170911|11782|0.130911|3600|0.040000|13393|71064|__MPEGTS Stream ID
+video|1|15382|0.170911|11782|0.130911|3600|0.040000|N/A|N/A|13393|71064|__MPEGTS Stream ID
 
-video|1|18982|0.210911|15382|0.170911|3600|0.040000|13092|84788|__MPEGTS Stream ID
+video|1|18982|0.210911|15382|0.170911|3600|0.040000|N/A|N/A|13092|84788|__MPEGTS Stream ID
 
-video|1|22582|0.250911|18982|0.210911|3600|0.040000|12755|98700|__MPEGTS Stream ID
+video|1|22582|0.250911|18982|0.210911|3600|0.040000|N/A|N/A|12755|98700|__MPEGTS Stream ID
 
-video|1|26182|0.290911|22582|0.250911|3600|0.040000|12023|111860|__MPEGTS Stream ID
+video|1|26182|0.290911|22582|0.250911|3600|0.040000|N/A|N/A|12023|111860|__MPEGTS Stream ID
 
-audio|0|0|0.000000|0|0.000000|2351|0.026122|208|152844|K_MPEGTS Stream ID
+audio|0|0|0.000000|0|0.000000|2351|0.026122|N/A|N/A|208|152844|K_MPEGTS Stream ID
 
-audio|0|2351|0.026122|2351|0.026122|2351|0.026122|209|N/A|K_
-audio|0|4702|0.052244|4702|0.052244|2351|0.026122|209|N/A|K_
-audio|0|7053|0.078367|7053|0.078367|2351|0.026122|209|N/A|K_
-audio|0|9404|0.104489|9404|0.104489|2351|0.026122|209|N/A|K_
-audio|0|11755|0.130611|11755|0.130611|2351|0.026122|209|N/A|K_
-audio|0|14106|0.156733|14106|0.156733|2351|0.026122|209|N/A|K_
-audio|0|16457|0.182856|16457|0.182856|2351|0.026122|209|N/A|K_
-audio|0|18808|0.208978|18808|0.208978|2351|0.026122|209|N/A|K_
-audio|0|21159|0.235100|21159|0.235100|2351|0.026122|209|N/A|K_
-audio|0|23510|0.261222|23510|0.261222|2351|0.026122|209|N/A|K_
-audio|0|25861|0.287344|25861|0.287344|2351|0.026122|209|N/A|K_
-audio|0|28212|0.313467|28212|0.313467|2351|0.026122|209|N/A|K_
-audio|0|30563|0.339589|30563|0.339589|2351|0.026122|209|N/A|K_
-video|1|29782|0.330911|26182|0.290911|3600|0.040000|14098|124268|__MPEGTS Stream ID
+audio|0|2351|0.026122|2351|0.026122|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|4702|0.052244|4702|0.052244|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|7053|0.078367|7053|0.078367|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|9404|0.104489|9404|0.104489|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|11755|0.130611|11755|0.130611|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|14106|0.156733|14106|0.156733|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|16457|0.182856|16457|0.182856|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|18808|0.208978|18808|0.208978|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|21159|0.235100|21159|0.235100|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|23510|0.261222|23510|0.261222|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|25861|0.287344|25861|0.287344|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|28212|0.313467|28212|0.313467|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|30563|0.339589|30563|0.339589|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|29782|0.330911|26182|0.290911|3600|0.040000|N/A|N/A|14098|124268|__MPEGTS Stream ID
 
-video|1|33382|0.370911|29782|0.330911|3600|0.040000|13329|139120|__MPEGTS Stream ID
+video|1|33382|0.370911|29782|0.330911|3600|0.040000|N/A|N/A|13329|139120|__MPEGTS Stream ID
 
-video|1|36982|0.410911|33382|0.370911|3600|0.040000|12135|155852|__MPEGTS Stream ID
+video|1|36982|0.410911|33382|0.370911|3600|0.040000|N/A|N/A|12135|155852|__MPEGTS Stream ID
 
-video|1|40582|0.450911|36982|0.410911|3600|0.040000|12282|168448|__MPEGTS Stream ID
+video|1|40582|0.450911|36982|0.410911|3600|0.040000|N/A|N/A|12282|168448|__MPEGTS Stream ID
 
-video|1|44182|0.490911|40582|0.450911|3600|0.040000|24786|181420|K_MPEGTS Stream ID
+video|1|44182|0.490911|40582|0.450911|3600|0.040000|N/A|N/A|24786|181420|K_MPEGTS Stream ID
 
-video|1|47782|0.530911|44182|0.490911|3600|0.040000|17440|206988|__MPEGTS Stream ID
+video|1|47782|0.530911|44182|0.490911|3600|0.040000|N/A|N/A|17440|206988|__MPEGTS Stream ID
 
-video|1|51382|0.570911|47782|0.530911|3600|0.040000|15019|224848|__MPEGTS Stream ID
+video|1|51382|0.570911|47782|0.530911|3600|0.040000|N/A|N/A|15019|224848|__MPEGTS Stream ID
 
-video|1|54982|0.610911|51382|0.570911|3600|0.040000|13449|240640|__MPEGTS Stream ID
+video|1|54982|0.610911|51382|0.570911|3600|0.040000|N/A|N/A|13449|240640|__MPEGTS Stream ID
 
-video|1|58582|0.650911|54982|0.610911|3600|0.040000|12398|254552|__MPEGTS Stream ID
+video|1|58582|0.650911|54982|0.610911|3600|0.040000|N/A|N/A|12398|254552|__MPEGTS Stream ID
 
-video|1|62182|0.690911|58582|0.650911|3600|0.040000|13455|267336|__MPEGTS Stream ID
+video|1|62182|0.690911|58582|0.650911|3600|0.040000|N/A|N/A|13455|267336|__MPEGTS Stream ID
 
-audio|0|32915|0.365722|32915|0.365722|2351|0.026122|209|308508|K_MPEGTS Stream ID
+audio|0|32915|0.365722|32915|0.365722|2351|0.026122|N/A|N/A|209|308508|K_MPEGTS Stream ID
 
-audio|0|35266|0.391844|35266|0.391844|2351|0.026122|209|N/A|K_
-audio|0|37617|0.417967|37617|0.417967|2351|0.026122|209|N/A|K_
-audio|0|39968|0.444089|39968|0.444089|2351|0.026122|209|N/A|K_
-audio|0|42319|0.470211|42319|0.470211|2351|0.026122|209|N/A|K_
-audio|0|44670|0.496333|44670|0.496333|2351|0.026122|209|N/A|K_
-audio|0|47021|0.522456|47021|0.522456|2351|0.026122|209|N/A|K_
-audio|0|49372|0.548578|49372|0.548578|2351|0.026122|209|N/A|K_
-audio|0|51723|0.574700|51723|0.574700|2351|0.026122|209|N/A|K_
-audio|0|54074|0.600822|54074|0.600822|2351|0.026122|209|N/A|K_
-audio|0|56425|0.626944|56425|0.626944|2351|0.026122|209|N/A|K_
-audio|0|58776|0.653067|58776|0.653067|2351|0.026122|209|N/A|K_
-audio|0|61127|0.679189|61127|0.679189|2351|0.026122|209|N/A|K_
-audio|0|63478|0.705311|63478|0.705311|2351|0.026122|209|N/A|K_
-video|1|65782|0.730911|62182|0.690911|3600|0.040000|13836|281624|__MPEGTS Stream ID
+audio|0|35266|0.391844|35266|0.391844|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|37617|0.417967|37617|0.417967|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|39968|0.444089|39968|0.444089|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|42319|0.470211|42319|0.470211|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|44670|0.496333|44670|0.496333|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|47021|0.522456|47021|0.522456|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|49372|0.548578|49372|0.548578|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|51723|0.574700|51723|0.574700|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|54074|0.600822|54074|0.600822|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|56425|0.626944|56425|0.626944|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|58776|0.653067|58776|0.653067|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|61127|0.679189|61127|0.679189|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|63478|0.705311|63478|0.705311|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|65782|0.730911|62182|0.690911|3600|0.040000|N/A|N/A|13836|281624|__MPEGTS Stream ID
 
-video|1|69382|0.770911|65782|0.730911|3600|0.040000|12163|295912|__MPEGTS Stream ID
+video|1|69382|0.770911|65782|0.730911|3600|0.040000|N/A|N/A|12163|295912|__MPEGTS Stream ID
 
-video|1|72982|0.810911|69382|0.770911|3600|0.040000|12692|311516|__MPEGTS Stream ID
+video|1|72982|0.810911|69382|0.770911|3600|0.040000|N/A|N/A|12692|311516|__MPEGTS Stream ID
 
-video|1|76582|0.850911|72982|0.810911|3600|0.040000|10824|325052|__MPEGTS Stream ID
+video|1|76582|0.850911|72982|0.810911|3600|0.040000|N/A|N/A|10824|325052|__MPEGTS Stream ID
 
-video|1|80182|0.890911|76582|0.850911|3600|0.040000|11286|336144|__MPEGTS Stream ID
+video|1|80182|0.890911|76582|0.850911|3600|0.040000|N/A|N/A|11286|336144|__MPEGTS Stream ID
 
-audio|0|65829|0.731433|65829|0.731433|2351|0.026122|209|386716|K_MPEGTS Stream ID
+audio|0|65829|0.731433|65829|0.731433|2351|0.026122|N/A|N/A|209|386716|K_MPEGTS Stream ID
 
-audio|0|68180|0.757556|68180|0.757556|2351|0.026122|209|N/A|K_
-audio|0|70531|0.783678|70531|0.783678|2351|0.026122|209|N/A|K_
-audio|0|72882|0.809800|72882|0.809800|2351|0.026122|209|N/A|K_
-audio|0|75233|0.835922|75233|0.835922|2351|0.026122|209|N/A|K_
-audio|0|77584|0.862044|77584|0.862044|2351|0.026122|209|N/A|K_
-audio|0|79935|0.888167|79935|0.888167|2351|0.026122|209|N/A|K_
-audio|0|82286|0.914289|82286|0.914289|2351|0.026122|209|N/A|K_
-audio|0|84637|0.940411|84637|0.940411|2351|0.026122|209|N/A|K_
-audio|0|86988|0.966533|86988|0.966533|2351|0.026122|209|N/A|K_
-audio|0|89339|0.992656|89339|0.992656|2351|0.026122|209|N/A|K_
-video|1|83782|0.930911|80182|0.890911|3600|0.040000|12678|347800|__MPEGTS Stream ID
+audio|0|68180|0.757556|68180|0.757556|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|70531|0.783678|70531|0.783678|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|72882|0.809800|72882|0.809800|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|75233|0.835922|75233|0.835922|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|77584|0.862044|77584|0.862044|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|79935|0.888167|79935|0.888167|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|82286|0.914289|82286|0.914289|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|84637|0.940411|84637|0.940411|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|86988|0.966533|86988|0.966533|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|89339|0.992656|89339|0.992656|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|83782|0.930911|80182|0.890911|3600|0.040000|N/A|N/A|12678|347800|__MPEGTS Stream ID
 
-video|1|87382|0.970911|83782|0.930911|3600|0.040000|24711|361336|K_
-video|1|91964|1.021822|88364|0.981822|3600|0.040000|24801|564|K_MPEGTS Stream ID
+video|1|87382|0.970911|83782|0.930911|3600|0.040000|N/A|N/A|24711|361336|K_
+video|1|91964|1.021822|88364|0.981822|3600|0.040000|N/A|N/A|24801|564|K_MPEGTS Stream ID
 
-video|1|95564|1.061822|91964|1.021822|3600|0.040000|16429|25944|__MPEGTS Stream ID
+video|1|95564|1.061822|91964|1.021822|3600|0.040000|N/A|N/A|16429|25944|__MPEGTS Stream ID
 
-video|1|99164|1.101822|95564|1.061822|3600|0.040000|14508|42864|__MPEGTS Stream ID
+video|1|99164|1.101822|95564|1.061822|3600|0.040000|N/A|N/A|14508|42864|__MPEGTS Stream ID
 
-video|1|102764|1.141822|99164|1.101822|3600|0.040000|12622|58092|__MPEGTS Stream ID
+video|1|102764|1.141822|99164|1.101822|3600|0.040000|N/A|N/A|12622|58092|__MPEGTS Stream ID
 
-video|1|106364|1.181822|102764|1.141822|3600|0.040000|13393|71064|__MPEGTS Stream ID
+video|1|106364|1.181822|102764|1.141822|3600|0.040000|N/A|N/A|13393|71064|__MPEGTS Stream ID
 
-video|1|109964|1.221822|106364|1.181822|3600|0.040000|13092|84788|__MPEGTS Stream ID
+video|1|109964|1.221822|106364|1.181822|3600|0.040000|N/A|N/A|13092|84788|__MPEGTS Stream ID
 
-video|1|113564|1.261822|109964|1.221822|3600|0.040000|12755|98700|__MPEGTS Stream ID
+video|1|113564|1.261822|109964|1.221822|3600|0.040000|N/A|N/A|12755|98700|__MPEGTS Stream ID
 
-video|1|117164|1.301822|113564|1.261822|3600|0.040000|12023|111860|__MPEGTS Stream ID
+video|1|117164|1.301822|113564|1.261822|3600|0.040000|N/A|N/A|12023|111860|__MPEGTS Stream ID
 
-audio|0|90982|1.010911|90982|1.010911|2351|0.026122|208|152844|K_MPEGTS Stream ID
+audio|0|90982|1.010911|90982|1.010911|2351|0.026122|N/A|N/A|208|152844|K_MPEGTS Stream ID
 
-audio|0|93333|1.037033|93333|1.037033|2351|0.026122|209|N/A|K_
-audio|0|95684|1.063156|95684|1.063156|2351|0.026122|209|N/A|K_
-audio|0|98035|1.089278|98035|1.089278|2351|0.026122|209|N/A|K_
-audio|0|100386|1.115400|100386|1.115400|2351|0.026122|209|N/A|K_
-audio|0|102737|1.141522|102737|1.141522|2351|0.026122|209|N/A|K_
-audio|0|105088|1.167644|105088|1.167644|2351|0.026122|209|N/A|K_
-audio|0|107439|1.193767|107439|1.193767|2351|0.026122|209|N/A|K_
-audio|0|109790|1.219889|109790|1.219889|2351|0.026122|209|N/A|K_
-audio|0|112141|1.246011|112141|1.246011|2351|0.026122|209|N/A|K_
-audio|0|114492|1.272133|114492|1.272133|2351|0.026122|209|N/A|K_
-audio|0|116843|1.298256|116843|1.298256|2351|0.026122|209|N/A|K_
-audio|0|119194|1.324378|119194|1.324378|2351|0.026122|209|N/A|K_
-audio|0|121545|1.350500|121545|1.350500|2351|0.026122|209|N/A|K_
-video|1|120764|1.341822|117164|1.301822|3600|0.040000|14098|124268|__MPEGTS Stream ID
+audio|0|93333|1.037033|93333|1.037033|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|95684|1.063156|95684|1.063156|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|98035|1.089278|98035|1.089278|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|100386|1.115400|100386|1.115400|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|102737|1.141522|102737|1.141522|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|105088|1.167644|105088|1.167644|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|107439|1.193767|107439|1.193767|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|109790|1.219889|109790|1.219889|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|112141|1.246011|112141|1.246011|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|114492|1.272133|114492|1.272133|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|116843|1.298256|116843|1.298256|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|119194|1.324378|119194|1.324378|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|121545|1.350500|121545|1.350500|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|120764|1.341822|117164|1.301822|3600|0.040000|N/A|N/A|14098|124268|__MPEGTS Stream ID
 
-video|1|124364|1.381822|120764|1.341822|3600|0.040000|13329|139120|__MPEGTS Stream ID
+video|1|124364|1.381822|120764|1.341822|3600|0.040000|N/A|N/A|13329|139120|__MPEGTS Stream ID
 
-video|1|127964|1.421822|124364|1.381822|3600|0.040000|12135|155852|__MPEGTS Stream ID
+video|1|127964|1.421822|124364|1.381822|3600|0.040000|N/A|N/A|12135|155852|__MPEGTS Stream ID
 
-video|1|131564|1.461822|127964|1.421822|3600|0.040000|12282|168448|__MPEGTS Stream ID
+video|1|131564|1.461822|127964|1.421822|3600|0.040000|N/A|N/A|12282|168448|__MPEGTS Stream ID
 
-video|1|135164|1.501822|131564|1.461822|3600|0.040000|24786|181420|K_MPEGTS Stream ID
+video|1|135164|1.501822|131564|1.461822|3600|0.040000|N/A|N/A|24786|181420|K_MPEGTS Stream ID
 
-video|1|138764|1.541822|135164|1.501822|3600|0.040000|17440|206988|__MPEGTS Stream ID
+video|1|138764|1.541822|135164|1.501822|3600|0.040000|N/A|N/A|17440|206988|__MPEGTS Stream ID
 
-video|1|142364|1.581822|138764|1.541822|3600|0.040000|15019|224848|__MPEGTS Stream ID
+video|1|142364|1.581822|138764|1.541822|3600|0.040000|N/A|N/A|15019|224848|__MPEGTS Stream ID
 
-video|1|145964|1.621822|142364|1.581822|3600|0.040000|13449|240640|__MPEGTS Stream ID
+video|1|145964|1.621822|142364|1.581822|3600|0.040000|N/A|N/A|13449|240640|__MPEGTS Stream ID
 
-video|1|149564|1.661822|145964|1.621822|3600|0.040000|12398|254552|__MPEGTS Stream ID
+video|1|149564|1.661822|145964|1.621822|3600|0.040000|N/A|N/A|12398|254552|__MPEGTS Stream ID
 
-video|1|153164|1.701822|149564|1.661822|3600|0.040000|13455|267336|__MPEGTS Stream ID
+video|1|153164|1.701822|149564|1.661822|3600|0.040000|N/A|N/A|13455|267336|__MPEGTS Stream ID
 
-audio|0|123897|1.376633|123897|1.376633|2351|0.026122|209|308508|K_MPEGTS Stream ID
+audio|0|123897|1.376633|123897|1.376633|2351|0.026122|N/A|N/A|209|308508|K_MPEGTS Stream ID
 
-audio|0|126248|1.402756|126248|1.402756|2351|0.026122|209|N/A|K_
-audio|0|128599|1.428878|128599|1.428878|2351|0.026122|209|N/A|K_
-audio|0|130950|1.455000|130950|1.455000|2351|0.026122|209|N/A|K_
-audio|0|133301|1.481122|133301|1.481122|2351|0.026122|209|N/A|K_
-audio|0|135652|1.507244|135652|1.507244|2351|0.026122|209|N/A|K_
-audio|0|138003|1.533367|138003|1.533367|2351|0.026122|209|N/A|K_
-audio|0|140354|1.559489|140354|1.559489|2351|0.026122|209|N/A|K_
-audio|0|142705|1.585611|142705|1.585611|2351|0.026122|209|N/A|K_
-audio|0|145056|1.611733|145056|1.611733|2351|0.026122|209|N/A|K_
-audio|0|147407|1.637856|147407|1.637856|2351|0.026122|209|N/A|K_
-audio|0|149758|1.663978|149758|1.663978|2351|0.026122|209|N/A|K_
-audio|0|152109|1.690100|152109|1.690100|2351|0.026122|209|N/A|K_
-audio|0|154460|1.716222|154460|1.716222|2351|0.026122|209|N/A|K_
-video|1|156764|1.741822|153164|1.701822|3600|0.040000|13836|281624|__MPEGTS Stream ID
+audio|0|126248|1.402756|126248|1.402756|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|128599|1.428878|128599|1.428878|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|130950|1.455000|130950|1.455000|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|133301|1.481122|133301|1.481122|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|135652|1.507244|135652|1.507244|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|138003|1.533367|138003|1.533367|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|140354|1.559489|140354|1.559489|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|142705|1.585611|142705|1.585611|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|145056|1.611733|145056|1.611733|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|147407|1.637856|147407|1.637856|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|149758|1.663978|149758|1.663978|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|152109|1.690100|152109|1.690100|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|154460|1.716222|154460|1.716222|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|156764|1.741822|153164|1.701822|3600|0.040000|N/A|N/A|13836|281624|__MPEGTS Stream ID
 
-video|1|160364|1.781822|156764|1.741822|3600|0.040000|12163|295912|__MPEGTS Stream ID
+video|1|160364|1.781822|156764|1.741822|3600|0.040000|N/A|N/A|12163|295912|__MPEGTS Stream ID
 
-video|1|163964|1.821822|160364|1.781822|3600|0.040000|12692|311516|__MPEGTS Stream ID
+video|1|163964|1.821822|160364|1.781822|3600|0.040000|N/A|N/A|12692|311516|__MPEGTS Stream ID
 
-video|1|167564|1.861822|163964|1.821822|3600|0.040000|10824|325052|__MPEGTS Stream ID
+video|1|167564|1.861822|163964|1.821822|3600|0.040000|N/A|N/A|10824|325052|__MPEGTS Stream ID
 
-video|1|171164|1.901822|167564|1.861822|3600|0.040000|11286|336144|__MPEGTS Stream ID
+video|1|171164|1.901822|167564|1.861822|3600|0.040000|N/A|N/A|11286|336144|__MPEGTS Stream ID
 
-audio|0|156811|1.742344|156811|1.742344|2351|0.026122|209|386716|K_MPEGTS Stream ID
+audio|0|156811|1.742344|156811|1.742344|2351|0.026122|N/A|N/A|209|386716|K_MPEGTS Stream ID
 
-audio|0|159162|1.768467|159162|1.768467|2351|0.026122|209|N/A|K_
-audio|0|161513|1.794589|161513|1.794589|2351|0.026122|209|N/A|K_
-audio|0|163864|1.820711|163864|1.820711|2351|0.026122|209|N/A|K_
-audio|0|166215|1.846833|166215|1.846833|2351|0.026122|209|N/A|K_
-audio|0|168566|1.872956|168566|1.872956|2351|0.026122|209|N/A|K_
-audio|0|170917|1.899078|170917|1.899078|2351|0.026122|209|N/A|K_
-audio|0|173268|1.925200|173268|1.925200|2351|0.026122|209|N/A|K_
-audio|0|175619|1.951322|175619|1.951322|2351|0.026122|209|N/A|K_
-audio|0|177970|1.977444|177970|1.977444|2351|0.026122|209|N/A|K_
-audio|0|180321|2.003567|180321|2.003567|2351|0.026122|209|N/A|K_
-video|1|174764|1.941822|171164|1.901822|3600|0.040000|12678|347800|__MPEGTS Stream ID
+audio|0|159162|1.768467|159162|1.768467|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|161513|1.794589|161513|1.794589|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|163864|1.820711|163864|1.820711|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|166215|1.846833|166215|1.846833|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|168566|1.872956|168566|1.872956|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|170917|1.899078|170917|1.899078|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|173268|1.925200|173268|1.925200|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|175619|1.951322|175619|1.951322|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|177970|1.977444|177970|1.977444|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|180321|2.003567|180321|2.003567|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|174764|1.941822|171164|1.901822|3600|0.040000|N/A|N/A|12678|347800|__MPEGTS Stream ID
 
-video|1|178364|1.981822|174764|1.941822|3600|0.040000|24711|361336|K_
-video|1|139582|1.550911|135982|1.510911|3600|0.040000|12692|311516|__MPEGTS Stream ID
+video|1|178364|1.981822|174764|1.941822|3600|0.040000|N/A|N/A|24711|361336|K_
+video|1|139582|1.550911|135982|1.510911|3600|0.040000|N/A|N/A|12692|311516|__MPEGTS Stream ID
 
-video|1|143182|1.590911|139582|1.550911|3600|0.040000|10824|325052|__MPEGTS Stream ID
+video|1|143182|1.590911|139582|1.550911|3600|0.040000|N/A|N/A|10824|325052|__MPEGTS Stream ID
 
-video|1|146782|1.630911|143182|1.590911|3600|0.040000|11286|336144|__MPEGTS Stream ID
+video|1|146782|1.630911|143182|1.590911|3600|0.040000|N/A|N/A|11286|336144|__MPEGTS Stream ID
 
-audio|0|132429|1.471433|132429|1.471433|2351|0.026122|209|386716|K_MPEGTS Stream ID
+audio|0|132429|1.471433|132429|1.471433|2351|0.026122|N/A|N/A|209|386716|K_MPEGTS Stream ID
 
-audio|0|134780|1.497556|134780|1.497556|2351|0.026122|209|N/A|K_
-audio|0|137131|1.523678|137131|1.523678|2351|0.026122|209|N/A|K_
-audio|0|139482|1.549800|139482|1.549800|2351|0.026122|209|N/A|K_
-audio|0|141833|1.575922|141833|1.575922|2351|0.026122|209|N/A|K_
-audio|0|144184|1.602044|144184|1.602044|2351|0.026122|209|N/A|K_
-audio|0|146535|1.628167|146535|1.628167|2351|0.026122|209|N/A|K_
-audio|0|148886|1.654289|148886|1.654289|2351|0.026122|209|N/A|K_
-audio|0|151237|1.680411|151237|1.680411|2351|0.026122|209|N/A|K_
-audio|0|153588|1.706533|153588|1.706533|2351|0.026122|209|N/A|K_
-audio|0|155939|1.732656|155939|1.732656|2351|0.026122|209|N/A|K_
-video|1|150382|1.670911|146782|1.630911|3600|0.040000|12678|347800|__MPEGTS Stream ID
+audio|0|134780|1.497556|134780|1.497556|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|137131|1.523678|137131|1.523678|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|139482|1.549800|139482|1.549800|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|141833|1.575922|141833|1.575922|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|144184|1.602044|144184|1.602044|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|146535|1.628167|146535|1.628167|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|148886|1.654289|148886|1.654289|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|151237|1.680411|151237|1.680411|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|153588|1.706533|153588|1.706533|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|155939|1.732656|155939|1.732656|2351|0.026122|N/A|N/A|209|N/A|K_
+video|1|150382|1.670911|146782|1.630911|3600|0.040000|N/A|N/A|12678|347800|__MPEGTS Stream ID
 
-video|1|153982|1.710911|150382|1.670911|3600|0.040000|24711|361336|K_
-video|1|161182|1.790911|157582|1.750911|3600|0.040000|12135|155852|__MPEGTS Stream ID
+video|1|153982|1.710911|150382|1.670911|3600|0.040000|N/A|N/A|24711|361336|K_
+video|1|161182|1.790911|157582|1.750911|3600|0.040000|N/A|N/A|12135|155852|__MPEGTS Stream ID
 
-video|1|164782|1.830911|161182|1.790911|3600|0.040000|12282|168448|__MPEGTS Stream ID
+video|1|164782|1.830911|161182|1.790911|3600|0.040000|N/A|N/A|12282|168448|__MPEGTS Stream ID
 
-video|1|168382|1.870911|164782|1.830911|3600|0.040000|24786|181420|K_MPEGTS Stream ID
+video|1|168382|1.870911|164782|1.830911|3600|0.040000|N/A|N/A|24786|181420|K_MPEGTS Stream ID
 
-video|1|171982|1.910911|168382|1.870911|3600|0.040000|17440|206988|__MPEGTS Stream ID
+video|1|171982|1.910911|168382|1.870911|3600|0.040000|N/A|N/A|17440|206988|__MPEGTS Stream ID
 
-video|1|175582|1.950911|171982|1.910911|3600|0.040000|15019|224848|__MPEGTS Stream ID
+video|1|175582|1.950911|171982|1.910911|3600|0.040000|N/A|N/A|15019|224848|__MPEGTS Stream ID
 
-0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0
-1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0|0
+0|mp2|unknown|audio|1/44100|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0
+1|mpeg2video|4|video|1/25|[2][0][0][0]|0x0002|352|288|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|N/A|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0|0
diff --git a/tests/ref/fate/copy-trac3074 b/tests/ref/fate/copy-trac3074
index 78b6015..b5b0b6a 100644
--- a/tests/ref/fate/copy-trac3074
+++ b/tests/ref/fate/copy-trac3074
@@ -1,4 +1,4 @@
-da6122873fb83ce4340cf5d0ab8d475e *tests/data/fate/copy-trac3074.mp4
+620e3ab4ee6241bec55ea2ec4ef42908 *tests/data/fate/copy-trac3074.mp4
 334012 tests/data/fate/copy-trac3074.mp4
 #tb 0: 1/48000
 #media_type 0: audio
diff --git a/tests/ref/fate/copy-trac4914 b/tests/ref/fate/copy-trac4914
index 743dc8c..7c8d0e9 100644
--- a/tests/ref/fate/copy-trac4914
+++ b/tests/ref/fate/copy-trac4914
@@ -1,4 +1,4 @@
-f5150fb82c1bb5a90906fce93dcc3f76 *tests/data/fate/copy-trac4914.mxf
+b37c4d5693cdb5b9ed9b33501ffb682a *tests/data/fate/copy-trac4914.mxf
 561721 tests/data/fate/copy-trac4914.mxf
 #tb 0: 1001/30000
 #media_type 0: video
diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe
deleted file mode 100644
index e116b2f..0000000
--- a/tests/ref/fate/dpx-probe
+++ /dev/null
@@ -1,16 +0,0 @@
-[FRAME]
-sample_aspect_ratio=1:1
-color_range=pc
-color_space=gbr
-color_primaries=bt709
-color_transfer=unknown
-TAG:timecode=00:00:01:18
-TAG:Creator=Apple Compressor
-TAG:Input Device=
-[SIDE_DATA]
-side_data_type=SMPTE 12-1 timecode
-[TIMECODE]
-value=00:00:01:18
-[/TIMECODE]
-[/SIDE_DATA]
-[/FRAME]
diff --git a/tests/ref/fate/exif-image-embedded b/tests/ref/fate/exif-image-embedded
index 9ad073e..392c145 100644
--- a/tests/ref/fate/exif-image-embedded
+++ b/tests/ref/fate/exif-image-embedded
@@ -29,6 +29,12 @@
 chroma_location=center
 TAG:UserComment=AppleMark
 
+[SIDE_DATA]
+side_data_type=QP table data
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=QP table properties
+[/SIDE_DATA]
 [/FRAME]
 [FRAME]
 media_type=audio
@@ -38,8 +44,8 @@
 pkt_pts_time=0.025057
 pkt_dts=353600
 pkt_dts_time=0.025057
-best_effort_timestamp=353600
-best_effort_timestamp_time=0.025057
+best_effort_timestamp=0
+best_effort_timestamp_time=0.000000
 pkt_duration=15040
 pkt_duration_time=0.001066
 pkt_pos=16292
diff --git a/tests/ref/fate/exif-image-jpg b/tests/ref/fate/exif-image-jpg
index b266501..eb18ded 100644
--- a/tests/ref/fate/exif-image-jpg
+++ b/tests/ref/fate/exif-image-jpg
@@ -229,4 +229,10 @@
 TAG:WhiteBalance=    0
 TAG:DigitalZoomRatio=   4000:4000
 TAG:SceneCaptureType=    0
+[SIDE_DATA]
+side_data_type=QP table data
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=QP table properties
+[/SIDE_DATA]
 [/FRAME]
diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact
index ded412e..03ae213 100644
--- a/tests/ref/fate/ffprobe_compact
+++ b/tests/ref/fate/ffprobe_compact
@@ -1,32 +1,32 @@
-packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1024|duration_time=0.023220|size=2048|pos=647|flags=K_
+packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=2048|pos=647|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.000000|pkt_dts=0|pkt_dts_time=0.000000|best_effort_timestamp=0|best_effort_timestamp_time=0.000000|pkt_duration=1024|pkt_duration_time=0.023220|pkt_pos=647|pkt_size=2048|sample_fmt=s16|nb_samples=1024|channels=1|channel_layout=unknown
-packet|codec_type=video|stream_index=1|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=2048|duration_time=0.040000|size=230400|pos=2722|flags=K_
+packet|codec_type=video|stream_index=1|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=230400|pos=2722|flags=K_
 frame|media_type=video|stream_index=1|key_frame=1|pkt_pts=0|pkt_pts_time=0.000000|pkt_dts=0|pkt_dts_time=0.000000|best_effort_timestamp=0|best_effort_timestamp_time=0.000000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=2722|pkt_size=230400|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=video|stream_index=2|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=2048|duration_time=0.040000|size=30000|pos=233143|flags=K_
+packet|codec_type=video|stream_index=2|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=233143|flags=K_
 frame|media_type=video|stream_index=2|key_frame=1|pkt_pts=0|pkt_pts_time=0.000000|pkt_dts=0|pkt_dts_time=0.000000|best_effort_timestamp=0|best_effort_timestamp_time=0.000000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=233143|pkt_size=30000|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=audio|stream_index=0|pts=1024|pts_time=0.023220|dts=1024|dts_time=0.023220|duration=1024|duration_time=0.023220|size=2048|pos=263148|flags=K_
+packet|codec_type=audio|stream_index=0|pts=1024|pts_time=0.023220|dts=1024|dts_time=0.023220|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=2048|pos=263148|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=1024|pkt_pts_time=0.023220|pkt_dts=1024|pkt_dts_time=0.023220|best_effort_timestamp=1024|best_effort_timestamp_time=0.023220|pkt_duration=1024|pkt_duration_time=0.023220|pkt_pos=263148|pkt_size=2048|sample_fmt=s16|nb_samples=1024|channels=1|channel_layout=unknown
-packet|codec_type=video|stream_index=1|pts=2048|pts_time=0.040000|dts=2048|dts_time=0.040000|duration=2048|duration_time=0.040000|size=230400|pos=265226|flags=K_
+packet|codec_type=video|stream_index=1|pts=2048|pts_time=0.040000|dts=2048|dts_time=0.040000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=230400|pos=265226|flags=K_
 frame|media_type=video|stream_index=1|key_frame=1|pkt_pts=2048|pkt_pts_time=0.040000|pkt_dts=2048|pkt_dts_time=0.040000|best_effort_timestamp=2048|best_effort_timestamp_time=0.040000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=265226|pkt_size=230400|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=video|stream_index=2|pts=2048|pts_time=0.040000|dts=2048|dts_time=0.040000|duration=2048|duration_time=0.040000|size=30000|pos=495650|flags=K_
+packet|codec_type=video|stream_index=2|pts=2048|pts_time=0.040000|dts=2048|dts_time=0.040000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=495650|flags=K_
 frame|media_type=video|stream_index=2|key_frame=1|pkt_pts=2048|pkt_pts_time=0.040000|pkt_dts=2048|pkt_dts_time=0.040000|best_effort_timestamp=2048|best_effort_timestamp_time=0.040000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=495650|pkt_size=30000|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=audio|stream_index=0|pts=2048|pts_time=0.046440|dts=2048|dts_time=0.046440|duration=1024|duration_time=0.023220|size=2048|pos=525655|flags=K_
+packet|codec_type=audio|stream_index=0|pts=2048|pts_time=0.046440|dts=2048|dts_time=0.046440|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=2048|pos=525655|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=2048|pkt_pts_time=0.046440|pkt_dts=2048|pkt_dts_time=0.046440|best_effort_timestamp=2048|best_effort_timestamp_time=0.046440|pkt_duration=1024|pkt_duration_time=0.023220|pkt_pos=525655|pkt_size=2048|sample_fmt=s16|nb_samples=1024|channels=1|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=3072|pts_time=0.069660|dts=3072|dts_time=0.069660|duration=1024|duration_time=0.023220|size=2048|pos=527726|flags=K_
+packet|codec_type=audio|stream_index=0|pts=3072|pts_time=0.069660|dts=3072|dts_time=0.069660|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=2048|pos=527726|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=3072|pkt_pts_time=0.069660|pkt_dts=3072|pkt_dts_time=0.069660|best_effort_timestamp=3072|best_effort_timestamp_time=0.069660|pkt_duration=1024|pkt_duration_time=0.023220|pkt_pos=527726|pkt_size=2048|sample_fmt=s16|nb_samples=1024|channels=1|channel_layout=unknown
-packet|codec_type=video|stream_index=1|pts=4096|pts_time=0.080000|dts=4096|dts_time=0.080000|duration=2048|duration_time=0.040000|size=230400|pos=529804|flags=K_
+packet|codec_type=video|stream_index=1|pts=4096|pts_time=0.080000|dts=4096|dts_time=0.080000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=230400|pos=529804|flags=K_
 frame|media_type=video|stream_index=1|key_frame=1|pkt_pts=4096|pkt_pts_time=0.080000|pkt_dts=4096|pkt_dts_time=0.080000|best_effort_timestamp=4096|best_effort_timestamp_time=0.080000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=529804|pkt_size=230400|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=video|stream_index=2|pts=4096|pts_time=0.080000|dts=4096|dts_time=0.080000|duration=2048|duration_time=0.040000|size=30000|pos=760228|flags=K_
+packet|codec_type=video|stream_index=2|pts=4096|pts_time=0.080000|dts=4096|dts_time=0.080000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=760228|flags=K_
 frame|media_type=video|stream_index=2|key_frame=1|pkt_pts=4096|pkt_pts_time=0.080000|pkt_dts=4096|pkt_dts_time=0.080000|best_effort_timestamp=4096|best_effort_timestamp_time=0.080000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=760228|pkt_size=30000|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=audio|stream_index=0|pts=4096|pts_time=0.092880|dts=4096|dts_time=0.092880|duration=1024|duration_time=0.023220|size=2048|pos=790233|flags=K_
+packet|codec_type=audio|stream_index=0|pts=4096|pts_time=0.092880|dts=4096|dts_time=0.092880|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=2048|pos=790233|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=4096|pkt_pts_time=0.092880|pkt_dts=4096|pkt_dts_time=0.092880|best_effort_timestamp=4096|best_effort_timestamp_time=0.092880|pkt_duration=1024|pkt_duration_time=0.023220|pkt_pos=790233|pkt_size=2048|sample_fmt=s16|nb_samples=1024|channels=1|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=5120|pts_time=0.116100|dts=5120|dts_time=0.116100|duration=393|duration_time=0.008912|size=786|pos=792304|flags=K_
+packet|codec_type=audio|stream_index=0|pts=5120|pts_time=0.116100|dts=5120|dts_time=0.116100|duration=393|duration_time=0.008912|convergence_duration=N/A|convergence_duration_time=N/A|size=786|pos=792304|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=5120|pkt_pts_time=0.116100|pkt_dts=5120|pkt_dts_time=0.116100|best_effort_timestamp=5120|best_effort_timestamp_time=0.116100|pkt_duration=393|pkt_duration_time=0.008912|pkt_pos=792304|pkt_size=786|sample_fmt=s16|nb_samples=393|channels=1|channel_layout=unknown
-packet|codec_type=video|stream_index=1|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|size=230400|pos=793120|flags=K_
+packet|codec_type=video|stream_index=1|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=230400|pos=793120|flags=K_
 frame|media_type=video|stream_index=1|key_frame=1|pkt_pts=6144|pkt_pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|best_effort_timestamp=6144|best_effort_timestamp_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=793120|pkt_size=230400|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-packet|codec_type=video|stream_index=2|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|size=30000|pos=1023544|flags=K_
+packet|codec_type=video|stream_index=2|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=1023544|flags=K_
 frame|media_type=video|stream_index=2|key_frame=1|pkt_pts=6144|pkt_pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|best_effort_timestamp=6144|best_effort_timestamp_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=1023544|pkt_size=30000|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
-stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layout=unknown|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=705600|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:E=mc²|tag:encoder=Lavc pcm_s16le
-stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|coded_width=320|coded_height=240|closed_captions=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt|tag:encoder=Lavc rawvideo
-stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|coded_width=100|coded_height=100|closed_captions=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:encoder=Lavc rawvideo
+stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layout=unknown|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=705600|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:E=mc²|tag:encoder=Lavc pcm_s16le
+stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|coded_width=320|coded_height=240|closed_captions=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt|tag:encoder=Lavc rawvideo
+stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|coded_width=100|coded_height=100|closed_captions=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:encoder=Lavc rawvideo
 format|filename=tests/data/ffprobe-test.nut|nb_streams=3|nb_programs=0|format_name=nut|start_time=0.000000|duration=0.120000|size=1053624|bit_rate=70241600|probe_score=100|tag:title=ffprobe test file|tag:comment='A comment with CSV, XML & JSON special chars': <tag value="x">|tag:comment2=I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_csv b/tests/ref/fate/ffprobe_csv
index d182fde..7240d1e 100644
--- a/tests/ref/fate/ffprobe_csv
+++ b/tests/ref/fate/ffprobe_csv
@@ -1,32 +1,32 @@
-packet,audio,0,0,0.000000,0,0.000000,1024,0.023220,2048,647,K_
+packet,audio,0,0,0.000000,0,0.000000,1024,0.023220,N/A,N/A,2048,647,K_
 frame,audio,0,1,0,0.000000,0,0.000000,0,0.000000,1024,0.023220,647,2048,s16,1024,1,unknown
-packet,video,1,0,0.000000,0,0.000000,2048,0.040000,230400,2722,K_
+packet,video,1,0,0.000000,0,0.000000,2048,0.040000,N/A,N/A,230400,2722,K_
 frame,video,1,1,0,0.000000,0,0.000000,0,0.000000,2048,0.040000,2722,230400,320,240,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,video,2,0,0.000000,0,0.000000,2048,0.040000,30000,233143,K_
+packet,video,2,0,0.000000,0,0.000000,2048,0.040000,N/A,N/A,30000,233143,K_
 frame,video,2,1,0,0.000000,0,0.000000,0,0.000000,2048,0.040000,233143,30000,100,100,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,audio,0,1024,0.023220,1024,0.023220,1024,0.023220,2048,263148,K_
+packet,audio,0,1024,0.023220,1024,0.023220,1024,0.023220,N/A,N/A,2048,263148,K_
 frame,audio,0,1,1024,0.023220,1024,0.023220,1024,0.023220,1024,0.023220,263148,2048,s16,1024,1,unknown
-packet,video,1,2048,0.040000,2048,0.040000,2048,0.040000,230400,265226,K_
+packet,video,1,2048,0.040000,2048,0.040000,2048,0.040000,N/A,N/A,230400,265226,K_
 frame,video,1,1,2048,0.040000,2048,0.040000,2048,0.040000,2048,0.040000,265226,230400,320,240,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,video,2,2048,0.040000,2048,0.040000,2048,0.040000,30000,495650,K_
+packet,video,2,2048,0.040000,2048,0.040000,2048,0.040000,N/A,N/A,30000,495650,K_
 frame,video,2,1,2048,0.040000,2048,0.040000,2048,0.040000,2048,0.040000,495650,30000,100,100,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,audio,0,2048,0.046440,2048,0.046440,1024,0.023220,2048,525655,K_
+packet,audio,0,2048,0.046440,2048,0.046440,1024,0.023220,N/A,N/A,2048,525655,K_
 frame,audio,0,1,2048,0.046440,2048,0.046440,2048,0.046440,1024,0.023220,525655,2048,s16,1024,1,unknown
-packet,audio,0,3072,0.069660,3072,0.069660,1024,0.023220,2048,527726,K_
+packet,audio,0,3072,0.069660,3072,0.069660,1024,0.023220,N/A,N/A,2048,527726,K_
 frame,audio,0,1,3072,0.069660,3072,0.069660,3072,0.069660,1024,0.023220,527726,2048,s16,1024,1,unknown
-packet,video,1,4096,0.080000,4096,0.080000,2048,0.040000,230400,529804,K_
+packet,video,1,4096,0.080000,4096,0.080000,2048,0.040000,N/A,N/A,230400,529804,K_
 frame,video,1,1,4096,0.080000,4096,0.080000,4096,0.080000,2048,0.040000,529804,230400,320,240,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,video,2,4096,0.080000,4096,0.080000,2048,0.040000,30000,760228,K_
+packet,video,2,4096,0.080000,4096,0.080000,2048,0.040000,N/A,N/A,30000,760228,K_
 frame,video,2,1,4096,0.080000,4096,0.080000,4096,0.080000,2048,0.040000,760228,30000,100,100,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,audio,0,4096,0.092880,4096,0.092880,1024,0.023220,2048,790233,K_
+packet,audio,0,4096,0.092880,4096,0.092880,1024,0.023220,N/A,N/A,2048,790233,K_
 frame,audio,0,1,4096,0.092880,4096,0.092880,4096,0.092880,1024,0.023220,790233,2048,s16,1024,1,unknown
-packet,audio,0,5120,0.116100,5120,0.116100,393,0.008912,786,792304,K_
+packet,audio,0,5120,0.116100,5120,0.116100,393,0.008912,N/A,N/A,786,792304,K_
 frame,audio,0,1,5120,0.116100,5120,0.116100,5120,0.116100,393,0.008912,792304,786,s16,393,1,unknown
-packet,video,1,6144,0.120000,6144,0.120000,2048,0.040000,230400,793120,K_
+packet,video,1,6144,0.120000,6144,0.120000,2048,0.040000,N/A,N/A,230400,793120,K_
 frame,video,1,1,6144,0.120000,6144,0.120000,6144,0.120000,2048,0.040000,793120,230400,320,240,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-packet,video,2,6144,0.120000,6144,0.120000,2048,0.040000,30000,1023544,K_
+packet,video,2,6144,0.120000,6144,0.120000,2048,0.040000,N/A,N/A,30000,1023544,K_
 frame,video,2,1,6144,0.120000,6144,0.120000,6144,0.120000,2048,0.040000,1023544,30000,100,100,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified
-stream,0,pcm_s16le,unknown,audio,PSD[16],0x10445350,s16,44100,1,unknown,16,N/A,0/0,0/0,1/44100,0,0.000000,N/A,N/A,705600,N/A,N/A,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,0,mc²,Lavc pcm_s16le
-stream,1,rawvideo,unknown,video,RGB[24],0x18424752,320,240,320,240,0,0,1:1,4:3,rgb24,-99,unknown,unknown,unknown,unknown,unspecified,unknown,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt,Lavc rawvideo
-stream,2,rawvideo,unknown,video,RGB[24],0x18424752,100,100,100,100,0,0,1:1,1:1,rgb24,-99,unknown,unknown,unknown,unknown,unspecified,unknown,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,0,Lavc rawvideo
+stream,0,pcm_s16le,unknown,audio,1/44100,PSD[16],0x10445350,s16,44100,1,unknown,16,N/A,0/0,0/0,1/44100,0,0.000000,N/A,N/A,705600,N/A,N/A,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,0,mc²,Lavc pcm_s16le
+stream,1,rawvideo,unknown,video,1/25,RGB[24],0x18424752,320,240,320,240,0,0,1:1,4:3,rgb24,-99,unknown,unknown,unknown,unknown,unspecified,unknown,N/A,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt,Lavc rawvideo
+stream,2,rawvideo,unknown,video,1/25,RGB[24],0x18424752,100,100,100,100,0,0,1:1,1:1,rgb24,-99,unknown,unknown,unknown,unknown,unspecified,unknown,N/A,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,0,Lavc rawvideo
 format,tests/data/ffprobe-test.nut,3,0,nut,0.000000,0.120000,1053624,70241600,100,ffprobe test file,"'A comment with CSV, XML & JSON special chars': <tag value=""x"">",I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_default b/tests/ref/fate/ffprobe_default
index fd36ecf..0c2908c 100644
--- a/tests/ref/fate/ffprobe_default
+++ b/tests/ref/fate/ffprobe_default
@@ -7,6 +7,8 @@
 dts_time=0.000000
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=647
 flags=K_
@@ -39,6 +41,8 @@
 dts_time=0.000000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=2722
 flags=K_
@@ -82,6 +86,8 @@
 dts_time=0.000000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=233143
 flags=K_
@@ -125,6 +131,8 @@
 dts_time=0.023220
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=263148
 flags=K_
@@ -157,6 +165,8 @@
 dts_time=0.040000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=265226
 flags=K_
@@ -200,6 +210,8 @@
 dts_time=0.040000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=495650
 flags=K_
@@ -243,6 +255,8 @@
 dts_time=0.046440
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=525655
 flags=K_
@@ -275,6 +289,8 @@
 dts_time=0.069660
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=527726
 flags=K_
@@ -307,6 +323,8 @@
 dts_time=0.080000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=529804
 flags=K_
@@ -350,6 +368,8 @@
 dts_time=0.080000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=760228
 flags=K_
@@ -393,6 +413,8 @@
 dts_time=0.092880
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=790233
 flags=K_
@@ -425,6 +447,8 @@
 dts_time=0.116100
 duration=393
 duration_time=0.008912
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=786
 pos=792304
 flags=K_
@@ -457,6 +481,8 @@
 dts_time=0.120000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=793120
 flags=K_
@@ -500,6 +526,8 @@
 dts_time=0.120000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=1023544
 flags=K_
@@ -539,6 +567,7 @@
 codec_name=pcm_s16le
 profile=unknown
 codec_type=audio
+codec_time_base=1/44100
 codec_tag_string=PSD[16]
 codec_tag=0x10445350
 sample_fmt=s16
@@ -580,6 +609,7 @@
 codec_name=rawvideo
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=RGB[24]
 codec_tag=0x18424752
 width=320
@@ -598,6 +628,7 @@
 color_primaries=unknown
 chroma_location=unspecified
 field_order=unknown
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
@@ -634,6 +665,7 @@
 codec_name=rawvideo
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=RGB[24]
 codec_tag=0x18424752
 width=100
@@ -652,6 +684,7 @@
 color_primaries=unknown
 chroma_location=unspecified
 field_order=unknown
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
diff --git a/tests/ref/fate/ffprobe_flat b/tests/ref/fate/ffprobe_flat
index 8d95cf6..b2437ce 100644
--- a/tests/ref/fate/ffprobe_flat
+++ b/tests/ref/fate/ffprobe_flat
@@ -6,6 +6,8 @@
 packets_and_frames.packet.0.dts_time="0.000000"
 packets_and_frames.packet.0.duration=1024
 packets_and_frames.packet.0.duration_time="0.023220"
+packets_and_frames.packet.0.convergence_duration="N/A"
+packets_and_frames.packet.0.convergence_duration_time="N/A"
 packets_and_frames.packet.0.size="2048"
 packets_and_frames.packet.0.pos="647"
 packets_and_frames.packet.0.flags="K_"
@@ -34,6 +36,8 @@
 packets_and_frames.packet.1.dts_time="0.000000"
 packets_and_frames.packet.1.duration=2048
 packets_and_frames.packet.1.duration_time="0.040000"
+packets_and_frames.packet.1.convergence_duration="N/A"
+packets_and_frames.packet.1.convergence_duration_time="N/A"
 packets_and_frames.packet.1.size="230400"
 packets_and_frames.packet.1.pos="2722"
 packets_and_frames.packet.1.flags="K_"
@@ -73,6 +77,8 @@
 packets_and_frames.packet.2.dts_time="0.000000"
 packets_and_frames.packet.2.duration=2048
 packets_and_frames.packet.2.duration_time="0.040000"
+packets_and_frames.packet.2.convergence_duration="N/A"
+packets_and_frames.packet.2.convergence_duration_time="N/A"
 packets_and_frames.packet.2.size="30000"
 packets_and_frames.packet.2.pos="233143"
 packets_and_frames.packet.2.flags="K_"
@@ -112,6 +118,8 @@
 packets_and_frames.packet.3.dts_time="0.023220"
 packets_and_frames.packet.3.duration=1024
 packets_and_frames.packet.3.duration_time="0.023220"
+packets_and_frames.packet.3.convergence_duration="N/A"
+packets_and_frames.packet.3.convergence_duration_time="N/A"
 packets_and_frames.packet.3.size="2048"
 packets_and_frames.packet.3.pos="263148"
 packets_and_frames.packet.3.flags="K_"
@@ -140,6 +148,8 @@
 packets_and_frames.packet.4.dts_time="0.040000"
 packets_and_frames.packet.4.duration=2048
 packets_and_frames.packet.4.duration_time="0.040000"
+packets_and_frames.packet.4.convergence_duration="N/A"
+packets_and_frames.packet.4.convergence_duration_time="N/A"
 packets_and_frames.packet.4.size="230400"
 packets_and_frames.packet.4.pos="265226"
 packets_and_frames.packet.4.flags="K_"
@@ -179,6 +189,8 @@
 packets_and_frames.packet.5.dts_time="0.040000"
 packets_and_frames.packet.5.duration=2048
 packets_and_frames.packet.5.duration_time="0.040000"
+packets_and_frames.packet.5.convergence_duration="N/A"
+packets_and_frames.packet.5.convergence_duration_time="N/A"
 packets_and_frames.packet.5.size="30000"
 packets_and_frames.packet.5.pos="495650"
 packets_and_frames.packet.5.flags="K_"
@@ -218,6 +230,8 @@
 packets_and_frames.packet.6.dts_time="0.046440"
 packets_and_frames.packet.6.duration=1024
 packets_and_frames.packet.6.duration_time="0.023220"
+packets_and_frames.packet.6.convergence_duration="N/A"
+packets_and_frames.packet.6.convergence_duration_time="N/A"
 packets_and_frames.packet.6.size="2048"
 packets_and_frames.packet.6.pos="525655"
 packets_and_frames.packet.6.flags="K_"
@@ -246,6 +260,8 @@
 packets_and_frames.packet.7.dts_time="0.069660"
 packets_and_frames.packet.7.duration=1024
 packets_and_frames.packet.7.duration_time="0.023220"
+packets_and_frames.packet.7.convergence_duration="N/A"
+packets_and_frames.packet.7.convergence_duration_time="N/A"
 packets_and_frames.packet.7.size="2048"
 packets_and_frames.packet.7.pos="527726"
 packets_and_frames.packet.7.flags="K_"
@@ -274,6 +290,8 @@
 packets_and_frames.packet.8.dts_time="0.080000"
 packets_and_frames.packet.8.duration=2048
 packets_and_frames.packet.8.duration_time="0.040000"
+packets_and_frames.packet.8.convergence_duration="N/A"
+packets_and_frames.packet.8.convergence_duration_time="N/A"
 packets_and_frames.packet.8.size="230400"
 packets_and_frames.packet.8.pos="529804"
 packets_and_frames.packet.8.flags="K_"
@@ -313,6 +331,8 @@
 packets_and_frames.packet.9.dts_time="0.080000"
 packets_and_frames.packet.9.duration=2048
 packets_and_frames.packet.9.duration_time="0.040000"
+packets_and_frames.packet.9.convergence_duration="N/A"
+packets_and_frames.packet.9.convergence_duration_time="N/A"
 packets_and_frames.packet.9.size="30000"
 packets_and_frames.packet.9.pos="760228"
 packets_and_frames.packet.9.flags="K_"
@@ -352,6 +372,8 @@
 packets_and_frames.packet.10.dts_time="0.092880"
 packets_and_frames.packet.10.duration=1024
 packets_and_frames.packet.10.duration_time="0.023220"
+packets_and_frames.packet.10.convergence_duration="N/A"
+packets_and_frames.packet.10.convergence_duration_time="N/A"
 packets_and_frames.packet.10.size="2048"
 packets_and_frames.packet.10.pos="790233"
 packets_and_frames.packet.10.flags="K_"
@@ -380,6 +402,8 @@
 packets_and_frames.packet.11.dts_time="0.116100"
 packets_and_frames.packet.11.duration=393
 packets_and_frames.packet.11.duration_time="0.008912"
+packets_and_frames.packet.11.convergence_duration="N/A"
+packets_and_frames.packet.11.convergence_duration_time="N/A"
 packets_and_frames.packet.11.size="786"
 packets_and_frames.packet.11.pos="792304"
 packets_and_frames.packet.11.flags="K_"
@@ -408,6 +432,8 @@
 packets_and_frames.packet.12.dts_time="0.120000"
 packets_and_frames.packet.12.duration=2048
 packets_and_frames.packet.12.duration_time="0.040000"
+packets_and_frames.packet.12.convergence_duration="N/A"
+packets_and_frames.packet.12.convergence_duration_time="N/A"
 packets_and_frames.packet.12.size="230400"
 packets_and_frames.packet.12.pos="793120"
 packets_and_frames.packet.12.flags="K_"
@@ -447,6 +473,8 @@
 packets_and_frames.packet.13.dts_time="0.120000"
 packets_and_frames.packet.13.duration=2048
 packets_and_frames.packet.13.duration_time="0.040000"
+packets_and_frames.packet.13.convergence_duration="N/A"
+packets_and_frames.packet.13.convergence_duration_time="N/A"
 packets_and_frames.packet.13.size="30000"
 packets_and_frames.packet.13.pos="1023544"
 packets_and_frames.packet.13.flags="K_"
@@ -482,6 +510,7 @@
 streams.stream.0.codec_name="pcm_s16le"
 streams.stream.0.profile="unknown"
 streams.stream.0.codec_type="audio"
+streams.stream.0.codec_time_base="1/44100"
 streams.stream.0.codec_tag_string="PSD[16]"
 streams.stream.0.codec_tag="0x10445350"
 streams.stream.0.sample_fmt="s16"
@@ -521,6 +550,7 @@
 streams.stream.1.codec_name="rawvideo"
 streams.stream.1.profile="unknown"
 streams.stream.1.codec_type="video"
+streams.stream.1.codec_time_base="1/25"
 streams.stream.1.codec_tag_string="RGB[24]"
 streams.stream.1.codec_tag="0x18424752"
 streams.stream.1.width=320
@@ -539,6 +569,7 @@
 streams.stream.1.color_primaries="unknown"
 streams.stream.1.chroma_location="unspecified"
 streams.stream.1.field_order="unknown"
+streams.stream.1.timecode="N/A"
 streams.stream.1.refs=1
 streams.stream.1.id="N/A"
 streams.stream.1.r_frame_rate="25/1"
@@ -573,6 +604,7 @@
 streams.stream.2.codec_name="rawvideo"
 streams.stream.2.profile="unknown"
 streams.stream.2.codec_type="video"
+streams.stream.2.codec_time_base="1/25"
 streams.stream.2.codec_tag_string="RGB[24]"
 streams.stream.2.codec_tag="0x18424752"
 streams.stream.2.width=100
@@ -591,6 +623,7 @@
 streams.stream.2.color_primaries="unknown"
 streams.stream.2.chroma_location="unspecified"
 streams.stream.2.field_order="unknown"
+streams.stream.2.timecode="N/A"
 streams.stream.2.refs=1
 streams.stream.2.id="N/A"
 streams.stream.2.r_frame_rate="25/1"
diff --git a/tests/ref/fate/ffprobe_ini b/tests/ref/fate/ffprobe_ini
index 1630237..f2cff76 100644
--- a/tests/ref/fate/ffprobe_ini
+++ b/tests/ref/fate/ffprobe_ini
@@ -9,6 +9,8 @@
 dts_time=0.000000
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=647
 flags=K_
@@ -41,6 +43,8 @@
 dts_time=0.000000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=2722
 flags=K_
@@ -84,6 +88,8 @@
 dts_time=0.000000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=233143
 flags=K_
@@ -127,6 +133,8 @@
 dts_time=0.023220
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=263148
 flags=K_
@@ -159,6 +167,8 @@
 dts_time=0.040000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=265226
 flags=K_
@@ -202,6 +212,8 @@
 dts_time=0.040000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=495650
 flags=K_
@@ -245,6 +257,8 @@
 dts_time=0.046440
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=525655
 flags=K_
@@ -277,6 +291,8 @@
 dts_time=0.069660
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=527726
 flags=K_
@@ -309,6 +325,8 @@
 dts_time=0.080000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=529804
 flags=K_
@@ -352,6 +370,8 @@
 dts_time=0.080000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=760228
 flags=K_
@@ -395,6 +415,8 @@
 dts_time=0.092880
 duration=1024
 duration_time=0.023220
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=2048
 pos=790233
 flags=K_
@@ -427,6 +449,8 @@
 dts_time=0.116100
 duration=393
 duration_time=0.008912
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=786
 pos=792304
 flags=K_
@@ -459,6 +483,8 @@
 dts_time=0.120000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=230400
 pos=793120
 flags=K_
@@ -502,6 +528,8 @@
 dts_time=0.120000
 duration=2048
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=30000
 pos=1023544
 flags=K_
@@ -541,6 +569,7 @@
 codec_name=pcm_s16le
 profile=unknown
 codec_type=audio
+codec_time_base=1/44100
 codec_tag_string=PSD[16]
 codec_tag=0x10445350
 sample_fmt=s16
@@ -586,6 +615,7 @@
 codec_name=rawvideo
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=RGB[24]
 codec_tag=0x18424752
 width=320
@@ -604,6 +634,7 @@
 color_primaries=unknown
 chroma_location=unspecified
 field_order=unknown
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
@@ -644,6 +675,7 @@
 codec_name=rawvideo
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=RGB[24]
 codec_tag=0x18424752
 width=100
@@ -662,6 +694,7 @@
 color_primaries=unknown
 chroma_location=unspecified
 field_order=unknown
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
diff --git a/tests/ref/fate/ffprobe_json b/tests/ref/fate/ffprobe_json
index 154f2ac..7b88e1a 100644
--- a/tests/ref/fate/ffprobe_json
+++ b/tests/ref/fate/ffprobe_json
@@ -524,6 +524,7 @@
             "index": 0,
             "codec_name": "pcm_s16le",
             "codec_type": "audio",
+            "codec_time_base": "1/44100",
             "codec_tag_string": "PSD[16]",
             "codec_tag": "0x10445350",
             "sample_fmt": "s16",
@@ -561,6 +562,7 @@
             "index": 1,
             "codec_name": "rawvideo",
             "codec_type": "video",
+            "codec_time_base": "1/25",
             "codec_tag_string": "RGB[24]",
             "codec_tag": "0x18424752",
             "width": 320,
@@ -605,6 +607,7 @@
             "index": 2,
             "codec_name": "rawvideo",
             "codec_type": "video",
+            "codec_time_base": "1/25",
             "codec_tag_string": "RGB[24]",
             "codec_tag": "0x18424752",
             "width": 100,
diff --git a/tests/ref/fate/ffprobe_xml b/tests/ref/fate/ffprobe_xml
index 04261ed..ccea287 100644
--- a/tests/ref/fate/ffprobe_xml
+++ b/tests/ref/fate/ffprobe_xml
@@ -32,18 +32,18 @@
     </packets_and_frames>
 
     <streams>
-        <stream index="0" codec_name="pcm_s16le" codec_type="audio" codec_tag_string="PSD[16]" codec_tag="0x10445350" sample_fmt="s16" sample_rate="44100" channels="1" bits_per_sample="16" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/44100" start_pts="0" start_time="0.000000" bit_rate="705600" nb_read_frames="6" nb_read_packets="6">
+        <stream index="0" codec_name="pcm_s16le" codec_type="audio" codec_time_base="1/44100" codec_tag_string="PSD[16]" codec_tag="0x10445350" sample_fmt="s16" sample_rate="44100" channels="1" bits_per_sample="16" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/44100" start_pts="0" start_time="0.000000" bit_rate="705600" nb_read_frames="6" nb_read_packets="6">
             <disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0" timed_thumbnails="0"/>
             <tag key="E" value="mc²"/>
             <tag key="encoder" value="Lavc pcm_s16le"/>
         </stream>
-        <stream index="1" codec_name="rawvideo" codec_type="video" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="320" height="240" coded_width="320" coded_height="240" closed_captions="0" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="4:3" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
+        <stream index="1" codec_name="rawvideo" codec_type="video" codec_time_base="1/25" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="320" height="240" coded_width="320" coded_height="240" closed_captions="0" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="4:3" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
             <disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0" timed_thumbnails="0"/>
             <tag key="title" value="foobar"/>
             <tag key="duration_ts" value="field-and-tags-conflict-attempt"/>
             <tag key="encoder" value="Lavc rawvideo"/>
         </stream>
-        <stream index="2" codec_name="rawvideo" codec_type="video" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="100" height="100" coded_width="100" coded_height="100" closed_captions="0" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="1:1" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
+        <stream index="2" codec_name="rawvideo" codec_type="video" codec_time_base="1/25" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="100" height="100" coded_width="100" coded_height="100" closed_captions="0" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="1:1" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
             <disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0" timed_thumbnails="0"/>
             <tag key="encoder" value="Lavc rawvideo"/>
         </stream>
@@ -51,7 +51,7 @@
 
     <format filename="tests/data/ffprobe-test.nut" nb_streams="3" nb_programs="0" format_name="nut" start_time="0.000000" duration="0.120000" size="1053624" bit_rate="70241600" probe_score="100">
         <tag key="title" value="ffprobe test file"/>
-        <tag key="comment" value="'A comment with CSV, XML &amp; JSON special chars': &lt;tag value=&quot;x&quot;&gt;"/>
+        <tag key="comment" value="&apos;A comment with CSV, XML &amp; JSON special chars&apos;: &lt;tag value=&quot;x&quot;&gt;"/>
         <tag key="comment2" value="I ♥ Üñîçød€"/>
     </format>
 </ffprobe>
diff --git a/tests/ref/fate/filter-thumbnail b/tests/ref/fate/filter-thumbnail
index 4d8c501..36f11f2 100644
--- a/tests/ref/fate/filter-thumbnail
+++ b/tests/ref/fate/filter-thumbnail
@@ -1 +1 @@
-thumbnail           8b54dbc891b9cc05742dd0f5b74c0727
+thumbnail           cd429b3d92c33bcc257e8e6a3284dbf7
diff --git a/tests/ref/fate/fits-demux b/tests/ref/fate/fits-demux
index de7aa11..85605ab 100644
--- a/tests/ref/fate/fits-demux
+++ b/tests/ref/fate/fits-demux
@@ -3,8 +3,8 @@
 #codec_id 0: fits
 #dimensions 0: 72x36
 #sar 0: 0/1
-0,          0,          0,        1,    14320, 0xa9ee75a4
-0,          1,          1,        1,    14320, 0xb9daf9af
-0,          2,          2,        1,    14320, 0xf6431b56
-0,          3,          3,        1,    14320, 0x921adec5
-0,          4,          4,        1,    14320, 0xa34e7331
+0,          0,          0,        1,    14320, 0x0ecf72e0
+0,          1,          1,        1,    14320, 0xd94af6eb
+0,          2,          2,        1,    14320, 0x15c21892
+0,          3,          3,        1,    14320, 0xb18adc01
+0,          4,          4,        1,    14320, 0xc2be706d
diff --git a/tests/ref/fate/fitsdec-gray b/tests/ref/fate/fitsdec-gray
index 488ee71..d080732 100644
--- a/tests/ref/fate/fitsdec-gray
+++ b/tests/ref/fate/fitsdec-gray
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 128x128
 #sar 0: 0/1
-0,          0,          0,        1,    16384, 0xeff50901
+0,          0,          0,        1,    16384, 0x353dbacd
diff --git a/tests/ref/fate/flcl1905 b/tests/ref/fate/flcl1905
index c651280..de42921 100644
--- a/tests/ref/fate/flcl1905
+++ b/tests/ref/fate/flcl1905
@@ -1,4 +1,4 @@
-packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=22528|duration_time=0.510839|size=4092|pos=56|flags=K_
+packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=56|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.000000|pkt_dts=0|pkt_dts_time=0.000000|best_effort_timestamp=0|best_effort_timestamp_time=0.000000|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=56|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=56|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=56|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -10,7 +10,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=56|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=56|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=56|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=22528|pts_time=0.510839|dts=22528|dts_time=0.510839|duration=22528|duration_time=0.510839|size=4092|pos=4148|flags=K_
+packet|codec_type=audio|stream_index=0|pts=22528|pts_time=0.510839|dts=22528|dts_time=0.510839|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=4148|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=22528|pkt_pts_time=0.510839|pkt_dts=22528|pkt_dts_time=0.510839|best_effort_timestamp=22528|best_effort_timestamp_time=0.510839|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=4148|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=4148|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=4148|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -22,7 +22,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=4148|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=4148|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=4148|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=45056|pts_time=1.021678|dts=45056|dts_time=1.021678|duration=22528|duration_time=0.510839|size=4092|pos=8240|flags=K_
+packet|codec_type=audio|stream_index=0|pts=45056|pts_time=1.021678|dts=45056|dts_time=1.021678|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=8240|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=45056|pkt_pts_time=1.021678|pkt_dts=45056|pkt_dts_time=1.021678|best_effort_timestamp=45056|best_effort_timestamp_time=1.021678|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=8240|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=8240|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=8240|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -34,7 +34,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=8240|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=8240|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=8240|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=67584|pts_time=1.532517|dts=67584|dts_time=1.532517|duration=22528|duration_time=0.510839|size=4092|pos=12332|flags=K_
+packet|codec_type=audio|stream_index=0|pts=67584|pts_time=1.532517|dts=67584|dts_time=1.532517|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=12332|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=67584|pkt_pts_time=1.532517|pkt_dts=67584|pkt_dts_time=1.532517|best_effort_timestamp=67584|best_effort_timestamp_time=1.532517|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=12332|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=12332|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=12332|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -46,7 +46,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=12332|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=12332|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=12332|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=90112|pts_time=2.043356|dts=90112|dts_time=2.043356|duration=22528|duration_time=0.510839|size=4092|pos=16424|flags=K_
+packet|codec_type=audio|stream_index=0|pts=90112|pts_time=2.043356|dts=90112|dts_time=2.043356|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=16424|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=90112|pkt_pts_time=2.043356|pkt_dts=90112|pkt_dts_time=2.043356|best_effort_timestamp=90112|best_effort_timestamp_time=2.043356|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=16424|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=16424|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=16424|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -58,7 +58,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=16424|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=16424|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=16424|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=112640|pts_time=2.554195|dts=112640|dts_time=2.554195|duration=22528|duration_time=0.510839|size=4092|pos=20516|flags=K_
+packet|codec_type=audio|stream_index=0|pts=112640|pts_time=2.554195|dts=112640|dts_time=2.554195|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=20516|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=112640|pkt_pts_time=2.554195|pkt_dts=112640|pkt_dts_time=2.554195|best_effort_timestamp=112640|best_effort_timestamp_time=2.554195|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=20516|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=20516|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=20516|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -70,7 +70,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=20516|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=20516|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=20516|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=135168|pts_time=3.065034|dts=135168|dts_time=3.065034|duration=22528|duration_time=0.510839|size=4092|pos=24608|flags=K_
+packet|codec_type=audio|stream_index=0|pts=135168|pts_time=3.065034|dts=135168|dts_time=3.065034|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=24608|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=135168|pkt_pts_time=3.065034|pkt_dts=135168|pkt_dts_time=3.065034|best_effort_timestamp=135168|best_effort_timestamp_time=3.065034|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=24608|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=24608|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=24608|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -82,7 +82,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=24608|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=24608|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=24608|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=157696|pts_time=3.575873|dts=157696|dts_time=3.575873|duration=22528|duration_time=0.510839|size=4092|pos=28700|flags=K_
+packet|codec_type=audio|stream_index=0|pts=157696|pts_time=3.575873|dts=157696|dts_time=3.575873|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=28700|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=157696|pkt_pts_time=3.575873|pkt_dts=157696|pkt_dts_time=3.575873|best_effort_timestamp=157696|best_effort_timestamp_time=3.575873|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=28700|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=28700|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=28700|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -94,7 +94,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=28700|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=28700|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=28700|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=180224|pts_time=4.086712|dts=180224|dts_time=4.086712|duration=22528|duration_time=0.510839|size=4092|pos=32792|flags=K_
+packet|codec_type=audio|stream_index=0|pts=180224|pts_time=4.086712|dts=180224|dts_time=4.086712|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=32792|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=180224|pkt_pts_time=4.086712|pkt_dts=180224|pkt_dts_time=4.086712|best_effort_timestamp=180224|best_effort_timestamp_time=4.086712|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=32792|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=32792|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=32792|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -106,7 +106,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=32792|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=32792|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=32792|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=202752|pts_time=4.597551|dts=202752|dts_time=4.597551|duration=22528|duration_time=0.510839|size=4092|pos=36884|flags=K_
+packet|codec_type=audio|stream_index=0|pts=202752|pts_time=4.597551|dts=202752|dts_time=4.597551|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=36884|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=202752|pkt_pts_time=4.597551|pkt_dts=202752|pkt_dts_time=4.597551|best_effort_timestamp=202752|best_effort_timestamp_time=4.597551|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=36884|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=36884|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=36884|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -118,7 +118,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=36884|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=36884|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=36884|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=225280|pts_time=5.108390|dts=225280|dts_time=5.108390|duration=22528|duration_time=0.510839|size=4092|pos=40976|flags=K_
+packet|codec_type=audio|stream_index=0|pts=225280|pts_time=5.108390|dts=225280|dts_time=5.108390|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=40976|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=225280|pkt_pts_time=5.108390|pkt_dts=225280|pkt_dts_time=5.108390|best_effort_timestamp=225280|best_effort_timestamp_time=5.108390|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=40976|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=40976|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=40976|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -130,7 +130,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=40976|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=40976|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=40976|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=247808|pts_time=5.619229|dts=247808|dts_time=5.619229|duration=22528|duration_time=0.510839|size=4092|pos=45068|flags=K_
+packet|codec_type=audio|stream_index=0|pts=247808|pts_time=5.619229|dts=247808|dts_time=5.619229|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=45068|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=247808|pkt_pts_time=5.619229|pkt_dts=247808|pkt_dts_time=5.619229|best_effort_timestamp=247808|best_effort_timestamp_time=5.619229|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=45068|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=45068|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=45068|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -142,7 +142,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=45068|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=45068|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=45068|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=270336|pts_time=6.130068|dts=270336|dts_time=6.130068|duration=22528|duration_time=0.510839|size=4092|pos=49160|flags=K_
+packet|codec_type=audio|stream_index=0|pts=270336|pts_time=6.130068|dts=270336|dts_time=6.130068|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=49160|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=270336|pkt_pts_time=6.130068|pkt_dts=270336|pkt_dts_time=6.130068|best_effort_timestamp=270336|best_effort_timestamp_time=6.130068|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=49160|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=49160|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=49160|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -154,7 +154,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=49160|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=49160|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=49160|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=292864|pts_time=6.640907|dts=292864|dts_time=6.640907|duration=22528|duration_time=0.510839|size=4092|pos=53252|flags=K_
+packet|codec_type=audio|stream_index=0|pts=292864|pts_time=6.640907|dts=292864|dts_time=6.640907|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=53252|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=292864|pkt_pts_time=6.640907|pkt_dts=292864|pkt_dts_time=6.640907|best_effort_timestamp=292864|best_effort_timestamp_time=6.640907|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=53252|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=53252|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=53252|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -166,7 +166,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=53252|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=53252|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=53252|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=315392|pts_time=7.151746|dts=315392|dts_time=7.151746|duration=22528|duration_time=0.510839|size=4092|pos=57344|flags=K_
+packet|codec_type=audio|stream_index=0|pts=315392|pts_time=7.151746|dts=315392|dts_time=7.151746|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=57344|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=315392|pkt_pts_time=7.151746|pkt_dts=315392|pkt_dts_time=7.151746|best_effort_timestamp=315392|best_effort_timestamp_time=7.151746|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=57344|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=57344|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=57344|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -178,7 +178,7 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=57344|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=57344|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=57344|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=337920|pts_time=7.662585|dts=337920|dts_time=7.662585|duration=22528|duration_time=0.510839|size=4092|pos=61436|flags=K_
+packet|codec_type=audio|stream_index=0|pts=337920|pts_time=7.662585|dts=337920|dts_time=7.662585|duration=22528|duration_time=0.510839|convergence_duration=N/A|convergence_duration_time=N/A|size=4092|pos=61436|flags=K_
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=337920|pkt_pts_time=7.662585|pkt_dts=337920|pkt_dts_time=7.662585|best_effort_timestamp=337920|best_effort_timestamp_time=7.662585|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=61436|pkt_size=4092|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=61436|pkt_size=3720|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=61436|pkt_size=3348|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
@@ -190,4 +190,4 @@
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=61436|pkt_size=1116|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=61436|pkt_size=744|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
 frame|media_type=audio|stream_index=0|key_frame=1|pkt_pts=N/A|pkt_pts_time=N/A|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=N/A|best_effort_timestamp_time=N/A|pkt_duration=22528|pkt_duration_time=0.510839|pkt_pos=61436|pkt_size=372|sample_fmt=fltp|nb_samples=2048|channels=2|channel_layout=unknown
-packet|codec_type=audio|stream_index=0|pts=360448|pts_time=8.173424|dts=360448|dts_time=8.173424|duration=44|duration_time=0.000998|size=8|pos=65528|flags=K_
+packet|codec_type=audio|stream_index=0|pts=360448|pts_time=8.173424|dts=360448|dts_time=8.173424|duration=44|duration_time=0.000998|convergence_duration=N/A|convergence_duration_time=N/A|size=8|pos=65528|flags=K_
diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
index 95b167b..76cbf22 100644
--- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
+++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
@@ -5,7 +5,7 @@
 [/STREAM]
 [FORMAT]
 start_time=0.000000
-duration=2.344000
+duration=2.367000
 [/FORMAT]
 packet|pts=-1024|dts=-1024|duration=1024|flags=KDside_data|
 
diff --git a/tests/ref/fate/gaplessenc-pcm-to-mov-aac b/tests/ref/fate/gaplessenc-pcm-to-mov-aac
index bfd47be..2b17956 100644
--- a/tests/ref/fate/gaplessenc-pcm-to-mov-aac
+++ b/tests/ref/fate/gaplessenc-pcm-to-mov-aac
@@ -5,7 +5,7 @@
 [/STREAM]
 [FORMAT]
 start_time=0.000000
-duration=12.000000
+duration=12.024000
 [/FORMAT]
 packet|pts=-1024|dts=-1024|duration=1024|flags=KDside_data|
 
diff --git a/tests/ref/fate/gaplessinfo-itunes1 b/tests/ref/fate/gaplessinfo-itunes1
index c10e4cc..bb5c09a 100644
--- a/tests/ref/fate/gaplessinfo-itunes1
+++ b/tests/ref/fate/gaplessinfo-itunes1
@@ -24,7 +24,7 @@
 packet|pts=1292288|dts=1292288|duration=1024|flags=K_
 packet|pts=1293312|dts=1293312|duration=1024|flags=K_
 stream|nb_read_packets=1264
-frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2112|pkt_duration=960|nb_samples=960
+frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2048|pkt_duration=960|nb_samples=960
 frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
diff --git a/tests/ref/fate/gaplessinfo-itunes2 b/tests/ref/fate/gaplessinfo-itunes2
index 752b953..0603ba8 100644
--- a/tests/ref/fate/gaplessinfo-itunes2
+++ b/tests/ref/fate/gaplessinfo-itunes2
@@ -24,7 +24,7 @@
 packet|pts=103424|dts=103424|duration=1024|flags=K_
 packet|pts=104448|dts=104448|duration=1024|flags=K_
 stream|nb_read_packets=103
-frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2112|pkt_duration=960|nb_samples=960
+frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2048|pkt_duration=960|nb_samples=960
 frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov
index d037463..04a965b 100644
--- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov
+++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov
@@ -7,6 +7,8 @@
 dts_time=0.000000
 duration=512
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=4612
 pos=36
 flags=K_
@@ -17,6 +19,7 @@
 codec_name=hap
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=HapA
 codec_tag=0x41706148
 width=127
@@ -35,6 +38,7 @@
 color_primaries=unknown
 chroma_location=unspecified
 field_order=unknown
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov
index 8180419..d9e5c94 100644
--- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov
+++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov
@@ -7,6 +7,8 @@
 dts_time=0.000000
 duration=512
 duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
 size=9220
 pos=36
 flags=K_
@@ -17,6 +19,7 @@
 codec_name=hap
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=HapY
 codec_tag=0x59706148
 width=127
@@ -35,6 +38,7 @@
 color_primaries=unknown
 chroma_location=unspecified
 field_order=unknown
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
diff --git a/tests/ref/fate/hls-fmp4_ac3 b/tests/ref/fate/hls-fmp4_ac3
index caccd70..1f45172 100644
--- a/tests/ref/fate/hls-fmp4_ac3
+++ b/tests/ref/fate/hls-fmp4_ac3
@@ -1,5 +1,6 @@
 [STREAM]
 codec_name=ac3
+codec_time_base=1/48000
 sample_fmt=fltp
 channels=6
 channel_layout=5.1(side)
diff --git a/tests/ref/fate/libavcodec-options b/tests/ref/fate/libavcodec-options
new file mode 100644
index 0000000..ecdcac5
--- /dev/null
+++ b/tests/ref/fate/libavcodec-options
@@ -0,0 +1,161 @@
+testing avcodec_copy_context()
+dummy_v1_codec -> dummy_v1_codec
+closed:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+opened:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v1_codec -> dummy_v2_codec
+closed:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+opened:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+dummy_v1_codec -> dummy_v3_codec
+closed:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v3_codec: 128x128 prv: set
+opened:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v3_codec: 128x128 prv: set
+dummy_v1_codec -> dummy_v4_codec
+closed:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v4_codec: 128x128 prv: null
+opened:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v4_codec: 128x128 prv: null
+dummy_v1_codec -> NULL
+closed:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+NULL          : 128x128 prv: null
+opened:
+dummy_v1_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+NULL          : 128x128 prv: null
+dummy_v2_codec -> dummy_v1_codec
+closed:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+opened:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+dummy_v2_codec -> dummy_v2_codec
+closed:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+opened:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v2_codec -> dummy_v3_codec
+closed:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v3_codec: 128x128 prv: set
+opened:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v3_codec: 128x128 prv: set
+dummy_v2_codec -> dummy_v4_codec
+closed:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v4_codec: 128x128 prv: null
+opened:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+dummy_v4_codec: 128x128 prv: null
+dummy_v2_codec -> NULL
+closed:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+NULL          : 128x128 prv: null
+opened:
+dummy_v2_codec: 128x128 prv: set opts: 1500100900 i'm src default value
+NULL          : 128x128 prv: null
+dummy_v3_codec -> dummy_v1_codec
+closed:
+dummy_v3_codec: 128x128 prv: set
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+opened:
+dummy_v3_codec: 128x128 prv: set
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+dummy_v3_codec -> dummy_v2_codec
+closed:
+dummy_v3_codec: 128x128 prv: set
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+opened:
+dummy_v3_codec: 128x128 prv: set
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+dummy_v3_codec -> dummy_v3_codec
+closed:
+dummy_v3_codec: 128x128 prv: set
+dummy_v3_codec: 128x128 prv: set
+opened:
+dummy_v3_codec: 128x128 prv: set
+dummy_v3_codec: 128x128 prv: set
+dummy_v3_codec -> dummy_v4_codec
+closed:
+dummy_v3_codec: 128x128 prv: set
+dummy_v4_codec: 128x128 prv: null
+opened:
+dummy_v3_codec: 128x128 prv: set
+dummy_v4_codec: 128x128 prv: null
+dummy_v3_codec -> NULL
+closed:
+dummy_v3_codec: 128x128 prv: set
+NULL          : 128x128 prv: null
+opened:
+dummy_v3_codec: 128x128 prv: set
+NULL          : 128x128 prv: null
+dummy_v4_codec -> dummy_v1_codec
+closed:
+dummy_v4_codec: 128x128 prv: null
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+opened:
+dummy_v4_codec: 128x128 prv: null
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+dummy_v4_codec -> dummy_v2_codec
+closed:
+dummy_v4_codec: 128x128 prv: null
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+opened:
+dummy_v4_codec: 128x128 prv: null
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+dummy_v4_codec -> dummy_v3_codec
+closed:
+dummy_v4_codec: 128x128 prv: null
+dummy_v3_codec: 128x128 prv: set
+opened:
+dummy_v4_codec: 128x128 prv: null
+dummy_v3_codec: 128x128 prv: set
+dummy_v4_codec -> dummy_v4_codec
+closed:
+dummy_v4_codec: 128x128 prv: null
+dummy_v4_codec: 128x128 prv: null
+opened:
+dummy_v4_codec: 128x128 prv: null
+dummy_v4_codec: 128x128 prv: null
+dummy_v4_codec -> NULL
+closed:
+dummy_v4_codec: 128x128 prv: null
+NULL          : 128x128 prv: null
+opened:
+dummy_v4_codec: 128x128 prv: null
+NULL          : 128x128 prv: null
+NULL -> dummy_v1_codec
+closed:
+NULL          : 128x128 prv: null
+dummy_v1_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+NULL -> dummy_v2_codec
+closed:
+NULL          : 128x128 prv: null
+dummy_v2_codec: 128x128 prv: set opts: 667 i'm dest value before copy
+NULL -> dummy_v3_codec
+closed:
+NULL          : 128x128 prv: null
+dummy_v3_codec: 128x128 prv: set
+NULL -> dummy_v4_codec
+closed:
+NULL          : 128x128 prv: null
+dummy_v4_codec: 128x128 prv: null
+NULL -> NULL
+closed:
+NULL          : 128x128 prv: null
+NULL          : 128x128 prv: null
diff --git a/tests/ref/fate/lscr b/tests/ref/fate/lscr
deleted file mode 100644
index 3b3fd4c..0000000
--- a/tests/ref/fate/lscr
+++ /dev/null
@@ -1,21 +0,0 @@
-#tb 0: 100/2397
-#media_type 0: video
-#codec_id 0: rawvideo
-#dimensions 0: 320x240
-#sar 0: 0/1
-0,          0,          0,        1,   230400, 0x07c93bd9
-0,          1,          1,        1,   230400, 0xdcacc274
-0,          2,          2,        1,   230400, 0x6115dc34
-0,          3,          3,        1,   230400, 0x7317f35c
-0,          4,          4,        1,   230400, 0xca18d9a6
-0,          5,          5,        1,   230400, 0x0c104d49
-0,          6,          6,        1,   230400, 0xc4c415cf
-0,          7,          7,        1,   230400, 0xd1e4149f
-0,          8,          8,        1,   230400, 0x5973ae25
-0,          9,          9,        1,   230400, 0xd77893e6
-0,         10,         10,        1,   230400, 0x7f9cac97
-0,         11,         11,        1,   230400, 0xc8f81940
-0,         12,         12,        1,   230400, 0xa2b6f5d4
-0,         13,         13,        1,   230400, 0x620c3222
-0,         14,         14,        1,   230400, 0x60d097a0
-0,         15,         15,        1,   230400, 0x47201c65
diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
deleted file mode 100644
index f9fb54a..0000000
--- a/tests/ref/fate/matroska-mastering-display-metadata
+++ /dev/null
@@ -1,97 +0,0 @@
-542ababe5c088ab925ee49373d8b8a85 *tests/data/fate/matroska-mastering-display-metadata.matroska
-1669695 tests/data/fate/matroska-mastering-display-metadata.matroska
-#extradata 0:        4, 0x040901a3
-#extradata 3:      200, 0x506463a8
-#tb 0: 1/1000
-#media_type 0: video
-#codec_id 0: prores
-#dimensions 0: 1280x720
-#sar 0: 1/1
-#tb 1: 1/1000
-#media_type 1: audio
-#codec_id 1: pcm_s24le
-#sample_rate 1: 48000
-#channel_layout 1: 4
-#channel_layout_name 1: mono
-#tb 2: 1/1000
-#media_type 2: audio
-#codec_id 2: pcm_s16be
-#sample_rate 2: 48000
-#channel_layout 2: 4
-#channel_layout_name 2: mono
-#tb 3: 1/1000
-#media_type 3: video
-#codec_id 3: ffv1
-#dimensions 3: 1280x720
-#sar 3: 1/1
-0,          0,          0,       16,    57008, 0x43416399, S=2,        8, 0x08e5014f,       88, 0xd65a04db
-1,          0,          0,       16,     2403, 0xaa818522
-3,          0,          0,       16,   274117, 0xc439610f, S=2,        8, 0x08e5014f,       88, 0xd65a04db
-0,         17,         17,       16,    57248, 0xa06cd7b5
-1,         17,         17,       16,     2403, 0xe1a991e5
-2,         17,         17,       16,     1602, 0x5d868171
-3,         17,         17,       16,   273691, 0x5a3b88a5, F=0x0
-0,         33,         33,       16,    57200, 0x5623da10
-1,         33,         33,       16,     2400, 0x6650907f
-2,         33,         33,       16,     1600, 0xa90f0044
-3,         33,         33,       16,   272987, 0x48c443e7, F=0x0
-0,         50,         50,       16,    57152, 0x52d89d3f
-1,         50,         50,       16,     2403, 0x43398a08
-2,         50,         50,       16,     1602, 0x3a350084
-3,         50,         50,       16,   271465, 0x251b9cbe, F=0x0
-0,         67,         67,       16,    56960, 0x431d5189
-1,         67,         67,       16,     2403, 0x61cd96cb
-2,         67,         67,       16,     1602, 0xd74800c6
-3,         67,         67,       16,   270800, 0x8fb2e217, F=0x0
-[STREAM]
-index=0
-codec_name=prores
-[SIDE_DATA]
-side_data_type=Content light level metadata
-max_content=1000
-max_average=100
-[/SIDE_DATA]
-[SIDE_DATA]
-side_data_type=Mastering display metadata
-red_x=17/25
-red_y=8/25
-green_x=53/200
-green_y=69/100
-blue_x=3/20
-blue_y=3/50
-white_point_x=3127/10000
-white_point_y=329/1000
-min_luminance=0/1
-max_luminance=1000/1
-[/SIDE_DATA]
-[/STREAM]
-[STREAM]
-index=1
-codec_name=pcm_s24le
-[/STREAM]
-[STREAM]
-index=2
-codec_name=pcm_s16be
-[/STREAM]
-[STREAM]
-index=3
-codec_name=ffv1
-[SIDE_DATA]
-side_data_type=Content light level metadata
-max_content=1000
-max_average=100
-[/SIDE_DATA]
-[SIDE_DATA]
-side_data_type=Mastering display metadata
-red_x=17/25
-red_y=8/25
-green_x=53/200
-green_y=69/100
-blue_x=3/20
-blue_y=3/50
-white_point_x=3127/10000
-white_point_y=329/1000
-min_luminance=0/1
-max_luminance=1000/1
-[/SIDE_DATA]
-[/STREAM]
diff --git a/tests/ref/fate/matroska-mpegts-remux b/tests/ref/fate/matroska-mpegts-remux
deleted file mode 100644
index 3c0b41c..0000000
--- a/tests/ref/fate/matroska-mpegts-remux
+++ /dev/null
@@ -1,52 +0,0 @@
-4e6253c1f5f96ff64ae855dea426547d *tests/data/fate/matroska-mpegts-remux.matroska
-6509 tests/data/fate/matroska-mpegts-remux.matroska
-#tb 0: 1/1000
-#media_type 0: audio
-#codec_id 0: ac3
-#sample_rate 0: 48000
-#channel_layout 0: 3
-#channel_layout_name 0: stereo
-#tb 1: 1/1000
-#media_type 1: audio
-#codec_id 1: ac3
-#sample_rate 1: 48000
-#channel_layout 1: 3
-#channel_layout_name 1: stereo
-0,          0,          0,       32,      768, 0xa63778d4
-1,          0,          0,       32,      768, 0xa63778d4
-0,         32,         32,       32,      768, 0x7d577f3f
-1,         32,         32,       32,      768, 0x7d577f3f
-0,         64,         64,       32,      768, 0xd86b7c8f
-1,         64,         64,       32,      768, 0xd86b7c8f
-0,         96,         96,       32,      626, 0x09f4382f
-1,         96,         96,       32,      626, 0x09f4382f
-[STREAM]
-index=0
-DISPOSITION:default=1
-DISPOSITION:dub=0
-DISPOSITION:original=0
-DISPOSITION:comment=0
-DISPOSITION:lyrics=0
-DISPOSITION:karaoke=0
-DISPOSITION:forced=0
-DISPOSITION:hearing_impaired=0
-DISPOSITION:visual_impaired=1
-DISPOSITION:clean_effects=0
-DISPOSITION:attached_pic=0
-DISPOSITION:timed_thumbnails=0
-[/STREAM]
-[STREAM]
-index=1
-DISPOSITION:default=0
-DISPOSITION:dub=0
-DISPOSITION:original=0
-DISPOSITION:comment=0
-DISPOSITION:lyrics=0
-DISPOSITION:karaoke=0
-DISPOSITION:forced=0
-DISPOSITION:hearing_impaired=1
-DISPOSITION:visual_impaired=0
-DISPOSITION:clean_effects=0
-DISPOSITION:attached_pic=0
-DISPOSITION:timed_thumbnails=0
-[/STREAM]
diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux
deleted file mode 100644
index e0e5f40..0000000
--- a/tests/ref/fate/matroska-spherical-mono-remux
+++ /dev/null
@@ -1,66 +0,0 @@
-9176856edc1ff2b401e323f422fd8e78 *tests/data/fate/matroska-spherical-mono-remux.matroska
-161583 tests/data/fate/matroska-spherical-mono-remux.matroska
-#extradata 0:       43, 0x2b0e0d7b
-#extradata 1:       43, 0x2b0e0d7b
-#tb 0: 1/1000
-#media_type 0: video
-#codec_id 0: h264
-#dimensions 0: 1920x1080
-#sar 0: 0/1
-#tb 1: 1/1000
-#media_type 1: video
-#codec_id 1: h264
-#dimensions 1: 1920x1080
-#sar 1: 0/1
-0,        -80,          0,       40,    69118, 0x73cb52f0, S=2,       12, 0x00000000,       36, 0x2cf8035c
-1,        -80,          0,       40,    69118, 0x73cb52f0, S=2,       12, 0x00000000,       36, 0x2cf8035c
-0,        -40,        160,       40,     1103, 0x082a059f, F=0x0
-1,        -40,        160,       40,     1103, 0x082a059f, F=0x0
-[STREAM]
-color_range=unknown
-color_space=unknown
-color_transfer=unknown
-color_primaries=unknown
-DISPOSITION:default=0
-DISPOSITION:forced=1
-[SIDE_DATA]
-side_data_type=Stereo 3D
-type=2D
-inverted=0
-[/SIDE_DATA]
-[SIDE_DATA]
-side_data_type=Spherical Mapping
-projection=tiled equirectangular
-bound_left=148
-bound_top=73
-bound_right=147
-bound_bottom=72
-yaw=45
-pitch=30
-roll=15
-[/SIDE_DATA]
-[/STREAM]
-[STREAM]
-color_range=pc
-color_space=bt2020c
-color_transfer=smpte170m
-color_primaries=bt709
-DISPOSITION:default=0
-DISPOSITION:forced=0
-[SIDE_DATA]
-side_data_type=Stereo 3D
-type=2D
-inverted=0
-[/SIDE_DATA]
-[SIDE_DATA]
-side_data_type=Spherical Mapping
-projection=tiled equirectangular
-bound_left=148
-bound_top=73
-bound_right=147
-bound_bottom=72
-yaw=45
-pitch=30
-roll=15
-[/SIDE_DATA]
-[/STREAM]
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux
deleted file mode 100644
index 0b6c779..0000000
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ /dev/null
@@ -1,33 +0,0 @@
-d06be833da8e8d9d00bf334e0dfe8a58 *tests/data/fate/matroska-vp8-alpha-remux.matroska
-237192 tests/data/fate/matroska-vp8-alpha-remux.matroska
-#tb 0: 1/1000
-#media_type 0: video
-#codec_id 0: vp8
-#dimensions 0: 320x213
-#sar 0: 1/1
-0,          0,          0,       33,     2108, 0x59b92a34, S=2,     1900, 0x8fb3adc5,       12, 0x00000000
-0,         32,         32,       33,      142, 0x2f2a3fed, F=0x0, S=1,      160, 0xa13346af
-0,         65,         65,       33,      157, 0x17804767, F=0x0, S=1,      209, 0x64115f15
-0,         99,         99,       33,      206, 0x537262ca, F=0x0, S=1,      317, 0x44a09dd0
-0,        132,        132,       33,      259, 0x73ff74b6, F=0x0, S=1,      384, 0x2ee2c588
-0,        165,        165,       33,      320, 0x0fcf8ce4, F=0x0, S=1,      415, 0xff68c953
-0,        199,        199,       33,      377, 0x8fffb5f5, F=0x0, S=1,      475, 0x4166f3eb
-[STREAM]
-DISPOSITION:default=1
-DISPOSITION:dub=0
-DISPOSITION:original=0
-DISPOSITION:comment=0
-DISPOSITION:lyrics=0
-DISPOSITION:karaoke=0
-DISPOSITION:forced=0
-DISPOSITION:hearing_impaired=1
-DISPOSITION:visual_impaired=0
-DISPOSITION:clean_effects=0
-DISPOSITION:attached_pic=0
-DISPOSITION:timed_thumbnails=0
-[SIDE_DATA]
-side_data_type=Stereo 3D
-type=2D
-inverted=0
-[/SIDE_DATA]
-[/STREAM]
diff --git a/tests/ref/fate/matroska-zero-length-block b/tests/ref/fate/matroska-zero-length-block
deleted file mode 100644
index e8c5dec..0000000
--- a/tests/ref/fate/matroska-zero-length-block
+++ /dev/null
@@ -1,10 +0,0 @@
-ba78b3e846d57002711bc481fa806717 *tests/data/fate/matroska-zero-length-block.matroska
-643 tests/data/fate/matroska-zero-length-block.matroska
-#tb 0: 1/1000
-#media_type 0: subtitle
-#codec_id 0: subrip
-0,       1000,       1000,     2000,        5, 0x05b801df
-0,       3300,       3300,     3700,       16, 0x300705b2
-[STREAM]
-TAG:DESCRIPTION=This track uses header removal compression and has a Block of size zero before reversing it.
-[/STREAM]
diff --git a/tests/ref/fate/mov-aac-2048-priming b/tests/ref/fate/mov-aac-2048-priming
index 5c63615..2616944 100644
--- a/tests/ref/fate/mov-aac-2048-priming
+++ b/tests/ref/fate/mov-aac-2048-priming
@@ -1,218 +1,218 @@
-packet|codec_type=audio|stream_index=0|pts=-2048|pts_time=-0.046440|dts=-2048|dts_time=-0.046440|duration=1024|duration_time=0.023220|size=258|pos=36|flags=KDside_data|side_data_type=Skip Samples|skip_samples=2048|discard_padding=0|skip_reason=0|discard_reason=0
+packet|codec_type=audio|stream_index=0|pts=-2048|pts_time=-0.046440|dts=-2048|dts_time=-0.046440|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=258|pos=36|flags=KDside_data|side_data_type=Skip Samples|skip_samples=2048|discard_padding=0|skip_reason=0|discard_reason=0
 
-packet|codec_type=audio|stream_index=0|pts=-1024|pts_time=-0.023220|dts=-1024|dts_time=-0.023220|duration=1024|duration_time=0.023220|size=258|pos=294|flags=KD
-packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1024|duration_time=0.023220|size=146|pos=552|flags=K_
-packet|codec_type=audio|stream_index=0|pts=1024|pts_time=0.023220|dts=1024|dts_time=0.023220|duration=1024|duration_time=0.023220|size=186|pos=698|flags=K_
-packet|codec_type=audio|stream_index=0|pts=2048|pts_time=0.046440|dts=2048|dts_time=0.046440|duration=1024|duration_time=0.023220|size=222|pos=884|flags=K_
-packet|codec_type=audio|stream_index=0|pts=3072|pts_time=0.069660|dts=3072|dts_time=0.069660|duration=1024|duration_time=0.023220|size=186|pos=1106|flags=K_
-packet|codec_type=audio|stream_index=0|pts=4096|pts_time=0.092880|dts=4096|dts_time=0.092880|duration=1024|duration_time=0.023220|size=206|pos=1292|flags=K_
-packet|codec_type=audio|stream_index=0|pts=5120|pts_time=0.116100|dts=5120|dts_time=0.116100|duration=1024|duration_time=0.023220|size=199|pos=1498|flags=K_
-packet|codec_type=audio|stream_index=0|pts=6144|pts_time=0.139320|dts=6144|dts_time=0.139320|duration=1024|duration_time=0.023220|size=236|pos=1697|flags=K_
-packet|codec_type=audio|stream_index=0|pts=7168|pts_time=0.162540|dts=7168|dts_time=0.162540|duration=1024|duration_time=0.023220|size=208|pos=1933|flags=K_
-packet|codec_type=audio|stream_index=0|pts=8192|pts_time=0.185760|dts=8192|dts_time=0.185760|duration=1024|duration_time=0.023220|size=238|pos=2141|flags=K_
-packet|codec_type=audio|stream_index=0|pts=9216|pts_time=0.208980|dts=9216|dts_time=0.208980|duration=1024|duration_time=0.023220|size=222|pos=2379|flags=K_
-packet|codec_type=audio|stream_index=0|pts=10240|pts_time=0.232200|dts=10240|dts_time=0.232200|duration=1024|duration_time=0.023220|size=211|pos=2601|flags=K_
-packet|codec_type=audio|stream_index=0|pts=11264|pts_time=0.255420|dts=11264|dts_time=0.255420|duration=1024|duration_time=0.023220|size=153|pos=2812|flags=K_
-packet|codec_type=audio|stream_index=0|pts=12288|pts_time=0.278639|dts=12288|dts_time=0.278639|duration=1024|duration_time=0.023220|size=191|pos=2965|flags=K_
-packet|codec_type=audio|stream_index=0|pts=13312|pts_time=0.301859|dts=13312|dts_time=0.301859|duration=1024|duration_time=0.023220|size=208|pos=3156|flags=K_
-packet|codec_type=audio|stream_index=0|pts=14336|pts_time=0.325079|dts=14336|dts_time=0.325079|duration=1024|duration_time=0.023220|size=188|pos=3364|flags=K_
-packet|codec_type=audio|stream_index=0|pts=15360|pts_time=0.348299|dts=15360|dts_time=0.348299|duration=1024|duration_time=0.023220|size=170|pos=3552|flags=K_
-packet|codec_type=audio|stream_index=0|pts=16384|pts_time=0.371519|dts=16384|dts_time=0.371519|duration=1024|duration_time=0.023220|size=221|pos=3722|flags=K_
-packet|codec_type=audio|stream_index=0|pts=17408|pts_time=0.394739|dts=17408|dts_time=0.394739|duration=1024|duration_time=0.023220|size=247|pos=3943|flags=K_
-packet|codec_type=audio|stream_index=0|pts=18432|pts_time=0.417959|dts=18432|dts_time=0.417959|duration=1024|duration_time=0.023220|size=202|pos=4190|flags=K_
-packet|codec_type=audio|stream_index=0|pts=19456|pts_time=0.441179|dts=19456|dts_time=0.441179|duration=1024|duration_time=0.023220|size=186|pos=4392|flags=K_
-packet|codec_type=audio|stream_index=0|pts=20480|pts_time=0.464399|dts=20480|dts_time=0.464399|duration=1024|duration_time=0.023220|size=196|pos=4578|flags=K_
-packet|codec_type=audio|stream_index=0|pts=21504|pts_time=0.487619|dts=21504|dts_time=0.487619|duration=1024|duration_time=0.023220|size=200|pos=4774|flags=K_
-packet|codec_type=audio|stream_index=0|pts=22528|pts_time=0.510839|dts=22528|dts_time=0.510839|duration=1024|duration_time=0.023220|size=170|pos=4974|flags=K_
-packet|codec_type=audio|stream_index=0|pts=23552|pts_time=0.534059|dts=23552|dts_time=0.534059|duration=1024|duration_time=0.023220|size=172|pos=5144|flags=K_
-packet|codec_type=audio|stream_index=0|pts=24576|pts_time=0.557279|dts=24576|dts_time=0.557279|duration=1024|duration_time=0.023220|size=206|pos=5316|flags=K_
-packet|codec_type=audio|stream_index=0|pts=25600|pts_time=0.580499|dts=25600|dts_time=0.580499|duration=1024|duration_time=0.023220|size=208|pos=5522|flags=K_
-packet|codec_type=audio|stream_index=0|pts=26624|pts_time=0.603719|dts=26624|dts_time=0.603719|duration=1024|duration_time=0.023220|size=217|pos=5730|flags=K_
-packet|codec_type=audio|stream_index=0|pts=27648|pts_time=0.626939|dts=27648|dts_time=0.626939|duration=1024|duration_time=0.023220|size=252|pos=5947|flags=K_
-packet|codec_type=audio|stream_index=0|pts=28672|pts_time=0.650159|dts=28672|dts_time=0.650159|duration=1024|duration_time=0.023220|size=171|pos=6199|flags=K_
-packet|codec_type=audio|stream_index=0|pts=29696|pts_time=0.673379|dts=29696|dts_time=0.673379|duration=1024|duration_time=0.023220|size=206|pos=6370|flags=K_
-packet|codec_type=audio|stream_index=0|pts=30720|pts_time=0.696599|dts=30720|dts_time=0.696599|duration=1024|duration_time=0.023220|size=237|pos=6576|flags=K_
-packet|codec_type=audio|stream_index=0|pts=31744|pts_time=0.719819|dts=31744|dts_time=0.719819|duration=1024|duration_time=0.023220|size=210|pos=6813|flags=K_
-packet|codec_type=audio|stream_index=0|pts=32768|pts_time=0.743039|dts=32768|dts_time=0.743039|duration=1024|duration_time=0.023220|size=166|pos=7023|flags=K_
-packet|codec_type=audio|stream_index=0|pts=33792|pts_time=0.766259|dts=33792|dts_time=0.766259|duration=1024|duration_time=0.023220|size=166|pos=7189|flags=K_
-packet|codec_type=audio|stream_index=0|pts=34816|pts_time=0.789478|dts=34816|dts_time=0.789478|duration=1024|duration_time=0.023220|size=177|pos=7355|flags=K_
-packet|codec_type=audio|stream_index=0|pts=35840|pts_time=0.812698|dts=35840|dts_time=0.812698|duration=1024|duration_time=0.023220|size=188|pos=7532|flags=K_
-packet|codec_type=audio|stream_index=0|pts=36864|pts_time=0.835918|dts=36864|dts_time=0.835918|duration=1024|duration_time=0.023220|size=193|pos=7720|flags=K_
-packet|codec_type=audio|stream_index=0|pts=37888|pts_time=0.859138|dts=37888|dts_time=0.859138|duration=1024|duration_time=0.023220|size=195|pos=7913|flags=K_
-packet|codec_type=audio|stream_index=0|pts=38912|pts_time=0.882358|dts=38912|dts_time=0.882358|duration=1024|duration_time=0.023220|size=211|pos=8108|flags=K_
-packet|codec_type=audio|stream_index=0|pts=39936|pts_time=0.905578|dts=39936|dts_time=0.905578|duration=1024|duration_time=0.023220|size=249|pos=8319|flags=K_
-packet|codec_type=audio|stream_index=0|pts=40960|pts_time=0.928798|dts=40960|dts_time=0.928798|duration=1024|duration_time=0.023220|size=223|pos=8568|flags=K_
-packet|codec_type=audio|stream_index=0|pts=41984|pts_time=0.952018|dts=41984|dts_time=0.952018|duration=1024|duration_time=0.023220|size=230|pos=8791|flags=K_
-packet|codec_type=audio|stream_index=0|pts=43008|pts_time=0.975238|dts=43008|dts_time=0.975238|duration=1024|duration_time=0.023220|size=203|pos=9021|flags=K_
-packet|codec_type=audio|stream_index=0|pts=44032|pts_time=0.998458|dts=44032|dts_time=0.998458|duration=1024|duration_time=0.023220|size=180|pos=9224|flags=K_
-packet|codec_type=audio|stream_index=0|pts=45056|pts_time=1.021678|dts=45056|dts_time=1.021678|duration=1024|duration_time=0.023220|size=172|pos=9404|flags=K_
-packet|codec_type=audio|stream_index=0|pts=46080|pts_time=1.044898|dts=46080|dts_time=1.044898|duration=1024|duration_time=0.023220|size=240|pos=9576|flags=K_
-packet|codec_type=audio|stream_index=0|pts=47104|pts_time=1.068118|dts=47104|dts_time=1.068118|duration=1024|duration_time=0.023220|size=179|pos=9816|flags=K_
-packet|codec_type=audio|stream_index=0|pts=48128|pts_time=1.091338|dts=48128|dts_time=1.091338|duration=1024|duration_time=0.023220|size=191|pos=9995|flags=K_
-packet|codec_type=audio|stream_index=0|pts=49152|pts_time=1.114558|dts=49152|dts_time=1.114558|duration=1024|duration_time=0.023220|size=184|pos=10186|flags=K_
-packet|codec_type=audio|stream_index=0|pts=50176|pts_time=1.137778|dts=50176|dts_time=1.137778|duration=1024|duration_time=0.023220|size=214|pos=10370|flags=K_
-packet|codec_type=audio|stream_index=0|pts=51200|pts_time=1.160998|dts=51200|dts_time=1.160998|duration=1024|duration_time=0.023220|size=194|pos=10584|flags=K_
-packet|codec_type=audio|stream_index=0|pts=52224|pts_time=1.184218|dts=52224|dts_time=1.184218|duration=1024|duration_time=0.023220|size=235|pos=10778|flags=K_
-packet|codec_type=audio|stream_index=0|pts=53248|pts_time=1.207438|dts=53248|dts_time=1.207438|duration=1024|duration_time=0.023220|size=195|pos=11013|flags=K_
-packet|codec_type=audio|stream_index=0|pts=54272|pts_time=1.230658|dts=54272|dts_time=1.230658|duration=1024|duration_time=0.023220|size=220|pos=11208|flags=K_
-packet|codec_type=audio|stream_index=0|pts=55296|pts_time=1.253878|dts=55296|dts_time=1.253878|duration=1024|duration_time=0.023220|size=187|pos=11428|flags=K_
-packet|codec_type=audio|stream_index=0|pts=56320|pts_time=1.277098|dts=56320|dts_time=1.277098|duration=1024|duration_time=0.023220|size=238|pos=11615|flags=K_
-packet|codec_type=audio|stream_index=0|pts=57344|pts_time=1.300317|dts=57344|dts_time=1.300317|duration=1024|duration_time=0.023220|size=175|pos=11853|flags=K_
-packet|codec_type=audio|stream_index=0|pts=58368|pts_time=1.323537|dts=58368|dts_time=1.323537|duration=1024|duration_time=0.023220|size=178|pos=12028|flags=K_
-packet|codec_type=audio|stream_index=0|pts=59392|pts_time=1.346757|dts=59392|dts_time=1.346757|duration=1024|duration_time=0.023220|size=219|pos=12206|flags=K_
-packet|codec_type=audio|stream_index=0|pts=60416|pts_time=1.369977|dts=60416|dts_time=1.369977|duration=1024|duration_time=0.023220|size=179|pos=12425|flags=K_
-packet|codec_type=audio|stream_index=0|pts=61440|pts_time=1.393197|dts=61440|dts_time=1.393197|duration=1024|duration_time=0.023220|size=193|pos=12604|flags=K_
-packet|codec_type=audio|stream_index=0|pts=62464|pts_time=1.416417|dts=62464|dts_time=1.416417|duration=1024|duration_time=0.023220|size=200|pos=12797|flags=K_
-packet|codec_type=audio|stream_index=0|pts=63488|pts_time=1.439637|dts=63488|dts_time=1.439637|duration=1024|duration_time=0.023220|size=218|pos=12997|flags=K_
-packet|codec_type=audio|stream_index=0|pts=64512|pts_time=1.462857|dts=64512|dts_time=1.462857|duration=1024|duration_time=0.023220|size=215|pos=13215|flags=K_
-packet|codec_type=audio|stream_index=0|pts=65536|pts_time=1.486077|dts=65536|dts_time=1.486077|duration=1024|duration_time=0.023220|size=209|pos=13430|flags=K_
-packet|codec_type=audio|stream_index=0|pts=66560|pts_time=1.509297|dts=66560|dts_time=1.509297|duration=1024|duration_time=0.023220|size=171|pos=13639|flags=K_
-packet|codec_type=audio|stream_index=0|pts=67584|pts_time=1.532517|dts=67584|dts_time=1.532517|duration=1024|duration_time=0.023220|size=179|pos=13810|flags=K_
-packet|codec_type=audio|stream_index=0|pts=68608|pts_time=1.555737|dts=68608|dts_time=1.555737|duration=1024|duration_time=0.023220|size=185|pos=13989|flags=K_
-packet|codec_type=audio|stream_index=0|pts=69632|pts_time=1.578957|dts=69632|dts_time=1.578957|duration=1024|duration_time=0.023220|size=225|pos=14174|flags=K_
-packet|codec_type=audio|stream_index=0|pts=70656|pts_time=1.602177|dts=70656|dts_time=1.602177|duration=1024|duration_time=0.023220|size=221|pos=14399|flags=K_
-packet|codec_type=audio|stream_index=0|pts=71680|pts_time=1.625397|dts=71680|dts_time=1.625397|duration=1024|duration_time=0.023220|size=201|pos=14620|flags=K_
-packet|codec_type=audio|stream_index=0|pts=72704|pts_time=1.648617|dts=72704|dts_time=1.648617|duration=1024|duration_time=0.023220|size=206|pos=14821|flags=K_
-packet|codec_type=audio|stream_index=0|pts=73728|pts_time=1.671837|dts=73728|dts_time=1.671837|duration=1024|duration_time=0.023220|size=182|pos=15027|flags=K_
-packet|codec_type=audio|stream_index=0|pts=74752|pts_time=1.695057|dts=74752|dts_time=1.695057|duration=1024|duration_time=0.023220|size=176|pos=15209|flags=K_
-packet|codec_type=audio|stream_index=0|pts=75776|pts_time=1.718277|dts=75776|dts_time=1.718277|duration=1024|duration_time=0.023220|size=233|pos=15385|flags=K_
-packet|codec_type=audio|stream_index=0|pts=76800|pts_time=1.741497|dts=76800|dts_time=1.741497|duration=1024|duration_time=0.023220|size=199|pos=15618|flags=K_
-packet|codec_type=audio|stream_index=0|pts=77824|pts_time=1.764717|dts=77824|dts_time=1.764717|duration=1024|duration_time=0.023220|size=220|pos=15817|flags=K_
-packet|codec_type=audio|stream_index=0|pts=78848|pts_time=1.787937|dts=78848|dts_time=1.787937|duration=1024|duration_time=0.023220|size=190|pos=16037|flags=K_
-packet|codec_type=audio|stream_index=0|pts=79872|pts_time=1.811156|dts=79872|dts_time=1.811156|duration=1024|duration_time=0.023220|size=210|pos=16227|flags=K_
-packet|codec_type=audio|stream_index=0|pts=80896|pts_time=1.834376|dts=80896|dts_time=1.834376|duration=1024|duration_time=0.023220|size=204|pos=16437|flags=K_
-packet|codec_type=audio|stream_index=0|pts=81920|pts_time=1.857596|dts=81920|dts_time=1.857596|duration=1024|duration_time=0.023220|size=171|pos=16641|flags=K_
-packet|codec_type=audio|stream_index=0|pts=82944|pts_time=1.880816|dts=82944|dts_time=1.880816|duration=1024|duration_time=0.023220|size=167|pos=16812|flags=K_
-packet|codec_type=audio|stream_index=0|pts=83968|pts_time=1.904036|dts=83968|dts_time=1.904036|duration=1024|duration_time=0.023220|size=200|pos=16979|flags=K_
-packet|codec_type=audio|stream_index=0|pts=84992|pts_time=1.927256|dts=84992|dts_time=1.927256|duration=1024|duration_time=0.023220|size=254|pos=17179|flags=K_
-packet|codec_type=audio|stream_index=0|pts=86016|pts_time=1.950476|dts=86016|dts_time=1.950476|duration=1024|duration_time=0.023220|size=205|pos=17433|flags=K_
-packet|codec_type=audio|stream_index=0|pts=87040|pts_time=1.973696|dts=87040|dts_time=1.973696|duration=1024|duration_time=0.023220|size=196|pos=17638|flags=K_
-packet|codec_type=audio|stream_index=0|pts=88064|pts_time=1.996916|dts=88064|dts_time=1.996916|duration=1024|duration_time=0.023220|size=190|pos=17834|flags=K_
-packet|codec_type=audio|stream_index=0|pts=89088|pts_time=2.020136|dts=89088|dts_time=2.020136|duration=1024|duration_time=0.023220|size=197|pos=18024|flags=K_
-packet|codec_type=audio|stream_index=0|pts=90112|pts_time=2.043356|dts=90112|dts_time=2.043356|duration=1024|duration_time=0.023220|size=186|pos=18221|flags=K_
-packet|codec_type=audio|stream_index=0|pts=91136|pts_time=2.066576|dts=91136|dts_time=2.066576|duration=1024|duration_time=0.023220|size=194|pos=18407|flags=K_
-packet|codec_type=audio|stream_index=0|pts=92160|pts_time=2.089796|dts=92160|dts_time=2.089796|duration=1024|duration_time=0.023220|size=227|pos=18601|flags=K_
-packet|codec_type=audio|stream_index=0|pts=93184|pts_time=2.113016|dts=93184|dts_time=2.113016|duration=1024|duration_time=0.023220|size=195|pos=18828|flags=K_
-packet|codec_type=audio|stream_index=0|pts=94208|pts_time=2.136236|dts=94208|dts_time=2.136236|duration=1024|duration_time=0.023220|size=228|pos=19023|flags=K_
-packet|codec_type=audio|stream_index=0|pts=95232|pts_time=2.159456|dts=95232|dts_time=2.159456|duration=1024|duration_time=0.023220|size=196|pos=19251|flags=K_
-packet|codec_type=audio|stream_index=0|pts=96256|pts_time=2.182676|dts=96256|dts_time=2.182676|duration=1024|duration_time=0.023220|size=197|pos=19447|flags=K_
-packet|codec_type=audio|stream_index=0|pts=97280|pts_time=2.205896|dts=97280|dts_time=2.205896|duration=1024|duration_time=0.023220|size=186|pos=19644|flags=K_
-packet|codec_type=audio|stream_index=0|pts=98304|pts_time=2.229116|dts=98304|dts_time=2.229116|duration=1024|duration_time=0.023220|size=191|pos=19830|flags=K_
-packet|codec_type=audio|stream_index=0|pts=99328|pts_time=2.252336|dts=99328|dts_time=2.252336|duration=1024|duration_time=0.023220|size=215|pos=20021|flags=K_
-packet|codec_type=audio|stream_index=0|pts=100352|pts_time=2.275556|dts=100352|dts_time=2.275556|duration=1024|duration_time=0.023220|size=203|pos=20236|flags=K_
-packet|codec_type=audio|stream_index=0|pts=101376|pts_time=2.298776|dts=101376|dts_time=2.298776|duration=1024|duration_time=0.023220|size=205|pos=20439|flags=K_
-packet|codec_type=audio|stream_index=0|pts=102400|pts_time=2.321995|dts=102400|dts_time=2.321995|duration=1024|duration_time=0.023220|size=205|pos=20644|flags=K_
-packet|codec_type=audio|stream_index=0|pts=103424|pts_time=2.345215|dts=103424|dts_time=2.345215|duration=1024|duration_time=0.023220|size=213|pos=20849|flags=K_
-packet|codec_type=audio|stream_index=0|pts=104448|pts_time=2.368435|dts=104448|dts_time=2.368435|duration=1024|duration_time=0.023220|size=198|pos=21062|flags=K_
-packet|codec_type=audio|stream_index=0|pts=105472|pts_time=2.391655|dts=105472|dts_time=2.391655|duration=1024|duration_time=0.023220|size=178|pos=21260|flags=K_
-packet|codec_type=audio|stream_index=0|pts=106496|pts_time=2.414875|dts=106496|dts_time=2.414875|duration=1024|duration_time=0.023220|size=195|pos=21438|flags=K_
-packet|codec_type=audio|stream_index=0|pts=107520|pts_time=2.438095|dts=107520|dts_time=2.438095|duration=1024|duration_time=0.023220|size=227|pos=21633|flags=K_
-packet|codec_type=audio|stream_index=0|pts=108544|pts_time=2.461315|dts=108544|dts_time=2.461315|duration=1024|duration_time=0.023220|size=185|pos=21860|flags=K_
-packet|codec_type=audio|stream_index=0|pts=109568|pts_time=2.484535|dts=109568|dts_time=2.484535|duration=1024|duration_time=0.023220|size=206|pos=22045|flags=K_
-packet|codec_type=audio|stream_index=0|pts=110592|pts_time=2.507755|dts=110592|dts_time=2.507755|duration=1024|duration_time=0.023220|size=183|pos=22251|flags=K_
-packet|codec_type=audio|stream_index=0|pts=111616|pts_time=2.530975|dts=111616|dts_time=2.530975|duration=1024|duration_time=0.023220|size=208|pos=22434|flags=K_
-packet|codec_type=audio|stream_index=0|pts=112640|pts_time=2.554195|dts=112640|dts_time=2.554195|duration=1024|duration_time=0.023220|size=204|pos=22642|flags=K_
-packet|codec_type=audio|stream_index=0|pts=113664|pts_time=2.577415|dts=113664|dts_time=2.577415|duration=1024|duration_time=0.023220|size=192|pos=22846|flags=K_
-packet|codec_type=audio|stream_index=0|pts=114688|pts_time=2.600635|dts=114688|dts_time=2.600635|duration=1024|duration_time=0.023220|size=190|pos=23038|flags=K_
-packet|codec_type=audio|stream_index=0|pts=115712|pts_time=2.623855|dts=115712|dts_time=2.623855|duration=1024|duration_time=0.023220|size=199|pos=23228|flags=K_
-packet|codec_type=audio|stream_index=0|pts=116736|pts_time=2.647075|dts=116736|dts_time=2.647075|duration=1024|duration_time=0.023220|size=229|pos=23427|flags=K_
-packet|codec_type=audio|stream_index=0|pts=117760|pts_time=2.670295|dts=117760|dts_time=2.670295|duration=1024|duration_time=0.023220|size=208|pos=23656|flags=K_
-packet|codec_type=audio|stream_index=0|pts=118784|pts_time=2.693515|dts=118784|dts_time=2.693515|duration=1024|duration_time=0.023220|size=195|pos=23864|flags=K_
-packet|codec_type=audio|stream_index=0|pts=119808|pts_time=2.716735|dts=119808|dts_time=2.716735|duration=1024|duration_time=0.023220|size=190|pos=24059|flags=K_
-packet|codec_type=audio|stream_index=0|pts=120832|pts_time=2.739955|dts=120832|dts_time=2.739955|duration=1024|duration_time=0.023220|size=190|pos=24249|flags=K_
-packet|codec_type=audio|stream_index=0|pts=121856|pts_time=2.763175|dts=121856|dts_time=2.763175|duration=1024|duration_time=0.023220|size=192|pos=24439|flags=K_
-packet|codec_type=audio|stream_index=0|pts=122880|pts_time=2.786395|dts=122880|dts_time=2.786395|duration=1024|duration_time=0.023220|size=226|pos=24631|flags=K_
-packet|codec_type=audio|stream_index=0|pts=123904|pts_time=2.809615|dts=123904|dts_time=2.809615|duration=1024|duration_time=0.023220|size=195|pos=24857|flags=K_
-packet|codec_type=audio|stream_index=0|pts=124928|pts_time=2.832834|dts=124928|dts_time=2.832834|duration=1024|duration_time=0.023220|size=230|pos=25052|flags=K_
-packet|codec_type=audio|stream_index=0|pts=125952|pts_time=2.856054|dts=125952|dts_time=2.856054|duration=1024|duration_time=0.023220|size=198|pos=25282|flags=K_
-packet|codec_type=audio|stream_index=0|pts=126976|pts_time=2.879274|dts=126976|dts_time=2.879274|duration=1024|duration_time=0.023220|size=183|pos=25480|flags=K_
-packet|codec_type=audio|stream_index=0|pts=128000|pts_time=2.902494|dts=128000|dts_time=2.902494|duration=1024|duration_time=0.023220|size=199|pos=25663|flags=K_
-packet|codec_type=audio|stream_index=0|pts=129024|pts_time=2.925714|dts=129024|dts_time=2.925714|duration=1024|duration_time=0.023220|size=196|pos=25862|flags=K_
-packet|codec_type=audio|stream_index=0|pts=130048|pts_time=2.948934|dts=130048|dts_time=2.948934|duration=1024|duration_time=0.023220|size=186|pos=26058|flags=K_
-packet|codec_type=audio|stream_index=0|pts=131072|pts_time=2.972154|dts=131072|dts_time=2.972154|duration=1024|duration_time=0.023220|size=200|pos=26244|flags=K_
-packet|codec_type=audio|stream_index=0|pts=132096|pts_time=2.995374|dts=132096|dts_time=2.995374|duration=1024|duration_time=0.023220|size=210|pos=26444|flags=K_
-packet|codec_type=audio|stream_index=0|pts=133120|pts_time=3.018594|dts=133120|dts_time=3.018594|duration=1024|duration_time=0.023220|size=196|pos=26654|flags=K_
-packet|codec_type=audio|stream_index=0|pts=134144|pts_time=3.041814|dts=134144|dts_time=3.041814|duration=1024|duration_time=0.023220|size=214|pos=26850|flags=K_
-packet|codec_type=audio|stream_index=0|pts=135168|pts_time=3.065034|dts=135168|dts_time=3.065034|duration=1024|duration_time=0.023220|size=185|pos=27064|flags=K_
-packet|codec_type=audio|stream_index=0|pts=136192|pts_time=3.088254|dts=136192|dts_time=3.088254|duration=1024|duration_time=0.023220|size=198|pos=27249|flags=K_
-packet|codec_type=audio|stream_index=0|pts=137216|pts_time=3.111474|dts=137216|dts_time=3.111474|duration=1024|duration_time=0.023220|size=200|pos=27447|flags=K_
-packet|codec_type=audio|stream_index=0|pts=138240|pts_time=3.134694|dts=138240|dts_time=3.134694|duration=1024|duration_time=0.023220|size=208|pos=27647|flags=K_
-packet|codec_type=audio|stream_index=0|pts=139264|pts_time=3.157914|dts=139264|dts_time=3.157914|duration=1024|duration_time=0.023220|size=212|pos=27855|flags=K_
-packet|codec_type=audio|stream_index=0|pts=140288|pts_time=3.181134|dts=140288|dts_time=3.181134|duration=1024|duration_time=0.023220|size=208|pos=28067|flags=K_
-packet|codec_type=audio|stream_index=0|pts=141312|pts_time=3.204354|dts=141312|dts_time=3.204354|duration=1024|duration_time=0.023220|size=192|pos=28275|flags=K_
-packet|codec_type=audio|stream_index=0|pts=142336|pts_time=3.227574|dts=142336|dts_time=3.227574|duration=1024|duration_time=0.023220|size=192|pos=28467|flags=K_
-packet|codec_type=audio|stream_index=0|pts=143360|pts_time=3.250794|dts=143360|dts_time=3.250794|duration=1024|duration_time=0.023220|size=211|pos=28659|flags=K_
-packet|codec_type=audio|stream_index=0|pts=144384|pts_time=3.274014|dts=144384|dts_time=3.274014|duration=1024|duration_time=0.023220|size=195|pos=28870|flags=K_
-packet|codec_type=audio|stream_index=0|pts=145408|pts_time=3.297234|dts=145408|dts_time=3.297234|duration=1024|duration_time=0.023220|size=208|pos=29065|flags=K_
-packet|codec_type=audio|stream_index=0|pts=146432|pts_time=3.320454|dts=146432|dts_time=3.320454|duration=1024|duration_time=0.023220|size=195|pos=29273|flags=K_
-packet|codec_type=audio|stream_index=0|pts=147456|pts_time=3.343673|dts=147456|dts_time=3.343673|duration=1024|duration_time=0.023220|size=204|pos=29468|flags=K_
-packet|codec_type=audio|stream_index=0|pts=148480|pts_time=3.366893|dts=148480|dts_time=3.366893|duration=1024|duration_time=0.023220|size=209|pos=29672|flags=K_
-packet|codec_type=audio|stream_index=0|pts=149504|pts_time=3.390113|dts=149504|dts_time=3.390113|duration=1024|duration_time=0.023220|size=195|pos=29881|flags=K_
-packet|codec_type=audio|stream_index=0|pts=150528|pts_time=3.413333|dts=150528|dts_time=3.413333|duration=1024|duration_time=0.023220|size=191|pos=30076|flags=K_
-packet|codec_type=audio|stream_index=0|pts=151552|pts_time=3.436553|dts=151552|dts_time=3.436553|duration=1024|duration_time=0.023220|size=210|pos=30267|flags=K_
-packet|codec_type=audio|stream_index=0|pts=152576|pts_time=3.459773|dts=152576|dts_time=3.459773|duration=1024|duration_time=0.023220|size=209|pos=30477|flags=K_
-packet|codec_type=audio|stream_index=0|pts=153600|pts_time=3.482993|dts=153600|dts_time=3.482993|duration=1024|duration_time=0.023220|size=175|pos=30686|flags=K_
-packet|codec_type=audio|stream_index=0|pts=154624|pts_time=3.506213|dts=154624|dts_time=3.506213|duration=1024|duration_time=0.023220|size=244|pos=30861|flags=K_
-packet|codec_type=audio|stream_index=0|pts=155648|pts_time=3.529433|dts=155648|dts_time=3.529433|duration=1024|duration_time=0.023220|size=177|pos=31105|flags=K_
-packet|codec_type=audio|stream_index=0|pts=156672|pts_time=3.552653|dts=156672|dts_time=3.552653|duration=1024|duration_time=0.023220|size=217|pos=31282|flags=K_
-packet|codec_type=audio|stream_index=0|pts=157696|pts_time=3.575873|dts=157696|dts_time=3.575873|duration=1024|duration_time=0.023220|size=182|pos=31499|flags=K_
-packet|codec_type=audio|stream_index=0|pts=158720|pts_time=3.599093|dts=158720|dts_time=3.599093|duration=1024|duration_time=0.023220|size=181|pos=31681|flags=K_
-packet|codec_type=audio|stream_index=0|pts=159744|pts_time=3.622313|dts=159744|dts_time=3.622313|duration=1024|duration_time=0.023220|size=203|pos=31862|flags=K_
-packet|codec_type=audio|stream_index=0|pts=160768|pts_time=3.645533|dts=160768|dts_time=3.645533|duration=1024|duration_time=0.023220|size=198|pos=32065|flags=K_
-packet|codec_type=audio|stream_index=0|pts=161792|pts_time=3.668753|dts=161792|dts_time=3.668753|duration=1024|duration_time=0.023220|size=217|pos=32263|flags=K_
-packet|codec_type=audio|stream_index=0|pts=162816|pts_time=3.691973|dts=162816|dts_time=3.691973|duration=1024|duration_time=0.023220|size=195|pos=32480|flags=K_
-packet|codec_type=audio|stream_index=0|pts=163840|pts_time=3.715193|dts=163840|dts_time=3.715193|duration=1024|duration_time=0.023220|size=198|pos=32675|flags=K_
-packet|codec_type=audio|stream_index=0|pts=164864|pts_time=3.738413|dts=164864|dts_time=3.738413|duration=1024|duration_time=0.023220|size=202|pos=32873|flags=K_
-packet|codec_type=audio|stream_index=0|pts=165888|pts_time=3.761633|dts=165888|dts_time=3.761633|duration=1024|duration_time=0.023220|size=185|pos=33075|flags=K_
-packet|codec_type=audio|stream_index=0|pts=166912|pts_time=3.784853|dts=166912|dts_time=3.784853|duration=1024|duration_time=0.023220|size=196|pos=33260|flags=K_
-packet|codec_type=audio|stream_index=0|pts=167936|pts_time=3.808073|dts=167936|dts_time=3.808073|duration=1024|duration_time=0.023220|size=226|pos=33456|flags=K_
-packet|codec_type=audio|stream_index=0|pts=168960|pts_time=3.831293|dts=168960|dts_time=3.831293|duration=1024|duration_time=0.023220|size=187|pos=33682|flags=K_
-packet|codec_type=audio|stream_index=0|pts=169984|pts_time=3.854512|dts=169984|dts_time=3.854512|duration=1024|duration_time=0.023220|size=193|pos=33869|flags=K_
-packet|codec_type=audio|stream_index=0|pts=171008|pts_time=3.877732|dts=171008|dts_time=3.877732|duration=1024|duration_time=0.023220|size=218|pos=34062|flags=K_
-packet|codec_type=audio|stream_index=0|pts=172032|pts_time=3.900952|dts=172032|dts_time=3.900952|duration=1024|duration_time=0.023220|size=200|pos=34280|flags=K_
-packet|codec_type=audio|stream_index=0|pts=173056|pts_time=3.924172|dts=173056|dts_time=3.924172|duration=1024|duration_time=0.023220|size=200|pos=34480|flags=K_
-packet|codec_type=audio|stream_index=0|pts=174080|pts_time=3.947392|dts=174080|dts_time=3.947392|duration=1024|duration_time=0.023220|size=198|pos=34680|flags=K_
-packet|codec_type=audio|stream_index=0|pts=175104|pts_time=3.970612|dts=175104|dts_time=3.970612|duration=1024|duration_time=0.023220|size=200|pos=34878|flags=K_
-packet|codec_type=audio|stream_index=0|pts=176128|pts_time=3.993832|dts=176128|dts_time=3.993832|duration=1024|duration_time=0.023220|size=197|pos=35078|flags=K_
-packet|codec_type=audio|stream_index=0|pts=177152|pts_time=4.017052|dts=177152|dts_time=4.017052|duration=1024|duration_time=0.023220|size=209|pos=35275|flags=K_
-packet|codec_type=audio|stream_index=0|pts=178176|pts_time=4.040272|dts=178176|dts_time=4.040272|duration=1024|duration_time=0.023220|size=205|pos=35484|flags=K_
-packet|codec_type=audio|stream_index=0|pts=179200|pts_time=4.063492|dts=179200|dts_time=4.063492|duration=1024|duration_time=0.023220|size=199|pos=35689|flags=K_
-packet|codec_type=audio|stream_index=0|pts=180224|pts_time=4.086712|dts=180224|dts_time=4.086712|duration=1024|duration_time=0.023220|size=192|pos=35888|flags=K_
-packet|codec_type=audio|stream_index=0|pts=181248|pts_time=4.109932|dts=181248|dts_time=4.109932|duration=1024|duration_time=0.023220|size=201|pos=36080|flags=K_
-packet|codec_type=audio|stream_index=0|pts=182272|pts_time=4.133152|dts=182272|dts_time=4.133152|duration=1024|duration_time=0.023220|size=200|pos=36281|flags=K_
-packet|codec_type=audio|stream_index=0|pts=183296|pts_time=4.156372|dts=183296|dts_time=4.156372|duration=1024|duration_time=0.023220|size=202|pos=36481|flags=K_
-packet|codec_type=audio|stream_index=0|pts=184320|pts_time=4.179592|dts=184320|dts_time=4.179592|duration=1024|duration_time=0.023220|size=196|pos=36683|flags=K_
-packet|codec_type=audio|stream_index=0|pts=185344|pts_time=4.202812|dts=185344|dts_time=4.202812|duration=1024|duration_time=0.023220|size=200|pos=36879|flags=K_
-packet|codec_type=audio|stream_index=0|pts=186368|pts_time=4.226032|dts=186368|dts_time=4.226032|duration=1024|duration_time=0.023220|size=209|pos=37079|flags=K_
-packet|codec_type=audio|stream_index=0|pts=187392|pts_time=4.249252|dts=187392|dts_time=4.249252|duration=1024|duration_time=0.023220|size=201|pos=37288|flags=K_
-packet|codec_type=audio|stream_index=0|pts=188416|pts_time=4.272472|dts=188416|dts_time=4.272472|duration=1024|duration_time=0.023220|size=201|pos=37489|flags=K_
-packet|codec_type=audio|stream_index=0|pts=189440|pts_time=4.295692|dts=189440|dts_time=4.295692|duration=1024|duration_time=0.023220|size=201|pos=37690|flags=K_
-packet|codec_type=audio|stream_index=0|pts=190464|pts_time=4.318912|dts=190464|dts_time=4.318912|duration=1024|duration_time=0.023220|size=199|pos=37891|flags=K_
-packet|codec_type=audio|stream_index=0|pts=191488|pts_time=4.342132|dts=191488|dts_time=4.342132|duration=1024|duration_time=0.023220|size=198|pos=38090|flags=K_
-packet|codec_type=audio|stream_index=0|pts=192512|pts_time=4.365351|dts=192512|dts_time=4.365351|duration=1024|duration_time=0.023220|size=205|pos=38288|flags=K_
-packet|codec_type=audio|stream_index=0|pts=193536|pts_time=4.388571|dts=193536|dts_time=4.388571|duration=1024|duration_time=0.023220|size=190|pos=38493|flags=K_
-packet|codec_type=audio|stream_index=0|pts=194560|pts_time=4.411791|dts=194560|dts_time=4.411791|duration=1024|duration_time=0.023220|size=207|pos=38683|flags=K_
-packet|codec_type=audio|stream_index=0|pts=195584|pts_time=4.435011|dts=195584|dts_time=4.435011|duration=1024|duration_time=0.023220|size=204|pos=38890|flags=K_
-packet|codec_type=audio|stream_index=0|pts=196608|pts_time=4.458231|dts=196608|dts_time=4.458231|duration=1024|duration_time=0.023220|size=192|pos=39094|flags=K_
-packet|codec_type=audio|stream_index=0|pts=197632|pts_time=4.481451|dts=197632|dts_time=4.481451|duration=1024|duration_time=0.023220|size=211|pos=39286|flags=K_
-packet|codec_type=audio|stream_index=0|pts=198656|pts_time=4.504671|dts=198656|dts_time=4.504671|duration=1024|duration_time=0.023220|size=195|pos=39497|flags=K_
-packet|codec_type=audio|stream_index=0|pts=199680|pts_time=4.527891|dts=199680|dts_time=4.527891|duration=1024|duration_time=0.023220|size=214|pos=39692|flags=K_
-packet|codec_type=audio|stream_index=0|pts=200704|pts_time=4.551111|dts=200704|dts_time=4.551111|duration=1024|duration_time=0.023220|size=195|pos=39906|flags=K_
-packet|codec_type=audio|stream_index=0|pts=201728|pts_time=4.574331|dts=201728|dts_time=4.574331|duration=1024|duration_time=0.023220|size=199|pos=40101|flags=K_
-packet|codec_type=audio|stream_index=0|pts=202752|pts_time=4.597551|dts=202752|dts_time=4.597551|duration=1024|duration_time=0.023220|size=183|pos=40300|flags=K_
-packet|codec_type=audio|stream_index=0|pts=203776|pts_time=4.620771|dts=203776|dts_time=4.620771|duration=1024|duration_time=0.023220|size=211|pos=40483|flags=K_
-packet|codec_type=audio|stream_index=0|pts=204800|pts_time=4.643991|dts=204800|dts_time=4.643991|duration=1024|duration_time=0.023220|size=200|pos=40694|flags=K_
-packet|codec_type=audio|stream_index=0|pts=205824|pts_time=4.667211|dts=205824|dts_time=4.667211|duration=1024|duration_time=0.023220|size=199|pos=40894|flags=K_
-packet|codec_type=audio|stream_index=0|pts=206848|pts_time=4.690431|dts=206848|dts_time=4.690431|duration=1024|duration_time=0.023220|size=213|pos=41093|flags=K_
-packet|codec_type=audio|stream_index=0|pts=207872|pts_time=4.713651|dts=207872|dts_time=4.713651|duration=1024|duration_time=0.023220|size=191|pos=41306|flags=K_
-packet|codec_type=audio|stream_index=0|pts=208896|pts_time=4.736871|dts=208896|dts_time=4.736871|duration=1024|duration_time=0.023220|size=211|pos=41497|flags=K_
-packet|codec_type=audio|stream_index=0|pts=209920|pts_time=4.760091|dts=209920|dts_time=4.760091|duration=1024|duration_time=0.023220|size=198|pos=41708|flags=K_
-packet|codec_type=audio|stream_index=0|pts=210944|pts_time=4.783311|dts=210944|dts_time=4.783311|duration=1024|duration_time=0.023220|size=203|pos=41906|flags=K_
-packet|codec_type=audio|stream_index=0|pts=211968|pts_time=4.806531|dts=211968|dts_time=4.806531|duration=1024|duration_time=0.023220|size=196|pos=42109|flags=K_
-packet|codec_type=audio|stream_index=0|pts=212992|pts_time=4.829751|dts=212992|dts_time=4.829751|duration=1024|duration_time=0.023220|size=197|pos=42305|flags=K_
-packet|codec_type=audio|stream_index=0|pts=214016|pts_time=4.852971|dts=214016|dts_time=4.852971|duration=1024|duration_time=0.023220|size=190|pos=42502|flags=K_
-packet|codec_type=audio|stream_index=0|pts=215040|pts_time=4.876190|dts=215040|dts_time=4.876190|duration=1024|duration_time=0.023220|size=208|pos=42692|flags=K_
-packet|codec_type=audio|stream_index=0|pts=216064|pts_time=4.899410|dts=216064|dts_time=4.899410|duration=1024|duration_time=0.023220|size=203|pos=42900|flags=K_
-packet|codec_type=audio|stream_index=0|pts=217088|pts_time=4.922630|dts=217088|dts_time=4.922630|duration=1024|duration_time=0.023220|size=198|pos=43103|flags=K_
-packet|codec_type=audio|stream_index=0|pts=218112|pts_time=4.945850|dts=218112|dts_time=4.945850|duration=1024|duration_time=0.023220|size=284|pos=43301|flags=K_
-packet|codec_type=audio|stream_index=0|pts=219136|pts_time=4.969070|dts=219136|dts_time=4.969070|duration=1364|duration_time=0.030930|size=5|pos=43585|flags=K_
+packet|codec_type=audio|stream_index=0|pts=-1024|pts_time=-0.023220|dts=-1024|dts_time=-0.023220|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=258|pos=294|flags=KD
+packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=146|pos=552|flags=K_
+packet|codec_type=audio|stream_index=0|pts=1024|pts_time=0.023220|dts=1024|dts_time=0.023220|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=698|flags=K_
+packet|codec_type=audio|stream_index=0|pts=2048|pts_time=0.046440|dts=2048|dts_time=0.046440|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=222|pos=884|flags=K_
+packet|codec_type=audio|stream_index=0|pts=3072|pts_time=0.069660|dts=3072|dts_time=0.069660|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=1106|flags=K_
+packet|codec_type=audio|stream_index=0|pts=4096|pts_time=0.092880|dts=4096|dts_time=0.092880|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=206|pos=1292|flags=K_
+packet|codec_type=audio|stream_index=0|pts=5120|pts_time=0.116100|dts=5120|dts_time=0.116100|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=1498|flags=K_
+packet|codec_type=audio|stream_index=0|pts=6144|pts_time=0.139320|dts=6144|dts_time=0.139320|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=236|pos=1697|flags=K_
+packet|codec_type=audio|stream_index=0|pts=7168|pts_time=0.162540|dts=7168|dts_time=0.162540|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=1933|flags=K_
+packet|codec_type=audio|stream_index=0|pts=8192|pts_time=0.185760|dts=8192|dts_time=0.185760|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=238|pos=2141|flags=K_
+packet|codec_type=audio|stream_index=0|pts=9216|pts_time=0.208980|dts=9216|dts_time=0.208980|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=222|pos=2379|flags=K_
+packet|codec_type=audio|stream_index=0|pts=10240|pts_time=0.232200|dts=10240|dts_time=0.232200|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=211|pos=2601|flags=K_
+packet|codec_type=audio|stream_index=0|pts=11264|pts_time=0.255420|dts=11264|dts_time=0.255420|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=153|pos=2812|flags=K_
+packet|codec_type=audio|stream_index=0|pts=12288|pts_time=0.278639|dts=12288|dts_time=0.278639|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=191|pos=2965|flags=K_
+packet|codec_type=audio|stream_index=0|pts=13312|pts_time=0.301859|dts=13312|dts_time=0.301859|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=3156|flags=K_
+packet|codec_type=audio|stream_index=0|pts=14336|pts_time=0.325079|dts=14336|dts_time=0.325079|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=188|pos=3364|flags=K_
+packet|codec_type=audio|stream_index=0|pts=15360|pts_time=0.348299|dts=15360|dts_time=0.348299|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=170|pos=3552|flags=K_
+packet|codec_type=audio|stream_index=0|pts=16384|pts_time=0.371519|dts=16384|dts_time=0.371519|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=221|pos=3722|flags=K_
+packet|codec_type=audio|stream_index=0|pts=17408|pts_time=0.394739|dts=17408|dts_time=0.394739|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=247|pos=3943|flags=K_
+packet|codec_type=audio|stream_index=0|pts=18432|pts_time=0.417959|dts=18432|dts_time=0.417959|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=202|pos=4190|flags=K_
+packet|codec_type=audio|stream_index=0|pts=19456|pts_time=0.441179|dts=19456|dts_time=0.441179|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=4392|flags=K_
+packet|codec_type=audio|stream_index=0|pts=20480|pts_time=0.464399|dts=20480|dts_time=0.464399|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=4578|flags=K_
+packet|codec_type=audio|stream_index=0|pts=21504|pts_time=0.487619|dts=21504|dts_time=0.487619|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=4774|flags=K_
+packet|codec_type=audio|stream_index=0|pts=22528|pts_time=0.510839|dts=22528|dts_time=0.510839|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=170|pos=4974|flags=K_
+packet|codec_type=audio|stream_index=0|pts=23552|pts_time=0.534059|dts=23552|dts_time=0.534059|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=172|pos=5144|flags=K_
+packet|codec_type=audio|stream_index=0|pts=24576|pts_time=0.557279|dts=24576|dts_time=0.557279|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=206|pos=5316|flags=K_
+packet|codec_type=audio|stream_index=0|pts=25600|pts_time=0.580499|dts=25600|dts_time=0.580499|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=5522|flags=K_
+packet|codec_type=audio|stream_index=0|pts=26624|pts_time=0.603719|dts=26624|dts_time=0.603719|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=217|pos=5730|flags=K_
+packet|codec_type=audio|stream_index=0|pts=27648|pts_time=0.626939|dts=27648|dts_time=0.626939|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=252|pos=5947|flags=K_
+packet|codec_type=audio|stream_index=0|pts=28672|pts_time=0.650159|dts=28672|dts_time=0.650159|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=171|pos=6199|flags=K_
+packet|codec_type=audio|stream_index=0|pts=29696|pts_time=0.673379|dts=29696|dts_time=0.673379|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=206|pos=6370|flags=K_
+packet|codec_type=audio|stream_index=0|pts=30720|pts_time=0.696599|dts=30720|dts_time=0.696599|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=237|pos=6576|flags=K_
+packet|codec_type=audio|stream_index=0|pts=31744|pts_time=0.719819|dts=31744|dts_time=0.719819|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=210|pos=6813|flags=K_
+packet|codec_type=audio|stream_index=0|pts=32768|pts_time=0.743039|dts=32768|dts_time=0.743039|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=166|pos=7023|flags=K_
+packet|codec_type=audio|stream_index=0|pts=33792|pts_time=0.766259|dts=33792|dts_time=0.766259|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=166|pos=7189|flags=K_
+packet|codec_type=audio|stream_index=0|pts=34816|pts_time=0.789478|dts=34816|dts_time=0.789478|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=177|pos=7355|flags=K_
+packet|codec_type=audio|stream_index=0|pts=35840|pts_time=0.812698|dts=35840|dts_time=0.812698|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=188|pos=7532|flags=K_
+packet|codec_type=audio|stream_index=0|pts=36864|pts_time=0.835918|dts=36864|dts_time=0.835918|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=193|pos=7720|flags=K_
+packet|codec_type=audio|stream_index=0|pts=37888|pts_time=0.859138|dts=37888|dts_time=0.859138|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=7913|flags=K_
+packet|codec_type=audio|stream_index=0|pts=38912|pts_time=0.882358|dts=38912|dts_time=0.882358|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=211|pos=8108|flags=K_
+packet|codec_type=audio|stream_index=0|pts=39936|pts_time=0.905578|dts=39936|dts_time=0.905578|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=249|pos=8319|flags=K_
+packet|codec_type=audio|stream_index=0|pts=40960|pts_time=0.928798|dts=40960|dts_time=0.928798|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=223|pos=8568|flags=K_
+packet|codec_type=audio|stream_index=0|pts=41984|pts_time=0.952018|dts=41984|dts_time=0.952018|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=230|pos=8791|flags=K_
+packet|codec_type=audio|stream_index=0|pts=43008|pts_time=0.975238|dts=43008|dts_time=0.975238|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=203|pos=9021|flags=K_
+packet|codec_type=audio|stream_index=0|pts=44032|pts_time=0.998458|dts=44032|dts_time=0.998458|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=180|pos=9224|flags=K_
+packet|codec_type=audio|stream_index=0|pts=45056|pts_time=1.021678|dts=45056|dts_time=1.021678|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=172|pos=9404|flags=K_
+packet|codec_type=audio|stream_index=0|pts=46080|pts_time=1.044898|dts=46080|dts_time=1.044898|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=240|pos=9576|flags=K_
+packet|codec_type=audio|stream_index=0|pts=47104|pts_time=1.068118|dts=47104|dts_time=1.068118|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=179|pos=9816|flags=K_
+packet|codec_type=audio|stream_index=0|pts=48128|pts_time=1.091338|dts=48128|dts_time=1.091338|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=191|pos=9995|flags=K_
+packet|codec_type=audio|stream_index=0|pts=49152|pts_time=1.114558|dts=49152|dts_time=1.114558|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=184|pos=10186|flags=K_
+packet|codec_type=audio|stream_index=0|pts=50176|pts_time=1.137778|dts=50176|dts_time=1.137778|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=214|pos=10370|flags=K_
+packet|codec_type=audio|stream_index=0|pts=51200|pts_time=1.160998|dts=51200|dts_time=1.160998|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=194|pos=10584|flags=K_
+packet|codec_type=audio|stream_index=0|pts=52224|pts_time=1.184218|dts=52224|dts_time=1.184218|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=235|pos=10778|flags=K_
+packet|codec_type=audio|stream_index=0|pts=53248|pts_time=1.207438|dts=53248|dts_time=1.207438|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=11013|flags=K_
+packet|codec_type=audio|stream_index=0|pts=54272|pts_time=1.230658|dts=54272|dts_time=1.230658|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=220|pos=11208|flags=K_
+packet|codec_type=audio|stream_index=0|pts=55296|pts_time=1.253878|dts=55296|dts_time=1.253878|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=187|pos=11428|flags=K_
+packet|codec_type=audio|stream_index=0|pts=56320|pts_time=1.277098|dts=56320|dts_time=1.277098|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=238|pos=11615|flags=K_
+packet|codec_type=audio|stream_index=0|pts=57344|pts_time=1.300317|dts=57344|dts_time=1.300317|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=175|pos=11853|flags=K_
+packet|codec_type=audio|stream_index=0|pts=58368|pts_time=1.323537|dts=58368|dts_time=1.323537|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=178|pos=12028|flags=K_
+packet|codec_type=audio|stream_index=0|pts=59392|pts_time=1.346757|dts=59392|dts_time=1.346757|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=219|pos=12206|flags=K_
+packet|codec_type=audio|stream_index=0|pts=60416|pts_time=1.369977|dts=60416|dts_time=1.369977|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=179|pos=12425|flags=K_
+packet|codec_type=audio|stream_index=0|pts=61440|pts_time=1.393197|dts=61440|dts_time=1.393197|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=193|pos=12604|flags=K_
+packet|codec_type=audio|stream_index=0|pts=62464|pts_time=1.416417|dts=62464|dts_time=1.416417|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=12797|flags=K_
+packet|codec_type=audio|stream_index=0|pts=63488|pts_time=1.439637|dts=63488|dts_time=1.439637|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=218|pos=12997|flags=K_
+packet|codec_type=audio|stream_index=0|pts=64512|pts_time=1.462857|dts=64512|dts_time=1.462857|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=215|pos=13215|flags=K_
+packet|codec_type=audio|stream_index=0|pts=65536|pts_time=1.486077|dts=65536|dts_time=1.486077|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=209|pos=13430|flags=K_
+packet|codec_type=audio|stream_index=0|pts=66560|pts_time=1.509297|dts=66560|dts_time=1.509297|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=171|pos=13639|flags=K_
+packet|codec_type=audio|stream_index=0|pts=67584|pts_time=1.532517|dts=67584|dts_time=1.532517|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=179|pos=13810|flags=K_
+packet|codec_type=audio|stream_index=0|pts=68608|pts_time=1.555737|dts=68608|dts_time=1.555737|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=185|pos=13989|flags=K_
+packet|codec_type=audio|stream_index=0|pts=69632|pts_time=1.578957|dts=69632|dts_time=1.578957|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=225|pos=14174|flags=K_
+packet|codec_type=audio|stream_index=0|pts=70656|pts_time=1.602177|dts=70656|dts_time=1.602177|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=221|pos=14399|flags=K_
+packet|codec_type=audio|stream_index=0|pts=71680|pts_time=1.625397|dts=71680|dts_time=1.625397|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=201|pos=14620|flags=K_
+packet|codec_type=audio|stream_index=0|pts=72704|pts_time=1.648617|dts=72704|dts_time=1.648617|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=206|pos=14821|flags=K_
+packet|codec_type=audio|stream_index=0|pts=73728|pts_time=1.671837|dts=73728|dts_time=1.671837|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=182|pos=15027|flags=K_
+packet|codec_type=audio|stream_index=0|pts=74752|pts_time=1.695057|dts=74752|dts_time=1.695057|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=176|pos=15209|flags=K_
+packet|codec_type=audio|stream_index=0|pts=75776|pts_time=1.718277|dts=75776|dts_time=1.718277|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=233|pos=15385|flags=K_
+packet|codec_type=audio|stream_index=0|pts=76800|pts_time=1.741497|dts=76800|dts_time=1.741497|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=15618|flags=K_
+packet|codec_type=audio|stream_index=0|pts=77824|pts_time=1.764717|dts=77824|dts_time=1.764717|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=220|pos=15817|flags=K_
+packet|codec_type=audio|stream_index=0|pts=78848|pts_time=1.787937|dts=78848|dts_time=1.787937|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=16037|flags=K_
+packet|codec_type=audio|stream_index=0|pts=79872|pts_time=1.811156|dts=79872|dts_time=1.811156|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=210|pos=16227|flags=K_
+packet|codec_type=audio|stream_index=0|pts=80896|pts_time=1.834376|dts=80896|dts_time=1.834376|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=204|pos=16437|flags=K_
+packet|codec_type=audio|stream_index=0|pts=81920|pts_time=1.857596|dts=81920|dts_time=1.857596|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=171|pos=16641|flags=K_
+packet|codec_type=audio|stream_index=0|pts=82944|pts_time=1.880816|dts=82944|dts_time=1.880816|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=167|pos=16812|flags=K_
+packet|codec_type=audio|stream_index=0|pts=83968|pts_time=1.904036|dts=83968|dts_time=1.904036|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=16979|flags=K_
+packet|codec_type=audio|stream_index=0|pts=84992|pts_time=1.927256|dts=84992|dts_time=1.927256|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=254|pos=17179|flags=K_
+packet|codec_type=audio|stream_index=0|pts=86016|pts_time=1.950476|dts=86016|dts_time=1.950476|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=205|pos=17433|flags=K_
+packet|codec_type=audio|stream_index=0|pts=87040|pts_time=1.973696|dts=87040|dts_time=1.973696|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=17638|flags=K_
+packet|codec_type=audio|stream_index=0|pts=88064|pts_time=1.996916|dts=88064|dts_time=1.996916|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=17834|flags=K_
+packet|codec_type=audio|stream_index=0|pts=89088|pts_time=2.020136|dts=89088|dts_time=2.020136|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=197|pos=18024|flags=K_
+packet|codec_type=audio|stream_index=0|pts=90112|pts_time=2.043356|dts=90112|dts_time=2.043356|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=18221|flags=K_
+packet|codec_type=audio|stream_index=0|pts=91136|pts_time=2.066576|dts=91136|dts_time=2.066576|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=194|pos=18407|flags=K_
+packet|codec_type=audio|stream_index=0|pts=92160|pts_time=2.089796|dts=92160|dts_time=2.089796|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=227|pos=18601|flags=K_
+packet|codec_type=audio|stream_index=0|pts=93184|pts_time=2.113016|dts=93184|dts_time=2.113016|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=18828|flags=K_
+packet|codec_type=audio|stream_index=0|pts=94208|pts_time=2.136236|dts=94208|dts_time=2.136236|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=228|pos=19023|flags=K_
+packet|codec_type=audio|stream_index=0|pts=95232|pts_time=2.159456|dts=95232|dts_time=2.159456|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=19251|flags=K_
+packet|codec_type=audio|stream_index=0|pts=96256|pts_time=2.182676|dts=96256|dts_time=2.182676|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=197|pos=19447|flags=K_
+packet|codec_type=audio|stream_index=0|pts=97280|pts_time=2.205896|dts=97280|dts_time=2.205896|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=19644|flags=K_
+packet|codec_type=audio|stream_index=0|pts=98304|pts_time=2.229116|dts=98304|dts_time=2.229116|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=191|pos=19830|flags=K_
+packet|codec_type=audio|stream_index=0|pts=99328|pts_time=2.252336|dts=99328|dts_time=2.252336|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=215|pos=20021|flags=K_
+packet|codec_type=audio|stream_index=0|pts=100352|pts_time=2.275556|dts=100352|dts_time=2.275556|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=203|pos=20236|flags=K_
+packet|codec_type=audio|stream_index=0|pts=101376|pts_time=2.298776|dts=101376|dts_time=2.298776|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=205|pos=20439|flags=K_
+packet|codec_type=audio|stream_index=0|pts=102400|pts_time=2.321995|dts=102400|dts_time=2.321995|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=205|pos=20644|flags=K_
+packet|codec_type=audio|stream_index=0|pts=103424|pts_time=2.345215|dts=103424|dts_time=2.345215|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=213|pos=20849|flags=K_
+packet|codec_type=audio|stream_index=0|pts=104448|pts_time=2.368435|dts=104448|dts_time=2.368435|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=21062|flags=K_
+packet|codec_type=audio|stream_index=0|pts=105472|pts_time=2.391655|dts=105472|dts_time=2.391655|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=178|pos=21260|flags=K_
+packet|codec_type=audio|stream_index=0|pts=106496|pts_time=2.414875|dts=106496|dts_time=2.414875|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=21438|flags=K_
+packet|codec_type=audio|stream_index=0|pts=107520|pts_time=2.438095|dts=107520|dts_time=2.438095|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=227|pos=21633|flags=K_
+packet|codec_type=audio|stream_index=0|pts=108544|pts_time=2.461315|dts=108544|dts_time=2.461315|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=185|pos=21860|flags=K_
+packet|codec_type=audio|stream_index=0|pts=109568|pts_time=2.484535|dts=109568|dts_time=2.484535|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=206|pos=22045|flags=K_
+packet|codec_type=audio|stream_index=0|pts=110592|pts_time=2.507755|dts=110592|dts_time=2.507755|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=183|pos=22251|flags=K_
+packet|codec_type=audio|stream_index=0|pts=111616|pts_time=2.530975|dts=111616|dts_time=2.530975|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=22434|flags=K_
+packet|codec_type=audio|stream_index=0|pts=112640|pts_time=2.554195|dts=112640|dts_time=2.554195|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=204|pos=22642|flags=K_
+packet|codec_type=audio|stream_index=0|pts=113664|pts_time=2.577415|dts=113664|dts_time=2.577415|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=192|pos=22846|flags=K_
+packet|codec_type=audio|stream_index=0|pts=114688|pts_time=2.600635|dts=114688|dts_time=2.600635|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=23038|flags=K_
+packet|codec_type=audio|stream_index=0|pts=115712|pts_time=2.623855|dts=115712|dts_time=2.623855|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=23228|flags=K_
+packet|codec_type=audio|stream_index=0|pts=116736|pts_time=2.647075|dts=116736|dts_time=2.647075|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=229|pos=23427|flags=K_
+packet|codec_type=audio|stream_index=0|pts=117760|pts_time=2.670295|dts=117760|dts_time=2.670295|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=23656|flags=K_
+packet|codec_type=audio|stream_index=0|pts=118784|pts_time=2.693515|dts=118784|dts_time=2.693515|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=23864|flags=K_
+packet|codec_type=audio|stream_index=0|pts=119808|pts_time=2.716735|dts=119808|dts_time=2.716735|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=24059|flags=K_
+packet|codec_type=audio|stream_index=0|pts=120832|pts_time=2.739955|dts=120832|dts_time=2.739955|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=24249|flags=K_
+packet|codec_type=audio|stream_index=0|pts=121856|pts_time=2.763175|dts=121856|dts_time=2.763175|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=192|pos=24439|flags=K_
+packet|codec_type=audio|stream_index=0|pts=122880|pts_time=2.786395|dts=122880|dts_time=2.786395|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=226|pos=24631|flags=K_
+packet|codec_type=audio|stream_index=0|pts=123904|pts_time=2.809615|dts=123904|dts_time=2.809615|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=24857|flags=K_
+packet|codec_type=audio|stream_index=0|pts=124928|pts_time=2.832834|dts=124928|dts_time=2.832834|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=230|pos=25052|flags=K_
+packet|codec_type=audio|stream_index=0|pts=125952|pts_time=2.856054|dts=125952|dts_time=2.856054|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=25282|flags=K_
+packet|codec_type=audio|stream_index=0|pts=126976|pts_time=2.879274|dts=126976|dts_time=2.879274|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=183|pos=25480|flags=K_
+packet|codec_type=audio|stream_index=0|pts=128000|pts_time=2.902494|dts=128000|dts_time=2.902494|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=25663|flags=K_
+packet|codec_type=audio|stream_index=0|pts=129024|pts_time=2.925714|dts=129024|dts_time=2.925714|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=25862|flags=K_
+packet|codec_type=audio|stream_index=0|pts=130048|pts_time=2.948934|dts=130048|dts_time=2.948934|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=26058|flags=K_
+packet|codec_type=audio|stream_index=0|pts=131072|pts_time=2.972154|dts=131072|dts_time=2.972154|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=26244|flags=K_
+packet|codec_type=audio|stream_index=0|pts=132096|pts_time=2.995374|dts=132096|dts_time=2.995374|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=210|pos=26444|flags=K_
+packet|codec_type=audio|stream_index=0|pts=133120|pts_time=3.018594|dts=133120|dts_time=3.018594|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=26654|flags=K_
+packet|codec_type=audio|stream_index=0|pts=134144|pts_time=3.041814|dts=134144|dts_time=3.041814|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=214|pos=26850|flags=K_
+packet|codec_type=audio|stream_index=0|pts=135168|pts_time=3.065034|dts=135168|dts_time=3.065034|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=185|pos=27064|flags=K_
+packet|codec_type=audio|stream_index=0|pts=136192|pts_time=3.088254|dts=136192|dts_time=3.088254|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=27249|flags=K_
+packet|codec_type=audio|stream_index=0|pts=137216|pts_time=3.111474|dts=137216|dts_time=3.111474|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=27447|flags=K_
+packet|codec_type=audio|stream_index=0|pts=138240|pts_time=3.134694|dts=138240|dts_time=3.134694|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=27647|flags=K_
+packet|codec_type=audio|stream_index=0|pts=139264|pts_time=3.157914|dts=139264|dts_time=3.157914|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=212|pos=27855|flags=K_
+packet|codec_type=audio|stream_index=0|pts=140288|pts_time=3.181134|dts=140288|dts_time=3.181134|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=28067|flags=K_
+packet|codec_type=audio|stream_index=0|pts=141312|pts_time=3.204354|dts=141312|dts_time=3.204354|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=192|pos=28275|flags=K_
+packet|codec_type=audio|stream_index=0|pts=142336|pts_time=3.227574|dts=142336|dts_time=3.227574|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=192|pos=28467|flags=K_
+packet|codec_type=audio|stream_index=0|pts=143360|pts_time=3.250794|dts=143360|dts_time=3.250794|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=211|pos=28659|flags=K_
+packet|codec_type=audio|stream_index=0|pts=144384|pts_time=3.274014|dts=144384|dts_time=3.274014|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=28870|flags=K_
+packet|codec_type=audio|stream_index=0|pts=145408|pts_time=3.297234|dts=145408|dts_time=3.297234|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=29065|flags=K_
+packet|codec_type=audio|stream_index=0|pts=146432|pts_time=3.320454|dts=146432|dts_time=3.320454|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=29273|flags=K_
+packet|codec_type=audio|stream_index=0|pts=147456|pts_time=3.343673|dts=147456|dts_time=3.343673|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=204|pos=29468|flags=K_
+packet|codec_type=audio|stream_index=0|pts=148480|pts_time=3.366893|dts=148480|dts_time=3.366893|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=209|pos=29672|flags=K_
+packet|codec_type=audio|stream_index=0|pts=149504|pts_time=3.390113|dts=149504|dts_time=3.390113|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=29881|flags=K_
+packet|codec_type=audio|stream_index=0|pts=150528|pts_time=3.413333|dts=150528|dts_time=3.413333|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=191|pos=30076|flags=K_
+packet|codec_type=audio|stream_index=0|pts=151552|pts_time=3.436553|dts=151552|dts_time=3.436553|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=210|pos=30267|flags=K_
+packet|codec_type=audio|stream_index=0|pts=152576|pts_time=3.459773|dts=152576|dts_time=3.459773|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=209|pos=30477|flags=K_
+packet|codec_type=audio|stream_index=0|pts=153600|pts_time=3.482993|dts=153600|dts_time=3.482993|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=175|pos=30686|flags=K_
+packet|codec_type=audio|stream_index=0|pts=154624|pts_time=3.506213|dts=154624|dts_time=3.506213|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=244|pos=30861|flags=K_
+packet|codec_type=audio|stream_index=0|pts=155648|pts_time=3.529433|dts=155648|dts_time=3.529433|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=177|pos=31105|flags=K_
+packet|codec_type=audio|stream_index=0|pts=156672|pts_time=3.552653|dts=156672|dts_time=3.552653|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=217|pos=31282|flags=K_
+packet|codec_type=audio|stream_index=0|pts=157696|pts_time=3.575873|dts=157696|dts_time=3.575873|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=182|pos=31499|flags=K_
+packet|codec_type=audio|stream_index=0|pts=158720|pts_time=3.599093|dts=158720|dts_time=3.599093|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=181|pos=31681|flags=K_
+packet|codec_type=audio|stream_index=0|pts=159744|pts_time=3.622313|dts=159744|dts_time=3.622313|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=203|pos=31862|flags=K_
+packet|codec_type=audio|stream_index=0|pts=160768|pts_time=3.645533|dts=160768|dts_time=3.645533|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=32065|flags=K_
+packet|codec_type=audio|stream_index=0|pts=161792|pts_time=3.668753|dts=161792|dts_time=3.668753|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=217|pos=32263|flags=K_
+packet|codec_type=audio|stream_index=0|pts=162816|pts_time=3.691973|dts=162816|dts_time=3.691973|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=32480|flags=K_
+packet|codec_type=audio|stream_index=0|pts=163840|pts_time=3.715193|dts=163840|dts_time=3.715193|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=32675|flags=K_
+packet|codec_type=audio|stream_index=0|pts=164864|pts_time=3.738413|dts=164864|dts_time=3.738413|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=202|pos=32873|flags=K_
+packet|codec_type=audio|stream_index=0|pts=165888|pts_time=3.761633|dts=165888|dts_time=3.761633|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=185|pos=33075|flags=K_
+packet|codec_type=audio|stream_index=0|pts=166912|pts_time=3.784853|dts=166912|dts_time=3.784853|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=33260|flags=K_
+packet|codec_type=audio|stream_index=0|pts=167936|pts_time=3.808073|dts=167936|dts_time=3.808073|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=226|pos=33456|flags=K_
+packet|codec_type=audio|stream_index=0|pts=168960|pts_time=3.831293|dts=168960|dts_time=3.831293|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=187|pos=33682|flags=K_
+packet|codec_type=audio|stream_index=0|pts=169984|pts_time=3.854512|dts=169984|dts_time=3.854512|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=193|pos=33869|flags=K_
+packet|codec_type=audio|stream_index=0|pts=171008|pts_time=3.877732|dts=171008|dts_time=3.877732|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=218|pos=34062|flags=K_
+packet|codec_type=audio|stream_index=0|pts=172032|pts_time=3.900952|dts=172032|dts_time=3.900952|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=34280|flags=K_
+packet|codec_type=audio|stream_index=0|pts=173056|pts_time=3.924172|dts=173056|dts_time=3.924172|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=34480|flags=K_
+packet|codec_type=audio|stream_index=0|pts=174080|pts_time=3.947392|dts=174080|dts_time=3.947392|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=34680|flags=K_
+packet|codec_type=audio|stream_index=0|pts=175104|pts_time=3.970612|dts=175104|dts_time=3.970612|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=34878|flags=K_
+packet|codec_type=audio|stream_index=0|pts=176128|pts_time=3.993832|dts=176128|dts_time=3.993832|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=197|pos=35078|flags=K_
+packet|codec_type=audio|stream_index=0|pts=177152|pts_time=4.017052|dts=177152|dts_time=4.017052|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=209|pos=35275|flags=K_
+packet|codec_type=audio|stream_index=0|pts=178176|pts_time=4.040272|dts=178176|dts_time=4.040272|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=205|pos=35484|flags=K_
+packet|codec_type=audio|stream_index=0|pts=179200|pts_time=4.063492|dts=179200|dts_time=4.063492|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=35689|flags=K_
+packet|codec_type=audio|stream_index=0|pts=180224|pts_time=4.086712|dts=180224|dts_time=4.086712|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=192|pos=35888|flags=K_
+packet|codec_type=audio|stream_index=0|pts=181248|pts_time=4.109932|dts=181248|dts_time=4.109932|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=201|pos=36080|flags=K_
+packet|codec_type=audio|stream_index=0|pts=182272|pts_time=4.133152|dts=182272|dts_time=4.133152|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=36281|flags=K_
+packet|codec_type=audio|stream_index=0|pts=183296|pts_time=4.156372|dts=183296|dts_time=4.156372|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=202|pos=36481|flags=K_
+packet|codec_type=audio|stream_index=0|pts=184320|pts_time=4.179592|dts=184320|dts_time=4.179592|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=36683|flags=K_
+packet|codec_type=audio|stream_index=0|pts=185344|pts_time=4.202812|dts=185344|dts_time=4.202812|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=36879|flags=K_
+packet|codec_type=audio|stream_index=0|pts=186368|pts_time=4.226032|dts=186368|dts_time=4.226032|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=209|pos=37079|flags=K_
+packet|codec_type=audio|stream_index=0|pts=187392|pts_time=4.249252|dts=187392|dts_time=4.249252|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=201|pos=37288|flags=K_
+packet|codec_type=audio|stream_index=0|pts=188416|pts_time=4.272472|dts=188416|dts_time=4.272472|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=201|pos=37489|flags=K_
+packet|codec_type=audio|stream_index=0|pts=189440|pts_time=4.295692|dts=189440|dts_time=4.295692|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=201|pos=37690|flags=K_
+packet|codec_type=audio|stream_index=0|pts=190464|pts_time=4.318912|dts=190464|dts_time=4.318912|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=37891|flags=K_
+packet|codec_type=audio|stream_index=0|pts=191488|pts_time=4.342132|dts=191488|dts_time=4.342132|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=38090|flags=K_
+packet|codec_type=audio|stream_index=0|pts=192512|pts_time=4.365351|dts=192512|dts_time=4.365351|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=205|pos=38288|flags=K_
+packet|codec_type=audio|stream_index=0|pts=193536|pts_time=4.388571|dts=193536|dts_time=4.388571|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=38493|flags=K_
+packet|codec_type=audio|stream_index=0|pts=194560|pts_time=4.411791|dts=194560|dts_time=4.411791|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=207|pos=38683|flags=K_
+packet|codec_type=audio|stream_index=0|pts=195584|pts_time=4.435011|dts=195584|dts_time=4.435011|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=204|pos=38890|flags=K_
+packet|codec_type=audio|stream_index=0|pts=196608|pts_time=4.458231|dts=196608|dts_time=4.458231|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=192|pos=39094|flags=K_
+packet|codec_type=audio|stream_index=0|pts=197632|pts_time=4.481451|dts=197632|dts_time=4.481451|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=211|pos=39286|flags=K_
+packet|codec_type=audio|stream_index=0|pts=198656|pts_time=4.504671|dts=198656|dts_time=4.504671|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=39497|flags=K_
+packet|codec_type=audio|stream_index=0|pts=199680|pts_time=4.527891|dts=199680|dts_time=4.527891|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=214|pos=39692|flags=K_
+packet|codec_type=audio|stream_index=0|pts=200704|pts_time=4.551111|dts=200704|dts_time=4.551111|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=195|pos=39906|flags=K_
+packet|codec_type=audio|stream_index=0|pts=201728|pts_time=4.574331|dts=201728|dts_time=4.574331|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=40101|flags=K_
+packet|codec_type=audio|stream_index=0|pts=202752|pts_time=4.597551|dts=202752|dts_time=4.597551|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=183|pos=40300|flags=K_
+packet|codec_type=audio|stream_index=0|pts=203776|pts_time=4.620771|dts=203776|dts_time=4.620771|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=211|pos=40483|flags=K_
+packet|codec_type=audio|stream_index=0|pts=204800|pts_time=4.643991|dts=204800|dts_time=4.643991|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=200|pos=40694|flags=K_
+packet|codec_type=audio|stream_index=0|pts=205824|pts_time=4.667211|dts=205824|dts_time=4.667211|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=40894|flags=K_
+packet|codec_type=audio|stream_index=0|pts=206848|pts_time=4.690431|dts=206848|dts_time=4.690431|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=213|pos=41093|flags=K_
+packet|codec_type=audio|stream_index=0|pts=207872|pts_time=4.713651|dts=207872|dts_time=4.713651|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=191|pos=41306|flags=K_
+packet|codec_type=audio|stream_index=0|pts=208896|pts_time=4.736871|dts=208896|dts_time=4.736871|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=211|pos=41497|flags=K_
+packet|codec_type=audio|stream_index=0|pts=209920|pts_time=4.760091|dts=209920|dts_time=4.760091|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=41708|flags=K_
+packet|codec_type=audio|stream_index=0|pts=210944|pts_time=4.783311|dts=210944|dts_time=4.783311|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=203|pos=41906|flags=K_
+packet|codec_type=audio|stream_index=0|pts=211968|pts_time=4.806531|dts=211968|dts_time=4.806531|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=196|pos=42109|flags=K_
+packet|codec_type=audio|stream_index=0|pts=212992|pts_time=4.829751|dts=212992|dts_time=4.829751|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=197|pos=42305|flags=K_
+packet|codec_type=audio|stream_index=0|pts=214016|pts_time=4.852971|dts=214016|dts_time=4.852971|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=190|pos=42502|flags=K_
+packet|codec_type=audio|stream_index=0|pts=215040|pts_time=4.876190|dts=215040|dts_time=4.876190|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=42692|flags=K_
+packet|codec_type=audio|stream_index=0|pts=216064|pts_time=4.899410|dts=216064|dts_time=4.899410|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=203|pos=42900|flags=K_
+packet|codec_type=audio|stream_index=0|pts=217088|pts_time=4.922630|dts=217088|dts_time=4.922630|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=198|pos=43103|flags=K_
+packet|codec_type=audio|stream_index=0|pts=218112|pts_time=4.945850|dts=218112|dts_time=4.945850|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=284|pos=43301|flags=K_
+packet|codec_type=audio|stream_index=0|pts=219136|pts_time=4.969070|dts=219136|dts_time=4.969070|duration=1364|duration_time=0.030930|convergence_duration=N/A|convergence_duration_time=N/A|size=5|pos=43585|flags=K_
diff --git a/tests/ref/fate/mov-init-nonkeyframe b/tests/ref/fate/mov-init-nonkeyframe
index 438f397..0e81846 100644
--- a/tests/ref/fate/mov-init-nonkeyframe
+++ b/tests/ref/fate/mov-init-nonkeyframe
@@ -1,120 +1,120 @@
-packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1001|duration_time=0.033367|size=599|pos=48|flags=__
-packet|codec_type=video|stream_index=0|pts=2002|pts_time=0.066733|dts=1001|dts_time=0.033367|duration=1001|duration_time=0.033367|size=2944|pos=1674|flags=__
-packet|codec_type=video|stream_index=0|pts=7007|pts_time=0.233567|dts=2002|dts_time=0.066733|duration=1001|duration_time=0.033367|size=21987|pos=5335|flags=__
-packet|codec_type=video|stream_index=0|pts=5005|pts_time=0.166833|dts=3003|dts_time=0.100100|duration=1001|duration_time=0.033367|size=4145|pos=28605|flags=__
-packet|codec_type=video|stream_index=0|pts=4004|pts_time=0.133467|dts=4004|dts_time=0.133467|duration=1001|duration_time=0.033367|size=3093|pos=33425|flags=__
-packet|codec_type=video|stream_index=0|pts=6006|pts_time=0.200200|dts=5005|dts_time=0.166833|duration=1001|duration_time=0.033367|size=572|pos=37769|flags=__
-packet|codec_type=video|stream_index=0|pts=11011|pts_time=0.367033|dts=6006|dts_time=0.200200|duration=1001|duration_time=0.033367|size=21599|pos=38999|flags=__
-packet|codec_type=video|stream_index=0|pts=9009|pts_time=0.300300|dts=7007|dts_time=0.233567|duration=1001|duration_time=0.033367|size=6287|pos=61922|flags=__
-packet|codec_type=video|stream_index=0|pts=8008|pts_time=0.266933|dts=8008|dts_time=0.266933|duration=1001|duration_time=0.033367|size=2720|pos=68909|flags=__
-packet|codec_type=video|stream_index=0|pts=10010|pts_time=0.333667|dts=9009|dts_time=0.300300|duration=1001|duration_time=0.033367|size=2715|pos=72301|flags=__
-packet|codec_type=video|stream_index=0|pts=15015|pts_time=0.500500|dts=10010|dts_time=0.333667|duration=1001|duration_time=0.033367|size=20221|pos=76433|flags=__
-packet|codec_type=video|stream_index=0|pts=13013|pts_time=0.433767|dts=11011|dts_time=0.367033|duration=1001|duration_time=0.033367|size=9505|pos=97381|flags=__
-packet|codec_type=video|stream_index=0|pts=12012|pts_time=0.400400|dts=12012|dts_time=0.400400|duration=1001|duration_time=0.033367|size=522|pos=108391|flags=__
-packet|codec_type=video|stream_index=0|pts=14014|pts_time=0.467133|dts=13013|dts_time=0.433767|duration=1001|duration_time=0.033367|size=2360|pos=109683|flags=__
-packet|codec_type=video|stream_index=0|pts=17017|pts_time=0.567233|dts=14014|dts_time=0.467133|duration=1001|duration_time=0.033367|size=22156|pos=113572|flags=__
-packet|codec_type=video|stream_index=0|pts=16016|pts_time=0.533867|dts=15015|dts_time=0.500500|duration=1001|duration_time=0.033367|size=1801|pos=136496|flags=__
-packet|codec_type=video|stream_index=0|pts=21021|pts_time=0.700700|dts=16016|dts_time=0.533867|duration=1001|duration_time=0.033367|size=20181|pos=139074|flags=__
-packet|codec_type=video|stream_index=0|pts=19019|pts_time=0.633967|dts=17017|dts_time=0.567233|duration=1001|duration_time=0.033367|size=3608|pos=160959|flags=__
-packet|codec_type=video|stream_index=0|pts=18018|pts_time=0.600600|dts=18018|dts_time=0.600600|duration=1001|duration_time=0.033367|size=368|pos=165305|flags=__
-packet|codec_type=video|stream_index=0|pts=20020|pts_time=0.667333|dts=19019|dts_time=0.633967|duration=1001|duration_time=0.033367|size=2989|pos=167054|flags=__
-packet|codec_type=video|stream_index=0|pts=25025|pts_time=0.834167|dts=20020|dts_time=0.667333|duration=1001|duration_time=0.033367|size=24475|pos=170801|flags=__
-packet|codec_type=video|stream_index=0|pts=23023|pts_time=0.767433|dts=21021|dts_time=0.700700|duration=1001|duration_time=0.033367|size=10682|pos=196732|flags=__
-packet|codec_type=video|stream_index=0|pts=22022|pts_time=0.734067|dts=22022|dts_time=0.734067|duration=1001|duration_time=0.033367|size=3198|pos=208151|flags=__
-packet|codec_type=video|stream_index=0|pts=24024|pts_time=0.800800|dts=23023|dts_time=0.767433|duration=1001|duration_time=0.033367|size=479|pos=212958|flags=__
-packet|codec_type=video|stream_index=0|pts=29029|pts_time=0.967633|dts=24024|dts_time=0.800800|duration=1001|duration_time=0.033367|size=21240|pos=214384|flags=__
-packet|codec_type=video|stream_index=0|pts=27027|pts_time=0.900900|dts=25025|dts_time=0.834167|duration=1001|duration_time=0.033367|size=4409|pos=236946|flags=__
-packet|codec_type=video|stream_index=0|pts=26026|pts_time=0.867533|dts=26026|dts_time=0.867533|duration=1001|duration_time=0.033367|size=3106|pos=242647|flags=__
-packet|codec_type=video|stream_index=0|pts=28028|pts_time=0.934267|dts=27027|dts_time=0.900900|duration=1001|duration_time=0.033367|size=453|pos=246428|flags=__
-packet|codec_type=video|stream_index=0|pts=33033|pts_time=1.101100|dts=28028|dts_time=0.934267|duration=1001|duration_time=0.033367|size=20668|pos=248308|flags=__
-packet|codec_type=video|stream_index=0|pts=31031|pts_time=1.034367|dts=29029|dts_time=0.967633|duration=1001|duration_time=0.033367|size=6668|pos=269708|flags=__
-packet|codec_type=video|stream_index=0|pts=30030|pts_time=1.001000|dts=30030|dts_time=1.001000|duration=1001|duration_time=0.033367|size=3027|pos=277789|flags=__
-packet|codec_type=video|stream_index=0|pts=32032|pts_time=1.067733|dts=31031|dts_time=1.034367|duration=1001|duration_time=0.033367|size=2884|pos=281613|flags=__
-packet|codec_type=video|stream_index=0|pts=37037|pts_time=1.234567|dts=32032|dts_time=1.067733|duration=1001|duration_time=0.033367|size=21313|pos=285261|flags=__
-packet|codec_type=video|stream_index=0|pts=35035|pts_time=1.167833|dts=33033|dts_time=1.101100|duration=1001|duration_time=0.033367|size=9890|pos=308303|flags=__
-packet|codec_type=video|stream_index=0|pts=34034|pts_time=1.134467|dts=34034|dts_time=1.134467|duration=1001|duration_time=0.033367|size=501|pos=318919|flags=__
-packet|codec_type=video|stream_index=0|pts=36036|pts_time=1.201200|dts=35035|dts_time=1.167833|duration=1001|duration_time=0.033367|size=3123|pos=320824|flags=__
-packet|codec_type=video|stream_index=0|pts=39039|pts_time=1.301300|dts=36036|dts_time=1.201200|duration=1001|duration_time=0.033367|size=21768|pos=324664|flags=__
-packet|codec_type=video|stream_index=0|pts=38038|pts_time=1.267933|dts=37037|dts_time=1.234567|duration=1001|duration_time=0.033367|size=2664|pos=347922|flags=__
-packet|codec_type=video|stream_index=0|pts=43043|pts_time=1.434767|dts=38038|dts_time=1.267933|duration=1001|duration_time=0.033367|size=19144|pos=351354|flags=__
-packet|codec_type=video|stream_index=0|pts=41041|pts_time=1.368033|dts=39039|dts_time=1.301300|duration=1001|duration_time=0.033367|size=4118|pos=371991|flags=__
-packet|codec_type=video|stream_index=0|pts=40040|pts_time=1.334667|dts=40040|dts_time=1.334667|duration=1001|duration_time=0.033367|size=423|pos=376899|flags=__
-packet|codec_type=video|stream_index=0|pts=42042|pts_time=1.401400|dts=41041|dts_time=1.368033|duration=1001|duration_time=0.033367|size=2785|pos=378037|flags=__
-packet|codec_type=video|stream_index=0|pts=45045|pts_time=1.501500|dts=42042|dts_time=1.401400|duration=1001|duration_time=0.033367|size=24489|pos=382144|flags=__
-packet|codec_type=video|stream_index=0|pts=44044|pts_time=1.468133|dts=43043|dts_time=1.434767|duration=1001|duration_time=0.033367|size=2984|pos=407344|flags=__
-packet|codec_type=video|stream_index=0|pts=49049|pts_time=1.634967|dts=44044|dts_time=1.468133|duration=1001|duration_time=0.033367|size=19174|pos=411791|flags=__
-packet|codec_type=video|stream_index=0|pts=47047|pts_time=1.568233|dts=45045|dts_time=1.501500|duration=1001|duration_time=0.033367|size=4905|pos=431740|flags=__
-packet|codec_type=video|stream_index=0|pts=46046|pts_time=1.534867|dts=46046|dts_time=1.534867|duration=1001|duration_time=0.033367|size=412|pos=438183|flags=__
-packet|codec_type=video|stream_index=0|pts=48048|pts_time=1.601600|dts=47047|dts_time=1.568233|duration=1001|duration_time=0.033367|size=3215|pos=439373|flags=__
-packet|codec_type=video|stream_index=0|pts=51051|pts_time=1.701700|dts=48048|dts_time=1.601600|duration=1001|duration_time=0.033367|size=21572|pos=443371|flags=__
-packet|codec_type=video|stream_index=0|pts=50050|pts_time=1.668333|dts=49049|dts_time=1.634967|duration=1001|duration_time=0.033367|size=2644|pos=466486|flags=__
-packet|codec_type=video|stream_index=0|pts=55055|pts_time=1.835167|dts=50050|dts_time=1.668333|duration=1001|duration_time=0.033367|size=19417|pos=470462|flags=__
-packet|codec_type=video|stream_index=0|pts=53053|pts_time=1.768433|dts=51051|dts_time=1.701700|duration=1001|duration_time=0.033367|size=3685|pos=491335|flags=__
-packet|codec_type=video|stream_index=0|pts=52052|pts_time=1.735067|dts=52052|dts_time=1.735067|duration=1001|duration_time=0.033367|size=355|pos=495771|flags=__
-packet|codec_type=video|stream_index=0|pts=54054|pts_time=1.801800|dts=53053|dts_time=1.768433|duration=1001|duration_time=0.033367|size=3021|pos=497714|flags=__
-packet|codec_type=video|stream_index=0|pts=59059|pts_time=1.968633|dts=54054|dts_time=1.801800|duration=1001|duration_time=0.033367|size=21464|pos=501431|flags=__
-packet|codec_type=video|stream_index=0|pts=57057|pts_time=1.901900|dts=55055|dts_time=1.835167|duration=1001|duration_time=0.033367|size=9340|pos=524392|flags=__
-packet|codec_type=video|stream_index=0|pts=56056|pts_time=1.868533|dts=56056|dts_time=1.868533|duration=1001|duration_time=0.033367|size=406|pos=534504|flags=__
-packet|codec_type=video|stream_index=0|pts=58058|pts_time=1.935267|dts=57057|dts_time=1.901900|duration=1001|duration_time=0.033367|size=3277|pos=535694|flags=__
-packet|codec_type=video|stream_index=0|pts=63063|pts_time=2.102100|dts=58058|dts_time=1.935267|duration=1001|duration_time=0.033367|size=21388|pos=541090|flags=__
-packet|codec_type=video|stream_index=0|pts=61061|pts_time=2.035367|dts=59059|dts_time=1.968633|duration=1001|duration_time=0.033367|size=4466|pos=563132|flags=__
-packet|codec_type=video|stream_index=0|pts=60060|pts_time=2.002000|dts=60060|dts_time=2.002000|duration=1001|duration_time=0.033367|size=3467|pos=569245|flags=__
-packet|codec_type=video|stream_index=0|pts=62062|pts_time=2.068733|dts=61061|dts_time=2.035367|duration=1001|duration_time=0.033367|size=499|pos=573478|flags=__
-packet|codec_type=video|stream_index=0|pts=67067|pts_time=2.235567|dts=62062|dts_time=2.068733|duration=1001|duration_time=0.033367|size=25972|pos=575469|flags=__
-packet|codec_type=video|stream_index=0|pts=65065|pts_time=2.168833|dts=63063|dts_time=2.102100|duration=1001|duration_time=0.033367|size=6643|pos=602163|flags=__
-packet|codec_type=video|stream_index=0|pts=64064|pts_time=2.135467|dts=64064|dts_time=2.135467|duration=1001|duration_time=0.033367|size=3069|pos=609558|flags=__
-packet|codec_type=video|stream_index=0|pts=66066|pts_time=2.202200|dts=65065|dts_time=2.168833|duration=1001|duration_time=0.033367|size=3049|pos=614133|flags=__
-packet|codec_type=video|stream_index=0|pts=68068|pts_time=2.268933|dts=66066|dts_time=2.202200|duration=1001|duration_time=0.033367|size=4559|pos=618551|flags=__
-packet|codec_type=video|stream_index=0|pts=72072|pts_time=2.402400|dts=67067|dts_time=2.235567|duration=1001|duration_time=0.033367|size=21251|pos=624621|flags=__
-packet|codec_type=video|stream_index=0|pts=70070|pts_time=2.335667|dts=68068|dts_time=2.268933|duration=1001|duration_time=0.033367|size=7108|pos=646657|flags=__
-packet|codec_type=video|stream_index=0|pts=69069|pts_time=2.302300|dts=69069|dts_time=2.302300|duration=1001|duration_time=0.033367|size=3250|pos=655299|flags=__
-packet|codec_type=video|stream_index=0|pts=71071|pts_time=2.369033|dts=70070|dts_time=2.335667|duration=1001|duration_time=0.033367|size=3365|pos=659310|flags=__
-packet|codec_type=video|stream_index=0|pts=73073|pts_time=2.435767|dts=71071|dts_time=2.369033|duration=1001|duration_time=0.033367|size=24803|pos=664201|flags=__
-packet|codec_type=video|stream_index=0|pts=77077|pts_time=2.569233|dts=72072|dts_time=2.402400|duration=1001|duration_time=0.033367|size=22185|pos=689763|flags=__
-packet|codec_type=video|stream_index=0|pts=75075|pts_time=2.502500|dts=73073|dts_time=2.435767|duration=1001|duration_time=0.033367|size=5088|pos=712679|flags=__
-packet|codec_type=video|stream_index=0|pts=74074|pts_time=2.469133|dts=74074|dts_time=2.469133|duration=1001|duration_time=0.033367|size=537|pos=719128|flags=__
-packet|codec_type=video|stream_index=0|pts=76076|pts_time=2.535867|dts=75075|dts_time=2.502500|duration=1001|duration_time=0.033367|size=3765|pos=720413|flags=__
-packet|codec_type=video|stream_index=0|pts=81081|pts_time=2.702700|dts=76076|dts_time=2.535867|duration=1001|duration_time=0.033367|size=20654|pos=725583|flags=__
-packet|codec_type=video|stream_index=0|pts=79079|pts_time=2.635967|dts=77077|dts_time=2.569233|duration=1001|duration_time=0.033367|size=10202|pos=746999|flags=__
-packet|codec_type=video|stream_index=0|pts=78078|pts_time=2.602600|dts=78078|dts_time=2.602600|duration=1001|duration_time=0.033367|size=3970|pos=758705|flags=__
-packet|codec_type=video|stream_index=0|pts=80080|pts_time=2.669333|dts=79079|dts_time=2.635967|duration=1001|duration_time=0.033367|size=421|pos=763442|flags=__
-packet|codec_type=video|stream_index=0|pts=84084|pts_time=2.802800|dts=80080|dts_time=2.669333|duration=1001|duration_time=0.033367|size=25685|pos=764653|flags=__
-packet|codec_type=video|stream_index=0|pts=82082|pts_time=2.736067|dts=81081|dts_time=2.702700|duration=1001|duration_time=0.033367|size=4077|pos=791911|flags=__
-packet|codec_type=video|stream_index=0|pts=83083|pts_time=2.769433|dts=82082|dts_time=2.736067|duration=1001|duration_time=0.033367|size=3049|pos=796780|flags=__
-packet|codec_type=video|stream_index=0|pts=88088|pts_time=2.936267|dts=83083|dts_time=2.769433|duration=1001|duration_time=0.033367|size=8924|pos=801473|flags=__
-packet|codec_type=video|stream_index=0|pts=86086|pts_time=2.869533|dts=84084|dts_time=2.802800|duration=1001|duration_time=0.033367|size=2512|pos=811078|flags=__
-packet|codec_type=video|stream_index=0|pts=85085|pts_time=2.836167|dts=85085|dts_time=2.836167|duration=1001|duration_time=0.033367|size=163|pos=815033|flags=__
-packet|codec_type=video|stream_index=0|pts=87087|pts_time=2.902900|dts=86086|dts_time=2.869533|duration=1001|duration_time=0.033367|size=1734|pos=815934|flags=__
-packet|codec_type=video|stream_index=0|pts=90090|pts_time=3.003000|dts=87087|dts_time=2.902900|duration=1001|duration_time=0.033367|size=11505|pos=819088|flags=__
-packet|codec_type=video|stream_index=0|pts=89089|pts_time=2.969633|dts=88088|dts_time=2.936267|duration=1001|duration_time=0.033367|size=1431|pos=831367|flags=__
-packet|codec_type=video|stream_index=0|pts=92092|pts_time=3.069733|dts=89089|dts_time=2.969633|duration=1001|duration_time=0.033367|size=5269|pos=833580|flags=__
-packet|codec_type=video|stream_index=0|pts=91091|pts_time=3.036367|dts=90090|dts_time=3.003000|duration=1001|duration_time=0.033367|size=199|pos=840352|flags=__
-packet|codec_type=video|stream_index=0|pts=93093|pts_time=3.103100|dts=91091|dts_time=3.036367|duration=1001|duration_time=0.033367|size=85650|pos=841722|flags=K_
-packet|codec_type=video|stream_index=0|pts=95095|pts_time=3.169833|dts=92092|dts_time=3.069733|duration=1001|duration_time=0.033367|size=13261|pos=928747|flags=__
-packet|codec_type=video|stream_index=0|pts=94094|pts_time=3.136467|dts=93093|dts_time=3.103100|duration=1001|duration_time=0.033367|size=1667|pos=942741|flags=__
-packet|codec_type=video|stream_index=0|pts=99099|pts_time=3.303300|dts=94094|dts_time=3.136467|duration=1001|duration_time=0.033367|size=20143|pos=945841|flags=__
-packet|codec_type=video|stream_index=0|pts=97097|pts_time=3.236567|dts=95095|dts_time=3.169833|duration=1001|duration_time=0.033367|size=2484|pos=966681|flags=__
-packet|codec_type=video|stream_index=0|pts=96096|pts_time=3.203200|dts=96096|dts_time=3.203200|duration=1001|duration_time=0.033367|size=278|pos=969887|flags=__
-packet|codec_type=video|stream_index=0|pts=98098|pts_time=3.269933|dts=97097|dts_time=3.236567|duration=1001|duration_time=0.033367|size=1539|pos=971696|flags=__
-packet|codec_type=video|stream_index=0|pts=101101|pts_time=3.370033|dts=98098|dts_time=3.269933|duration=1001|duration_time=0.033367|size=20270|pos=974088|flags=__
-packet|codec_type=video|stream_index=0|pts=100100|pts_time=3.336667|dts=99099|dts_time=3.303300|duration=1001|duration_time=0.033367|size=1754|pos=995975|flags=__
-packet|codec_type=video|stream_index=0|pts=105105|pts_time=3.503500|dts=100100|dts_time=3.336667|duration=1001|duration_time=0.033367|size=19154|pos=998420|flags=__
-packet|codec_type=video|stream_index=0|pts=103103|pts_time=3.436767|dts=101101|dts_time=3.370033|duration=1001|duration_time=0.033367|size=3359|pos=1019010|flags=__
-packet|codec_type=video|stream_index=0|pts=102102|pts_time=3.403400|dts=102102|dts_time=3.403400|duration=1001|duration_time=0.033367|size=287|pos=1023138|flags=__
-packet|codec_type=video|stream_index=0|pts=104104|pts_time=3.470133|dts=103103|dts_time=3.436767|duration=1001|duration_time=0.033367|size=2111|pos=1024928|flags=__
-packet|codec_type=video|stream_index=0|pts=109109|pts_time=3.636967|dts=104104|dts_time=3.470133|duration=1001|duration_time=0.033367|size=17178|pos=1027833|flags=__
-packet|codec_type=video|stream_index=0|pts=107107|pts_time=3.570233|dts=105105|dts_time=3.503500|duration=1001|duration_time=0.033367|size=7205|pos=1045716|flags=__
-packet|codec_type=video|stream_index=0|pts=106106|pts_time=3.536867|dts=106106|dts_time=3.536867|duration=1001|duration_time=0.033367|size=2209|pos=1054354|flags=__
-packet|codec_type=video|stream_index=0|pts=108108|pts_time=3.603600|dts=107107|dts_time=3.570233|duration=1001|duration_time=0.033367|size=359|pos=1057226|flags=__
-packet|codec_type=video|stream_index=0|pts=113113|pts_time=3.770433|dts=108108|dts_time=3.603600|duration=1001|duration_time=0.033367|size=18469|pos=1059024|flags=__
-packet|codec_type=video|stream_index=0|pts=111111|pts_time=3.703700|dts=109109|dts_time=3.636967|duration=1001|duration_time=0.033367|size=3314|pos=1078213|flags=__
-packet|codec_type=video|stream_index=0|pts=110110|pts_time=3.670333|dts=110110|dts_time=3.670333|duration=1001|duration_time=0.033367|size=2556|pos=1083059|flags=__
-packet|codec_type=video|stream_index=0|pts=112112|pts_time=3.737067|dts=111111|dts_time=3.703700|duration=1001|duration_time=0.033367|size=437|pos=1086388|flags=__
-packet|codec_type=video|stream_index=0|pts=117117|pts_time=3.903900|dts=112112|dts_time=3.737067|duration=1001|duration_time=0.033367|size=19707|pos=1087610|flags=__
-packet|codec_type=video|stream_index=0|pts=115115|pts_time=3.837167|dts=113113|dts_time=3.770433|duration=1001|duration_time=0.033367|size=5917|pos=1108845|flags=__
-packet|codec_type=video|stream_index=0|pts=114114|pts_time=3.803800|dts=114114|dts_time=3.803800|duration=1001|duration_time=0.033367|size=2613|pos=1115495|flags=__
-packet|codec_type=video|stream_index=0|pts=116116|pts_time=3.870533|dts=115115|dts_time=3.837167|duration=1001|duration_time=0.033367|size=2672|pos=1119530|flags=__
-packet|codec_type=video|stream_index=0|pts=121121|pts_time=4.037367|dts=116116|dts_time=3.870533|duration=1001|duration_time=0.033367|size=19091|pos=1122970|flags=_D
-packet|codec_type=video|stream_index=0|pts=119119|pts_time=3.970633|dts=117117|dts_time=3.903900|duration=1001|duration_time=0.033367|size=9244|pos=1143585|flags=__
-packet|codec_type=video|stream_index=0|pts=118118|pts_time=3.937267|dts=118118|dts_time=3.937267|duration=1001|duration_time=0.033367|size=284|pos=1153587|flags=__
-packet|codec_type=video|stream_index=0|pts=120120|pts_time=4.004000|dts=119119|dts_time=3.970633|duration=1001|duration_time=0.033367|size=2381|pos=1155393|flags=_D
+packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=599|pos=48|flags=__
+packet|codec_type=video|stream_index=0|pts=2002|pts_time=0.066733|dts=1001|dts_time=0.033367|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2944|pos=1674|flags=__
+packet|codec_type=video|stream_index=0|pts=7007|pts_time=0.233567|dts=2002|dts_time=0.066733|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21987|pos=5335|flags=__
+packet|codec_type=video|stream_index=0|pts=5005|pts_time=0.166833|dts=3003|dts_time=0.100100|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4145|pos=28605|flags=__
+packet|codec_type=video|stream_index=0|pts=4004|pts_time=0.133467|dts=4004|dts_time=0.133467|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3093|pos=33425|flags=__
+packet|codec_type=video|stream_index=0|pts=6006|pts_time=0.200200|dts=5005|dts_time=0.166833|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=572|pos=37769|flags=__
+packet|codec_type=video|stream_index=0|pts=11011|pts_time=0.367033|dts=6006|dts_time=0.200200|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21599|pos=38999|flags=__
+packet|codec_type=video|stream_index=0|pts=9009|pts_time=0.300300|dts=7007|dts_time=0.233567|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=6287|pos=61922|flags=__
+packet|codec_type=video|stream_index=0|pts=8008|pts_time=0.266933|dts=8008|dts_time=0.266933|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2720|pos=68909|flags=__
+packet|codec_type=video|stream_index=0|pts=10010|pts_time=0.333667|dts=9009|dts_time=0.300300|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2715|pos=72301|flags=__
+packet|codec_type=video|stream_index=0|pts=15015|pts_time=0.500500|dts=10010|dts_time=0.333667|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=20221|pos=76433|flags=__
+packet|codec_type=video|stream_index=0|pts=13013|pts_time=0.433767|dts=11011|dts_time=0.367033|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=9505|pos=97381|flags=__
+packet|codec_type=video|stream_index=0|pts=12012|pts_time=0.400400|dts=12012|dts_time=0.400400|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=522|pos=108391|flags=__
+packet|codec_type=video|stream_index=0|pts=14014|pts_time=0.467133|dts=13013|dts_time=0.433767|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2360|pos=109683|flags=__
+packet|codec_type=video|stream_index=0|pts=17017|pts_time=0.567233|dts=14014|dts_time=0.467133|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=22156|pos=113572|flags=__
+packet|codec_type=video|stream_index=0|pts=16016|pts_time=0.533867|dts=15015|dts_time=0.500500|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1801|pos=136496|flags=__
+packet|codec_type=video|stream_index=0|pts=21021|pts_time=0.700700|dts=16016|dts_time=0.533867|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=20181|pos=139074|flags=__
+packet|codec_type=video|stream_index=0|pts=19019|pts_time=0.633967|dts=17017|dts_time=0.567233|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3608|pos=160959|flags=__
+packet|codec_type=video|stream_index=0|pts=18018|pts_time=0.600600|dts=18018|dts_time=0.600600|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=368|pos=165305|flags=__
+packet|codec_type=video|stream_index=0|pts=20020|pts_time=0.667333|dts=19019|dts_time=0.633967|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2989|pos=167054|flags=__
+packet|codec_type=video|stream_index=0|pts=25025|pts_time=0.834167|dts=20020|dts_time=0.667333|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=24475|pos=170801|flags=__
+packet|codec_type=video|stream_index=0|pts=23023|pts_time=0.767433|dts=21021|dts_time=0.700700|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=10682|pos=196732|flags=__
+packet|codec_type=video|stream_index=0|pts=22022|pts_time=0.734067|dts=22022|dts_time=0.734067|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3198|pos=208151|flags=__
+packet|codec_type=video|stream_index=0|pts=24024|pts_time=0.800800|dts=23023|dts_time=0.767433|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=479|pos=212958|flags=__
+packet|codec_type=video|stream_index=0|pts=29029|pts_time=0.967633|dts=24024|dts_time=0.800800|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21240|pos=214384|flags=__
+packet|codec_type=video|stream_index=0|pts=27027|pts_time=0.900900|dts=25025|dts_time=0.834167|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4409|pos=236946|flags=__
+packet|codec_type=video|stream_index=0|pts=26026|pts_time=0.867533|dts=26026|dts_time=0.867533|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3106|pos=242647|flags=__
+packet|codec_type=video|stream_index=0|pts=28028|pts_time=0.934267|dts=27027|dts_time=0.900900|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=453|pos=246428|flags=__
+packet|codec_type=video|stream_index=0|pts=33033|pts_time=1.101100|dts=28028|dts_time=0.934267|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=20668|pos=248308|flags=__
+packet|codec_type=video|stream_index=0|pts=31031|pts_time=1.034367|dts=29029|dts_time=0.967633|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=6668|pos=269708|flags=__
+packet|codec_type=video|stream_index=0|pts=30030|pts_time=1.001000|dts=30030|dts_time=1.001000|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3027|pos=277789|flags=__
+packet|codec_type=video|stream_index=0|pts=32032|pts_time=1.067733|dts=31031|dts_time=1.034367|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2884|pos=281613|flags=__
+packet|codec_type=video|stream_index=0|pts=37037|pts_time=1.234567|dts=32032|dts_time=1.067733|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21313|pos=285261|flags=__
+packet|codec_type=video|stream_index=0|pts=35035|pts_time=1.167833|dts=33033|dts_time=1.101100|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=9890|pos=308303|flags=__
+packet|codec_type=video|stream_index=0|pts=34034|pts_time=1.134467|dts=34034|dts_time=1.134467|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=501|pos=318919|flags=__
+packet|codec_type=video|stream_index=0|pts=36036|pts_time=1.201200|dts=35035|dts_time=1.167833|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3123|pos=320824|flags=__
+packet|codec_type=video|stream_index=0|pts=39039|pts_time=1.301300|dts=36036|dts_time=1.201200|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21768|pos=324664|flags=__
+packet|codec_type=video|stream_index=0|pts=38038|pts_time=1.267933|dts=37037|dts_time=1.234567|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2664|pos=347922|flags=__
+packet|codec_type=video|stream_index=0|pts=43043|pts_time=1.434767|dts=38038|dts_time=1.267933|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=19144|pos=351354|flags=__
+packet|codec_type=video|stream_index=0|pts=41041|pts_time=1.368033|dts=39039|dts_time=1.301300|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4118|pos=371991|flags=__
+packet|codec_type=video|stream_index=0|pts=40040|pts_time=1.334667|dts=40040|dts_time=1.334667|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=423|pos=376899|flags=__
+packet|codec_type=video|stream_index=0|pts=42042|pts_time=1.401400|dts=41041|dts_time=1.368033|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2785|pos=378037|flags=__
+packet|codec_type=video|stream_index=0|pts=45045|pts_time=1.501500|dts=42042|dts_time=1.401400|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=24489|pos=382144|flags=__
+packet|codec_type=video|stream_index=0|pts=44044|pts_time=1.468133|dts=43043|dts_time=1.434767|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2984|pos=407344|flags=__
+packet|codec_type=video|stream_index=0|pts=49049|pts_time=1.634967|dts=44044|dts_time=1.468133|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=19174|pos=411791|flags=__
+packet|codec_type=video|stream_index=0|pts=47047|pts_time=1.568233|dts=45045|dts_time=1.501500|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4905|pos=431740|flags=__
+packet|codec_type=video|stream_index=0|pts=46046|pts_time=1.534867|dts=46046|dts_time=1.534867|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=412|pos=438183|flags=__
+packet|codec_type=video|stream_index=0|pts=48048|pts_time=1.601600|dts=47047|dts_time=1.568233|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3215|pos=439373|flags=__
+packet|codec_type=video|stream_index=0|pts=51051|pts_time=1.701700|dts=48048|dts_time=1.601600|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21572|pos=443371|flags=__
+packet|codec_type=video|stream_index=0|pts=50050|pts_time=1.668333|dts=49049|dts_time=1.634967|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2644|pos=466486|flags=__
+packet|codec_type=video|stream_index=0|pts=55055|pts_time=1.835167|dts=50050|dts_time=1.668333|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=19417|pos=470462|flags=__
+packet|codec_type=video|stream_index=0|pts=53053|pts_time=1.768433|dts=51051|dts_time=1.701700|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3685|pos=491335|flags=__
+packet|codec_type=video|stream_index=0|pts=52052|pts_time=1.735067|dts=52052|dts_time=1.735067|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=355|pos=495771|flags=__
+packet|codec_type=video|stream_index=0|pts=54054|pts_time=1.801800|dts=53053|dts_time=1.768433|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3021|pos=497714|flags=__
+packet|codec_type=video|stream_index=0|pts=59059|pts_time=1.968633|dts=54054|dts_time=1.801800|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21464|pos=501431|flags=__
+packet|codec_type=video|stream_index=0|pts=57057|pts_time=1.901900|dts=55055|dts_time=1.835167|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=9340|pos=524392|flags=__
+packet|codec_type=video|stream_index=0|pts=56056|pts_time=1.868533|dts=56056|dts_time=1.868533|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=406|pos=534504|flags=__
+packet|codec_type=video|stream_index=0|pts=58058|pts_time=1.935267|dts=57057|dts_time=1.901900|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3277|pos=535694|flags=__
+packet|codec_type=video|stream_index=0|pts=63063|pts_time=2.102100|dts=58058|dts_time=1.935267|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21388|pos=541090|flags=__
+packet|codec_type=video|stream_index=0|pts=61061|pts_time=2.035367|dts=59059|dts_time=1.968633|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4466|pos=563132|flags=__
+packet|codec_type=video|stream_index=0|pts=60060|pts_time=2.002000|dts=60060|dts_time=2.002000|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3467|pos=569245|flags=__
+packet|codec_type=video|stream_index=0|pts=62062|pts_time=2.068733|dts=61061|dts_time=2.035367|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=499|pos=573478|flags=__
+packet|codec_type=video|stream_index=0|pts=67067|pts_time=2.235567|dts=62062|dts_time=2.068733|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=25972|pos=575469|flags=__
+packet|codec_type=video|stream_index=0|pts=65065|pts_time=2.168833|dts=63063|dts_time=2.102100|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=6643|pos=602163|flags=__
+packet|codec_type=video|stream_index=0|pts=64064|pts_time=2.135467|dts=64064|dts_time=2.135467|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3069|pos=609558|flags=__
+packet|codec_type=video|stream_index=0|pts=66066|pts_time=2.202200|dts=65065|dts_time=2.168833|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3049|pos=614133|flags=__
+packet|codec_type=video|stream_index=0|pts=68068|pts_time=2.268933|dts=66066|dts_time=2.202200|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4559|pos=618551|flags=__
+packet|codec_type=video|stream_index=0|pts=72072|pts_time=2.402400|dts=67067|dts_time=2.235567|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=21251|pos=624621|flags=__
+packet|codec_type=video|stream_index=0|pts=70070|pts_time=2.335667|dts=68068|dts_time=2.268933|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=7108|pos=646657|flags=__
+packet|codec_type=video|stream_index=0|pts=69069|pts_time=2.302300|dts=69069|dts_time=2.302300|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3250|pos=655299|flags=__
+packet|codec_type=video|stream_index=0|pts=71071|pts_time=2.369033|dts=70070|dts_time=2.335667|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3365|pos=659310|flags=__
+packet|codec_type=video|stream_index=0|pts=73073|pts_time=2.435767|dts=71071|dts_time=2.369033|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=24803|pos=664201|flags=__
+packet|codec_type=video|stream_index=0|pts=77077|pts_time=2.569233|dts=72072|dts_time=2.402400|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=22185|pos=689763|flags=__
+packet|codec_type=video|stream_index=0|pts=75075|pts_time=2.502500|dts=73073|dts_time=2.435767|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=5088|pos=712679|flags=__
+packet|codec_type=video|stream_index=0|pts=74074|pts_time=2.469133|dts=74074|dts_time=2.469133|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=537|pos=719128|flags=__
+packet|codec_type=video|stream_index=0|pts=76076|pts_time=2.535867|dts=75075|dts_time=2.502500|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3765|pos=720413|flags=__
+packet|codec_type=video|stream_index=0|pts=81081|pts_time=2.702700|dts=76076|dts_time=2.535867|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=20654|pos=725583|flags=__
+packet|codec_type=video|stream_index=0|pts=79079|pts_time=2.635967|dts=77077|dts_time=2.569233|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=10202|pos=746999|flags=__
+packet|codec_type=video|stream_index=0|pts=78078|pts_time=2.602600|dts=78078|dts_time=2.602600|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3970|pos=758705|flags=__
+packet|codec_type=video|stream_index=0|pts=80080|pts_time=2.669333|dts=79079|dts_time=2.635967|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=421|pos=763442|flags=__
+packet|codec_type=video|stream_index=0|pts=84084|pts_time=2.802800|dts=80080|dts_time=2.669333|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=25685|pos=764653|flags=__
+packet|codec_type=video|stream_index=0|pts=82082|pts_time=2.736067|dts=81081|dts_time=2.702700|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4077|pos=791911|flags=__
+packet|codec_type=video|stream_index=0|pts=83083|pts_time=2.769433|dts=82082|dts_time=2.736067|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3049|pos=796780|flags=__
+packet|codec_type=video|stream_index=0|pts=88088|pts_time=2.936267|dts=83083|dts_time=2.769433|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=8924|pos=801473|flags=__
+packet|codec_type=video|stream_index=0|pts=86086|pts_time=2.869533|dts=84084|dts_time=2.802800|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2512|pos=811078|flags=__
+packet|codec_type=video|stream_index=0|pts=85085|pts_time=2.836167|dts=85085|dts_time=2.836167|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=163|pos=815033|flags=__
+packet|codec_type=video|stream_index=0|pts=87087|pts_time=2.902900|dts=86086|dts_time=2.869533|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1734|pos=815934|flags=__
+packet|codec_type=video|stream_index=0|pts=90090|pts_time=3.003000|dts=87087|dts_time=2.902900|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=11505|pos=819088|flags=__
+packet|codec_type=video|stream_index=0|pts=89089|pts_time=2.969633|dts=88088|dts_time=2.936267|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1431|pos=831367|flags=__
+packet|codec_type=video|stream_index=0|pts=92092|pts_time=3.069733|dts=89089|dts_time=2.969633|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=5269|pos=833580|flags=__
+packet|codec_type=video|stream_index=0|pts=91091|pts_time=3.036367|dts=90090|dts_time=3.003000|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=840352|flags=__
+packet|codec_type=video|stream_index=0|pts=93093|pts_time=3.103100|dts=91091|dts_time=3.036367|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=85650|pos=841722|flags=K_
+packet|codec_type=video|stream_index=0|pts=95095|pts_time=3.169833|dts=92092|dts_time=3.069733|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=13261|pos=928747|flags=__
+packet|codec_type=video|stream_index=0|pts=94094|pts_time=3.136467|dts=93093|dts_time=3.103100|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1667|pos=942741|flags=__
+packet|codec_type=video|stream_index=0|pts=99099|pts_time=3.303300|dts=94094|dts_time=3.136467|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=20143|pos=945841|flags=__
+packet|codec_type=video|stream_index=0|pts=97097|pts_time=3.236567|dts=95095|dts_time=3.169833|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2484|pos=966681|flags=__
+packet|codec_type=video|stream_index=0|pts=96096|pts_time=3.203200|dts=96096|dts_time=3.203200|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=278|pos=969887|flags=__
+packet|codec_type=video|stream_index=0|pts=98098|pts_time=3.269933|dts=97097|dts_time=3.236567|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1539|pos=971696|flags=__
+packet|codec_type=video|stream_index=0|pts=101101|pts_time=3.370033|dts=98098|dts_time=3.269933|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=20270|pos=974088|flags=__
+packet|codec_type=video|stream_index=0|pts=100100|pts_time=3.336667|dts=99099|dts_time=3.303300|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1754|pos=995975|flags=__
+packet|codec_type=video|stream_index=0|pts=105105|pts_time=3.503500|dts=100100|dts_time=3.336667|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=19154|pos=998420|flags=__
+packet|codec_type=video|stream_index=0|pts=103103|pts_time=3.436767|dts=101101|dts_time=3.370033|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3359|pos=1019010|flags=__
+packet|codec_type=video|stream_index=0|pts=102102|pts_time=3.403400|dts=102102|dts_time=3.403400|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=287|pos=1023138|flags=__
+packet|codec_type=video|stream_index=0|pts=104104|pts_time=3.470133|dts=103103|dts_time=3.436767|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2111|pos=1024928|flags=__
+packet|codec_type=video|stream_index=0|pts=109109|pts_time=3.636967|dts=104104|dts_time=3.470133|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=17178|pos=1027833|flags=__
+packet|codec_type=video|stream_index=0|pts=107107|pts_time=3.570233|dts=105105|dts_time=3.503500|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=7205|pos=1045716|flags=__
+packet|codec_type=video|stream_index=0|pts=106106|pts_time=3.536867|dts=106106|dts_time=3.536867|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2209|pos=1054354|flags=__
+packet|codec_type=video|stream_index=0|pts=108108|pts_time=3.603600|dts=107107|dts_time=3.570233|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=359|pos=1057226|flags=__
+packet|codec_type=video|stream_index=0|pts=113113|pts_time=3.770433|dts=108108|dts_time=3.603600|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=18469|pos=1059024|flags=__
+packet|codec_type=video|stream_index=0|pts=111111|pts_time=3.703700|dts=109109|dts_time=3.636967|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3314|pos=1078213|flags=__
+packet|codec_type=video|stream_index=0|pts=110110|pts_time=3.670333|dts=110110|dts_time=3.670333|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2556|pos=1083059|flags=__
+packet|codec_type=video|stream_index=0|pts=112112|pts_time=3.737067|dts=111111|dts_time=3.703700|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=437|pos=1086388|flags=__
+packet|codec_type=video|stream_index=0|pts=117117|pts_time=3.903900|dts=112112|dts_time=3.737067|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=19707|pos=1087610|flags=__
+packet|codec_type=video|stream_index=0|pts=115115|pts_time=3.837167|dts=113113|dts_time=3.770433|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=5917|pos=1108845|flags=__
+packet|codec_type=video|stream_index=0|pts=114114|pts_time=3.803800|dts=114114|dts_time=3.803800|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2613|pos=1115495|flags=__
+packet|codec_type=video|stream_index=0|pts=116116|pts_time=3.870533|dts=115115|dts_time=3.837167|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2672|pos=1119530|flags=__
+packet|codec_type=video|stream_index=0|pts=121121|pts_time=4.037367|dts=116116|dts_time=3.870533|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=19091|pos=1122970|flags=_D
+packet|codec_type=video|stream_index=0|pts=119119|pts_time=3.970633|dts=117117|dts_time=3.903900|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=9244|pos=1143585|flags=__
+packet|codec_type=video|stream_index=0|pts=118118|pts_time=3.937267|dts=118118|dts_time=3.937267|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=284|pos=1153587|flags=__
+packet|codec_type=video|stream_index=0|pts=120120|pts_time=4.004000|dts=119119|dts_time=3.970633|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2381|pos=1155393|flags=_D
diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
index f4415fe..c566b14 100644
--- a/tests/ref/fate/mov-zombie
+++ b/tests/ref/fate/mov-zombie
@@ -1,198 +1,198 @@
-packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|size=4133|pos=11309|flags=K_
-packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|size=1077|pos=15442|flags=__
+packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
+packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__
 frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.000000|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.000000|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=2437|pts_time=0.027078|dts=2436|dts_time=0.027067|duration=3003|duration_time=0.033367|size=355|pos=16519|flags=__
+packet|codec_type=video|stream_index=0|pts=2437|pts_time=0.027078|dts=2436|dts_time=0.027067|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=355|pos=16519|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=2437|pkt_pts_time=0.027078|pkt_dts=2436|pkt_dts_time=0.027067|best_effort_timestamp=2437|best_effort_timestamp_time=0.027078|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=16519|pkt_size=355|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=2|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=11446|pts_time=0.127178|dts=5439|dts_time=0.060433|duration=3003|duration_time=0.033367|size=1110|pos=16874|flags=__
+packet|codec_type=video|stream_index=0|pts=11446|pts_time=0.127178|dts=5439|dts_time=0.060433|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1110|pos=16874|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=5440|pkt_pts_time=0.060444|pkt_dts=5439|pkt_dts_time=0.060433|best_effort_timestamp=5440|best_effort_timestamp_time=0.060444|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=15442|pkt_size=1077|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=1|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=8443|pts_time=0.093811|dts=8442|dts_time=0.093800|duration=3003|duration_time=0.033367|size=430|pos=17984|flags=__
+packet|codec_type=video|stream_index=0|pts=8443|pts_time=0.093811|dts=8442|dts_time=0.093800|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=430|pos=17984|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=8443|pkt_pts_time=0.093811|pkt_dts=8442|pkt_dts_time=0.093800|best_effort_timestamp=8443|best_effort_timestamp_time=0.093811|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=17984|pkt_size=430|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=4|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=17452|pts_time=0.193911|dts=11445|dts_time=0.127167|duration=3003|duration_time=0.033367|size=1485|pos=18414|flags=__
+packet|codec_type=video|stream_index=0|pts=17452|pts_time=0.193911|dts=11445|dts_time=0.127167|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1485|pos=18414|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=11446|pkt_pts_time=0.127178|pkt_dts=11445|pkt_dts_time=0.127167|best_effort_timestamp=11446|best_effort_timestamp_time=0.127178|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=16874|pkt_size=1110|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=3|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=14449|pts_time=0.160544|dts=14448|dts_time=0.160533|duration=3003|duration_time=0.033367|size=1005|pos=19899|flags=__
+packet|codec_type=video|stream_index=0|pts=14449|pts_time=0.160544|dts=14448|dts_time=0.160533|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1005|pos=19899|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=14449|pkt_pts_time=0.160544|pkt_dts=14448|pkt_dts_time=0.160533|best_effort_timestamp=14449|best_effort_timestamp_time=0.160544|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=19899|pkt_size=1005|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=6|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=23458|pts_time=0.260644|dts=17451|dts_time=0.193900|duration=3003|duration_time=0.033367|size=1976|pos=20904|flags=__
+packet|codec_type=video|stream_index=0|pts=23458|pts_time=0.260644|dts=17451|dts_time=0.193900|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1976|pos=20904|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=17452|pkt_pts_time=0.193911|pkt_dts=17451|pkt_dts_time=0.193900|best_effort_timestamp=17452|best_effort_timestamp_time=0.193911|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=18414|pkt_size=1485|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=5|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=20455|pts_time=0.227278|dts=20454|dts_time=0.227267|duration=3003|duration_time=0.033367|size=904|pos=22880|flags=__
+packet|codec_type=video|stream_index=0|pts=20455|pts_time=0.227278|dts=20454|dts_time=0.227267|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=904|pos=22880|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=20455|pkt_pts_time=0.227278|pkt_dts=20454|pkt_dts_time=0.227267|best_effort_timestamp=20455|best_effort_timestamp_time=0.227278|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=22880|pkt_size=904|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=8|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=29464|pts_time=0.327378|dts=23457|dts_time=0.260633|duration=3003|duration_time=0.033367|size=1254|pos=23784|flags=__
+packet|codec_type=video|stream_index=0|pts=29464|pts_time=0.327378|dts=23457|dts_time=0.260633|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1254|pos=23784|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=23458|pkt_pts_time=0.260644|pkt_dts=23457|pkt_dts_time=0.260633|best_effort_timestamp=23458|best_effort_timestamp_time=0.260644|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=20904|pkt_size=1976|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=7|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=26461|pts_time=0.294011|dts=26460|dts_time=0.294000|duration=3003|duration_time=0.033367|size=700|pos=25038|flags=__
+packet|codec_type=video|stream_index=0|pts=26461|pts_time=0.294011|dts=26460|dts_time=0.294000|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=700|pos=25038|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=26461|pkt_pts_time=0.294011|pkt_dts=26460|pkt_dts_time=0.294000|best_effort_timestamp=26461|best_effort_timestamp_time=0.294011|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=25038|pkt_size=700|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=10|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=35470|pts_time=0.394111|dts=29463|dts_time=0.327367|duration=3003|duration_time=0.033367|size=1311|pos=25738|flags=__
+packet|codec_type=video|stream_index=0|pts=35470|pts_time=0.394111|dts=29463|dts_time=0.327367|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1311|pos=25738|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=29464|pkt_pts_time=0.327378|pkt_dts=29463|pkt_dts_time=0.327367|best_effort_timestamp=29464|best_effort_timestamp_time=0.327378|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=23784|pkt_size=1254|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=9|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=32467|pts_time=0.360744|dts=32466|dts_time=0.360733|duration=3003|duration_time=0.033367|size=631|pos=27049|flags=__
+packet|codec_type=video|stream_index=0|pts=32467|pts_time=0.360744|dts=32466|dts_time=0.360733|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=631|pos=27049|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=32467|pkt_pts_time=0.360744|pkt_dts=32466|pkt_dts_time=0.360733|best_effort_timestamp=32467|best_effort_timestamp_time=0.360744|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=27049|pkt_size=631|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=12|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=41476|pts_time=0.460844|dts=35469|dts_time=0.394100|duration=3003|duration_time=0.033367|size=1296|pos=27680|flags=__
+packet|codec_type=video|stream_index=0|pts=41476|pts_time=0.460844|dts=35469|dts_time=0.394100|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1296|pos=27680|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=35470|pkt_pts_time=0.394111|pkt_dts=35469|pkt_dts_time=0.394100|best_effort_timestamp=35470|best_effort_timestamp_time=0.394111|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=25738|pkt_size=1311|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=11|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=38473|pts_time=0.427478|dts=38472|dts_time=0.427467|duration=3003|duration_time=0.033367|size=466|pos=28976|flags=__
+packet|codec_type=video|stream_index=0|pts=38473|pts_time=0.427478|dts=38472|dts_time=0.427467|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=466|pos=28976|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=38473|pkt_pts_time=0.427478|pkt_dts=38472|pkt_dts_time=0.427467|best_effort_timestamp=38473|best_effort_timestamp_time=0.427478|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=28976|pkt_size=466|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=14|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=47482|pts_time=0.527578|dts=41475|dts_time=0.460833|duration=3003|duration_time=0.033367|size=1638|pos=29442|flags=__
+packet|codec_type=video|stream_index=0|pts=47482|pts_time=0.527578|dts=41475|dts_time=0.460833|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1638|pos=29442|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=41476|pkt_pts_time=0.460844|pkt_dts=41475|pkt_dts_time=0.460833|best_effort_timestamp=41476|best_effort_timestamp_time=0.460844|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=27680|pkt_size=1296|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=13|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=44479|pts_time=0.494211|dts=44478|dts_time=0.494200|duration=3003|duration_time=0.033367|size=907|pos=31080|flags=__
+packet|codec_type=video|stream_index=0|pts=44479|pts_time=0.494211|dts=44478|dts_time=0.494200|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=907|pos=31080|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=44479|pkt_pts_time=0.494211|pkt_dts=44478|pkt_dts_time=0.494200|best_effort_timestamp=44479|best_effort_timestamp_time=0.494211|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=31080|pkt_size=907|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=16|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=53488|pts_time=0.594311|dts=47481|dts_time=0.527567|duration=3003|duration_time=0.033367|size=1362|pos=31987|flags=__
+packet|codec_type=video|stream_index=0|pts=53488|pts_time=0.594311|dts=47481|dts_time=0.527567|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1362|pos=31987|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=47482|pkt_pts_time=0.527578|pkt_dts=47481|pkt_dts_time=0.527567|best_effort_timestamp=47482|best_effort_timestamp_time=0.527578|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=29442|pkt_size=1638|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=15|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=50485|pts_time=0.560944|dts=50484|dts_time=0.560933|duration=3003|duration_time=0.033367|size=682|pos=33349|flags=__
+packet|codec_type=video|stream_index=0|pts=50485|pts_time=0.560944|dts=50484|dts_time=0.560933|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=682|pos=33349|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=50485|pkt_pts_time=0.560944|pkt_dts=50484|pkt_dts_time=0.560933|best_effort_timestamp=50485|best_effort_timestamp_time=0.560944|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=33349|pkt_size=682|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=18|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=59494|pts_time=0.661044|dts=53487|dts_time=0.594300|duration=3003|duration_time=0.033367|size=2917|pos=34031|flags=__
+packet|codec_type=video|stream_index=0|pts=59494|pts_time=0.661044|dts=53487|dts_time=0.594300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2917|pos=34031|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=53488|pkt_pts_time=0.594311|pkt_dts=53487|pkt_dts_time=0.594300|best_effort_timestamp=53488|best_effort_timestamp_time=0.594311|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=31987|pkt_size=1362|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=17|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=56491|pts_time=0.627678|dts=56490|dts_time=0.627667|duration=3003|duration_time=0.033367|size=1174|pos=36948|flags=__
+packet|codec_type=video|stream_index=0|pts=56491|pts_time=0.627678|dts=56490|dts_time=0.627667|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1174|pos=36948|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=56491|pkt_pts_time=0.627678|pkt_dts=56490|pkt_dts_time=0.627667|best_effort_timestamp=56491|best_effort_timestamp_time=0.627678|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=36948|pkt_size=1174|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=20|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=65500|pts_time=0.727778|dts=59493|dts_time=0.661033|duration=3003|duration_time=0.033367|size=1748|pos=38122|flags=__
+packet|codec_type=video|stream_index=0|pts=65500|pts_time=0.727778|dts=59493|dts_time=0.661033|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1748|pos=38122|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=59494|pkt_pts_time=0.661044|pkt_dts=59493|pkt_dts_time=0.661033|best_effort_timestamp=59494|best_effort_timestamp_time=0.661044|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=34031|pkt_size=2917|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=19|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=62497|pts_time=0.694411|dts=62496|dts_time=0.694400|duration=3003|duration_time=0.033367|size=926|pos=39870|flags=__
+packet|codec_type=video|stream_index=0|pts=62497|pts_time=0.694411|dts=62496|dts_time=0.694400|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=926|pos=39870|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=62497|pkt_pts_time=0.694411|pkt_dts=62496|pkt_dts_time=0.694400|best_effort_timestamp=62497|best_effort_timestamp_time=0.694411|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=39870|pkt_size=926|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=22|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=68503|pts_time=0.761144|dts=65499|dts_time=0.727767|duration=3003|duration_time=0.033367|size=918|pos=40796|flags=__
+packet|codec_type=video|stream_index=0|pts=68503|pts_time=0.761144|dts=65499|dts_time=0.727767|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=918|pos=40796|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=65500|pkt_pts_time=0.727778|pkt_dts=65499|pkt_dts_time=0.727767|best_effort_timestamp=65500|best_effort_timestamp_time=0.727778|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=38122|pkt_size=1748|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=21|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=71506|pts_time=0.794511|dts=68502|dts_time=0.761133|duration=3003|duration_time=0.033367|size=3846|pos=41714|flags=K_
+packet|codec_type=video|stream_index=0|pts=71506|pts_time=0.794511|dts=68502|dts_time=0.761133|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=3846|pos=41714|flags=K_
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=68503|pkt_pts_time=0.761144|pkt_dts=68502|pkt_dts_time=0.761133|best_effort_timestamp=68503|best_effort_timestamp_time=0.761144|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=40796|pkt_size=918|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=23|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=77512|pts_time=0.861244|dts=71505|dts_time=0.794500|duration=3003|duration_time=0.033367|size=1932|pos=45560|flags=__
+packet|codec_type=video|stream_index=0|pts=77512|pts_time=0.861244|dts=71505|dts_time=0.794500|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1932|pos=45560|flags=__
 frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=71506|pkt_pts_time=0.794511|pkt_dts=71505|pkt_dts_time=0.794500|best_effort_timestamp=71506|best_effort_timestamp_time=0.794511|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=41714|pkt_size=3846|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=24|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=74509|pts_time=0.827878|dts=74508|dts_time=0.827867|duration=3003|duration_time=0.033367|size=1159|pos=47492|flags=__
+packet|codec_type=video|stream_index=0|pts=74509|pts_time=0.827878|dts=74508|dts_time=0.827867|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1159|pos=47492|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=74509|pkt_pts_time=0.827878|pkt_dts=74508|pkt_dts_time=0.827867|best_effort_timestamp=74509|best_effort_timestamp_time=0.827878|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=47492|pkt_size=1159|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=26|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=83518|pts_time=0.927978|dts=77511|dts_time=0.861233|duration=3003|duration_time=0.033367|size=1522|pos=48651|flags=__
+packet|codec_type=video|stream_index=0|pts=83518|pts_time=0.927978|dts=77511|dts_time=0.861233|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1522|pos=48651|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=77512|pkt_pts_time=0.861244|pkt_dts=77511|pkt_dts_time=0.861233|best_effort_timestamp=77512|best_effort_timestamp_time=0.861244|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=45560|pkt_size=1932|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=25|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=80515|pts_time=0.894611|dts=80514|dts_time=0.894600|duration=3003|duration_time=0.033367|size=719|pos=50173|flags=__
+packet|codec_type=video|stream_index=0|pts=80515|pts_time=0.894611|dts=80514|dts_time=0.894600|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=719|pos=50173|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=80515|pkt_pts_time=0.894611|pkt_dts=80514|pkt_dts_time=0.894600|best_effort_timestamp=80515|best_effort_timestamp_time=0.894611|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=50173|pkt_size=719|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=28|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=89524|pts_time=0.994711|dts=83517|dts_time=0.927967|duration=3003|duration_time=0.033367|size=1700|pos=50892|flags=__
+packet|codec_type=video|stream_index=0|pts=89524|pts_time=0.994711|dts=83517|dts_time=0.927967|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1700|pos=50892|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=83518|pkt_pts_time=0.927978|pkt_dts=83517|pkt_dts_time=0.927967|best_effort_timestamp=83518|best_effort_timestamp_time=0.927978|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=48651|pkt_size=1522|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=27|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=86521|pts_time=0.961344|dts=86520|dts_time=0.961333|duration=3003|duration_time=0.033367|size=1099|pos=52592|flags=__
+packet|codec_type=video|stream_index=0|pts=86521|pts_time=0.961344|dts=86520|dts_time=0.961333|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1099|pos=52592|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=86521|pkt_pts_time=0.961344|pkt_dts=86520|pkt_dts_time=0.961333|best_effort_timestamp=86521|best_effort_timestamp_time=0.961344|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=52592|pkt_size=1099|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=30|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=95530|pts_time=1.061444|dts=89523|dts_time=0.994700|duration=3003|duration_time=0.033367|size=2558|pos=53691|flags=__
+packet|codec_type=video|stream_index=0|pts=95530|pts_time=1.061444|dts=89523|dts_time=0.994700|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2558|pos=53691|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=89524|pkt_pts_time=0.994711|pkt_dts=89523|pkt_dts_time=0.994700|best_effort_timestamp=89524|best_effort_timestamp_time=0.994711|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=50892|pkt_size=1700|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=29|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=92527|pts_time=1.028078|dts=92526|dts_time=1.028067|duration=3003|duration_time=0.033367|size=1008|pos=56249|flags=__
+packet|codec_type=video|stream_index=0|pts=92527|pts_time=1.028078|dts=92526|dts_time=1.028067|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1008|pos=56249|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=92527|pkt_pts_time=1.028078|pkt_dts=92526|pkt_dts_time=1.028067|best_effort_timestamp=92527|best_effort_timestamp_time=1.028078|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=56249|pkt_size=1008|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=32|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=101536|pts_time=1.128178|dts=95529|dts_time=1.061433|duration=3003|duration_time=0.033367|size=1236|pos=57257|flags=__
+packet|codec_type=video|stream_index=0|pts=101536|pts_time=1.128178|dts=95529|dts_time=1.061433|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1236|pos=57257|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=95530|pkt_pts_time=1.061444|pkt_dts=95529|pkt_dts_time=1.061433|best_effort_timestamp=95530|best_effort_timestamp_time=1.061444|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=53691|pkt_size=2558|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=31|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=98533|pts_time=1.094811|dts=98532|dts_time=1.094800|duration=3003|duration_time=0.033367|size=607|pos=58493|flags=__
+packet|codec_type=video|stream_index=0|pts=98533|pts_time=1.094811|dts=98532|dts_time=1.094800|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=607|pos=58493|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=98533|pkt_pts_time=1.094811|pkt_dts=98532|pkt_dts_time=1.094800|best_effort_timestamp=98533|best_effort_timestamp_time=1.094811|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=58493|pkt_size=607|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=34|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=107542|pts_time=1.194911|dts=101535|dts_time=1.128167|duration=3003|duration_time=0.033367|size=1883|pos=59100|flags=__
+packet|codec_type=video|stream_index=0|pts=107542|pts_time=1.194911|dts=101535|dts_time=1.128167|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1883|pos=59100|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=101536|pkt_pts_time=1.128178|pkt_dts=101535|pkt_dts_time=1.128167|best_effort_timestamp=101536|best_effort_timestamp_time=1.128178|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=57257|pkt_size=1236|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=33|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=104539|pts_time=1.161544|dts=104538|dts_time=1.161533|duration=3003|duration_time=0.033367|size=893|pos=60983|flags=__
+packet|codec_type=video|stream_index=0|pts=104539|pts_time=1.161544|dts=104538|dts_time=1.161533|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=893|pos=60983|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=104539|pkt_pts_time=1.161544|pkt_dts=104538|pkt_dts_time=1.161533|best_effort_timestamp=104539|best_effort_timestamp_time=1.161544|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=60983|pkt_size=893|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=36|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=113548|pts_time=1.261644|dts=107541|dts_time=1.194900|duration=3003|duration_time=0.033367|size=1305|pos=61876|flags=__
+packet|codec_type=video|stream_index=0|pts=113548|pts_time=1.261644|dts=107541|dts_time=1.194900|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1305|pos=61876|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=107542|pkt_pts_time=1.194911|pkt_dts=107541|pkt_dts_time=1.194900|best_effort_timestamp=107542|best_effort_timestamp_time=1.194911|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=59100|pkt_size=1883|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=35|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=110545|pts_time=1.228278|dts=110544|dts_time=1.228267|duration=3003|duration_time=0.033367|size=472|pos=63181|flags=__
+packet|codec_type=video|stream_index=0|pts=110545|pts_time=1.228278|dts=110544|dts_time=1.228267|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=472|pos=63181|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=110545|pkt_pts_time=1.228278|pkt_dts=110544|pkt_dts_time=1.228267|best_effort_timestamp=110545|best_effort_timestamp_time=1.228278|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=63181|pkt_size=472|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=38|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=119554|pts_time=1.328378|dts=113547|dts_time=1.261633|duration=3003|duration_time=0.033367|size=1411|pos=63653|flags=__
+packet|codec_type=video|stream_index=0|pts=119554|pts_time=1.328378|dts=113547|dts_time=1.261633|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1411|pos=63653|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=113548|pkt_pts_time=1.261644|pkt_dts=113547|pkt_dts_time=1.261633|best_effort_timestamp=113548|best_effort_timestamp_time=1.261644|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=61876|pkt_size=1305|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=37|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=116551|pts_time=1.295011|dts=116550|dts_time=1.295000|duration=3003|duration_time=0.033367|size=616|pos=65064|flags=__
+packet|codec_type=video|stream_index=0|pts=116551|pts_time=1.295011|dts=116550|dts_time=1.295000|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=616|pos=65064|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=116551|pkt_pts_time=1.295011|pkt_dts=116550|pkt_dts_time=1.295000|best_effort_timestamp=116551|best_effort_timestamp_time=1.295011|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=65064|pkt_size=616|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=40|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=125560|pts_time=1.395111|dts=119553|dts_time=1.328367|duration=3003|duration_time=0.033367|size=1291|pos=65680|flags=__
+packet|codec_type=video|stream_index=0|pts=125560|pts_time=1.395111|dts=119553|dts_time=1.328367|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1291|pos=65680|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=119554|pkt_pts_time=1.328378|pkt_dts=119553|pkt_dts_time=1.328367|best_effort_timestamp=119554|best_effort_timestamp_time=1.328378|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=63653|pkt_size=1411|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=39|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=122557|pts_time=1.361744|dts=122556|dts_time=1.361733|duration=3003|duration_time=0.033367|size=470|pos=66971|flags=__
+packet|codec_type=video|stream_index=0|pts=122557|pts_time=1.361744|dts=122556|dts_time=1.361733|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=470|pos=66971|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=122557|pkt_pts_time=1.361744|pkt_dts=122556|pkt_dts_time=1.361733|best_effort_timestamp=122557|best_effort_timestamp_time=1.361744|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=66971|pkt_size=470|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=42|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=131566|pts_time=1.461844|dts=125559|dts_time=1.395100|duration=3003|duration_time=0.033367|size=1977|pos=67441|flags=__
+packet|codec_type=video|stream_index=0|pts=131566|pts_time=1.461844|dts=125559|dts_time=1.395100|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1977|pos=67441|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=125560|pkt_pts_time=1.395111|pkt_dts=125559|pkt_dts_time=1.395100|best_effort_timestamp=125560|best_effort_timestamp_time=1.395111|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=65680|pkt_size=1291|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=41|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=128563|pts_time=1.428478|dts=128562|dts_time=1.428467|duration=3003|duration_time=0.033367|size=436|pos=69418|flags=__
+packet|codec_type=video|stream_index=0|pts=128563|pts_time=1.428478|dts=128562|dts_time=1.428467|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=436|pos=69418|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=128563|pkt_pts_time=1.428478|pkt_dts=128562|pkt_dts_time=1.428467|best_effort_timestamp=128563|best_effort_timestamp_time=1.428478|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=69418|pkt_size=436|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=44|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=137572|pts_time=1.528578|dts=131565|dts_time=1.461833|duration=3003|duration_time=0.033367|size=2566|pos=69854|flags=__
+packet|codec_type=video|stream_index=0|pts=137572|pts_time=1.528578|dts=131565|dts_time=1.461833|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2566|pos=69854|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=131566|pkt_pts_time=1.461844|pkt_dts=131565|pkt_dts_time=1.461833|best_effort_timestamp=131566|best_effort_timestamp_time=1.461844|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=67441|pkt_size=1977|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=43|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=134569|pts_time=1.495211|dts=134568|dts_time=1.495200|duration=3003|duration_time=0.033367|size=886|pos=72420|flags=__
+packet|codec_type=video|stream_index=0|pts=134569|pts_time=1.495211|dts=134568|dts_time=1.495200|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=886|pos=72420|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=134569|pkt_pts_time=1.495211|pkt_dts=134568|pkt_dts_time=1.495200|best_effort_timestamp=134569|best_effort_timestamp_time=1.495211|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=72420|pkt_size=886|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=46|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=140575|pts_time=1.561944|dts=137571|dts_time=1.528567|duration=3003|duration_time=0.033367|size=1330|pos=73306|flags=__
+packet|codec_type=video|stream_index=0|pts=140575|pts_time=1.561944|dts=137571|dts_time=1.528567|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1330|pos=73306|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=137572|pkt_pts_time=1.528578|pkt_dts=137571|pkt_dts_time=1.528567|best_effort_timestamp=137572|best_effort_timestamp_time=1.528578|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=69854|pkt_size=2566|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=45|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=143578|pts_time=1.595311|dts=140574|dts_time=1.561933|duration=3003|duration_time=0.033367|size=2227|pos=74636|flags=K_
+packet|codec_type=video|stream_index=0|pts=143578|pts_time=1.595311|dts=140574|dts_time=1.561933|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2227|pos=74636|flags=K_
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=140575|pkt_pts_time=1.561944|pkt_dts=140574|pkt_dts_time=1.561933|best_effort_timestamp=140575|best_effort_timestamp_time=1.561944|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=73306|pkt_size=1330|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=47|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=149584|pts_time=1.662044|dts=143577|dts_time=1.595300|duration=3003|duration_time=0.033367|size=2210|pos=76863|flags=__
+packet|codec_type=video|stream_index=0|pts=149584|pts_time=1.662044|dts=143577|dts_time=1.595300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2210|pos=76863|flags=__
 frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=143578|pkt_pts_time=1.595311|pkt_dts=143577|pkt_dts_time=1.595300|best_effort_timestamp=143578|best_effort_timestamp_time=1.595311|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=74636|pkt_size=2227|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=48|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=146581|pts_time=1.628678|dts=146580|dts_time=1.628667|duration=3003|duration_time=0.033367|size=1498|pos=79073|flags=__
+packet|codec_type=video|stream_index=0|pts=146581|pts_time=1.628678|dts=146580|dts_time=1.628667|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1498|pos=79073|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=146581|pkt_pts_time=1.628678|pkt_dts=146580|pkt_dts_time=1.628667|best_effort_timestamp=146581|best_effort_timestamp_time=1.628678|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=79073|pkt_size=1498|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=50|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=155590|pts_time=1.728778|dts=149583|dts_time=1.662033|duration=3003|duration_time=0.033367|size=1721|pos=80571|flags=__
+packet|codec_type=video|stream_index=0|pts=155590|pts_time=1.728778|dts=149583|dts_time=1.662033|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1721|pos=80571|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=149584|pkt_pts_time=1.662044|pkt_dts=149583|pkt_dts_time=1.662033|best_effort_timestamp=149584|best_effort_timestamp_time=1.662044|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=76863|pkt_size=2210|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=49|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=152587|pts_time=1.695411|dts=152586|dts_time=1.695400|duration=3003|duration_time=0.033367|size=1238|pos=82292|flags=__
+packet|codec_type=video|stream_index=0|pts=152587|pts_time=1.695411|dts=152586|dts_time=1.695400|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1238|pos=82292|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=152587|pkt_pts_time=1.695411|pkt_dts=152586|pkt_dts_time=1.695400|best_effort_timestamp=152587|best_effort_timestamp_time=1.695411|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=82292|pkt_size=1238|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=52|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=161596|pts_time=1.795511|dts=155589|dts_time=1.728767|duration=3003|duration_time=0.033367|size=1753|pos=83530|flags=__
+packet|codec_type=video|stream_index=0|pts=161596|pts_time=1.795511|dts=155589|dts_time=1.728767|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1753|pos=83530|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=155590|pkt_pts_time=1.728778|pkt_dts=155589|pkt_dts_time=1.728767|best_effort_timestamp=155590|best_effort_timestamp_time=1.728778|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=80571|pkt_size=1721|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=51|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=158593|pts_time=1.762144|dts=158592|dts_time=1.762133|duration=3003|duration_time=0.033367|size=1014|pos=85283|flags=__
+packet|codec_type=video|stream_index=0|pts=158593|pts_time=1.762144|dts=158592|dts_time=1.762133|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1014|pos=85283|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=158593|pkt_pts_time=1.762144|pkt_dts=158592|pkt_dts_time=1.762133|best_effort_timestamp=158593|best_effort_timestamp_time=1.762144|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=85283|pkt_size=1014|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=54|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=167602|pts_time=1.862244|dts=161595|dts_time=1.795500|duration=3003|duration_time=0.033367|size=2408|pos=86297|flags=__
+packet|codec_type=video|stream_index=0|pts=167602|pts_time=1.862244|dts=161595|dts_time=1.795500|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=2408|pos=86297|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=161596|pkt_pts_time=1.795511|pkt_dts=161595|pkt_dts_time=1.795500|best_effort_timestamp=161596|best_effort_timestamp_time=1.795511|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=83530|pkt_size=1753|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=53|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=164599|pts_time=1.828878|dts=164598|dts_time=1.828867|duration=3003|duration_time=0.033367|size=1727|pos=88705|flags=__
+packet|codec_type=video|stream_index=0|pts=164599|pts_time=1.828878|dts=164598|dts_time=1.828867|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1727|pos=88705|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=164599|pkt_pts_time=1.828878|pkt_dts=164598|pkt_dts_time=1.828867|best_effort_timestamp=164599|best_effort_timestamp_time=1.828878|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=88705|pkt_size=1727|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=56|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=173608|pts_time=1.928978|dts=167601|dts_time=1.862233|duration=3003|duration_time=0.033367|size=1504|pos=90432|flags=__
+packet|codec_type=video|stream_index=0|pts=173608|pts_time=1.928978|dts=167601|dts_time=1.862233|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1504|pos=90432|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=167602|pkt_pts_time=1.862244|pkt_dts=167601|pkt_dts_time=1.862233|best_effort_timestamp=167602|best_effort_timestamp_time=1.862244|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=86297|pkt_size=2408|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=55|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=170605|pts_time=1.895611|dts=170604|dts_time=1.895600|duration=3003|duration_time=0.033367|size=957|pos=91936|flags=__
+packet|codec_type=video|stream_index=0|pts=170605|pts_time=1.895611|dts=170604|dts_time=1.895600|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=957|pos=91936|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=170605|pkt_pts_time=1.895611|pkt_dts=170604|pkt_dts_time=1.895600|best_effort_timestamp=170605|best_effort_timestamp_time=1.895611|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=91936|pkt_size=957|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=58|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=179614|pts_time=1.995711|dts=173607|dts_time=1.928967|duration=3003|duration_time=0.033367|size=1890|pos=92893|flags=__
+packet|codec_type=video|stream_index=0|pts=179614|pts_time=1.995711|dts=173607|dts_time=1.928967|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1890|pos=92893|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=173608|pkt_pts_time=1.928978|pkt_dts=173607|pkt_dts_time=1.928967|best_effort_timestamp=173608|best_effort_timestamp_time=1.928978|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=90432|pkt_size=1504|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=57|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=176611|pts_time=1.962344|dts=176610|dts_time=1.962333|duration=3003|duration_time=0.033367|size=1239|pos=94783|flags=__
+packet|codec_type=video|stream_index=0|pts=176611|pts_time=1.962344|dts=176610|dts_time=1.962333|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1239|pos=94783|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=176611|pkt_pts_time=1.962344|pkt_dts=176610|pkt_dts_time=1.962333|best_effort_timestamp=176611|best_effort_timestamp_time=1.962344|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=94783|pkt_size=1239|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=60|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=185620|pts_time=2.062444|dts=179613|dts_time=1.995700|duration=3003|duration_time=0.033367|size=1856|pos=96022|flags=__
+packet|codec_type=video|stream_index=0|pts=185620|pts_time=2.062444|dts=179613|dts_time=1.995700|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1856|pos=96022|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=179614|pkt_pts_time=1.995711|pkt_dts=179613|pkt_dts_time=1.995700|best_effort_timestamp=179614|best_effort_timestamp_time=1.995711|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=92893|pkt_size=1890|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=59|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=182617|pts_time=2.029078|dts=182616|dts_time=2.029067|duration=3003|duration_time=0.033367|size=1302|pos=97878|flags=__
+packet|codec_type=video|stream_index=0|pts=182617|pts_time=2.029078|dts=182616|dts_time=2.029067|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1302|pos=97878|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=182617|pkt_pts_time=2.029078|pkt_dts=182616|pkt_dts_time=2.029067|best_effort_timestamp=182617|best_effort_timestamp_time=2.029078|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=97878|pkt_size=1302|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=62|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=191626|pts_time=2.129178|dts=185619|dts_time=2.062433|duration=3003|duration_time=0.033367|size=1666|pos=99180|flags=__
+packet|codec_type=video|stream_index=0|pts=191626|pts_time=2.129178|dts=185619|dts_time=2.062433|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1666|pos=99180|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=185620|pkt_pts_time=2.062444|pkt_dts=185619|pkt_dts_time=2.062433|best_effort_timestamp=185620|best_effort_timestamp_time=2.062444|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=96022|pkt_size=1856|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=61|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=188623|pts_time=2.095811|dts=188622|dts_time=2.095800|duration=3003|duration_time=0.033367|size=974|pos=100846|flags=__
+packet|codec_type=video|stream_index=0|pts=188623|pts_time=2.095811|dts=188622|dts_time=2.095800|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=974|pos=100846|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=188623|pkt_pts_time=2.095811|pkt_dts=188622|pkt_dts_time=2.095800|best_effort_timestamp=188623|best_effort_timestamp_time=2.095811|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=100846|pkt_size=974|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=B|coded_picture_number=64|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-packet|codec_type=video|stream_index=0|pts=197632|pts_time=2.195911|dts=191625|dts_time=2.129167|duration=3003|duration_time=0.033367|size=580|pos=101820|flags=__
+packet|codec_type=video|stream_index=0|pts=197632|pts_time=2.195911|dts=191625|dts_time=2.129167|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=580|pos=101820|flags=__
 frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=191626|pkt_pts_time=2.129178|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=191626|best_effort_timestamp_time=2.129178|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=99180|pkt_size=1666|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=63|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message
 
-stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_tag_string=avc1|codec_tag=0x31637661|width=160|height=240|coded_width=160|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=2:1|display_aspect_ratio=4:3|pix_fmt=yuv420p|level=12|color_range=tv|color_space=smpte170m|color_transfer=bt709|color_primaries=smpte170m|chroma_location=topleft|field_order=unknown|refs=2|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=6372000/212521|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=2125200|duration=23.613333|bit_rate=333874|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=708|nb_read_frames=65|nb_read_packets=66|disposition:default=1|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:rotate=0|tag:creation_time=2008-05-12T20:59:27.000000Z|tag:language=eng|tag:handler_name=Apple Video Media Handler|tag:vendor_id=appl|tag:encoder=H.264
+stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_time_base=212521/12744000|codec_tag_string=avc1|codec_tag=0x31637661|width=160|height=240|coded_width=160|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=2:1|display_aspect_ratio=4:3|pix_fmt=yuv420p|level=12|color_range=tv|color_space=smpte170m|color_transfer=bt709|color_primaries=smpte170m|chroma_location=topleft|field_order=unknown|timecode=N/A|refs=2|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=6372000/212521|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=2125200|duration=23.613333|bit_rate=333874|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=708|nb_read_frames=65|nb_read_packets=66|disposition:default=1|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:rotate=0|tag:creation_time=2008-05-12T20:59:27.000000Z|tag:language=eng|tag:handler_name=Apple Video Media Handler|tag:vendor_id=appl|tag:encoder=H.264
 side_data|side_data_type=Display Matrix|displaymatrix=\n00000000:       131072           0           0\n00000001:            0       65536           0\n00000002:            0           0  1073741824\n|rotation=0
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 81ea75f..6026391 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -7,7 +7,7 @@
 write_data len 2761, time nopts, type header atom -
 write_data len 908, time 966667, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-caf0876986b5f033efc0958c338289cc 3815 non-empty-moov-elst
+5b6e4211a45cd5dac99c8b90752a03d7 3815 non-empty-moov-elst
 write_data len 36, time nopts, type header atom ftyp
 write_data len 2669, time nopts, type header atom -
 write_data len 908, time 1000000, type sync atom moof
diff --git a/tests/ref/fate/mxf-d10-user-comments b/tests/ref/fate/mxf-d10-user-comments
index 13761fb..de4f26c 100644
--- a/tests/ref/fate/mxf-d10-user-comments
+++ b/tests/ref/fate/mxf-d10-user-comments
@@ -1,28 +1 @@
-6dc13ae283257e898e069e5041ac8435 *tests/data/fate/mxf-d10-user-comments.mxf_d10
-3782189 tests/data/fate/mxf-d10-user-comments.mxf_d10
-#extradata 0:       34, 0x716b05c4
-#tb 0: 1/25
-#media_type 0: video
-#codec_id 0: mpeg2video
-#dimensions 0: 1280x720
-#sar 0: 3/4
-0,         -1,          0,        1,   150000, 0x0547870d, S=1,       24, 0x5aa90ad0
-0,          0,          1,        1,   150000, 0xe80a1612, F=0x0
-0,          1,          2,        1,   150000, 0xc5c50e2f, F=0x0
-0,          2,          3,        1,   150000, 0x51e28a04, F=0x0
-0,          3,          4,        1,   150000, 0x9bbe6feb, F=0x0
-[FORMAT]
-TAG:operational_pattern_ul=060e2b34.04010101.0d010201.01010900
-TAG:uid=adab4424-2f25-4dc7-92ff-29bd000c0000
-TAG:generation_uid=adab4424-2f25-4dc7-92ff-29bd000c0001
-TAG:company_name=FATE-company
-TAG:product_name=FATE-test
-TAG:product_version_num=0.0.0.0.0
-TAG:product_version=3.14159
-TAG:application_platform=Lavf
-TAG:product_uid=adab4424-2f25-4dc7-92ff-29bd000c0002
-TAG:toolkit_version_num=0.0.0.0.0
-TAG:material_package_umid=0x060A2B340101010501010D001300000000000000000000000000000000000000
-TAG:comment_test=value
-TAG:timecode=01:00:00:00
-[/FORMAT]
+68f0fa62b6a676894afbbe4c34ebf70b
diff --git a/tests/ref/fate/mxf-opatom-user-comments b/tests/ref/fate/mxf-opatom-user-comments
index ec4fdff..90e3fb2 100644
--- a/tests/ref/fate/mxf-opatom-user-comments
+++ b/tests/ref/fate/mxf-opatom-user-comments
@@ -1 +1 @@
-8475bebf3448a972ae89ba59309fd7d6
+f6760a9e710ba478bc3949f3e5c9b34a
diff --git a/tests/ref/fate/mxf-probe-applehdr10 b/tests/ref/fate/mxf-probe-applehdr10
index 49ca72c..53a767c 100644
--- a/tests/ref/fate/mxf-probe-applehdr10
+++ b/tests/ref/fate/mxf-probe-applehdr10
@@ -3,6 +3,7 @@
 codec_name=prores
 profile=0
 codec_type=video
+codec_time_base=0/1
 codec_tag_string=apco
 codec_tag=0x6f637061
 width=1280
@@ -21,6 +22,7 @@
 color_primaries=bt2020
 chroma_location=unspecified
 field_order=progressive
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=60000/1001
@@ -73,6 +75,7 @@
 codec_name=pcm_s24le
 profile=unknown
 codec_type=audio
+codec_time_base=1/48000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 sample_fmt=s32
@@ -113,6 +116,7 @@
 codec_name=pcm_s24le
 profile=unknown
 codec_type=audio
+codec_time_base=1/48000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 sample_fmt=s32
@@ -160,7 +164,6 @@
 TAG:product_version=4.4.7 (4.4.7)
 TAG:product_uid=00000000-0000-0000-0000-000000000000
 TAG:modification_date=2020-09-08T16:18:57.036000Z
-TAG:toolkit_version_num=3.8.0.171.1
 TAG:material_package_umid=0x060A2B340101010501010D201300000045843C9FE69D4B8FA90DDAAA1602A2E8
 TAG:timecode=00:01:15;26
 [/FORMAT]
diff --git a/tests/ref/fate/mxf-probe-d10 b/tests/ref/fate/mxf-probe-d10
index 4958c40..17f4763 100644
--- a/tests/ref/fate/mxf-probe-d10
+++ b/tests/ref/fate/mxf-probe-d10
@@ -3,6 +3,7 @@
 codec_name=mpeg2video
 profile=0
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 width=720
@@ -21,6 +22,7 @@
 color_primaries=unknown
 chroma_location=topleft
 field_order=tt
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
@@ -58,6 +60,7 @@
 codec_name=pcm_s16le
 profile=unknown
 codec_type=audio
+codec_time_base=1/48000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 sample_fmt=s16
diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd
index f4c1988..5a6221b 100644
--- a/tests/ref/fate/mxf-probe-dnxhd
+++ b/tests/ref/fate/mxf-probe-dnxhd
@@ -111,6 +111,7 @@
 codec_name=dnxhd
 profile=1
 codec_type=video
+codec_time_base=0/1
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 width=640
@@ -129,6 +130,7 @@
 color_primaries=bt709
 chroma_location=unspecified
 field_order=progressive
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=24000/1001
@@ -171,11 +173,9 @@
 TAG:uid=784c8132-ae36-ed4d-b0ff-2edf1f3f2d92
 TAG:generation_uid=b6bcfcab-70ff-7331-c47c-478869de11d2
 TAG:application_platform=AAFSDK (MacOS X)
-TAG:toolkit_version_num=1.1.0.0.0
 TAG:modification_date=2016-09-18T19:25:25.000000Z
 TAG:product_uid=acfbf03a-4f42-a231-d0b7-c06ecd3d4ad7
 TAG:product_version=Unknown version
-TAG:product_version_num=8.6.0.0.1
 TAG:product_name=Avid Media Composer 8.6.3.43955
 TAG:company_name=Avid Technology, Inc.
 TAG:material_package_umid=0x060A2B340101010101010F001300000057DEEA1570665313060E2B347F7F2A80
diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25
index 7cc4c88..ffd26c4 100644
--- a/tests/ref/fate/mxf-probe-dv25
+++ b/tests/ref/fate/mxf-probe-dv25
@@ -3,6 +3,7 @@
 codec_name=dvvideo
 profile=unknown
 codec_type=video
+codec_time_base=1/25
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 width=720
@@ -21,6 +22,7 @@
 color_primaries=unknown
 chroma_location=topleft
 field_order=bb
+timecode=N/A
 refs=1
 id=N/A
 r_frame_rate=25/1
@@ -55,6 +57,7 @@
 codec_name=pcm_s16le
 profile=unknown
 codec_type=audio
+codec_time_base=1/48000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 sample_fmt=s16
@@ -95,6 +98,7 @@
 codec_name=pcm_s16le
 profile=unknown
 codec_type=audio
+codec_time_base=1/48000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 sample_fmt=s16
diff --git a/tests/ref/fate/mxf-reel_name b/tests/ref/fate/mxf-reel_name
index d50f0f6..16022b1 100644
--- a/tests/ref/fate/mxf-reel_name
+++ b/tests/ref/fate/mxf-reel_name
@@ -1 +1 @@
-ce49a0361d3f79106e1952d387eace51
+73a891041b2fc836a893ffb49fff4fff
diff --git a/tests/ref/fate/mxf-user-comments b/tests/ref/fate/mxf-user-comments
index 5fcdc58..ddf51d9 100644
--- a/tests/ref/fate/mxf-user-comments
+++ b/tests/ref/fate/mxf-user-comments
@@ -1 +1 @@
-956f653cd75e1a319569caec9df81b4f
+1255faf854223a74d707553121e5eca3
diff --git a/tests/ref/fate/sub-ttmlenc b/tests/ref/fate/sub-ttmlenc
deleted file mode 100644
index 51eab97..0000000
--- a/tests/ref/fate/sub-ttmlenc
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tt
-  xmlns="http://www.w3.org/ns/ttml"
-  xmlns:ttm="http://www.w3.org/ns/ttml#metadata"
-  xmlns:tts="http://www.w3.org/ns/ttml#styling"
-  xml:lang="">
-  <body>
-    <div>
-      <p
-        begin="00:00:00.000"
-        end="00:00:00.000">Don't show this text it may be used to insert hidden data</p>
-      <p
-        begin="00:00:01.500"
-        end="00:00:04.500">SubRip subtitles capability tester 1.3o by ale5000<br/>Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others<br/>This text should be blue<br/>This text should be red<br/>This text should be black<br/>If you see this with the normal font, the player don't (fully) support font face</p>
-      <p
-        begin="00:00:04.500"
-        end="00:00:04.500">Hidden</p>
-      <p
-        begin="00:00:04.501"
-        end="00:00:07.500">This text should be small<br/>This text should be normal<br/>This text should be big</p>
-      <p
-        begin="00:00:07.501"
-        end="00:00:11.500">This should be an E with an accent: È<br/>日本語<br/>This text should be bold, italics and underline<br/>This text should be small and green<br/>This text should be small and red<br/>This text should be big and brown</p>
-      <p
-        begin="00:00:11.501"
-        end="00:00:14.500">This line should be bold<br/>This line should be italics<br/>This line should be underline<br/>This line should be strikethrough<br/>Both lines<br/>should be underline</p>
-      <p
-        begin="00:00:14.501"
-        end="00:00:17.500">&gt;<br/>It would be a good thing to<br/>hide invalid html tags that are closed and show the text in them<br/>but show un-closed invalid html tags<br/>Show not opened tags<br/>&lt;</p>
-      <p
-        begin="00:00:17.501"
-        end="00:00:20.500">and also<br/>hide invalid html tags with parameters that are closed and show the text in them<br/>but show un-closed invalid html tags<br/>This text should be showed underlined without problems also: 2&lt;3,5&gt;1,4&lt;6<br/>This shouldn't be underlined</p>
-      <p
-        begin="00:00:20.501"
-        end="00:00:21.500">This text should be in the normal position...</p>
-      <p
-        begin="00:00:21.501"
-        end="00:00:22.500">This text should NOT be in the normal position</p>
-      <p
-        begin="00:00:22.501"
-        end="00:00:24.500">Implementation is the same of the ASS tag<br/>This text should be at the<br/>top and horizontally centered</p>
-      <p
-        begin="00:00:22.501"
-        end="00:00:24.500">This text should be at the<br/>middle and horizontally centered</p>
-      <p
-        begin="00:00:22.501"
-        end="00:00:24.500">This text should be at the<br/>bottom and horizontally centered</p>
-      <p
-        begin="00:00:24.501"
-        end="00:00:26.500">This text should be at the<br/>top and horizontally at the left</p>
-      <p
-        begin="00:00:24.501"
-        end="00:00:26.500">This text should be at the<br/>middle and horizontally at the left<br/>(The second position must be ignored)</p>
-      <p
-        begin="00:00:24.501"
-        end="00:00:26.500">This text should be at the<br/>bottom and horizontally at the left</p>
-      <p
-        begin="00:00:26.501"
-        end="00:00:28.500">This text should be at the<br/>top and horizontally at the right</p>
-      <p
-        begin="00:00:26.501"
-        end="00:00:28.500">This text should be at the<br/>middle and horizontally at the right</p>
-      <p
-        begin="00:00:26.501"
-        end="00:00:28.500">This text should be at the<br/>bottom and horizontally at the right</p>
-      <p
-        begin="00:00:28.501"
-        end="00:00:31.500">This could be the most difficult thing to implement</p>
-      <p
-        begin="00:00:31.501"
-        end="00:00:50.500">First text</p>
-      <p
-        begin="00:00:33.500"
-        end="00:00:35.500">Second, it shouldn't overlap first</p>
-      <p
-        begin="00:00:35.501"
-        end="00:00:37.500">Third, it should replace second</p>
-      <p
-        begin="00:00:36.501"
-        end="00:00:50.500">Fourth, it shouldn't overlap first and third</p>
-      <p
-        begin="00:00:40.501"
-        end="00:00:45.500">Fifth, it should replace third</p>
-      <p
-        begin="00:00:45.501"
-        end="00:00:50.500">Sixth, it shouldn't be<br/>showed overlapped</p>
-      <p
-        begin="00:00:50.501"
-        end="00:00:52.500">TEXT 1 (bottom)</p>
-      <p
-        begin="00:00:50.501"
-        end="00:00:52.500">text 2</p>
-      <p
-        begin="00:00:52.501"
-        end="00:00:54.500">Hide these tags:<br/>also hide these tags:<br/>but show this: {normal text}</p>
-      <p
-        begin="00:00:54.501"
-        end="00:01:00.500"><br/>\ N is a forced line break<br/>\ h is a hard space<br/>Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.<br/>The\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D</p>
-      <p
-        begin="00:00:54.501"
-        end="00:00:56.500"><br/>\h\h\h\h\hA (05 hard spaces followed by a letter)<br/>A (Normal  spaces followed by a letter)<br/>A (No hard spaces followed by a letter)</p>
-      <p
-        begin="00:00:56.501"
-        end="00:00:58.500">\h\h\h\h\hA (05 hard spaces followed by a letter)<br/>A (Normal  spaces followed by a letter)<br/>A (No hard spaces followed by a letter)<br/>Show this: \TEST and this: \-)</p>
-      <p
-        begin="00:00:58.501"
-        end="00:01:00.500"><br/>A letter followed by 05 hard spaces: A\h\h\h\h\h<br/>A letter followed by normal  spaces: A<br/>A letter followed by no hard spaces: A<br/>05 hard  spaces between letters: A\h\h\h\h\hA<br/>5 normal spaces between letters: A     A<br/><br/>^--Forced line break</p>
-      <p
-        begin="00:01:00.501"
-        end="00:01:02.500">Both line should be strikethrough,<br/>yes.<br/>Correctly closed tags<br/>should be hidden.</p>
-      <p
-        begin="00:01:02.501"
-        end="00:01:04.500">It shouldn't be strikethrough,<br/>not opened tag showed as text.<br/>Not opened tag showed as text.</p>
-      <p
-        begin="00:01:04.501"
-        end="00:01:06.500">Three lines should be strikethrough,<br/>yes.<br/>Not closed tags showed as text</p>
-      <p
-        begin="00:01:06.501"
-        end="00:01:08.500">Both line should be strikethrough but<br/>the wrong closing tag should be showed</p>
-    </div>
-  </body>
-</tt>
diff --git a/tests/ref/fate/time_base b/tests/ref/fate/time_base
index 28815d0..710fde1 100644
--- a/tests/ref/fate/time_base
+++ b/tests/ref/fate/time_base
@@ -1 +1 @@
-78ac0348027b75d73acb8bea14e67a59
+42863a53f6c63efbc8c5a2eb76f13f5f
diff --git a/tests/ref/fate/unknown_layout-ac3 b/tests/ref/fate/unknown_layout-ac3
index 719a44a..d332efc 100644
--- a/tests/ref/fate/unknown_layout-ac3
+++ b/tests/ref/fate/unknown_layout-ac3
@@ -1 +1 @@
-febdb165cfd6cba375aa086195e61213
+bbb7550d6d93973c10f4ee13c87cf799
diff --git a/tests/ref/lavf/gbrap.fits b/tests/ref/lavf/gbrap.fits
index 4662c3e..57c71e1 100644
--- a/tests/ref/lavf/gbrap.fits
+++ b/tests/ref/lavf/gbrap.fits
@@ -1,3 +1,3 @@
-d953a6a2c719de9d922d0624a7eb796b *tests/data/lavf/lavf.gbrap.fits
+28eb102547b82acca57ef097a6c639d8 *tests/data/lavf/lavf.gbrap.fits
 10224000 tests/data/lavf/lavf.gbrap.fits
 tests/data/lavf/lavf.gbrap.fits CRC=0x883af247
diff --git a/tests/ref/lavf/gbrap16be.fits b/tests/ref/lavf/gbrap16be.fits
index 7206d24..030a6d9 100644
--- a/tests/ref/lavf/gbrap16be.fits
+++ b/tests/ref/lavf/gbrap16be.fits
@@ -1,3 +1,3 @@
-e9a04d25104fc43ddc62b58eb33ecd08 *tests/data/lavf/lavf.gbrap16be.fits
+ff5fb24a67aeabd4f56088ca8b03d8b0 *tests/data/lavf/lavf.gbrap16be.fits
 20376000 tests/data/lavf/lavf.gbrap16be.fits
 tests/data/lavf/lavf.gbrap16be.fits CRC=0xa981271b
diff --git a/tests/ref/lavf/gbrp.fits b/tests/ref/lavf/gbrp.fits
index 54c2396..2b60ddb 100644
--- a/tests/ref/lavf/gbrp.fits
+++ b/tests/ref/lavf/gbrp.fits
@@ -1,3 +1,3 @@
-3952247f7f9669f968826c909852bbd7 *tests/data/lavf/lavf.gbrp.fits
+dae49b5f6eb58981ba91e3e108355717 *tests/data/lavf/lavf.gbrp.fits
 7704000 tests/data/lavf/lavf.gbrp.fits
 tests/data/lavf/lavf.gbrp.fits CRC=0x80745c5e
diff --git a/tests/ref/lavf/gbrp16be.fits b/tests/ref/lavf/gbrp16be.fits
index 5bec5e8..9aa9db6 100644
--- a/tests/ref/lavf/gbrp16be.fits
+++ b/tests/ref/lavf/gbrp16be.fits
@@ -1,3 +1,3 @@
-caf72fec125df9c7a1d59c9d1bc70b80 *tests/data/lavf/lavf.gbrp16be.fits
+693ea80c33eb9b348db27a0bc4a5cc8a *tests/data/lavf/lavf.gbrp16be.fits
 15336000 tests/data/lavf/lavf.gbrp16be.fits
 tests/data/lavf/lavf.gbrp16be.fits CRC=0x9573fb2b
diff --git a/tests/ref/lavf/gray.fits b/tests/ref/lavf/gray.fits
index 4104675..ce6783b 100644
--- a/tests/ref/lavf/gray.fits
+++ b/tests/ref/lavf/gray.fits
@@ -1,3 +1,3 @@
-e690dc6db533b87f5f843737007ed070 *tests/data/lavf/lavf.gray.fits
+d76b46a5a336b56f73451817cdf3897c *tests/data/lavf/lavf.gray.fits
 2664000 tests/data/lavf/lavf.gray.fits
 tests/data/lavf/lavf.gray.fits CRC=0x7aa0122f
diff --git a/tests/ref/lavf/gray16be.fits b/tests/ref/lavf/gray16be.fits
index a0526f3..058fa4a 100644
--- a/tests/ref/lavf/gray16be.fits
+++ b/tests/ref/lavf/gray16be.fits
@@ -1,3 +1,3 @@
-262658f437a256cd843db2b401bc20a9 *tests/data/lavf/lavf.gray16be.fits
+15e85a553bbd07783f92377ed369308b *tests/data/lavf/lavf.gray16be.fits
 5184000 tests/data/lavf/lavf.gray16be.fits
-tests/data/lavf/lavf.gray16be.fits CRC=0x737e8998
+tests/data/lavf/lavf.gray16be.fits CRC=0x8cdcbeb2
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 21bf2be..5b16496 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,9 +1,9 @@
-8938d5c4a396ff1b24d10d4f917ae1c9 *tests/data/lavf/lavf.mxf
+27b98795036b334e100c15c7e06d948f *tests/data/lavf/lavf.mxf
 526393 tests/data/lavf/lavf.mxf
 tests/data/lavf/lavf.mxf CRC=0x8dddfaab
-93ea2cfdf5dda7fffdc0d2fdcfb6a9a4 *tests/data/lavf/lavf.mxf
+783b475a818602f54e947094d57e2981 *tests/data/lavf/lavf.mxf
 561721 tests/data/lavf/lavf.mxf
 tests/data/lavf/lavf.mxf CRC=0x96ff1b48
-87bdf844ae34bcc758e44419e80177a0 *tests/data/lavf/lavf.mxf
+02bf8f0cd8951a49e277306691cb1538 *tests/data/lavf/lavf.mxf
 526393 tests/data/lavf/lavf.mxf
 tests/data/lavf/lavf.mxf CRC=0x8dddfaab
diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10
index 47ef244..3070161 100644
--- a/tests/ref/lavf/mxf_d10
+++ b/tests/ref/lavf/mxf_d10
@@ -1,3 +1,3 @@
-7f16902e28718c2a92bc082400a1c6ee *tests/data/lavf/lavf.mxf_d10
+da0ebbebb50a530b14c0f06017f464b3 *tests/data/lavf/lavf.mxf_d10
 5332013 tests/data/lavf/lavf.mxf_d10
 tests/data/lavf/lavf.mxf_d10 CRC=0x6c74d488
diff --git a/tests/ref/lavf/mxf_dv25 b/tests/ref/lavf/mxf_dv25
index 92509cf..d4559df 100644
--- a/tests/ref/lavf/mxf_dv25
+++ b/tests/ref/lavf/mxf_dv25
@@ -1,3 +1,3 @@
-106e33eb1634595623f0334e92204b65 *tests/data/lavf/lavf.mxf_dv25
+57623b3b968c0bb0d8a0bbaeef6fe657 *tests/data/lavf/lavf.mxf_dv25
 3834413 tests/data/lavf/lavf.mxf_dv25
 tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52
diff --git a/tests/ref/lavf/mxf_dvcpro50 b/tests/ref/lavf/mxf_dvcpro50
index 2d569b0..8bcf67d 100644
--- a/tests/ref/lavf/mxf_dvcpro50
+++ b/tests/ref/lavf/mxf_dvcpro50
@@ -1,3 +1,3 @@
-3d5a303c22666996700f0e8f6e4cb938 *tests/data/lavf/lavf.mxf_dvcpro50
+6e82b4cc962199e2593e30851ff7ccfb *tests/data/lavf/lavf.mxf_dvcpro50
 7431213 tests/data/lavf/lavf.mxf_dvcpro50
 tests/data/lavf/lavf.mxf_dvcpro50 CRC=0xe3bbe4b4
diff --git a/tests/ref/lavf/mxf_opatom b/tests/ref/lavf/mxf_opatom
index 61e7555..1aa843a 100644
--- a/tests/ref/lavf/mxf_opatom
+++ b/tests/ref/lavf/mxf_opatom
@@ -1,3 +1,3 @@
-5d235c127ace64b1f4fe6c79a7ca8be6 *tests/data/lavf/lavf.mxf_opatom
+d5f56215c2b16dee204f03bfa653dd1b *tests/data/lavf/lavf.mxf_opatom
 4717625 tests/data/lavf/lavf.mxf_opatom
 tests/data/lavf/lavf.mxf_opatom CRC=0xf55aa22a
diff --git a/tests/ref/lavf/mxf_opatom_audio b/tests/ref/lavf/mxf_opatom_audio
index 97362e7..2b9306f 100644
--- a/tests/ref/lavf/mxf_opatom_audio
+++ b/tests/ref/lavf/mxf_opatom_audio
@@ -1,3 +1,3 @@
-c356a3fdd49a1e015961678e837c12bb *tests/data/lavf/lavf.mxf_opatom_audio
+c45bb140605339556a77e751fda2c449 *tests/data/lavf/lavf.mxf_opatom_audio
 102969 tests/data/lavf/lavf.mxf_opatom_audio
 tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff
diff --git a/tests/ref/lavf/rm b/tests/ref/lavf/rm
index fc2a656..43ea4c7 100644
--- a/tests/ref/lavf/rm
+++ b/tests/ref/lavf/rm
@@ -1,2 +1,2 @@
-8dfb8d4556d61d3615e0d0012ffe540c *tests/data/lavf/lavf.rm
+e30681d05d6f3d24108d3614600bf116 *tests/data/lavf/lavf.rm
 346424 tests/data/lavf/lavf.rm
diff --git a/tests/ref/lavf/xbm b/tests/ref/lavf/xbm
index e54d6bc..bc15783 100644
--- a/tests/ref/lavf/xbm
+++ b/tests/ref/lavf/xbm
@@ -1,3 +1,3 @@
-83ed197cc88f382d9253365ffef70ec5 *tests/data/images/xbm/02.xbm
+0629055fd82366317c651a0af4bb82d7 *tests/data/images/xbm/02.xbm
 tests/data/images/xbm/%02d.xbm CRC=0xc9a20204
-76410 tests/data/images/xbm/02.xbm
+76411 tests/data/images/xbm/02.xbm
diff --git a/tools/ffescape.c b/tools/ffescape.c
index 1ed8daa..0530d28 100644
--- a/tools/ffescape.c
+++ b/tools/ffescape.c
@@ -78,10 +78,8 @@
             infilename = optarg;
             break;
         case 'f':
-            if      (!strcmp(optarg, "whitespace"))        escape_flags |= AV_ESCAPE_FLAG_WHITESPACE;
-            else if (!strcmp(optarg, "strict"))            escape_flags |= AV_ESCAPE_FLAG_STRICT;
-            else if (!strcmp(optarg, "xml_single_quotes")) escape_flags |= AV_ESCAPE_FLAG_XML_SINGLE_QUOTES;
-            else if (!strcmp(optarg, "xml_double_quotes")) escape_flags |= AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES;
+            if      (!strcmp(optarg, "whitespace")) escape_flags |= AV_ESCAPE_FLAG_WHITESPACE;
+            else if (!strcmp(optarg, "strict"))     escape_flags |= AV_ESCAPE_FLAG_STRICT;
             else {
                 av_log(NULL, AV_LOG_ERROR,
                        "Invalid value '%s' for option -f, "
@@ -106,7 +104,6 @@
             if      (!strcmp(optarg, "auto"))      escape_mode = AV_ESCAPE_MODE_AUTO;
             else if (!strcmp(optarg, "backslash")) escape_mode = AV_ESCAPE_MODE_BACKSLASH;
             else if (!strcmp(optarg, "quote"))     escape_mode = AV_ESCAPE_MODE_QUOTE;
-            else if (!strcmp(optarg, "xml"))       escape_mode = AV_ESCAPE_MODE_XML;
             else {
                 av_log(NULL, AV_LOG_ERROR,
                        "Invalid value '%s' for option -m, "
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 2372ed1..11530cb 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -88,17 +88,9 @@
     return ret;
 }
 
-static int audio_video_handler(AVCodecContext *avctx, AVFrame *frame,
-                               int *got_frame, const AVPacket *dummy)
-{
-    int ret = avcodec_receive_frame(avctx, frame);
-    *got_frame = ret >= 0;
-    return ret;
-}
-
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
-uint64_t maxpixels_per_frame = 4096 * 4096;
+const uint64_t maxpixels_per_frame = 4096 * 4096;
 uint64_t maxpixels;
 
 uint64_t maxsamples_per_frame = 256*1024*32;
@@ -141,8 +133,8 @@
     }
 
     switch (c->type) {
-    case AVMEDIA_TYPE_AUDIO   :
-    case AVMEDIA_TYPE_VIDEO   : decode_handler = audio_video_handler  ; break;
+    case AVMEDIA_TYPE_AUDIO   : decode_handler = avcodec_decode_audio4; break;
+    case AVMEDIA_TYPE_VIDEO   : decode_handler = avcodec_decode_video2; break;
     case AVMEDIA_TYPE_SUBTITLE: decode_handler = subtitle_handler     ; break;
     }
     switch (c->id) {
@@ -154,13 +146,11 @@
     case AV_CODEC_ID_AGM:         maxpixels  /= 1024;  break;
     case AV_CODEC_ID_BINKVIDEO:   maxpixels  /= 32;    break;
     case AV_CODEC_ID_CFHD:        maxpixels  /= 128;   break;
-    case AV_CODEC_ID_COOK:        maxsamples /= 1<<20; break;
     case AV_CODEC_ID_DIRAC:       maxpixels  /= 8192;  break;
     case AV_CODEC_ID_DST:         maxsamples /= 1<<20; break;
     case AV_CODEC_ID_DXV:         maxpixels  /= 32;    break;
     case AV_CODEC_ID_FFWAVESYNTH: maxsamples /= 16384; break;
-    case AV_CODEC_ID_FLV1:        maxpixels  /= 1024;  break;
-    case AV_CODEC_ID_G2M:         maxpixels  /= 1024;  break;
+    case AV_CODEC_ID_G2M:         maxpixels  /= 64;    break;
     case AV_CODEC_ID_GDV:         maxpixels  /= 512;   break;
     case AV_CODEC_ID_GIF:         maxpixels  /= 16;    break;
     case AV_CODEC_ID_HAP:         maxpixels  /= 128;   break;
@@ -168,12 +158,10 @@
     case AV_CODEC_ID_HNM4_VIDEO:  maxpixels  /= 128;   break;
     case AV_CODEC_ID_IFF_ILBM:    maxpixels  /= 128;   break;
     case AV_CODEC_ID_INDEO4:      maxpixels  /= 128;   break;
-    case AV_CODEC_ID_INTERPLAY_ACM: maxsamples /= 16384;  break;
     case AV_CODEC_ID_LAGARITH:    maxpixels  /= 1024;  break;
     case AV_CODEC_ID_LSCR:        maxpixels  /= 16;    break;
     case AV_CODEC_ID_MOTIONPIXELS:maxpixels  /= 256;   break;
     case AV_CODEC_ID_MP4ALS:      maxsamples /= 65536; break;
-    case AV_CODEC_ID_MSA1:        maxpixels  /= 16384; break;
     case AV_CODEC_ID_MSRLE:       maxpixels  /= 16;    break;
     case AV_CODEC_ID_MSS2:        maxpixels  /= 16384; break;
     case AV_CODEC_ID_MSZH:        maxpixels  /= 128;   break;
@@ -188,13 +176,9 @@
     case AV_CODEC_ID_SMACKVIDEO:  maxpixels  /= 64;    break;
     case AV_CODEC_ID_SNOW:        maxpixels  /= 128;   break;
     case AV_CODEC_ID_TGV:         maxpixels  /= 32;    break;
-    case AV_CODEC_ID_THEORA:      maxpixels  /= 1024;  break;
     case AV_CODEC_ID_TRUEMOTION2: maxpixels  /= 1024;  break;
-    case AV_CODEC_ID_VC1IMAGE:    maxpixels  /= 8192;  break;
-    case AV_CODEC_ID_VMNC:        maxpixels  /= 8192;  break;
     case AV_CODEC_ID_VP7:         maxpixels  /= 256;   break;
     case AV_CODEC_ID_VP9:         maxpixels  /= 4096;  break;
-    case AV_CODEC_ID_WAVPACK:     maxsamples /= 1024;  break;
     case AV_CODEC_ID_WMV3IMAGE:   maxpixels  /= 8192;  break;
     case AV_CODEC_ID_WS_VQA:      maxpixels  /= 16384; break;
     case AV_CODEC_ID_WMALOSSLESS: maxsamples /= 1024;  break;
@@ -202,7 +186,6 @@
     }
 
     maxsamples_per_frame = FFMIN(maxsamples_per_frame, maxsamples);
-    maxpixels_per_frame  = FFMIN(maxpixels_per_frame , maxpixels);
 
     AVCodecContext* ctx = avcodec_alloc_context3(c);
     AVCodecContext* parser_avctx = avcodec_alloc_context3(NULL);
@@ -211,6 +194,7 @@
 
     if (ctx->max_pixels == 0 || ctx->max_pixels > maxpixels_per_frame)
         ctx->max_pixels = maxpixels_per_frame; //To reduce false positive OOM and hangs
+    ctx->refcounted_frames = 1; //To reduce false positive timeouts and focus testing on the refcounted API
 
     ctx->max_samples = maxsamples_per_frame;
 
@@ -322,7 +306,6 @@
         last = data;
 
         while (parsepkt.size > 0) {
-            int decode_more;
 
             if (parser) {
                 av_init_packet(&avpkt);
@@ -355,21 +338,8 @@
               avcodec_flush_buffers(ctx);
           flushpattern = (flushpattern >> 3) + (flushpattern << 61);
 
-          if (ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
-              int ret = avcodec_send_packet(ctx, &avpkt);
-              decode_more = ret >= 0;
-              if(!decode_more) {
-                    ec_pixels += (ctx->width + 32LL) * (ctx->height + 32LL);
-                    if (it > 20 || ec_pixels > 4 * ctx->max_pixels)
-                        ctx->error_concealment = 0;
-                    if (ec_pixels > maxpixels)
-                        goto maximums_reached;
-              }
-          } else
-              decode_more = 1;
-
           // Iterate through all data
-          while (decode_more && it++ < maxiteration) {
+          while (avpkt.size > 0 && it++ < maxiteration) {
             av_frame_unref(frame);
             int ret = decode_handler(ctx, frame, &got_frame, &avpkt);
 
@@ -390,13 +360,10 @@
 
             if (ret <= 0 || ret > avpkt.size)
                break;
-
-            if (ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
-                avpkt.data += ret;
-                avpkt.size -= ret;
-                decode_more = avpkt.size > 0;
-            } else
-                decode_more = ret >= 0;
+            if (ctx->codec_type != AVMEDIA_TYPE_AUDIO)
+                ret = avpkt.size;
+            avpkt.data += ret;
+            avpkt.size -= ret;
           }
           av_packet_unref(&avpkt);
         }
@@ -406,9 +373,6 @@
 
     av_packet_unref(&avpkt);
 
-    if (ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)
-        avcodec_send_packet(ctx, NULL);
-
     do {
         got_frame = 0;
         av_frame_unref(frame);
diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c
index 8ff98af..e5c41ee 100644
--- a/tools/target_dem_fuzzer.c
+++ b/tools/target_dem_fuzzer.c
@@ -88,7 +88,7 @@
 
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
-const int maxblocks= 50000;
+const int maxblocks= 100000;
 
 static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL;
 
@@ -200,7 +200,7 @@
             break;
         av_packet_unref(&pkt);
     }
-
+end:
     av_freep(&fuzzed_pb->buffer);
     avio_context_free(&fuzzed_pb);
     avformat_close_input(&avfmt);