From 393988c27486cf001f5ae277730641210e83165e Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 13 Jan 2013 23:39:36 +0200 Subject: [PATCH] build: clean up remnants from internal FFmpeg build Clean up some obsolete configure tests and other things left over from the time years ago when MPlayer used hacks to build FFmpeg inside the same source tree. Remove the configure switches --as, --ar, --ranlib. --ar and --ranlib were useless since nothing is built as a library. --as wasn't directly used; removing it means removing some sanity checks though (the default assembler selected was tested to see that it could compile SSE opcodes, which may be used in inline asm). It's unlikely that anyone would try to make the filters depending on Libavcodec internals build any more. Remove the undocumented configure option --fmpeg-source-dir and remove the mcdeint and spp filters from the source tree (they were already not built). Remove some configure tests which were added for the sake of FFmpeg build and whose results are not used by mplayer2 now. Removing the memalign checks actually required removing two remaining uses in the code. Also remove the malloc.h check and includes in code (I guess the reason to add malloc.h includes at some point was memalign use, though most of the files in question did not actually use memalign now, if ever). --- DOCS/man/en/vf.rst | 46 +--- Makefile | 7 - configure | 269 +------------------ libmpcodecs/vd_dmo.c | 3 - libmpcodecs/vf.c | 9 - libmpcodecs/vf_mcdeint.c | 330 ----------------------- libmpcodecs/vf_noise.c | 4 - libmpcodecs/vf_perspective.c | 4 - libmpcodecs/vf_pp.c | 4 - libmpcodecs/vf_pp7.c | 4 - libmpcodecs/vf_sab.c | 4 - libmpcodecs/vf_spp.c | 612 ------------------------------------------- libmpcodecs/vf_unsharp.c | 4 - libmpdemux/video.c | 11 +- sub/sub.c | 15 +- 15 files changed, 16 insertions(+), 1310 deletions(-) delete mode 100644 libmpcodecs/vf_mcdeint.c delete mode 100644 libmpcodecs/vf_spp.c diff --git a/DOCS/man/en/vf.rst b/DOCS/man/en/vf.rst index 5e5007d1db..c864f5e48a 100644 --- a/DOCS/man/en/vf.rst +++ b/DOCS/man/en/vf.rst @@ -428,33 +428,11 @@ pp[=filter1[:option1[:option2...]]/[-]filter2...] Horizontal deblocking on luminance only, and switch vertical deblocking on or off automatically depending on available CPU time. -spp[=quality[:qp[:mode]]] - Simple postprocessing filter that compresses and decompresses the image at - several (or - in the case of quality level 6 - all) shifts and averages - the results. - - - 0-6 (default: 3) - - - Force quantization parameter (default: 0, use QP from video). - - - - :0: hard thresholding (default) - :1: soft thresholding (better deringing, but blurrier) - :4: like 0, but also use B-frames' QP (may cause flicker) - :5: like 1, but also use B-frames' QP (may cause flicker) - uspp[=quality[:qp]] Ultra simple & slow postprocessing filter that compresses and decompresses the image at several (or - in the case of quality level 8 - all) shifts and averages the results. - The way this differs from the behavior of spp is that uspp actually - encodes & decodes each case with libavcodec Snow, whereas spp uses a - simplified intra only 8x8 DCT similar to MJPEG. - 0-8 (default: 3) @@ -462,10 +440,10 @@ uspp[=quality[:qp]] Force quantization parameter (default: 0, use QP from video). fspp[=quality[:qp[:strength[:bframes]]]] - faster version of the simple postprocessing filter + simple postprocessing filter - 4-5 (equivalent to spp; default: 4) + 4-5 (default: 4) Force quantization parameter (default: 0, use QP from video). @@ -480,8 +458,7 @@ fspp[=quality[:qp[:strength[:bframes]]]] 1: use QP from B-frames too (may cause flicker) pp7[=qp[:mode]] - Variant of the spp filter, similar to spp=6 with 7 point DCT where only - the center sample is used after IDCT. + Another postprocessing filter Force quantization parameter (default: 0, use QP from video). @@ -1097,23 +1074,6 @@ yadif=[mode[:field_dominance]] *NOTE*: This option will possibly be removed in a future version. Use ``--field-dominance`` instead. -mcdeint=[mode[:parity[:qp]]] - Motion compensating deinterlacer. It needs one field per frame as input - and must thus be used together with tfields=1 or yadif=1/3 or equivalent. - - - :0: fast - :1: medium - :2: slow, iterative motion estimation - :3: extra slow, like 2 plus multiple reference frames - - - 0 or 1 selects which field to use (note: no autodetection yet!). - - - Higher values should result in a smoother motion vector field but less - optimal individual vectors. - boxblur=radius:power[:radius:power] box blur diff --git a/Makefile b/Makefile index d649847000..32fd561fce 100644 --- a/Makefile +++ b/Makefile @@ -58,10 +58,6 @@ SRCS_COMMON-$(DVDREAD_INTERNAL) += libdvdread4/bitreader.c \ SRCS_COMMON-$(FAAD) += libmpcodecs/ad_faad.c SRCS_COMMON-$(FASTMEMCPY) += libvo/aclib.c -# These filters use private headers and do not work with shared libavcodec. -SRCS_COMMON-$(FFMPEG_INTERNALS) += libmpcodecs/vf_mcdeint.c \ - libmpcodecs/vf_spp.c \ - SRCS_COMMON-$(FTP) += stream/stream_ftp.c SRCS_COMMON-$(GIF) += libmpdemux/demux_gif.c SRCS_COMMON-$(HAVE_POSIX_SELECT) += libmpcodecs/vf_bmovl.c @@ -616,9 +612,6 @@ libmpdemux/ebml.o libmpdemux/demux_mkv.o: libmpdemux/ebml_types.h libmpdemux/ebml.o: libmpdemux/ebml_defs.c sub/osd_libass.o: sub/osd_font.h -# Files that depend on libavcodec internals -libmpcodecs/vf_fspp.o libmpcodecs/vf_mcdeint.o libmpcodecs/vf_spp.o: CFLAGS := -I$(FFMPEG_SOURCE_PATH) $(CFLAGS) - osdep/mplayer-rc.o: osdep/mplayer.exe.manifest libdvdcss/%: CFLAGS := -Ilibdvdcss -D_GNU_SOURCE -DVERSION=\"1.2.10\" $(CFLAGS_LIBDVDCSS) $(CFLAGS) diff --git a/configure b/configure index 1cd2cd3c7b..b5c3aea80a 100755 --- a/configure +++ b/configure @@ -148,19 +148,6 @@ EOF compile_check $TMPC $@ } -yasm_check() { - echo >> "$TMPLOG" - cat "$TMPS" >> "$TMPLOG" - echo >> "$TMPLOG" - echo "$_yasm $YASMFLAGS -o $TMPEXE $TMPS $@" >> "$TMPLOG" - rm -f "$TMPEXE" - $_yasm $YASMFLAGS -o "$TMPEXE" "$TMPS" "$@" >> "$TMPLOG" 2>&1 - TMPRES="$?" - echo >> "$TMPLOG" - echo >> "$TMPLOG" - return "$TMPRES" -} - pkg_config_add() { unset IFS # shell should not be used for programming echo >> "$TMPLOG" @@ -437,12 +424,8 @@ Miscellaneous options: --enable-runtime-cpudetection enable runtime CPU detection [disable] --enable-cross-compile enable cross-compilation [disable] --cc=COMPILER C compiler to build MPlayer [gcc] - --as=ASSEMBLER assembler to build MPlayer [as] --nm=NM nm tool to build MPlayer [nm] - --yasm=YASM Yasm assembler to build MPlayer [yasm] - --ar=AR librarian to build MPlayer [ar] --pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config] - --ranlib=RANLIB ranlib to build MPlayer [ranlib] --windres=WINDRES windres to build MPlayer [windres] --target=PLATFORM target platform (i386-linux, arm-linux, etc) --enable-static build a statically linked binary @@ -511,19 +494,15 @@ _iwmmxt=auto _altivec=auto _install=install _pkg_config=auto -_ranlib=auto _windres=auto _cc=auto -_ar=auto test "$CC" && _cc="$CC" _as=auto _nm=auto -_yasm=auto _runtime_cpudetection=no _cross_compile=no _prefix="/usr/local" ffmpeg=auto -ffmpeg_internals=no _x11=auto _xss=auto _xv=auto @@ -708,24 +687,12 @@ for ac_option do --cc=*) _cc=$(echo $ac_option | cut -d '=' -f 2) ;; - --as=*) - _as=$(echo $ac_option | cut -d '=' -f 2) - ;; --nm=*) _nm=$(echo $ac_option | cut -d '=' -f 2) ;; - --yasm=*) - _yasm=$(echo $ac_option | cut -d '=' -f 2) - ;; - --ar=*) - _ar=$(echo $ac_option | cut -d '=' -f 2) - ;; --pkg-config=*) _pkg_config=$(echo $ac_option | cut -d '=' -f 2) ;; - --ranlib=*) - _ranlib=$(echo $ac_option | cut -d '=' -f 2) - ;; --windres=*) _windres=$(echo $ac_option | cut -d '=' -f 2) ;; @@ -921,8 +888,6 @@ for ac_option do --enable-libnut) _libnut=yes ;; --disable-libnut) _libnut=no ;; --enable-libav) ffmpeg=yes ;; - --ffmpeg-source-dir=*) - _ffmpeg_source=$(echo $ac_option | cut -d '=' -f 2 ) ;; --enable-lirc) _lirc=yes ;; --disable-lirc) _lirc=no ;; @@ -1087,10 +1052,7 @@ if test $_cross_compile = yes ; then test -n "$_target" && tool_prefix="$_target"- fi -test "$_ranlib" = auto && _ranlib="$tool_prefix"ranlib test "$_windres" = auto && _windres="$tool_prefix"windres -test "$_ar" = auto && _ar="$tool_prefix"ar -test "$_yasm" = auto && _yasm="$tool_prefix"yasm test "$_pkg_config" = auto && _pkg_config="$tool_prefix"pkg-config if test "$_cc" = auto ; then @@ -1215,10 +1177,6 @@ if aix ; then extra_ldflags="$extra_ldflags -lC" fi -if linux ; then - _ranlib='true' -fi - if win32 ; then _exesuf=".exe" extra_cflags="$extra_cflags -fno-common" @@ -1340,13 +1298,6 @@ echo "Detected host architecture: $host_arch" # --- -# now that we know what compiler should be used for compilation, try to find -# out which assembler is used by the $_cc compiler -if test "$_as" = auto ; then - _as=$($_cc -print-prog-name=as) - test -z "$_as" && _as=as -fi - if test "$_nm" = auto ; then _nm=$($_cc -print-prog-name=nm) test -z "$_nm" && _nm=nm @@ -1836,7 +1787,6 @@ case "$host_arch" in ppc|ppc64|powerpc|powerpc64) arch='ppc' - def_dcbzl='#define HAVE_DCBZL 0' def_fast_unaligned='#define HAVE_FAST_UNALIGNED 1' iproc='ppc' @@ -1908,8 +1858,7 @@ case "$host_arch" in # gcc 3.2 and up supports 970 if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "3" || test "$_cc_major" -ge "4"; then case "$proc" in - 970*|PPC970*) _march='-mcpu=970' _mcpu='-mtune=970' - def_dcbzl='#define HAVE_DCBZL 1' ;; + 970*|PPC970*) _march='-mcpu=970' _mcpu='-mtune=970' ;; *) ;; esac fi @@ -2180,58 +2129,6 @@ fi -if x86_32 ; then - # Checking assembler (_as) compatibility... - # Added workaround for older as that reads from stdin by default - atmos - as_version=$(echo '' | $_as -version 2>&1 | sed -n 's/^.*assembler \(version \)*\([0-9.]*\).*$/\2/p') - echocheck "assembler ($_as $as_version)" - - _pref_as_version='2.9.1' - echo 'nop' > $TMPS - if test "$_mmx" = yes ; then - echo 'emms' >> $TMPS - fi - if test "$_3dnow" = yes ; then - _pref_as_version='2.10.1' - echo 'femms' >> $TMPS - fi - if test "$_3dnowext" = yes ; then - _pref_as_version='2.10.1' - echo 'pswapd %mm0, %mm0' >> $TMPS - fi - if test "$_mmxext" = yes ; then - _pref_as_version='2.10.1' - echo 'movntq %mm0, (%eax)' >> $TMPS - fi - if test "$_sse" = yes ; then - _pref_as_version='2.10.1' - echo 'xorps %xmm0, %xmm0' >> $TMPS - fi - #if test "$_sse2" = yes ; then - # _pref_as_version='2.11' - # echo 'xorpd %xmm0, %xmm0' >> $TMPS - #fi - if test "$_cmov" = yes ; then - _pref_as_version='2.10.1' - echo 'cmovb %eax, %ebx' >> $TMPS - fi - if test "$_ssse3" = yes ; then - _pref_as_version='2.16.92' - echo 'pabsd %xmm0, %xmm1' >> $TMPS - fi - $_as $TMPS -o $TMPEXE > /dev/null 2>&1 || as_verc_fail=yes - - if test "$as_verc_fail" != yes ; then - echores "ok" - else - res_comment="Upgrade binutils to ${_pref_as_version} or use --disable-ssse3 etc." - echores "failed" - die "obsolete binutils version" - fi - -fi #if x86_32 - - echocheck "PIC" pic=no cat > $TMPC << EOF @@ -2281,48 +2178,8 @@ EOF cc_check && ebx_available=yes && def_ebx_available='#define HAVE_EBX_AVAILABLE 1' echores $ebx_available - -echocheck "yasm" -if test -z "$YASMFLAGS" ; then - if darwin ; then - x86_64 && objformat="macho64" || objformat="macho" - elif win32 ; then - objformat="win32" - else - objformat="elf" - fi - # currently tested for Linux x86, x86_64 - YASMFLAGS="-f $objformat" - x86_64 && YASMFLAGS="$YASMFLAGS -DARCH_X86_64 -m amd64" - test "$pic" = "yes" && YASMFLAGS="$YASMFLAGS -DPIC" - case "$objformat" in - elf) test $_debug && YASMFLAGS="$YASMFLAGS -g dwarf2" ;; - *) YASMFLAGS="$YASMFLAGS -DPREFIX" ;; - esac -else - warn_cflags=yes -fi - -echo "pabsw xmm0, xmm0" > $TMPS -yasm_check || _yasm="" -if test $_yasm ; then - def_yasm='#define HAVE_YASM 1' - have_yasm="yes" - echores "$_yasm" -else - def_yasm='#define HAVE_YASM 0' - have_yasm="no" - echores "no" -fi - -echocheck "bswap" -def_bswap='#define HAVE_BSWAP 0' -echo 'bswap %eax' > $TMPS -$_as $TMPS -o $TMPEXE > /dev/null 2>&1 && def_bswap='#define HAVE_BSWAP 1' && bswap=yes || bswap=no -echores "$bswap" fi #if x86 - #FIXME: This should happen before the check for CFLAGS.. def_altivec_h='#define HAVE_ALTIVEC_H 0' if ppc && ( test "$_altivec" = yes || test "$_runtime_cpudetection" = yes ) ; then @@ -2366,15 +2223,6 @@ EOF test "$_altivec" = yes && CFLAGS="$CFLAGS $_altivec_gcc_flags" fi -if ppc ; then -def_xform_asm='#define HAVE_XFORM_ASM 0' -xform_asm=no -echocheck "XFORM ASM support" -inline_asm_check '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)' && - xform_asm=yes && def_xform_asm='#define HAVE_XFORM_ASM 1' -echores "$xform_asm" -fi - if arm ; then echocheck "ARMv5TE (Enhanced DSP Extensions)" if test $_armv5te = "auto" ; then @@ -2633,30 +2481,6 @@ if test "$_posix4" = yes ; then fi echores "$_posix4" -for func in exp2 exp2f llrint log2 log2f lrint lrintf round roundf truncf; do -echocheck $func -eval _$func=no -statement_check math.h "${func}(2.0)" -D_ISOC99_SOURCE $_ld_lm && eval _$func=yes -if eval test "x\$_$func" = "xyes"; then - eval def_$func="\"#define HAVE_$(echo $func | tr '[a-z]' '[A-Z]') 1\"" - echores yes -else - eval def_$func="\"#define HAVE_$(echo $func | tr '[a-z]' '[A-Z]') 0\"" - echores no -fi -done - - -echocheck "mkstemp" -_mkstemp=no -define_statement_check "_XOPEN_SOURCE 600" "stdlib.h" 'mkstemp("")' && _mkstemp=yes -if test "$_mkstemp" = yes ; then - def_mkstemp='#define HAVE_MKSTEMP 1' -else - def_mkstemp='#define HAVE_MKSTEMP 0' -fi -echores "$_mkstemp" - echocheck "nanosleep" _nanosleep=no @@ -2698,14 +2522,6 @@ else fi -echocheck "arpa/inet.h" -arpa_inet_h=no -def_arpa_inet_h='#define HAVE_ARPA_INET_H 0' -header_check arpa/inet.h && arpa_inet_h=yes && - def_arpa_inet_h='#define HAVE_ARPA_INET_H 1' -echores "$arpa_inet_h" - - echocheck "inet_pton()" def_inet_pton='#define HAVE_INET_PTON 0' inet_pton=no @@ -2834,40 +2650,6 @@ if test "$_inttypes" = no ; then fi -echocheck "malloc.h" -_malloc=no -header_check malloc.h && _malloc=yes -if test "$_malloc" = yes ; then - def_malloc_h='#define HAVE_MALLOC_H 1' -else - def_malloc_h='#define HAVE_MALLOC_H 0' -fi -echores "$_malloc" - - -echocheck "memalign()" -# XXX restrict to x86 ? extend to other CPUs/cacheline sizes ? -def_memalign_hack='#define CONFIG_MEMALIGN_HACK 0' -_memalign=no -statement_check malloc.h 'memalign(64, sizeof(char))' && _memalign=yes -if test "$_memalign" = yes ; then - def_memalign='#define HAVE_MEMALIGN 1' -else - def_memalign='#define HAVE_MEMALIGN 0' - def_map_memalign='#define memalign(a, b) malloc(b)' - darwin || def_memalign_hack='#define CONFIG_MEMALIGN_HACK 1' -fi -echores "$_memalign" - - -echocheck "posix_memalign()" -posix_memalign=no -def_posix_memalign='#define HAVE_POSIX_MEMALIGN 0' -define_statement_check "_XOPEN_SOURCE 600" "stdlib.h" 'posix_memalign(NULL, 0, 0)' && - posix_memalign=yes && def_posix_memalign='#define HAVE_POSIX_MEMALIGN 1' -echores "$posix_memalign" - - echocheck "alloca.h" _alloca=no statement_check alloca.h 'alloca(0)' && _alloca=yes @@ -2919,8 +2701,6 @@ fi echores "$_dl" -def_threads='#define HAVE_THREADS 0' - echocheck "pthread" if linux ; then THREAD_CFLAGS=-D_REENTRANT @@ -2955,7 +2735,6 @@ fi if test "$_pthreads" = yes ; then test $_ld_pthread && res_comment="using $_ld_pthread" def_pthreads='#define HAVE_PTHREADS 1' - def_threads='#define HAVE_THREADS 1' extra_cflags="$extra_cflags $THREAD_CFLAGS" else res_comment="v4l, v4l2, win32 loader disabled" @@ -2983,7 +2762,6 @@ if test "$_w32threads" = auto ; then _w32threads=no mingw32 && _w32threads=yes fi -test "$_w32threads" = yes && def_threads='#define HAVE_THREADS 1' echores "$_w32threads" echocheck "rpath" @@ -5007,11 +4785,6 @@ if test "$ffmpeg" = auto ; then fi echores "yes" -def_ffmpeg_internals="#undef CONFIG_FFMPEG_INTERNALS" -if ! test -z "$_ffmpeg_source" ; then - def_ffmpeg_internals="#define CONFIG_FFMPEG_INTERNALS 1" && ffmpeg_internals=yes -fi - echocheck "libpostproc >= 52.0.0" if test "$libpostproc" = auto ; then libpostproc=no @@ -5577,8 +5350,6 @@ MANDIR = \$(DESTDIR)$_mandir CONFDIR = \$(DESTDIR)$_confdir LOCALEDIR = \$(DESTDIR)$_localedir -AR = $_ar -AS = $_cc CC = $_cc INSTALL = $_install INSTALLSTRIP = $_install_strip @@ -5715,21 +5486,12 @@ XV = $_xv XVID4 = $_xvid YUV4MPEG = $_yuv4mpeg -# FFmpeg -FFMPEG_INTERNALS = $ffmpeg_internals -FFMPEG_SOURCE_PATH = $_ffmpeg_source - -RANLIB = $_ranlib -YASM = $_yasm -YASMFLAGS = $YASMFLAGS - CONFIG_VDPAU = $_vdpau CONFIG_ZLIB = $_zlib HAVE_PTHREADS = $_pthreads HAVE_SHM = $_shm HAVE_W32THREADS = $_w32threads -HAVE_YASM = $have_yasm EOF @@ -5789,7 +5551,6 @@ $def_dvdcss /* system headers */ $def_alloca_h $def_altivec_h -$def_malloc_h $def_mman_h $def_mman_has_map_failed $def_soundcard_h @@ -5806,9 +5567,6 @@ $def_gethostbyname2 $def_gettimeofday $def_glob $def_langinfo -$def_lrintf -$def_map_memalign -$def_memalign $def_nanosleep $def_posix_select $def_select @@ -6012,32 +5770,9 @@ $def_xv $def_yuv4mpeg -/* FFmpeg */ -$def_ffmpeg_internals - -$def_arpa_inet_h -$def_bswap -$def_dcbzl -$def_exp2 -$def_exp2f $def_fast_64bit $def_fast_unaligned -$def_llrint -$def_log2 -$def_log2f -$def_lrint -$def_memalign_hack -$def_mkstemp -$def_posix_memalign $def_pthreads -$def_round -$def_roundf -$def_threads -$def_truncf -$def_xform_asm -$def_yasm - -#define HAVE_INLINE_ASM 1 /* Use these registers in x86 inline asm. No proper detection yet. */ #define HAVE_EBP_AVAILABLE 1 @@ -6108,7 +5843,7 @@ EOF if test "$warn_cflags" = yes; then cat < -#endif #include #include #include diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index f4d6768531..e5ea6808ef 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -22,9 +22,6 @@ #include #include "config.h" -#if HAVE_MALLOC_H -#include -#endif #include "mp_msg.h" #include "m_option.h" @@ -93,7 +90,6 @@ extern const vf_info_t vf_info_tile; extern const vf_info_t vf_info_delogo; extern const vf_info_t vf_info_remove_logo; extern const vf_info_t vf_info_hue; -extern const vf_info_t vf_info_spp; extern const vf_info_t vf_info_uspp; extern const vf_info_t vf_info_fspp; extern const vf_info_t vf_info_pp7; @@ -107,7 +103,6 @@ extern const vf_info_t vf_info_harddup; extern const vf_info_t vf_info_softskip; extern const vf_info_t vf_info_screenshot; extern const vf_info_t vf_info_ass; -extern const vf_info_t vf_info_mcdeint; extern const vf_info_t vf_info_yadif; extern const vf_info_t vf_info_blackframe; extern const vf_info_t vf_info_geq; @@ -183,10 +178,6 @@ static const vf_info_t *const filter_list[] = { &vf_info_delogo, &vf_info_remove_logo, &vf_info_hue, -#ifdef CONFIG_FFMPEG_INTERNALS - &vf_info_spp, - &vf_info_mcdeint, -#endif &vf_info_geq, &vf_info_qp, &vf_info_yuvcsp, diff --git a/libmpcodecs/vf_mcdeint.c b/libmpcodecs/vf_mcdeint.c deleted file mode 100644 index 82635e5dfd..0000000000 --- a/libmpcodecs/vf_mcdeint.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (C) 2006 Michael Niedermayer - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - - -/* -Known Issues: -* The motion estimation is somewhat at the mercy of the input, if the input - frames are created purely based on spatial interpolation then for example - a thin black line or another random and not interpolateable pattern - will cause problems - Note: completly ignoring the "unavailable" lines during motion estimation - didnt look any better, so the most obvious solution would be to improve - tfields or penalize problematic motion vectors ... - -* If non iterative ME is used then snow currently ignores the OBMC window - and as a result sometimes creates artifacts - -* only past frames are used, we should ideally use future frames too, something - like filtering the whole movie in forward and then backward direction seems - like a interresting idea but the current filter framework is FAR from - supporting such things - -* combining the motion compensated image with the input image also isnt - as trivial as it seems, simple blindly taking even lines from one and - odd ones from the other doesnt work at all as ME/MC sometimes simple - has nothing in the previous frames which matches the current, the current - algo has been found by trial and error and almost certainly can be - improved ... -*/ - -#include -#include -#include -#include -#include - -#include "mp_msg.h" -#include "cpudetect.h" - -#include "libavutil/intreadwrite.h" -#include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" - -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" - -#define MIN(a,b) ((a) > (b) ? (b) : (a)) -#define MAX(a,b) ((a) < (b) ? (b) : (a)) -#define ABS(a) ((a) > 0 ? (a) : (-(a))) - -//===========================================================================// - -struct vf_priv_s { - int mode; - int qp; - int parity; -#if 0 - int temp_stride[3]; - uint8_t *src[3]; - int16_t *temp[3]; -#endif - int outbuf_size; - uint8_t *outbuf; - AVCodecContext *avctx_enc; - AVFrame *frame; - AVFrame *frame_dec; -}; - -static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int dst_stride[3], int src_stride[3], int width, int height){ - int x, y, i; - int out_size; - - for(i=0; i<3; i++){ - p->frame->data[i]= src[i]; - p->frame->linesize[i]= src_stride[i]; - } - - p->avctx_enc->me_cmp= - p->avctx_enc->me_sub_cmp= FF_CMP_SAD /*| (p->parity ? FF_CMP_ODD : FF_CMP_EVEN)*/; - p->frame->quality= p->qp*FF_QP2LAMBDA; - out_size = avcodec_encode_video(p->avctx_enc, p->outbuf, p->outbuf_size, p->frame); - p->frame_dec = p->avctx_enc->coded_frame; - - for(i=0; i<3; i++){ - int is_chroma= !!i; - int w= width >>is_chroma; - int h= height>>is_chroma; - int fils= p->frame_dec->linesize[i]; - int srcs= src_stride[i]; - - for(y=0; yparity) & 1){ - for(x=0; x=0 && (x+2)+(y+1)*wframe_dec->data[i][x + y*fils]; - uint8_t *srcp= &src[i][x + y*srcs]; - int diff0= filp[-fils] - srcp[-srcs]; - int diff1= filp[+fils] - srcp[+srcs]; - int spatial_score= ABS(srcp[-srcs-1] - srcp[+srcs-1]) - +ABS(srcp[-srcs ] - srcp[+srcs ]) - +ABS(srcp[-srcs+1] - srcp[+srcs+1]) - 1; - int temp= filp[0]; - -#define CHECK(j)\ - { int score= ABS(srcp[-srcs-1+j] - srcp[+srcs-1-j])\ - + ABS(srcp[-srcs +j] - srcp[+srcs -j])\ - + ABS(srcp[-srcs+1+j] - srcp[+srcs+1-j]);\ - if(score < spatial_score){\ - spatial_score= score;\ - diff0= filp[-fils+j] - srcp[-srcs+j];\ - diff1= filp[+fils-j] - srcp[+srcs-j]; - - CHECK(-1) CHECK(-2) }} }} - CHECK( 1) CHECK( 2) }} }} -#if 0 - if((diff0 ^ diff1) > 0){ - int mindiff= ABS(diff0) > ABS(diff1) ? diff1 : diff0; - temp-= mindiff; - } -#elif 1 - if(diff0 + diff1 > 0) - temp-= (diff0 + diff1 - ABS( ABS(diff0) - ABS(diff1) )/2)/2; - else - temp-= (diff0 + diff1 + ABS( ABS(diff0) - ABS(diff1) )/2)/2; -#else - temp-= (diff0 + diff1)/2; -#endif -#if 1 - filp[0]= - dst[i][x + y*dst_stride[i]]= temp > 255U ? ~(temp>>31) : temp; -#else - dst[i][x + y*dst_stride[i]]= filp[0]; - filp[0]= temp > 255U ? ~(temp>>31) : temp; -#endif - }else - dst[i][x + y*dst_stride[i]]= p->frame_dec->data[i][x + y*fils]; - } - } - } - for(y=0; yparity) & 1)){ - for(x=0; xframe_dec->data[i][x + y*fils]= - dst[i][x + y*dst_stride[i]]= src[i][x + y*srcs]; -#else - dst[i][x + y*dst_stride[i]]= p->frame_dec->data[i][x + y*fils]; - p->frame_dec->data[i][x + y*fils]= src[i][x + y*srcs]; -#endif - } - } - } - } - p->parity ^= 1; - -} - -static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ - int i; - AVCodec *enc= avcodec_find_encoder(CODEC_ID_SNOW); - - for(i=0; i<3; i++){ - AVCodecContext *avctx_enc; -#if 0 - int is_chroma= !!i; - int w= ((width + 31) & (~31))>>is_chroma; - int h= ((height + 31) & (~31))>>is_chroma; - - vf->priv->temp_stride[i]= w; - vf->priv->temp[i]= malloc(vf->priv->temp_stride[i]*h*sizeof(int16_t)); - vf->priv->src [i]= malloc(vf->priv->temp_stride[i]*h*sizeof(uint8_t)); -#endif - avctx_enc= - vf->priv->avctx_enc= avcodec_alloc_context(); - avctx_enc->width = width; - avctx_enc->height = height; - avctx_enc->time_base= (AVRational){1,25}; // meaningless - avctx_enc->gop_size = 300; - avctx_enc->max_b_frames= 0; - avctx_enc->pix_fmt = PIX_FMT_YUV420P; - avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; - avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; - avctx_enc->global_quality= 1; - avctx_enc->flags2= CODEC_FLAG2_MEMC_ONLY; - avctx_enc->me_cmp= - avctx_enc->me_sub_cmp= FF_CMP_SAD; //SSE; - avctx_enc->mb_cmp= FF_CMP_SSE; - - switch(vf->priv->mode){ - case 3: - avctx_enc->refs= 3; - case 2: - avctx_enc->me_method= ME_ITER; - case 1: - avctx_enc->flags |= CODEC_FLAG_4MV; - avctx_enc->dia_size=2; -// avctx_enc->mb_decision = MB_DECISION_RD; - case 0: - avctx_enc->flags |= CODEC_FLAG_QPEL; - } - - avcodec_open(avctx_enc, enc); - - } - vf->priv->frame= avcodec_alloc_frame(); - - vf->priv->outbuf_size= width*height*10; - vf->priv->outbuf= malloc(vf->priv->outbuf_size); - - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); -} - -static void get_image(struct vf_instance *vf, mp_image_t *mpi){ - if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change -return; //caused problems, dunno why - // ok, we can do pp in-place (or pp disabled): - vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, - mpi->type, mpi->flags | MP_IMGFLAG_READABLE, mpi->width, mpi->height); - mpi->planes[0]=vf->dmpi->planes[0]; - mpi->stride[0]=vf->dmpi->stride[0]; - mpi->width=vf->dmpi->width; - if(mpi->flags&MP_IMGFLAG_PLANAR){ - mpi->planes[1]=vf->dmpi->planes[1]; - mpi->planes[2]=vf->dmpi->planes[2]; - mpi->stride[1]=vf->dmpi->stride[1]; - mpi->stride[2]=vf->dmpi->stride[2]; - } - mpi->flags|=MP_IMGFLAG_DIRECT; -} - -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - - if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ - // no DR, so get a new image! hope we'll get DR buffer: - dmpi=vf_get_image(vf->next,mpi->imgfmt, - MP_IMGTYPE_TEMP, - MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, - mpi->width,mpi->height); - vf_clone_mpi_attributes(dmpi, mpi); - }else{ - dmpi=vf->dmpi; - } - - filter(vf->priv, dmpi->planes, mpi->planes, dmpi->stride, mpi->stride, mpi->w, mpi->h); - - return vf_next_put_image(vf,dmpi, pts); -} - -static void uninit(struct vf_instance *vf){ - if(!vf->priv) return; - -#if 0 - for(i=0; i<3; i++){ - free(vf->priv->temp[i]); - vf->priv->temp[i]= NULL; - free(vf->priv->src[i]); - vf->priv->src[i]= NULL; - } -#endif - if (vf->priv->avctx_enc) { - avcodec_close(vf->priv->avctx_enc); - av_freep(&vf->priv->avctx_enc); - } - - free(vf->priv->outbuf); - free(vf->priv); - vf->priv=NULL; -} - -//===========================================================================// -static int query_format(struct vf_instance *vf, unsigned int fmt){ - switch(fmt){ - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - case IMGFMT_Y800: - case IMGFMT_Y8: - return vf_next_query_format(vf,fmt); - } - return 0; -} - -static int vf_open(vf_instance_t *vf, char *args){ - - vf->config=config; - vf->put_image=put_image; - vf->get_image=get_image; - vf->query_format=query_format; - vf->uninit=uninit; - vf->priv=malloc(sizeof(struct vf_priv_s)); - memset(vf->priv, 0, sizeof(struct vf_priv_s)); - - vf->priv->mode=0; - vf->priv->parity= -1; - vf->priv->qp=1; - - if (args) sscanf(args, "%d:%d:%d", &vf->priv->mode, &vf->priv->parity, &vf->priv->qp); - - return 1; -} - -const vf_info_t vf_info_mcdeint = { - "motion compensating deinterlacer", - "mcdeint", - "Michael Niedermayer", - "", - vf_open, - NULL -}; diff --git a/libmpcodecs/vf_noise.c b/libmpcodecs/vf_noise.c index f8d4c2e6a3..c623e11562 100644 --- a/libmpcodecs/vf_noise.c +++ b/libmpcodecs/vf_noise.c @@ -28,10 +28,6 @@ #include "mp_msg.h" #include "cpudetect.h" -#if HAVE_MALLOC_H -#include -#endif - #include "img_format.h" #include "mp_image.h" #include "vf.h" diff --git a/libmpcodecs/vf_perspective.c b/libmpcodecs/vf_perspective.c index b835e6b1cb..df196bb1c9 100644 --- a/libmpcodecs/vf_perspective.c +++ b/libmpcodecs/vf_perspective.c @@ -28,10 +28,6 @@ #include "config.h" #include "mp_msg.h" -#if HAVE_MALLOC_H -#include -#endif - #include "libavutil/mem.h" #include "img_format.h" diff --git a/libmpcodecs/vf_pp.c b/libmpcodecs/vf_pp.c index 694fa09bf2..4bf649cd24 100644 --- a/libmpcodecs/vf_pp.c +++ b/libmpcodecs/vf_pp.c @@ -26,10 +26,6 @@ #include "mp_msg.h" #include "cpudetect.h" -#if HAVE_MALLOC_H -#include -#endif - #include "img_format.h" #include "mp_image.h" #include "vf.h" diff --git a/libmpcodecs/vf_pp7.c b/libmpcodecs/vf_pp7.c index 1c0274d24f..0a30022576 100644 --- a/libmpcodecs/vf_pp7.c +++ b/libmpcodecs/vf_pp7.c @@ -30,10 +30,6 @@ #include "mp_msg.h" #include "cpudetect.h" -#if HAVE_MALLOC_H -#include -#endif - #include "libavutil/mem.h" #include "img_format.h" diff --git a/libmpcodecs/vf_sab.c b/libmpcodecs/vf_sab.c index 1f2b17a052..33f6754555 100644 --- a/libmpcodecs/vf_sab.c +++ b/libmpcodecs/vf_sab.c @@ -30,10 +30,6 @@ #include "config.h" #include "mp_msg.h" -#if HAVE_MALLOC_H -#include -#endif - #include "img_format.h" #include "mp_image.h" #include "vf.h" diff --git a/libmpcodecs/vf_spp.c b/libmpcodecs/vf_spp.c deleted file mode 100644 index 2402d72554..0000000000 --- a/libmpcodecs/vf_spp.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright (C) 2003 Michael Niedermayer - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * This implementation is based on an algorithm described in - * "Aria Nosratinia Embedded Post-Processing for - * Enhancement of Compressed Images (1999)" - * (http://citeseer.nj.nec.com/nosratinia99embedded.html) - */ - - -#include -#include -#include -#include -#include - -#include "config.h" - -#include "mp_msg.h" -#include "cpudetect.h" - -#include "libavutil/intreadwrite.h" -#include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" - -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" -#include "libvo/fastmemcpy.h" - -#define XMIN(a,b) ((a) < (b) ? (a) : (b)) - -//===========================================================================// -static const uint8_t __attribute__((aligned(8))) dither[8][8]={ -{ 0, 48, 12, 60, 3, 51, 15, 63, }, -{ 32, 16, 44, 28, 35, 19, 47, 31, }, -{ 8, 56, 4, 52, 11, 59, 7, 55, }, -{ 40, 24, 36, 20, 43, 27, 39, 23, }, -{ 2, 50, 14, 62, 1, 49, 13, 61, }, -{ 34, 18, 46, 30, 33, 17, 45, 29, }, -{ 10, 58, 6, 54, 9, 57, 5, 53, }, -{ 42, 26, 38, 22, 41, 25, 37, 21, }, -}; - -static const uint8_t offset[127][2]= { -{0,0}, -{0,0}, {4,4}, -{0,0}, {2,2}, {6,4}, {4,6}, -{0,0}, {5,1}, {2,2}, {7,3}, {4,4}, {1,5}, {6,6}, {3,7}, - -{0,0}, {4,0}, {1,1}, {5,1}, {3,2}, {7,2}, {2,3}, {6,3}, -{0,4}, {4,4}, {1,5}, {5,5}, {3,6}, {7,6}, {2,7}, {6,7}, - -{0,0}, {0,2}, {0,4}, {0,6}, {1,1}, {1,3}, {1,5}, {1,7}, -{2,0}, {2,2}, {2,4}, {2,6}, {3,1}, {3,3}, {3,5}, {3,7}, -{4,0}, {4,2}, {4,4}, {4,6}, {5,1}, {5,3}, {5,5}, {5,7}, -{6,0}, {6,2}, {6,4}, {6,6}, {7,1}, {7,3}, {7,5}, {7,7}, - -{0,0}, {4,4}, {0,4}, {4,0}, {2,2}, {6,6}, {2,6}, {6,2}, -{0,2}, {4,6}, {0,6}, {4,2}, {2,0}, {6,4}, {2,4}, {6,0}, -{1,1}, {5,5}, {1,5}, {5,1}, {3,3}, {7,7}, {3,7}, {7,3}, -{1,3}, {5,7}, {1,7}, {5,3}, {3,1}, {7,5}, {3,5}, {7,1}, -{0,1}, {4,5}, {0,5}, {4,1}, {2,3}, {6,7}, {2,7}, {6,3}, -{0,3}, {4,7}, {0,7}, {4,3}, {2,1}, {6,5}, {2,5}, {6,1}, -{1,0}, {5,4}, {1,4}, {5,0}, {3,2}, {7,6}, {3,6}, {7,2}, -{1,2}, {5,6}, {1,6}, {5,2}, {3,0}, {7,4}, {3,4}, {7,0}, -}; - -struct vf_priv_s { - int log2_count; - int qp; - int mode; - int mpeg2; - int temp_stride; - uint8_t *src; - int16_t *temp; - AVCodecContext *avctx; - DSPContext dsp; - char *non_b_qp; -}; - -#define SHIFT 22 - -static void hardthresh_c(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ - int i; - int bias= 0; //FIXME - unsigned int threshold1, threshold2; - - threshold1= qp*((1<<4) - bias) - 1; - threshold2= (threshold1<<1); - - memset(dst, 0, 64*sizeof(DCTELEM)); - dst[0]= (src[0] + 4)>>3; - - for(i=1; i<64; i++){ - int level= src[i]; - if(((unsigned)(level+threshold1))>threshold2){ - const int j= permutation[i]; - dst[j]= (level + 4)>>3; - } - } -} - -static void softthresh_c(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ - int i; - int bias= 0; //FIXME - unsigned int threshold1, threshold2; - - threshold1= qp*((1<<4) - bias) - 1; - threshold2= (threshold1<<1); - - memset(dst, 0, 64*sizeof(DCTELEM)); - dst[0]= (src[0] + 4)>>3; - - for(i=1; i<64; i++){ - int level= src[i]; - if(((unsigned)(level+threshold1))>threshold2){ - const int j= permutation[i]; - if(level>0) - dst[j]= (level - threshold1 + 4)>>3; - else - dst[j]= (level + threshold1 + 4)>>3; - } - } -} - -#if HAVE_MMX -static void hardthresh_mmx(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ - int bias= 0; //FIXME - unsigned int threshold1; - - threshold1= qp*((1<<4) - bias) - 1; - - __asm__ volatile( -#define REQUANT_CORE(dst0, dst1, dst2, dst3, src0, src1, src2, src3) \ - "movq " #src0 ", %%mm0 \n\t"\ - "movq " #src1 ", %%mm1 \n\t"\ - "movq " #src2 ", %%mm2 \n\t"\ - "movq " #src3 ", %%mm3 \n\t"\ - "psubw %%mm4, %%mm0 \n\t"\ - "psubw %%mm4, %%mm1 \n\t"\ - "psubw %%mm4, %%mm2 \n\t"\ - "psubw %%mm4, %%mm3 \n\t"\ - "paddusw %%mm5, %%mm0 \n\t"\ - "paddusw %%mm5, %%mm1 \n\t"\ - "paddusw %%mm5, %%mm2 \n\t"\ - "paddusw %%mm5, %%mm3 \n\t"\ - "paddw %%mm6, %%mm0 \n\t"\ - "paddw %%mm6, %%mm1 \n\t"\ - "paddw %%mm6, %%mm2 \n\t"\ - "paddw %%mm6, %%mm3 \n\t"\ - "psubusw %%mm6, %%mm0 \n\t"\ - "psubusw %%mm6, %%mm1 \n\t"\ - "psubusw %%mm6, %%mm2 \n\t"\ - "psubusw %%mm6, %%mm3 \n\t"\ - "psraw $3, %%mm0 \n\t"\ - "psraw $3, %%mm1 \n\t"\ - "psraw $3, %%mm2 \n\t"\ - "psraw $3, %%mm3 \n\t"\ -\ - "movq %%mm0, %%mm7 \n\t"\ - "punpcklwd %%mm2, %%mm0 \n\t" /*A*/\ - "punpckhwd %%mm2, %%mm7 \n\t" /*C*/\ - "movq %%mm1, %%mm2 \n\t"\ - "punpcklwd %%mm3, %%mm1 \n\t" /*B*/\ - "punpckhwd %%mm3, %%mm2 \n\t" /*D*/\ - "movq %%mm0, %%mm3 \n\t"\ - "punpcklwd %%mm1, %%mm0 \n\t" /*A*/\ - "punpckhwd %%mm7, %%mm3 \n\t" /*C*/\ - "punpcklwd %%mm2, %%mm7 \n\t" /*B*/\ - "punpckhwd %%mm2, %%mm1 \n\t" /*D*/\ -\ - "movq %%mm0, " #dst0 " \n\t"\ - "movq %%mm7, " #dst1 " \n\t"\ - "movq %%mm3, " #dst2 " \n\t"\ - "movq %%mm1, " #dst3 " \n\t" - - "movd %2, %%mm4 \n\t" - "movd %3, %%mm5 \n\t" - "movd %4, %%mm6 \n\t" - "packssdw %%mm4, %%mm4 \n\t" - "packssdw %%mm5, %%mm5 \n\t" - "packssdw %%mm6, %%mm6 \n\t" - "packssdw %%mm4, %%mm4 \n\t" - "packssdw %%mm5, %%mm5 \n\t" - "packssdw %%mm6, %%mm6 \n\t" - REQUANT_CORE( (%1), 8(%1), 16(%1), 24(%1), (%0), 8(%0), 64(%0), 72(%0)) - REQUANT_CORE(32(%1), 40(%1), 48(%1), 56(%1),16(%0),24(%0), 48(%0), 56(%0)) - REQUANT_CORE(64(%1), 72(%1), 80(%1), 88(%1),32(%0),40(%0), 96(%0),104(%0)) - REQUANT_CORE(96(%1),104(%1),112(%1),120(%1),80(%0),88(%0),112(%0),120(%0)) - : : "r" (src), "r" (dst), "g" (threshold1+1), "g" (threshold1+5), "g" (threshold1-4) //FIXME maybe more accurate then needed? - ); - dst[0]= (src[0] + 4)>>3; -} - -static void softthresh_mmx(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ - int bias= 0; //FIXME - unsigned int threshold1; - - threshold1= qp*((1<<4) - bias) - 1; - - __asm__ volatile( -#undef REQUANT_CORE -#define REQUANT_CORE(dst0, dst1, dst2, dst3, src0, src1, src2, src3) \ - "movq " #src0 ", %%mm0 \n\t"\ - "movq " #src1 ", %%mm1 \n\t"\ - "pxor %%mm6, %%mm6 \n\t"\ - "pxor %%mm7, %%mm7 \n\t"\ - "pcmpgtw %%mm0, %%mm6 \n\t"\ - "pcmpgtw %%mm1, %%mm7 \n\t"\ - "pxor %%mm6, %%mm0 \n\t"\ - "pxor %%mm7, %%mm1 \n\t"\ - "psubusw %%mm4, %%mm0 \n\t"\ - "psubusw %%mm4, %%mm1 \n\t"\ - "pxor %%mm6, %%mm0 \n\t"\ - "pxor %%mm7, %%mm1 \n\t"\ - "movq " #src2 ", %%mm2 \n\t"\ - "movq " #src3 ", %%mm3 \n\t"\ - "pxor %%mm6, %%mm6 \n\t"\ - "pxor %%mm7, %%mm7 \n\t"\ - "pcmpgtw %%mm2, %%mm6 \n\t"\ - "pcmpgtw %%mm3, %%mm7 \n\t"\ - "pxor %%mm6, %%mm2 \n\t"\ - "pxor %%mm7, %%mm3 \n\t"\ - "psubusw %%mm4, %%mm2 \n\t"\ - "psubusw %%mm4, %%mm3 \n\t"\ - "pxor %%mm6, %%mm2 \n\t"\ - "pxor %%mm7, %%mm3 \n\t"\ -\ - "paddsw %%mm5, %%mm0 \n\t"\ - "paddsw %%mm5, %%mm1 \n\t"\ - "paddsw %%mm5, %%mm2 \n\t"\ - "paddsw %%mm5, %%mm3 \n\t"\ - "psraw $3, %%mm0 \n\t"\ - "psraw $3, %%mm1 \n\t"\ - "psraw $3, %%mm2 \n\t"\ - "psraw $3, %%mm3 \n\t"\ -\ - "movq %%mm0, %%mm7 \n\t"\ - "punpcklwd %%mm2, %%mm0 \n\t" /*A*/\ - "punpckhwd %%mm2, %%mm7 \n\t" /*C*/\ - "movq %%mm1, %%mm2 \n\t"\ - "punpcklwd %%mm3, %%mm1 \n\t" /*B*/\ - "punpckhwd %%mm3, %%mm2 \n\t" /*D*/\ - "movq %%mm0, %%mm3 \n\t"\ - "punpcklwd %%mm1, %%mm0 \n\t" /*A*/\ - "punpckhwd %%mm7, %%mm3 \n\t" /*C*/\ - "punpcklwd %%mm2, %%mm7 \n\t" /*B*/\ - "punpckhwd %%mm2, %%mm1 \n\t" /*D*/\ -\ - "movq %%mm0, " #dst0 " \n\t"\ - "movq %%mm7, " #dst1 " \n\t"\ - "movq %%mm3, " #dst2 " \n\t"\ - "movq %%mm1, " #dst3 " \n\t" - - "movd %2, %%mm4 \n\t" - "movd %3, %%mm5 \n\t" - "packssdw %%mm4, %%mm4 \n\t" - "packssdw %%mm5, %%mm5 \n\t" - "packssdw %%mm4, %%mm4 \n\t" - "packssdw %%mm5, %%mm5 \n\t" - REQUANT_CORE( (%1), 8(%1), 16(%1), 24(%1), (%0), 8(%0), 64(%0), 72(%0)) - REQUANT_CORE(32(%1), 40(%1), 48(%1), 56(%1),16(%0),24(%0), 48(%0), 56(%0)) - REQUANT_CORE(64(%1), 72(%1), 80(%1), 88(%1),32(%0),40(%0), 96(%0),104(%0)) - REQUANT_CORE(96(%1),104(%1),112(%1),120(%1),80(%0),88(%0),112(%0),120(%0)) - : : "r" (src), "r" (dst), "g" (threshold1), "rm" (4) //FIXME maybe more accurate then needed? - ); - - dst[0]= (src[0] + 4)>>3; -} -#endif - -static inline void add_block(int16_t *dst, int stride, DCTELEM block[64]){ - int y; - - for(y=0; y<8; y++){ - *(uint32_t*)&dst[0 + y*stride]+= *(uint32_t*)&block[0 + y*8]; - *(uint32_t*)&dst[2 + y*stride]+= *(uint32_t*)&block[2 + y*8]; - *(uint32_t*)&dst[4 + y*stride]+= *(uint32_t*)&block[4 + y*8]; - *(uint32_t*)&dst[6 + y*stride]+= *(uint32_t*)&block[6 + y*8]; - } -} - -static void store_slice_c(uint8_t *dst, int16_t *src, int dst_stride, int src_stride, int width, int height, int log2_scale){ - int y, x; - -#define STORE(pos) \ - temp= ((src[x + y*src_stride + pos]<>6;\ - if(temp & 0x100) temp= ~(temp>>31);\ - dst[x + y*dst_stride + pos]= temp; - - for(y=0; ylog2_count; - const int stride= is_luma ? p->temp_stride : ((width+16+15)&(~15)); - uint64_t __attribute__((aligned(16))) block_align[32]; - DCTELEM *block = (DCTELEM *)block_align; - DCTELEM *block2= (DCTELEM *)(block_align+16); - - if (!src || !dst) return; // HACK avoid crash for Y8 colourspace - for(y=0; ysrc + index, src + y*src_stride, width); - for(x=0; x<8; x++){ - p->src[index - x - 1]= p->src[index + x ]; - p->src[index + width + x ]= p->src[index + width - x - 1]; - } - } - for(y=0; y<8; y++){ - fast_memcpy(p->src + ( 7-y)*stride, p->src + ( y+8)*stride, stride); - fast_memcpy(p->src + (height+8+y)*stride, p->src + (height-y+7)*stride, stride); - } - //FIXME (try edge emu) - - for(y=0; ytemp + (8+y)*stride, 0, 8*stride*sizeof(int16_t)); - for(x=0; xqp) - qp= p->qp; - else{ - qp= qp_store[ (XMIN(x, width-1)>>qps) + (XMIN(y, height-1)>>qps) * qp_stride]; - qp = FFMAX(1, norm_qscale(qp, p->mpeg2)); - } - for(i=0; idsp.get_pixels(block, p->src + index, stride); - p->dsp.fdct(block); - requantize(block2, block, qp, p->dsp.idct_permutation); - p->dsp.idct(block2); - add_block(p->temp + index, stride, block2); - } - } - if(y) - store_slice(dst + (y-8)*dst_stride, p->temp + 8 + y*stride, dst_stride, stride, width, XMIN(8, height+8-y), 6-p->log2_count); - } -#if 0 - for(y=0; y>6) ^ (y>>6)) & 1) == 0) - dst[x + y*dst_stride]= p->src[8 + 8*stride + x + y*stride]; - if((x&63) == 0 || (y&63)==0) - dst[x + y*dst_stride] += 128; - } - } -#endif - //FIXME reorder for better caching -} - -static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ - int h= (height+16+15)&(~15); - - vf->priv->temp_stride= (width+16+15)&(~15); - vf->priv->temp= malloc(vf->priv->temp_stride*h*sizeof(int16_t)); - vf->priv->src = malloc(vf->priv->temp_stride*h*sizeof(uint8_t)); - - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); -} - -static void get_image(struct vf_instance *vf, mp_image_t *mpi){ - if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change - // ok, we can do pp in-place (or pp disabled): - vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, - mpi->type, mpi->flags | MP_IMGFLAG_READABLE, mpi->width, mpi->height); - mpi->planes[0]=vf->dmpi->planes[0]; - mpi->stride[0]=vf->dmpi->stride[0]; - mpi->width=vf->dmpi->width; - if(mpi->flags&MP_IMGFLAG_PLANAR){ - mpi->planes[1]=vf->dmpi->planes[1]; - mpi->planes[2]=vf->dmpi->planes[2]; - mpi->stride[1]=vf->dmpi->stride[1]; - mpi->stride[2]=vf->dmpi->stride[2]; - } - mpi->flags|=MP_IMGFLAG_DIRECT; -} - -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - - if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ - // no DR, so get a new image! hope we'll get DR buffer: - dmpi=vf_get_image(vf->next,mpi->imgfmt, - MP_IMGTYPE_TEMP, - MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, - mpi->width,mpi->height); - vf_clone_mpi_attributes(dmpi, mpi); - }else{ - dmpi=vf->dmpi; - } - - vf->priv->mpeg2= mpi->qscale_type; - if(mpi->pict_type != 3 && mpi->qscale && !vf->priv->qp){ - int w = mpi->qstride; - int h = (mpi->h + 15) >> 4; - if (!w) { - w = (mpi->w + 15) >> 4; - h = 1; - } - if(!vf->priv->non_b_qp) - vf->priv->non_b_qp= malloc(w*h); - fast_memcpy(vf->priv->non_b_qp, mpi->qscale, w*h); - } - if(vf->priv->log2_count || !(mpi->flags&MP_IMGFLAG_DIRECT)){ - char *qp_tab= vf->priv->non_b_qp; - if((vf->priv->mode&4) || !qp_tab) - qp_tab= mpi->qscale; - - if(qp_tab || vf->priv->qp){ - filter(vf->priv, dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, qp_tab, mpi->qstride, 1); - filter(vf->priv, dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, qp_tab, mpi->qstride, 0); - filter(vf->priv, dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, qp_tab, mpi->qstride, 0); - }else{ - memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); - memcpy_pic(dmpi->planes[1], mpi->planes[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[1], mpi->stride[1]); - memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[2], mpi->stride[2]); - } - } - -#if HAVE_MMX - if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t"); -#endif -#if HAVE_MMX2 - if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t"); -#endif - - return vf_next_put_image(vf,dmpi, pts); -} - -static void uninit(struct vf_instance *vf){ - if(!vf->priv) return; - - free(vf->priv->temp); - vf->priv->temp= NULL; - free(vf->priv->src); - vf->priv->src= NULL; - free(vf->priv->avctx); - vf->priv->avctx= NULL; - free(vf->priv->non_b_qp); - vf->priv->non_b_qp= NULL; - - free(vf->priv); - vf->priv=NULL; -} - -//===========================================================================// -static int query_format(struct vf_instance *vf, unsigned int fmt){ - switch(fmt){ - case IMGFMT_YVU9: - case IMGFMT_IF09: - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - case IMGFMT_CLPL: - case IMGFMT_Y800: - case IMGFMT_Y8: - case IMGFMT_444P: - case IMGFMT_422P: - case IMGFMT_411P: - return vf_next_query_format(vf,fmt); - } - return 0; -} - -static int control(struct vf_instance *vf, int request, void* data){ - switch(request){ - case VFCTRL_QUERY_MAX_PP_LEVEL: - return 6; - case VFCTRL_SET_PP_LEVEL: - vf->priv->log2_count= *((unsigned int*)data); - return CONTROL_TRUE; - } - return vf_next_control(vf,request,data); -} - -static int vf_open(vf_instance_t *vf, char *args){ - - int log2c=-1; - - vf->config=config; - vf->put_image=put_image; - vf->get_image=get_image; - vf->query_format=query_format; - vf->uninit=uninit; - vf->control= control; - vf->priv=malloc(sizeof(struct vf_priv_s)); - memset(vf->priv, 0, sizeof(struct vf_priv_s)); - - vf->priv->avctx= avcodec_alloc_context(); - dsputil_init(&vf->priv->dsp, vf->priv->avctx); - - vf->priv->log2_count= 3; - - if (args) sscanf(args, "%d:%d:%d", &log2c, &vf->priv->qp, &vf->priv->mode); - - if( log2c >=0 && log2c <=6 ) - vf->priv->log2_count = log2c; - - if(vf->priv->qp < 0) - vf->priv->qp = 0; - - switch(vf->priv->mode&3){ - default: - case 0: requantize= hardthresh_c; break; - case 1: requantize= softthresh_c; break; - } - -#if HAVE_MMX - if(gCpuCaps.hasMMX){ - store_slice= store_slice_mmx; - switch(vf->priv->mode&3){ - case 0: requantize= hardthresh_mmx; break; - case 1: requantize= softthresh_mmx; break; - } - } -#endif - - return 1; -} - -const vf_info_t vf_info_spp = { - "simple postprocess", - "spp", - "Michael Niedermayer", - "", - vf_open, - NULL -}; diff --git a/libmpcodecs/vf_unsharp.c b/libmpcodecs/vf_unsharp.c index 9014a2b6e3..864c99862a 100644 --- a/libmpcodecs/vf_unsharp.c +++ b/libmpcodecs/vf_unsharp.c @@ -28,10 +28,6 @@ #include "mp_msg.h" #include "cpudetect.h" -#if HAVE_MALLOC_H -#include -#endif - #include "img_format.h" #include "mp_image.h" #include "vf.h" diff --git a/libmpdemux/video.c b/libmpdemux/video.c index def9cac53c..1ea85190ea 100644 --- a/libmpdemux/video.c +++ b/libmpdemux/video.c @@ -21,9 +21,6 @@ #include "config.h" #include -#if HAVE_MALLOC_H -#include -#endif #include #include #include @@ -124,7 +121,7 @@ switch(video_codec){ } mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); if(!videobuffer) { - videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); + videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE); else { mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n"); @@ -219,7 +216,7 @@ switch(video_codec){ } mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); if(!videobuffer) { - videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); + videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE); else { mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n"); @@ -284,7 +281,7 @@ mpeg_header_parser: mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); // ========= Read & process sequence header & extension ============ if(!videobuffer) { - videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); + videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE); else { mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n"); @@ -352,7 +349,7 @@ mpeg_header_parser: } mp_msg(MSGT_DECVIDEO,MSGL_INFO,"found\n"); if(!videobuffer) { - videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); + videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE); if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE); else { mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n"); diff --git a/sub/sub.c b/sub/sub.c index a8a6d03b2d..fefbdb645e 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -20,10 +20,10 @@ #include #include +#include +#include + #include "config.h" -#if HAVE_MALLOC_H -#include -#endif #include "stream/stream.h" #include "stream/stream_dvdnav.h" @@ -40,7 +40,6 @@ #include "sub.h" #include "sub/ass_mp.h" #include "spudec.h" -#include "libavutil/common.h" char * const sub_osd_names[]={ @@ -105,10 +104,10 @@ void osd_alloc_buf(mp_osd_obj_t* obj) len = obj->stride*(obj->bbox.y2-obj->bbox.y1); if (obj->allocatedallocated = len; - free(obj->bitmap_buffer); - free(obj->alpha_buffer); - obj->bitmap_buffer = memalign(16, len); - obj->alpha_buffer = memalign(16, len); + av_free(obj->bitmap_buffer); + av_free(obj->alpha_buffer); + obj->bitmap_buffer = av_malloc(len); + obj->alpha_buffer = av_malloc(len); } memset(obj->bitmap_buffer, sub_bg_color, len); memset(obj->alpha_buffer, sub_bg_alpha, len); -- 2.11.4.GIT